Entitlements
Read BillStack as the billing source of truth while keeping app authorization simple.
Entitlements tell your app what a billing subject can access. For workspace billing, persist one stable workspace subject and use it consistently in checkout, country confirmation, entitlement reads, and portal requests.
Provider-neutral v2 workspace synchronization
Use the public Synchronize BillStack entitlements skill for the authoritative v2 reconciliation and lifecycle instructions. Read /api/billstack/v2/teams/{teamId}/projects/{projectId}/entitlements/{externalId}?mode=test on your backend. Inspect data.effective and data.grants; explicitly choose test or live.
V2 plan/tier come from canonical price tierAlias, falling back to the price variant ID. Map approved labels to your application's plans, limits, and features. The v2 effective response does not contain the legacy limits, enabledFeatures, version, or updatedAt fields shown below.
BillStack can notify your server when a customer's entitlement changes: register an outbound webhook endpoint on payload version 2026-10-26 and subscribe to entitlement.updated (and, if useful, subscription.* and purchase.*). Those events are a trigger and a hint, never the only source of truth: keep reconciling by reading the entitlement, as below, because events are delivered at least once, can arrive out of order, and do not cover time-based endings (see Reconcile with events). Provider webhooks arrive at BillStack and its internal worker projects canonical state. Implement periodic server-side reconciliation, refresh after checkout/portal return and on billing loads, and recheck known expiry boundaries. A checkout success URL does not authorize paid access. Read effective access after purchase, renewal, cancellation, failed payment, and recovery; another valid grant can preserve access after one subscription ends.
How the effective plan is chosen
data.grants lists every entitlement a customer holds; data.effective reduces them to one plan and tier:
- Only active grants count. Canceled, expired, revoked and not-yet-started grants are skipped, as is a grant that is not entitled.
cancelingandbilling_issuegrants stay active until they end. - Active grants are reduced to one per
commercialKey, keeping the higher priority and then the latestendsAt. - The remaining grants are ordered by priority (
0unless a manual grant sets one; higher wins), then by latestendsAtfirst (a grant withendsAt: nullis open-ended and sorts first), then bysourceExternalIdascending. The first grant's plan and tier becomeeffective.planandeffective.tier.
Nothing is merged: there is no feature or limit union across grants, and the v2 response has no features or limits.
For a stripe_subscription or razorpay_subscription grant, sourceExternalId is the grant's source key, for example stripe:binc_9f2:live:stripe_subscription:sub_123:user_123 (older rows can show stripe_subscription:sub_123 or the bare sub_123). The subscription management routes take either that value or the bare provider subscription id to read, change, cancel or resume the subscription.
grants[].commercialKey identifies what was bought: the price variant ID, else the provider product ID, else the grant's sourceExternalId. For v2 checkouts it is the canonical price variant ID.
Add-ons
Because the grant that ends last wins, an add-on grant that ends later than the base plan, or never ends, can become effective.plan. To sell add-ons next to a base plan:
- Use one customer (the same
customerExternalId) per end customer per project, and make each add-on its own product and price variant. - Use
effective.planfor the base plan only. - Derive add-on access from
grants[]: look for a grant with the add-on'scommercialKey,statusofactiveandprovenanceofverified.
Complimentary grants
To give a customer a plan without a payment (a partner, a pilot, a goodwill extension), create a manual grant with POST /entitlements/{externalId}/grants and withdraw it with DELETE /entitlements/{externalId}/grants/{grantId}. See Manual (complimentary) grants for the request, and client.entitlements.grants in the SDK. A manual grant appears in data.grants with sourceKind: "manual", reason and grantedBy, and takes part in the choice of effective like any other grant. Set endsAt to make it expire by itself; leave it out and it lasts until you revoke it.
Decide what should win when the customer also pays:
- To let a paid plan win, leave
priorityat0and give the grant a finiteendsAt. The grant that ends last wins, so a paid period that ends later takes over. - An open-ended grant (no
endsAt) at priority0outlasts any finite paid period and becomeseffective.plan, even if it is a lower plan. SetendsAt, or comp the same plan the customer pays for. - To force the comped plan over paid plans, set
priorityabove0(for example10). Only manual grants can carry a priority; provider grants are always0. - A comp of an add-on competes for
effective.planexactly like a paid add-on does (see Add-ons).
Revoking keeps the grant in data.grants with status: "revoked" and removes its effect on effective; it never touches a paid subscription or payment. Manual grants are separate for test and live and are not copied between environments. They do not change the legacy snapshot API below.
One-time purchases and credit packs
A plain one_time price variant (one without a lifetime billing scheme) produces a grant with sourceKind: "stripe_payment", status: "active", endsAt: null and lifetime: false. It is open-ended: it does not expire and ends only if a refund revokes it. v2 checkout does not block a repeat purchase of the same variant. Each payment adds a grant with its own sourceExternalId (for Stripe, the payment intent ID, pi_...), and effective does not change.
For things that are bought and used up, such as credit packs and top-ups, create the price variant with billingScheme: "consumable" (one-time prices only, set when the variant is created; variants are immutable, so a standard variant cannot be turned into a consumable). Paying for a consumable records the purchase but never grants access: its grant has isEntitled: false and consumable: true, stays out of the choice of effective, and is refunded like any other payment. BillStack records what was bought and paid; it keeps no balance of units, so credit the units in your own system once per purchase:
- Start the checkout with
quantityand your own order id (externalId) andmetadata. They are saved with the checkout. - After the customer returns, read the purchase with
GET /checkouts/{checkoutId}(thecheckoutIdthe checkout call returned). Fulfill whenstatusiscompletedandpaymentStatusispaid. Key your ledger oncheckoutId(orpaymentId) so repeated reads and repeated webhook deliveries credit it once. - Reverse or adjust the credit when
paymentStatusbecomesrefunded.
GET /checkouts lists purchases, filtered by customerExternalId, idempotencyKey, priceVariantId or status, newest first. Each checkout reports status, paymentStatus, quantity, amountMinor and currency (the amount actually paid; null until the payment event has been processed), unitAmountMinor, priceVariantId, paymentId, customerExternalId, your metadata and completedAt. See Reading checkouts.
The consumable's grant stays in data.grants as the record of the purchase, with checkoutId pointing back at the checkout. Do not treat a grant with isEntitled: false as access. The same read works for a standard one-time purchase; there effective does reflect the grant.
Quantity
grants[].quantity is the number of units the grant was bought with: the checkout quantity for a one-time purchase, and the subscription's current quantity for a subscription (it follows quantity changes made later in the portal). It is null when BillStack did not record one, which is the case for grants created before quantities were recorded and for sources that do not carry it. null does not mean 1. effective never sums quantities across grants.
A refund that revokes a grant keeps its quantity, so a revoked grant still reports what was bought.
Trials
A subscription started with trialDays (or a trial you set up in your payment account) produces an active, entitled grant while the trial runs:
{
"status": "active",
"trialing": true,
"trialEndsAt": "2026-11-06T12:00:00.000Z",
"endsAt": "2026-11-06T12:00:00.000Z",
"quantity": 1
}trialing: true means the customer is entitled but nothing has been paid yet. trialEndsAt is when the trial ends; endsAt is the end of the current period, which equals the trial end while trialing. When the trial converts, the next subscription update clears trialing and trialEndsAt; if the customer cancels during the trial the grant follows the usual canceling and canceled states. A trial whose end has passed is no longer reported as trialing even before the conversion event arrives. Both fields are present on every grant (false and null when there is no trial).
Reconcile with events
entitlement.updated is sent when a customer's effective entitlement changes, whatever caused it: a subscription starting, renewing or ending, a payment or refund, or a complimentary grant made or revoked through the API. It carries the entitlement before and after, a transition (granted, revoked, changed) and a version. The subscription.created, .renewed, .canceled, .updated and purchase.completed, .refunded events describe the subscription or payment behind it. Payloads and delivery rules are in Outbound webhooks.
Endpoints created before payload version 2026-10-26 do not receive these events until you move them to it. Use the events like this:
- Verify the signature and dedupe on the event
id. - Drop the event if its
versionis not higher than the last one you applied for that customer (anullversion, from a manual grant, has no order: compareoccurredAtor simply re-read). - Either apply
afterto your cache, or re-readGET .../entitlements/{externalId}and overwrite the cache with the response, which is always authoritative. - Keep the periodic reconciliation. A subscription or comp whose period runs out with no provider event, and a comp that starts in the future, change the entitlement without an event.
Local cache shape
Your local cache only needs the fields your app checks frequently:
type CachedEntitlement = {
externalId: string;
plan: string;
status: string;
isEntitled: boolean;
cycle: string | null;
limits: Record<string, number>;
enabledFeatures: string[];
version: number;
updatedAt: string;
};Do not duplicate provider checkout logic in the app cache. If the cache disagrees with BillStack, refresh from BillStack.
Legacy snapshot API (v1)
Legacy (v1) API. The snapshot route below belongs to the Stripe-first legacy API. It stays supported for existing integrations but is frozen: new features ship only in v2. New integrations read data.effective from the v2 route above; see also Legacy entitlements reference.
Fetch by external ID
curl "https://billing.w3dev.app/api/billstack/teams/{teamId}/projects/{projectId}/entitlements/by-external-id/user_123" \
-H "Authorization: Bearer <private-api-key>"Response:
{
"plan": "pro",
"tier": "pro",
"status": "active",
"provider": "stripe",
"cycle": "annual",
"source": "subscription",
"isEntitled": true,
"currentPeriodStart": "2026-06-01T00:00:00.000Z",
"currentPeriodEnd": "2027-06-01T00:00:00.000Z",
"trialEndsAt": null,
"bonusEndsAt": null,
"limits": { "agents": 5 },
"enabledFeatures": ["calendar", "integrations"],
"updatedAt": "2026-06-01T00:00:00.000Z",
"version": 1
}App-side usage
Use isEntitled, plan, limits, and enabledFeatures for authorization.
Recommended app pattern:
- Read BillStack on account/dashboard load.
- Cache the entitlement in your app database for fast checks.
- Treat the cache as derived data.
- Refresh after checkout/portal return and on a short TTL or periodic reconciliation. Provider webhooks update BillStack internally; subscribe to
entitlement.updatedto refresh your cache sooner (see Reconcile with events).