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.
From your app
Section titled “From your app”Call your tenant domain with the access token the user signed in with:
GET https://<tenant-domain>/billing/entitlementsAuthorization: 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} />;}const { plan, features, limits } = await client.getEntitlements();const canExport = await client.hasFeature('export_pdf');On your server
Section titled “On your server”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.
With the Management API
Section titled “With the Management API”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.
Response
Section titled “Response”| Field | Meaning |
|---|---|
subject | { type, id }: the user or organization answered for |
plan | { id, key, name }, or null |
source | subscription, assigned, default or none |
features | Feature keys of the plan |
limits | Limits of the plan |
subscription | The 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.