Billing portal
Changing plan or cancelling, through the Stripe Billing Portal.
packages/api/src/billing/portal.controller.ts by packages/docs/tools/generate-reference.mjs. Every example is a real exchange recorded against the control plane by packages/api/src/testing/reference-examples.spec.ts, with ids from that run. Credentials in the formats this product issues (kr_, krsk_, krses_, JWTs) and values under credential-named fields (password, *_secret, *_token, *_key, lookup_hash) are elided at record time; the recorded file and every page of this site are swept for credential shapes (kr_, krsk_, krses_, JWTs, URLs carrying a password, password fields) before either is accepted. Do not edit by hand: src/reference.spec.ts regenerates it and fails on a difference.POST /v1/billing/portal_session -- where a paying workspace changes plan,
updates its card or cancels. Stripe hosts the page; this only mints the link.
A live credential (a subscription has no environment, so a krsk_test_ key
is refused by env-boundary.spec.ts's sweep), a person who owns the
workspace -- from the portal page the holder can upgrade or cancel, and a
vendor's backend must not raise its own bill, which is
PATCH /v1/billing/subscription's rule -- and a configured gateway.
Nothing here moves an entitlement. A plan change or a cancellation made in
the portal reaches workspace_subscription through the webhook, exactly as a
purchase does.
The customer is the one already stored on the workspace's row, never one a caller names, and the return URL is a fixed path off the configured dashboard origin.
POST /v1/billing/portal_session
Answers 201 on success.
Authentication.
- A
krsk_secret key or akrses_dashboard session, asAuthorization: Bearer.
Example.
curl https://api.keyringdev.com/v1/billing/portal_session \
-X POST \
-H "Authorization: Bearer $SESSION_TOKEN"HTTP/1.1 201 Created
Content-Type: application/json
{
"object": "portal_session",
"id": "bps_reference_muqfmpe2",
"url": "https://billing.stripe.com/p/session/test_a1b2c3"
}