Skip to content

Checkout and portal

All three return a URL to send the user to. The web SDK’s redirectTo... methods call them and redirect in one step.

POST https://<tenant-domain>/billing/checkout
Authorization: Bearer <access token>
Content-Type: application/json
{
"planKey": "pro",
"interval": "month",
"successUrl": "https://app.example.com/billing?paid=1",
"cancelUrl": "https://app.example.com/pricing"
}

Returns { "url": "https://checkout.stripe.com/..." }.

  • Pass planKey or planId. End users can only buy public plans.
  • Add currency only when the plan sells the same interval in several currencies.
  • Add organization to subscribe an organization instead of the user.
  • A user or organization with a subscription in force gets 409: they change plan in the portal instead, so nobody is billed twice.
await client.redirectToCheckout({ planKey: "pro", interval: "year" });

When the user comes back, Stripe has already told AuthAction. Read the entitlements again with forceRefresh: true.

POST https://<tenant-domain>/billing/portal
Authorization: Bearer <access token>
Content-Type: application/json
{ "returnUrl": "https://app.example.com/settings/billing" }

The portal lets a subscriber switch between your public plans, update their card, download invoices and cancel at the end of the period.

If your app has no pricing page of its own, send users to AuthAction’s:

await client.redirectToPricingPage();

or POST /billing/pricing-session with { "returnUrl": "..." }. The page shows your public plans in your tenant’s branding and language, starts checkout, and offers Manage subscription to subscribers. Its link works for one hour and only for the user it was made for.

successUrl, cancelUrl and returnUrl must be on an origin your application registered: one of its callback URLs, logout URLs, allowed origins or homepage. Anything else gets 400, so these endpoints can’t be used to bounce people to another site.

The token must be an access token issued to that application, not an ID token.

By default, end users can’t buy or manage an organization’s subscription. Under Billing > Organizations, choose the roles (for example billing-admin) whose holders may do so in an organization they belong to. Every member of an organization can still read its entitlements.

To bill organizations from your own backend instead, leave the roles empty and use the Management API, which can act for any user or organization and sell any plan, public or not:

POST https://<tenant-domain>/api/v1/billing/checkout-sessions
Authorization: Bearer <management token>
{
"subjectType": "organization",
"subjectId": "<organization id>",
"planKey": "enterprise",
"interval": "year",
"successUrl": "https://app.example.com/billing/done",
"cancelUrl": "https://app.example.com/billing"
}

POST /api/v1/billing/portal-sessions does the same for the portal, and POST /api/v1/billing/subscriptions/{id}/cancel cancels at the end of the period (or at once with { "atPeriodEnd": false }).