Skip to content

Entitlements

Entitlements answer one question: what may this user, or this organization, use right now? See where a plan comes from for how the plan is chosen.

Call your tenant domain with the access token the user signed in with:

GET https://<tenant-domain>/billing/entitlements
Authorization: Bearer <access token>

Add ?organization=<id> for an organization the user belongs to. A user who isn’t a member gets 404. An access token from an organization login reads that organization’s entitlements without the parameter.

import { useEntitlements } from '@authaction/web-sdk/react';
function Export() {
const { hasFeature, entitlements, isLoading } = useEntitlements();
if (isLoading) return null;
if (!hasFeature('export_pdf')) return <UpgradeButton />;
return <ExportButton limit={entitlements?.limits.exports} />;
}

Showing or hiding a button is not enforcement. Check again on your server before doing paid work. Every access token AuthAction issues to a user, including one for your own API, can read that user’s entitlements:

import { EntitlementsClient } from "@authaction/node-sdk";
import { requireAuth, requireFeature } from "@authaction/node-sdk/express";
const entitlements = new EntitlementsClient({ domain: process.env.AUTHACTION_DOMAIN! });
app.post(
"/api/export",
requireAuth(verifier),
requireFeature(entitlements, "export_pdf"),
exportHandler
);
app.post("/api/projects", requireAuth(verifier), async (req, res) => {
const token = req.headers.authorization!.slice(7);
const { limits } = await entitlements.forUser(token);
if (projectCount >= (limits.projects ?? 0)) {
return res.status(403).json({ error: "Project limit reached" });
}
// ...
});

In other languages, send the same GET /billing/entitlements request with the user’s token.

To look up anyone, for example in a background job, use a Management API token:

GET https://<tenant-domain>/api/v1/billing/entitlements?subjectType=user&subjectId=<user id>
Authorization: Bearer <management token>

subjectType is user or organization. Subscriptions are listed at GET /api/v1/billing/subscriptions, filterable by status, subjectType, subjectId and plan. Both are also tools on the AuthAction MCP server.

FieldMeaning
subject{ type, id }: the user or organization answered for
plan{ id, key, name }, or null
sourcesubscription, assigned, default or none
featuresFeature keys of the plan
limitsLimits of the plan
subscriptionThe subscription granting the plan, else the latest one (which may have ended), else null. Has status, interval, currentPeriodEnd, cancelAtPeriodEnd and trialEnd.

Show a renewal date from currentPeriodEnd, and “ends on” when cancelAtPeriodEnd is true.