Skip to content

Billing (self-serve plans)

While impersonating ("View as User"), the billing and wallet endpoints are refused with 403 impersonation_forbidden — an administrator viewing as a user cannot read or act on the user's billing, wallet balance, top-ups or payment methods. The plan a user is on is still visible via GET /admin/auth/me. See Admin impersonation.

Workspaces on the self-serve paid plan (self_serve_custom) manage their subscription through these endpoints. They are part of the pay-first self-sign-up flow: a workspace only exists after a successful Stripe payment. The first registrant is the account owner (role tenant_admin) and may invite teammates up to the plan's seat cap (see the Seats note below).

These endpoints are unavailable to non-self-serve (manually provisioned) workspaces — a member of such a workspace receives 403 forbidden. Exception — the manual Standard plan: its owner uses the wallet endpoints (/billing/wallet, top-up, automatic top-up, card removal) like a Custom owner, and its other roles read GET /billing/wallet read-only (see the wallet). Within a self-serve workspace they are gated by who the caller is:

  • Owner-only — the account owner (role admin or tenant_admin) alone may manage the subscription and the saved card: the Stripe portal (POST /billing/portal), POST /billing/reactivate and DELETE /billing/wallet/payment-method. Any other caller receives 403 forbidden.
  • Owner or holder — buying: the trial conversion (POST /billing/checkout), the wallet top-up (POST /billing/wallet/topup) and the automatic top-up (PUT /billing/wallet/auto-topup), and the plan change (POST /billing/change/preview, POST /billing/change and DELETE /billing/change). A holder is a user whose effective permissions include BILLING_PURCHASE ("Buy plans and add budget"). The owner roles hold it by default (and are admitted by their role even if that grant is missing); a tenant admin can grant it to anyone else through a custom role. It is not a default of the finance role. The demo account (demouser) is never a holder, even if a custom role grants the key; a session whose role is absent or unknown is never a holder; and if the custom-role grants cannot be read, a caller the grant could admit receives the retry 503 (temporarily unavailable; retry later) — never admitted, and never a 403 that reads as "you lack this permission". The owner is unaffected (admitted by role), and so is a caller the key could never admit (the demo account, an unknown role), who keeps the 403. The same rule applies wherever the grant decides what is shown: the summary's member view and invoice list, and the budget requests' payer scope.

  • Every role of a paid workspace (read) — the summary behind Your plan: the owner, a holder, and every other role of a paid self-serve workspace (member, finance, viewer, AI manager — not the demo account, not a trial: a trial's page renders from /me). The invoice list in it is the owner's and that of a holder of BILLING_SETTINGS_MANAGE ("Manage billing settings" — by default the finance role, besides the owner roles); everyone else gets invoices: null. The same audience receives the plan name on /admin/auth/me.

Every other member of a self-serve workspace receives 403 forbidden (its code names the reason: billing_owner_only, billing_purchaser_only, self_serve_plan_required, caller_has_no_tenant, billing_member_read_denied, trial_plan_required or partner_billed; see Typed codes on billing and voucher routes; GET /billing/catalog answers a user without a workspace no_tenant, the same condition as caller_has_no_tenant) from the owner-only and the buying routes. The portal, reactivation and the summary also need a subscription row: a self-serve workspace that has none yet (a provisioning race) receives 409 no_subscription.

Scheduled seat-reduction notice

When the items healer atomically confirms an actual purchased-seat decrease and clears its applied schedule, it queues one best-effort operational email. In the callback it re-reads the current workspace plan, purchased cap and active-user count (every non-deleted user, including disabled users and invites). Only a workspace still above that same confirmed cap is notified. An increase, ordinary drift, unchanged cap, cancelled/replaced/unapplied schedule, losing confirmation or missing entitlement never triggers it. Returned entitlement JSON must contain positive integral numeric seats; strings, fractions, nulls, arrays and unreadable values are not evidence of a purchased decrease. Unreadable or superseded callback state suppresses the email rather than guessing a cap or count.

The recipient is a current admin of that workspace (admin or tenant_admin); there is no ordinary member fallback. The address is validated before rendering. Language follows recipient locale, workspace default, then English, using the existing English/German mail layouts, escaped branding and trusted app links. The message states active users and paid seats and asks the admin to remove unneeded workspace members or increase seats. Disabling a user alone does not free a seat: disabled non-deleted users still count. The notice does not remove users, refuse the applied reduction or initiate a purchase. Partner-billed workspaces and unreadable partner classification suppress this self-serve mail through the shared billing-mail policy. Suspension alone does not suppress this operational notice for native tenants.

Delivery is best effort, not durable: at most one enqueue per winning observed transition. Queue, read, rendering and transport failures are logged without rolling back the cap or failing the webhook; replaying a consumed transition does not retry lost mail. A shutdown callback attempts delivery with a warning. The existing operator over-limit alert remains independent. Support can inspect the confirmed cap, active users and mail failure logs; there is no dedicated resend/outbox recovery tool.

Billing page visibility (interface affordance, not an authorization boundary)

The billing pages are the Billing section of the Organisation area — Plan · Wallet · Invoices at /org/<own organisation id>/billing/…, always the caller's own organisation (these endpoints serve no other); the former /billing… and /account/billing… addresses redirect there with the query kept (the Stripe return URLs below stay /billing?…). The section is shown to the people who run the workspace's money: the owner (tenant admin; also of a free trial), finance, a holder of Manage billing settings and a holder of Buy plans and add budget — on a free trial, a paid self-serve workspace and a manually provisioned (Standard / Enterprise) workspace alike; never to the platform administrator or a demo account. Every other role — a member who reads the wallet but may not add budget — keeps a read-only wallet balance card on Account › Usage, and on a paid self-serve workspace the link Request more budget to the budget-request page (/account/usage/request-budget); the rows below that describe a member's read-only Wallet apply to the billing roles that see the section without paying (finance, a holder of Manage billing settings). What each sees differs by persona:

  • Trial — the trial credit balance and the trial countdown; no top-up (a trial has no payment method).
  • Paid self-serve owner — the full page: Your plan, the upgrade funnel (Upgrade / Contact us), Wallet, Invoices.
  • Paid holder of a self-serve workspace (a non-owner whose role grants Buy plans and add budget, see above) — Your plan, the upgrade funnel (Upgrade / Contact us, as the owner sees it; sending a Contact us enquiry still needs the SUPPORT_CONTACT permission — without it the form says to talk to the organisation administrator, see Contact us enquiries) and the Wallet with Top up / Add budget and the automatic top-up settings. The wallet shows the member view of the card (no brand or last four digits). There is no billing portal, no Reactivate, no Forget card, no "top up with a new card" or "add a card" action, and no Invoices tab unless the role also grants Manage billing settings (a link to /billing/invoices then opens Your plan). In the cancel row, Your plan says The workspace owner manages the subscription: payment method, cancellation and reactivation. The payment-overdue and inactive banners and the full-screen inactive prompt are not shown to a holder; on an inactive subscription the upgrade view says Your subscription is inactive. Ask the workspace owner to reactivate it.
  • Paid member of a self-serve workspace (any other non-owner role: member, finance, viewer, AI manager, without Buy plans and add budget) — a member, viewer or AI manager has no Billing section: the read-only wallet balance and Request more budget are on Account › Usage. Finance and a holder of Manage billing settings see Your plan, read-only: the plan, its status and renewal date and the wallet balance (from the summary), with The workspace owner manages the subscription… where the owner's actions sit, and no Invite user; and, while the prepaid wallet is on, a read-only Wallet: the balance, the automatic top-up notices (without their actions), the payments ledger ("What was paid") and an "it is set by a workspace admin" note on the Automatic top-up sub-tab. No Top up / Add budget, no automatic top-up settings, no card details. The upgrade funnel (Upgrade / Contact us) is absent (not greyed out) — the workspace owner (or a holder) buys. Finance (any holder of Manage billing settings) also sees Invoices: the invoice list, read-only — replacing the card stays the owner's.
  • Standard workspace (the manual Standard plan, set by a platform admin; no subscription) — the owner sees the managed Your plan (plan, seats, balance) and the full Wallet: Top up / Add budget by card and the automatic top-up. Finance and a holder of Buy plans and add budget (on Standard only the owner adds budget) see a read-only Wallet (as on a paid self-serve workspace: the balance, the notices without actions, the payments ledger, the automatic top-up note) with Adding budget is done by the workspace owner., and on Your plan the note Your plan is managed by Myra. Ask your workspace owner if you need a change. with the balance and a link to the Wallet. A member, viewer or AI manager has no Billing section and sees the balance read-only on Account › Usage. There are no budget requests on Standard ("Request budget" is not offered). The upgrade funnel and Invoices are absent.
  • Member of a manually provisioned (Enterprise) workspace — no Billing section (no wallet on /me). Finance sees Your plan with the note Your plan is managed by Myra. Ask your workspace owner if you need a change. (no figures, no Wallet).
  • Trial member — no Billing section: the read-only wallet balance is on Account › Usage (no top-up). Only the trial owner, finance, or a trial member whose role grants Buy plans and add budget or Manage billing settings sees the section; Upgrade / Contact us only the owner or a Buy plans and add budget holder (who can convert the trial).
  • Manual / enterprise tenant admin — a read-only "managed plan" state: the workspace is billed directly by Myra, with no upgrade or checkout path. The Your plan page shows the plan name, the seats (in use / cap) and its live prepaid wallet balance (the same tenant_wallet balance the Wallet tab shows, not the organisation's configured budget); the Wallet tab shows that same wallet balance as a read-only balance (no top-up); the Invoices tab shows the awaiting/empty state until Myra uploads invoices. These figures come from GET /billing/overview, the managed admin's own-tenant read path — not from GET /billing/summary (which 403s a manual tenant). The read is owner-only: a member of a managed workspace gets the Your plan note above, and the page makes no billing call for them.

This visibility is a client affordance only — never the authorization boundary. The session-authenticated self-serve billing endpoints stay gated server-side regardless of who can see the tab, by the groups above: a member without Buy plans and add budget still receives 403 forbidden from POST /billing/checkout, POST /billing/wallet/topup and PUT /billing/wallet/auto-topup (and reads the summary without the invoice list); a manually provisioned/enterprise tenant receives 403 forbidden from all of them and from GET /billing/summary; a holder too receives 403 forbidden from the owner-only POST /billing/portal, POST /billing/reactivate and DELETE /billing/wallet/payment-method. The purchase routes share one server decision (the same one that gives a holder the paid billing snapshot on /me), and the owner-only routes share the owner gate. The two reads are the exception: GET /billing/wallet also answers a paid member, read-only (see there) — the same audience that receives wallet_usd on /me — and GET /billing/summary answers every role of a paid workspace (the audience that receives the plan name on /me); each is decided by one server predicate. The separate GET /billing/overview (below) is the managed admin's own-tenant read path, owner-gated and scoped to the caller's own tenant only.

GET /admin/v1/billing/overview (managed read)

The manual / enterprise tenant admin's own-tenant billing read. It exists because such a workspace has no other read path: /me carries the billing snapshot only for a self-serve tenant, and GET /billing/summary 403s a non-self-serve caller. It reuses the same underlying authorities as the self-serve surfaces — the effective seat cap, the active-user count, and the live prepaid tenant_wallet balance (the same spendable figure /me and /billing/summary carry, via storage.get_wallet_balance_micro) — so there is no second source of truth.

Authorization (fail closed). Session-authenticated and owner-only (admin or tenant_admin, via is_owner_role); a member/viewer/ki_manager/finance, an absent session and a nil/garbage role all receive 403 forbidden (ABSENT and MALFORMED share the deny outcome). The tenant is always the caller's own tenant_id from the session — there is no tenant identifier in the request body, query or headers, so the endpoint can only ever return the caller's own tenant (no IDOR surface). Unlike the self-serve endpoints it does not require a subscription row, and it does not 403 a manual/enterprise tenant — a managed owner is exactly its intended caller.

Response 200:

{ "plan": "enterprise", "seats": 50, "seats_used": 7, "spendable_usd": 67.0,
  "wallet_usd": 42.0, "promo_usd": 25.0, "promo_expires_at": 1801234567 }
  • plan — the tenant's plan value (enterprise / standard / free / a self-serve slug), or null if the row carries no plan.
  • seats — the effective seat cap (the admin-set entitlement override, else the plan floor). null = uncapped (an ordinary enterprise tenant with no seat override) or a transient read blip — both render as "no seat limit" (a display cap of null defeats no control; the real seat gate is the server-side capped insert).
  • seats_used — active member count (the same count enforcement uses); null on a read blip (a dash).
  • promo_usd / promo_expires_at — the workspace's promotional credit (a redeemed campaign voucher) in USD (the sum of the still-valid voucher grants only: never the opening credit or a customer-success grant), and the unix-seconds instant the soonest of them lapses. Reported beside wallet_usd, never folded into it: promo is spendable but not refundable, so adding the two would overstate what a refund can draw on. promo_usd counts only grants that are valid now, so a lapsed grant is not counted. With no live voucher promo_usd is 0 and promo_expires_at is null; when the money log cannot be replayed both are null (never reported as 0). Promo is per workspace, not per seat, and is never multiplied by the seat count.
  • spendable_usd — the frozen-aware spendable tenant_wallet balance in USD (0 while the wallet is disputed). This is the figure the managed Your plan tile and Wallet tab display — the same spendable figure /me and /billing/summary carry. null = a wallet read fault only — rendered as a dash, and it must never fall back to any org budget. 0 = a real balance of zero.
  • wallet_usd — the refundable cash part of the balance in USD (replayed from the payment log, 0 while disputed): what a refund may draw on. A wallet funded only by grants reads 0 here (finite, never a dash while the wallet row exists). null on a wallet read fault.
  • spendable_usd and wallet_usd are emitted ungated (unlike /summary's view_enabled-gated wallet fields): the managed persona has no self-serve top-up offer to gate on. There is no per-tenant budget field any more (tenant.budget_usd was dropped in the wallet money-model rework — enforcement is wallet-only), so no org-budget figure is emitted or displayed anywhere. An Enterprise tenant is funded by an operator funding grant: a one-shot, additive grant_usd on the tenant PATCH writes an admin-grant wallet credit of exactly that amount (see Tenants & gateways, and the admin_grant ledger kind under wallet), so this figure reflects the wallet balance once a grant has been credited (a brand-new tenant reads its $9 seed, or 0 once spent down).

Rejected: 403 forbidden (no session / not an owner / not the caller's own tenant — there is no cross-tenant parameter to attempt); 503 { "error": "temporarily unavailable; retry later" } (the caller's own tenant row could not be read — fail closed, never an invented empty overview; retry). Secondary figures (seats, seats_used, spendable_usd, wallet_usd, promo_usd, promo_expires_at) degrade to null on their own read blip rather than failing the whole response.

Prices, seats and intervals

Every price the workspace shows comes from the product catalog, which mirrors Stripe exactly — what is shown is what is charged. A charge only ever happens in a Stripe Checkout the owner or a holder completes (card entry and Stripe's confirmation); nothing is billed automatically without it, except the opt-in wallet auto top-up and a confirmed plan upgrade, which charges the subscription's saved payment method (or sends the customer to Stripe's payment page when the card needs confirmation).

  • Interval. The paid plan can be bought monthly or annually (the annual price and its saving are whatever the catalog's annual price is — the sign-up page computes the saving from the two prices). The interval does not change the entitlement (models, allowance). The usage allowance is "per month" for both intervals (see the allowance note below).
  • Seats. The customer picks the number of seats at checkout (1 … the plan's seat maximum, max_seats in the catalog feed; for a trial conversion at least the workspace's active users). The Stripe Checkout charges exactly that quantity × the seat price, and after payment the workspace's seat limit is the purchased number. It is written when a checkout completes (sign-up, trial conversion, reactivation) and when a plan change takes effect — never by a renewal.
  • EU-governed add-on. A trial conversion or a plan change may also buy the EU-governed add-on (catalog row eu_gov, which grants myra_hosted_models). It is sold per seat: the Stripe Checkout then has two subscription lines — the seat price × seats and the add-on price × the same seats. The add-on must be priced in the plan's interval, currency and tax basis; when it cannot be (for example the plan is annual and the add-on has no annual price) it cannot be bought online. Sign-up never sells it.
  • Self-serve limit. A self-serve checkout (sign-up and trial conversion) and a plan change (its new monthly total) may reach at most the platform setting self_serve_checkout_monthly_max_minor per month, in EUR (default 2 000.00 EUR; self-serve sells EUR prices only — a plan or add-on price in another currency cannot be bought online, see Which price is charged). What counts is the purchase's monthly net: (seat price + add-on price) × seats; an annual price counts as a twelfth (rounded down). A wallet top-up never counts. Above it the checkout is refused with 409 above_self_serve_limit and the workspace UI offers Discuss requirements instead (a plan change answers the same 409 above_self_serve_limit). Reactivation is exempt (it restores what was bought).

Changing seats and add-on

A workspace that already pays can change its seats and its EU-governed add-on in the workspace, in two steps: a preview that shows exactly what will be charged, then a commit that carries the previewed figures back. The rules:

  • Upgrade — applies now. When the new monthly total is higher than the current one, the change takes effect immediately and the difference for the rest of the period is charged now, prorated, to the subscription's saved payment method. If the card needs confirmation (3-D Secure) or is declined, the plan is not changed; the customer is sent to Stripe's payment page instead (pending_payment).
  • Downgrade — at the period end. When the new monthly total is the same or lower, nothing is charged or refunded; the change is scheduled for the end of the current period and can be cancelled until then.
  • Mixed changes are split (MAP-4596). A mixed change — one part goes up, the other down: for example more seats and no add-on, or fewer seats and the add-on added — is not decided by the total. The part that goes up (the added seats, or the added or dearer add-on) applies now and its prorated difference is charged now, like an upgrade; the part that goes down (the removed or cheaper add-on, or the seat cut) is scheduled for the end of the current period, like a downgrade, and can be cancelled until then. The preview answers kind: "mixed" and shows both parts. Every other change is decided by the monthly total: the monthly net of the target (seat price + add-on price) × seats, against the current one. An annual price counts as a twelfth (rounded down) — the same rule as the self-serve limit.
  • Prices. Added seats are priced at the price the subscription already pays. An add-on the subscription already has is priced at the price it already pays, even when its catalog row is no longer public; a newly added add-on at the catalog price for the subscription's interval and currency. A different add-on replaces the current one at the catalog price.
  • The interval is not changed here. Switching between monthly and annual is not offered; the summary reports the current interval.
  • When the seat limit and the add-on change. The workspace's seat limit and add-on entitlement follow the subscription: an applied upgrade changes them at once; a scheduled downgrade changes them at the period end, when Stripe applies it (until then the current seats and add-on stay, and the scheduled seat count caps every seat-giving add: invite, restore, move into the workspace and SCIM provisioning are refused above it, see the Seats note below); an upgrade in payment_pending changes nothing — it changes them once its invoice is paid, and never if the invoice lapses.
  • One scheduled change at a time. A new downgrade replaces a scheduled one (the preview says so in replaces_scheduled); an upgrade while a downgrade is scheduled is refused until the downgrade is cancelled.
  • Roll-out. Plan changes are enabled per workspace. Where they are not, POST /billing/change/preview and POST /billing/change answer 404, exactly like a route that does not exist; a scheduled change stays visible in the summary and can still be cancelled.
  • The Stripe Billing Portal still offers no subscription changes — only invoices, the payment method and cancellation (at period end).

A trial workspace has no subscription and uses the trial conversion checkout instead: here it answers 409 no_subscription once plan changes are enabled for the workspace (404 before, on preview and commit; cancel always answers 409 no_subscription).

Who may call, and the check order

All three routes are session-authenticated, and the owner or a holder of Buy plans and add budget may call them — the same decision as the checkout. The client is never the authorization boundary: role, enablement and blockers are re-checked on every call, and the workspace comes only from the session (no workspace id in any body).

The first failing check answers.

Preview and commit:

  1. Impersonation → 403 impersonation_forbidden.
  2. The caller is the owner or a holder → else 403 forbidden (code billing_purchaser_only).
  3. Plan changes are enabled for the workspace → else 404 { "error": "not found", "code": "route_not_found" }.
  4. The workspace is self-serve → else 403 forbidden (code self_serve_plan_required; a workspace billed by an account manager).
  5. A subscription exists → else 409 no_subscription.
  6. The body shape (see the input table), with no catalog read: seats an integer from 1 to 100 000, addon null or a string matching the slug pattern → 400. Then the per-workspace rate limit → 429 rate_limited (only a body that passed this check counts).
  7. Commit only: the per-workspace lock (409 busy when another change, a cancel or a checkout for the workspace is in flight; the lock is the same one the checkout takes, so the two exclude each other), then the subscription is read again under the lock and every following check runs on that row. While a commit holds the lock, a preview or the summary of the same workspace reports the blocker checkout_open (409 change_blocked on the preview) until the commit has finished. The lock also covers a Stripe update whose outcome is still unknown: the commit records the update before it sends it and drops the record once Stripe has answered it (applied, pending or refused). While a record exists the next commit or cancel answers 409 busy for the first 5 minutes, since the update may still be in flight. After that it reads the live subscription: the update's target, or a pending update to that target, means it was applied (409 busy: the plan changed, so re-preview); a live state that cannot be read in full answers 502 stripe_unavailable and keeps the record; anything else means it was not applied, the record is dropped and the request goes on with its own checks. A recorded update that nobody retries is settled in the background (about every minute, once it is older than 5 minutes) the same way; an applied update is audited for the user who confirmed it. A recorded update is never sent again, so no change is charged after its request answered an error, and no second, different change is sent while the first one's outcome is open.
  8. The stored state is readable: the seats, the billing interval of the recorded seat price, the add-on, the scheduled change and the pending payment → else 500 internal error (logged; never a guessed value). A subscription with no recorded seat price, or with one that is not bound to a catalog plan (legacy or sales-made), is not a fault here; step 9 answers it as not_self_serve. A catalog that cannot answer is 503 checkout_unavailable.
  9. Blockers → 409 change_blocked (precedence as in the summary).
  10. A previous upgrade still waits for payment → 409 payment_pending. The same answer, with pending_payment: null, comes from the Stripe check of an upgrade (preview and commit) and of a downgrade commit in the short window after that upgrade's invoice was paid, or after an upgrade (or the increase of a mixed change) that was paid at once: Stripe has applied it, but the gateway has not recorded the new seats or add-on yet. It is given only when Stripe's live seats and add-on are exactly what the latest recorded change bought and the stored ones are what it started from; otherwise (any other difference, or a failed lookup) the answer stays 502 stripe_unavailable. A retry works once the summary shows the new seats.
  11. The target equals the current plan or the scheduled one → 409 noop.
  12. Add-on resolution. A newly added add-on must be a public self-serve add-on row → else 400 unknown_addon, with a price for the subscription's interval and currency → else 409 addon_unavailable. The add-on the subscription already has is resolved from its own price and binding, whatever the row's visibility (step 9 has already refused it when that price is not self-serve or not active).
  13. Seats against the plan's max_seats → 400 invalid_seats (only this invalid_seats carries max_seats).
  14. The kind (upgrade or downgrade, from the resolved prices; mixed where the seat part and the add-on part go in opposite directions); an upgrade or a mixed change while a downgrade is scheduled → 409 downgrade_scheduled. The schedule webhook leaves the stored change untouched while the schedule is inert (see pending_change below), so the stored change of a downgrade that has already landed still counts as scheduled: DELETE (409 noop) clears it and releases the inert schedule, then the upgrade goes through. An upgrade preview whose live subscription carries a schedule that is not inert is 502.
  15. Seats against active users → 409 seats_below_active_users — except for a pure reduction: seats at or below the current seats with no add-on added or replaced (keeping the stored add-on, or removing it, including at equal seats, is a pure reduction; adding or switching one is not). A pure reduction may target below the active users: it is scheduled for the period end, the current seat cap and every member stay untouched until then, and a new invite is refused against the scheduled count meanwhile. A change that raises the seats, adds or replaces an add-on, or any trial or first purchase keeps the floor. A mixed change is checked at the seats of the part it applies now (the higher of the current and the target seats); its scheduled seat cut is exempt like any scheduled reduction.
  16. The self-serve limit → 409 above_self_serve_limit. A mixed change is checked at the state right after its increase, the highest total it reaches.
  17. Commit only: the expect window and the re-preview → 409 price_changed.
  18. The live payment-method check, only when the change charges now (an upgrade) → 409 change_blocked with no_payment_method: none saved, one Stripe no longer has or that is detached, or a card past its expiry month at the time of the request (PC-127; the commit does not judge it at the quoted proration_date). A method Stripe's answer cannot decide (read failure, a card without a readable expiry) is 502 stripe_unavailable. A downgrade is scheduled without a charge and needs no saved payment method.
  19. Stripe → 502 stripe_unavailable on failure.

Commit upgrade over an inert schedule: the commit releases the inert schedule (and clears the stored change) under the lock before the items update; a failed release is 502 with no update sent, a lost lock is 409 busy.

Commit, today: an upgrade is applied and a downgrade is scheduled for the end of the current period. An upgrade that removes or replaces the add-on answers 501 not_implemented (after step 16, before the expect check and before any Stripe call). Removing the add-on with more seats is a mixed change and is split, so in practice only a swap to a dearer add-on answers 501. A commit that carries expect.kind: "mixed" for a change that is no longer mixed (the subscription or an add-on price changed since the preview) answers 409 price_changed before that 501. The preview of such a change still answers 200. A different change right after an applied one (before the webhook has mirrored the applied change into the stored subscription, a matter of seconds) answers 409 payment_pending with pending_payment: null when Stripe's live seats and add-on are exactly what that change set and the stored ones are what it started from (step 10); any other difference between the live and the stored subscription answers 502 stripe_unavailable. Retry shortly in both cases.

A caller who is not an owner or holder gets 403 whatever the enablement or the body; for an owner or holder, the 404 of a workspace without plan changes cannot be told apart from an absent route. Preview never takes the lock and never answers busy (it only reads; two tabs may preview at once). Commit evaluates noop under the lock, so the second request of a double submit answers noop once the first has landed, or payment_pending when the first waits for payment. The answer comes from the live subscription at Stripe: if it already has the requested seats and add-on, the commit answers 409 noop; if it waits for payment, 409 payment_pending. Two requests at the same moment: one is applied (200), the other answers 409 busy or 409 noop. Never a second Stripe update.

Cancel: impersonation → owner or holder → self-serve → subscription → rate limit (429) → lock (busy) → subscription read again under the lock → Stripe's live subscription (502) → nothing scheduled at Stripe (noop) → release the schedule (502) → clear the stored change (503). No enablement step and no blocker step. A running Checkout session does not make cancel busy.

A workspace whose subscription is on a price the self-serve catalog does not sell — seat or add-on — carries the blocker not_self_serve, so it answers 409 change_blocked before any add-on lookup or plan max_seats check, never unknown_addon or invalid_seats for a seat count within 1 … 100 000.

Rate limit

Preview and commit call Stripe, whose API quota every workspace shares, so both are limited per workspace: at most 30 previews, 10 commits and 10 cancels within 60 s; above that → 429 rate_limited. Only requests that passed the body check count (a malformed body is never throttled), so the counter cannot be filled by trying values. The counter is per server node, so the effective limit is the stated number × nodes. Cancel is limited as well (it reads Stripe once, also when it answers noop); the body check does not apply, since cancel reads no body.

POST /admin/v1/billing/change/preview

Partner-billed workspace: 403 {"error":"forbidden","code":"partner_billed"}, see Partner-billed tenants.

Read-only: shows what the change would cost and does not change anything.

{ "seats": 30, "addon": "eu_gov" }
  • seats — integer, 1 … the plan's max_seats (see the catalog); never above 100 000.
  • Removing the add-on (or switching to a cheaper one) with more seats is a mixed change and is split. An upgrade that replaces the add-on with a dearer one is previewed normally, but its commit answers 501 not_implemented for now. Fewer seats with a switch to a dearer add-on answers 501 not_implemented already at the preview (and at the commit).
  • addon — a bare slug string (^[a-z0-9_-]{1,64}$) or null for no add-on. Unlike the checkout, where addon is a { slug, expect } object.
  • Both keys are required — an absent key and a malformed one are different answers.
  • This route is stricter than the checkout: every unknown top-level key answers 400 unsupported_field (with field naming it); on the preview that includes expect. The checkout and the top-up are strict in the same way.

Response 200

{
  "kind": "upgrade",
  "effective_at": 1760000000,
  "current": { "seats": 25, "addon": null,     "monthly_net_minor": 32500 },
  "target":  { "seats": 30, "addon": "eu_gov", "monthly_net_minor": 48000 },
  "currency": "EUR",
  "tax_behavior": "exclusive",
  "amount_due_now_minor": 2190,
  "replaces_scheduled": false,
  "expect": { "proration_date": 1760000000, "amount_due_now_minor": 2190, "currency": "EUR",
              "monthly_net_minor": 48000, "kind": "upgrade" }
}
  • kind — upgrade (the target's monthly net is higher: applies now, prorated charge) or downgrade (the same or lower: scheduled for effective_at, the period end, with amount_due_now_minor: 0). For an upgrade effective_at is the moment of the preview, the same instant as expect.proration_date.
  • monthly_net_minor — (seat price + add-on price) × seats; an annual price counts as a twelfth (rounded down), as for the self-serve limit.
  • amount_due_now_minor — the prorated amount Stripe will charge now: Stripe's own amount due, that is the invoice total including tax, after any discount or coupon on the subscription, less any credit balance of the customer. A downgrade makes no Stripe call: the amount is 0 and effective_at is the stored period end. An amount below Stripe's minimum is still shown; Stripe carries it to the next invoice.
  • replaces_scheduled — true when a downgrade is already scheduled and this downgrade overwrites it.
  • expect — hand it back unchanged in the commit; the client does not interpret it. It locks everything the customer was shown: today's charge and currency, and the target's monthly net and the kind (a downgrade charges 0 now, so its new monthly price must be locked too).

Response 200, mixed change: 25 seats with the add-on → 30 seats without it.

{
  "kind": "mixed",
  "effective_at": 1762000000,
  "current":   { "seats": 25, "addon": "eu_gov", "monthly_net_minor": 40000 },
  "target":    { "seats": 30, "addon": null,     "monthly_net_minor": 39000 },
  "increase":  { "seats": 30, "addon": "eu_gov", "monthly_net_minor": 48000, "amount_due_now_minor": 2190 },
  "reduction": { "seats": 30, "addon": null,     "monthly_net_minor": 39000, "effective_at": 1762000000 },
  "currency": "EUR",
  "tax_behavior": "exclusive",
  "amount_due_now_minor": 2190,
  "replaces_scheduled": false,
  "expect": { "proration_date": 1760000000, "amount_due_now_minor": 2190, "currency": "EUR",
              "monthly_net_minor": 39000, "kind": "mixed",
              "increase_monthly_net_minor": 48000, "effective_at": 1762000000 }
}
  • increase — the state right after the part that goes up: the higher seat count with the add-on side that went up (more seats: the current add-on is kept on them until the period end; fewer seats: the added or dearer add-on applies at the current seats). It is applied at the commit; amount_due_now_minor is Stripe's invoice preview of only this part (prorated, the same rule as an upgrade).
  • reduction — the part that goes down, scheduled for effective_at: Stripe's live current period end (not the stored one). Nothing is charged or refunded for it. It ends at the full target.
  • effective_at (top level) is the reduction's date; amount_due_now_minor is the increase's charge.
  • expect additionally locks increase_monthly_net_minor and effective_at. These two members exist only with kind: "mixed" (see Accepted input).
  • A live period end that cannot be read, or that is not ahead, is 502 stripe_unavailable.

POST /admin/v1/billing/change

Partner-billed workspace: 403 {"error":"forbidden","code":"partner_billed"}, see Partner-billed tenants.

Applies a previewed change. The body is the preview body plus expect, echoed verbatim from the preview:

{
  "seats": 30, "addon": "eu_gov",
  "expect": { "proration_date": 1760000000, "amount_due_now_minor": 2190, "currency": "EUR",
              "monthly_net_minor": 48000, "kind": "upgrade" }
}

Any other top-level key answers 400 unsupported_field, as on the preview.

expect.proration_date is supplied by the client, so it is validated: an integer, not in the future, not older than the preview's validity window of 10 minutes, and not before the current period start. A client re-previews instead of committing a preview older than that. Outside the window the answer is 409 price_changed with a fresh preview. The server then prices the change again at that proration_date; any difference in the amount due now, the currency, the target's monthly net or the kind is also 409 price_changed with the fresh preview — show it and ask the customer again. What is charged or scheduled is always what the customer saw.

Retry-safe. A retry of the same confirmed preview (same target and proration_date) is never charged twice: the Stripe write carries an idempotency key made of the subscription, the target seats and add-on and expect.proration_date, and a retry first reads the live subscription, so a change that already landed answers 409 noop (or 409 payment_pending) instead of a second charge. After a 502, re-preview instead of resending the same expect: the change may or may not have applied, and the summary shows the truth.

The commit applies an upgrade at once and schedules a downgrade for the end of the current period; an upgrade that replaces the add-on with a dearer one answers 501 not_implemented for now (removing it with more seats is a mixed change and is split, see above; see the staged rollout). The seats and add-on of an applied upgrade are written by Stripe's subscription webhook once Stripe has applied the change, not by the commit. A downgrade charges nothing and needs no saved payment method: the commit puts a Stripe subscription schedule on the subscription (the current terms until the period end, then the target terms) and stores the scheduled change, which the summary shows as pending_change until it lands. expect.amount_due_now_minor must be 0 for a downgrade, as the preview showed. A downgrade while another is scheduled replaces it (the preview says replaces_scheduled: true); the earlier one is never kept alongside. The phase boundary is the live period end, read again under the lock: if Stripe's period end is no longer the one the preview showed, or has passed, the commit answers 502 stripe_unavailable and schedules nothing (retry shortly).

Response 200

{ "result": "applied", "pending_change": null, "pending_payment": null }
result Meaning
applied An upgrade, paid; the plan is changed.
scheduled A downgrade, scheduled for the end of the period; pending_change is filled (seats, addon, effective_at) and pending_payment is null. Nothing is charged.
payment_pending An upgrade that needs payment or 3-D Secure, or whose card was declined. The plan is not changed; pending_payment is filled and the client sends the customer to hosted_invoice_url.

Mixed change (the answer carries "kind": "mixed" and pending_reduction). The commit checks expect like an upgrade's, plus increase_monthly_net_minor and effective_at against Stripe's live period end (a renewal since the preview is 409 price_changed). It sends only the increase to Stripe (the same payment and 3-D Secure handling as an upgrade, its own idempotency key plan_change_mixed:<sub>:<seats>:<addon or ->:<proration_date>), then schedules the reduction:

result Meaning
applied, pending_change filled The increase is applied and paid; the reduction is scheduled (pending_change: seats, addon, effective_at); pending_reduction is null. One plan-change-mixed mail.
applied, pending_reduction filled The increase is applied and paid; the reduction is recorded but not scheduled yet (a Stripe or lease fault right after the charge). It is scheduled by the follow-up; if Stripe's period has already moved past effective_at, the change is held and the operators are alerted. No mail yet.
payment_pending The increase waits for payment (3-D Secure, a declined card); nothing is scheduled yet. pending_payment and pending_reduction are filled; the reduction is scheduled once the increase is paid, never if the invoice lapses.

Finishing a mixed change. After the commit, the reduction of a change answered with pending_reduction is scheduled automatically: when Stripe reports the increase paid (also after a 3-D Secure payment), on the next commit or cancel of the workspace, or by the background check (about every minute, once the change is older than 5 minutes). Then the summary shows the reduction as pending_change and the plan-change-mixed mail is sent. The change is abandoned (the reduction is never scheduled, an audit entry billing.change_abandoned says why) when the increase's payment lapses (the invoice is voided or the pending update expires: nothing was charged), when the subscription has ended (or is still cancelling once the period end has passed), or when it was changed elsewhere (the operators are alerted). A cancellation that is only pending does not abandon it: it can be withdrawn, so the change waits, and is finished as normal if the cancellation is withdrawn before the period end. If Stripe's period end has passed before the reduction could be scheduled, the change is held and the operators are alerted. While a mixed change is still being finished, the next commit or cancel of the workspace first finishes it: if that schedules the reduction, or the change cannot be finished yet, it answers 409 busy (preview again); if the change is abandoned, the request goes on with its own checks.

In the summary. While a committed mixed change is not finished yet, GET /admin/v1/billing/summary carries pending_mixed (only where a mixed change was committed), for the owner or a holder of Buy plans and add budget (withheld from other members, like pending_payment):

"pending_mixed": { "stage": "awaiting_payment",
                   "increase":  { "seats": 30, "addon": "eu_gov" },
                   "reduction": { "seats": 30, "addon": null, "effective_at": 1762000000 } }

stage is increase (the charge is being confirmed), awaiting_payment (the increase waits for payment) or reduce (the increase is applied, the reduction will be scheduled). The key is absent when there is no such change (it is never null), and also when the stored change cannot be read (logged). Once the reduction is scheduled it shows as pending_change instead.

"late": true is added once effective_at has passed while the change is still not finished (for example after an outage): the reduction is then applied as soon as possible (once the increase is paid), without proration, instead of being scheduled (MAP-4597). The key is absent before effective_at; it is never false. Once the reduction is applied, pending_mixed disappears and seats / addon show the reduced plan.

Late reduction: the invoice list (MAP-4597). For the operator alert of a late reduction the gateway reads the subscription's invoices from Stripe (GET /v1/invoices with subscription and created[gte] = effective_at less one hour, read-only, every page up to 5 pages of 100). The answer is a third-party input and is taken whole or not at all: it is rejected, and the alert says "invoice list unavailable, check in Stripe", when a page is not an object with a data array and a boolean has_more, has_more is true on an empty page, the listing is not finished after 5 pages, or any invoice has an id that is not an in_ id, a total that is not an integer, an amount_paid / amount_remaining that is not a non-negative integer, a created that is not a positive integer or lies before the requested date, a number / status / billing_reason that is present but not a non-empty string, a paid_out_of_band that is present but not a boolean, a total_discount_amounts that is present but not an array of objects with a non-negative integer amount (an empty JSON object is not an empty array), a credit-note amount that is present but not a non-negative integer, a parent or parent.subscription_details that is absent, null or not an object, or a parent.subscription_details.subscription that is not exactly this subscription (absent, null or another one). An absent or null optional field stays unknown. A hosted_invoice_url that is not an https://invoice.stripe.com link is dropped; the invoice is kept. The list never delays or blocks the reduction itself.

Confirmation mail (MAP-3261). A commit that answers 200 with applied or scheduled sends the tenant's notification recipient (normally the owner; the same recipient as the other billing mails) one mail, in the recipient's language (their own locale, else the tenant's default language, else English) and with the tenant's product name: plan-change-applied (the new seat count, an add-on change, and whether the proration is charged now) or plan-change-scheduled (the target seats and the date it takes effect), or, for a mixed change whose reduction is scheduled, plan-change-mixed (the amount charged now when Stripe's applied invoice shows it, the new seat count, the add-on change, and the date the reduction takes effect). The mail is sent after the commit's lock is released and never changes the HTTP answer: a missing recipient or a send failure is logged (plan-change mail) and the answer stays 200. No mail is sent for payment_pending, for any answer other than 200 applied / 200 scheduled, for a commit that was settled later (including an upgrade paid after 3-D Secure; the one exception is a mixed change, whose plan-change-mixed mail is sent when its reduction is scheduled, also by the follow-up), or for DELETE /admin/v1/billing/change. Separately, the tier-changed mail sent on the subscription webhook no longer promises that a downgrade "takes effect next billing period"; it says the new plan is active now.

DELETE /admin/v1/billing/change

Cancels the scheduled change (releases the schedule). The route takes no input: a body or a query string is not read, by design — nothing in it could change the outcome, so ignoring it is not permissive.

Response 200: { "cancelled": true }. 409 noop when nothing is scheduled at Stripe: the answer comes from the live subscription, not from the stored copy. If Stripe has no schedule but the workspace still shows one (the downgrade already took effect, or the schedule was released elsewhere), the stale stored change is cleared and the answer is 409 noop. A schedule that Stripe still keeps attached but that is inert (the downgrade has landed, or it never got a later phase; see Accepted input) is released first, whoever made it (tagged or not), then the stored change is cleared and the answer is 409 noop (no audit entry); a schedule with a later phase that is not ours (no tag or another product tag), or that does not end with release, is 502 and is left alone; if that release fails the answer is 502 and the stored change is left as it was. It takes the same per-workspace lock as the commit (409 busy when a change or cancel is in flight) and the rate limit; a running Checkout session does not block it. A Stripe failure (reading the subscription or releasing the schedule) is 502 stripe_unavailable and the stored change is left as it was; a database fault while clearing it after the release is 503 (retry: the next cancel answers noop and finishes the clearing). It does not touch a pending payment (that is paid, or lapses on its own). It is not gated by enablement and is allowed in every blocker state — dropping a downgrade is always safe.

Accepted input / rejected input (preview and commit)

Key Absent JSON null Wrong type Out of range
seats 400 missing_field 400 invalid_seats 400 invalid_seats (not an integer: 30.5, "30") 400 invalid_seats: below 1 or above 100 000 at the body check; above the plan's max_seats after the blockers (check order step 13), with max_seats in the body
addon 400 missing_field accepted: no add-on 400 invalid_addon (not a string: object, array, number) 400 invalid_addon (fails the slug pattern); 400 unknown_addon (well-formed, a newly added add-on that is not a public self-serve add-on; the add-on the subscription already has is accepted even when its row is no longer public)
expect (commit) 400 missing_field 400 invalid_expect 400 invalid_expect (not an object; an array included) —
expect.proration_date 400 missing_field 400 invalid_expect 400 invalid_expect (not an integer) 400 invalid_expect (below 1, or above 2^53 − 1); 409 price_changed (in the future, older than the window, or before the period start)
expect.amount_due_now_minor 400 missing_field 400 invalid_expect 400 invalid_expect (not an integer) 400 invalid_expect (below 0 or above 2^53 − 1); a different amount is 409 price_changed
expect.currency 400 missing_field 400 invalid_expect 400 invalid_expect (not a string) 400 invalid_expect (not three ASCII letters); a different currency is 409 price_changed
expect.monthly_net_minor 400 missing_field 400 invalid_expect 400 invalid_expect (not an integer) 400 invalid_expect (below 0 or above 2^53 − 1); a different monthly net is 409 price_changed
expect.kind 400 missing_field 400 invalid_expect 400 invalid_expect (not a string) 400 invalid_expect (not upgrade, downgrade or mixed); a different kind is 409 price_changed
expect.increase_monthly_net_minor (only with kind mixed) 400 missing_field with kind mixed 400 invalid_expect 400 invalid_expect (not an integer) 400 invalid_expect (below 0 or above 2^53 − 1; or present with another kind); a different net is 409 price_changed
expect.effective_at (only with kind mixed) 400 missing_field with kind mixed 400 invalid_expect 400 invalid_expect (not an integer) 400 invalid_expect (below 1 or above 2^53 − 1; or present with another kind); a different live period end is 409 price_changed

missing_field carries field (dotted for expect.*, for example expect.currency). An unknown top-level key answers 400 unsupported_field on both routes (on the preview that includes expect); an unknown key inside expect answers 400 invalid_expect. A body that is not a JSON object answers 400 invalid_body; text that is not valid JSON answers 400 malformed_body.

Validation order. Unknown top-level keys, then seats, then addon, then (commit) expect, then an unknown key inside expect (invalid_expect), then the members of expect in the table's order (the two mixed members last). Within expect, an absent member answers missing_field and an invalid one invalid_expect, whichever comes first in that order. A key repeated in the JSON text counts as its last value.

Scheduled-change confirmation

A schedule release or completion webhook can arrive before the background items check. If the live subscription has no attached schedule but already has the stored target items at or after its effective period boundary, the webhook uses the same claimed, fresh-read confirmation as the background check: the enforced seat cap and the pending-change clear commit together. The event payload alone is never proof that the change applied. A repeated delivery cannot apply the same transition twice.

A release before application, confirmed by the live period or complete live items, clears the cancelled change without lowering the cap. An unreadable target or period, zero or malformed live quantity, incomplete catalog, read/write fault, competing claim or changed schedule target is not cancellation proof: the pending evidence stays for retry and the webhook reports failure. If a self-serve workspace has no plan entitlement row, the evidence also stays until the cap can be confirmed; a separate schedule reconciliation must not discard it. Existing terminal-subscription cleanup is unchanged.

Stripe answers (untrusted input)

The gateway treats every Stripe answer the plan change reads as untrusted and validates it before use:

  • Calls made. The preview asks Stripe for POST /v1/invoices/create_preview with automatic tax and subscription_details. A scheduled change creates a schedule from the subscription (or reads the one the subscription already has, to replace it), then sets its phases (the current terms until the period end, then the target terms, each with automatic tax) with end_behavior=release, proration_behavior=none and metadata.product=ai-gateway. The answer is checked before it is believed: it must belong to this subscription, be active, have complete phases, and the second phase must start at the period end with exactly the target items; an updated schedule must in addition be ours (metadata.product = ai-gateway, end_behavior = release); anything else is 502 stripe_unavailable. A schedule created by a request that then fails is released again; a schedule that already existed is left as it was.
  • Idempotency keys of schedule writes. Every schedule write carries an idempotency key that is unique per request. The create and update keys include the lock lease generation. The release keys (plan_change_cancel:, plan_change_spent:, plan_change_undo:) include it too; under an unfenced open-Checkout lock, which has no generation, they include a per-request nonce instead. Within one request, a resend after an unknown outcome reuses its key and is safe. A later request is a fresh Stripe write, even with the same target (after a DELETE, or 3 -> 4 -> 3 seats): Stripe stores the first answer per key, including a transient error, and never replays it to another request.
  • Lost lock lease. After the lease is lost, the request writes nothing more, not even the release of a schedule it created, and answers 409 busy (503 when the lock row cannot be read to check the lease). The schedule is left for the next downgrade, DELETE or the webhook sync, and the error log names it. If the lease was lost before the resend of a creation or update whose outcome is unknown, Stripe may already hold that write: after a phases update, the requested downgrade may be scheduled although the summary does not show it. Retrying the commit replaces and stores it; DELETE releases it.
  • Untagged schedules. Stripe refuses any metadata together with from_subscription, so the creation request carries none: a created schedule is untagged until the phases update tags it. A leftover of our own create is therefore untagged but inert (one phase, the live items): the next downgrade replaces it and DELETE releases it. The create answer is not tag-checked, but one that is not a valid, release-ending schedule of this subscription is a bad answer (502). A schedule with a later phase that is not ours (foreign tag, no tag, or an end behavior other than release) is never touched by DELETE or a downgrade; operations release it at Stripe. An answer that is not a valid schedule object is a definitive bad answer (502), never resent. A schedule is released by DELETE /billing/change (and when it is no longer needed).
  • An inert schedule counts as nothing scheduled. Stripe keeps a schedule attached through its last phase after a downgrade has landed, and refuses item updates on a schedule-managed subscription. The gateway reads the schedule and calls it inert only when all of this holds:

    • it ends with end_behavior = release (the tag does not matter: Stripe cannot tag a schedule at creation);
    • it belongs to this subscription and is active with complete phases;
    • exactly one usable phase is current, and every other phase started earlier (the current phase is the last one);
    • the current phase's items equal the live items (price, quantity).

    The current phase is the one that contains the live subscription's current_period_start, never the gateway's clock, which can differ from Stripe's. A period start that falls in no phase, or a missing one, means not inert. Anything else, or an unreadable schedule, is not inert and fails closed (502). A schedule with a later phase that is not ours (no tag or another product tag) or that does not end with release is never released or replaced by DELETE, a downgrade or an upgrade: the answer is 502 stripe_unavailable, nothing is written, and an error naming the schedule and the subscription is logged for operations to resolve at Stripe. An inert schedule is released by DELETE (409 noop) and, before the items update, by an upgrade commit.

  • Commit calls. The commit reads the subscription (with its latest invoice), prices the change again with the preview call at the confirmed proration_date, and then updates the subscription once: seat quantity (and the add-on's quantity, or the newly added add-on) in one call, proration_behavior=always_invoice, payment_behavior=pending_if_incomplete, the confirmed proration_date and an idempotency key. It then classifies the answer: no pending update and the new items → applied; a pending update to exactly the new items, with an open invoice and a hosted payment link → payment_pending; anything else (or a call that fails or times out) → it reads the subscription again and, if the outcome is still unproven, answers 502 stripe_unavailable. A write whose outcome is unknown is retried once with the identical key, and only when the subscription is demonstrably unchanged. A 2xx answer to the upgrade write whose body cannot be read is an unknown outcome (see "Unreadable 2xx" below). The confirmation e-mail says the prorated amount is charged to the payment method only when the applied subscription's latest invoice is a new subscription_update invoice with amount_paid above zero. Otherwise (a change below Stripe's minimum charge, or one paid from the account credit balance) it says: "No amount was collected from your payment method for this change now; any prorated amount appears on your next invoice or was covered by your account credit." If the applied invoice's fields are absent or unreadable, or the invoice before the write cannot be read, the e-mail follows the preview's figure and a WARN is logged. A malformed amount_paid or billing_reason is treated as unreadable. (PC-172.)

  • cancel_at (MAP-3777). A live cancellation - cancel_at set, which Stripe also sets for a period-end cancellation - is 409 change_blocked with blocker: cancel_pending on the upgrade preview and on every commit (nothing sent to Stripe); a downgrade preview is priced offline, so the block shows when the downgrade is confirmed. A malformed cancel_at (not a positive integer timestamp) is 502 stripe_unavailable, never read as "not cancelling". (PC-170.) A live cancel_at_period_end=true without a cancel_at is treated the same way. One rule: any live pending cancellation is 409 cancel_pending, even when the stored row does not show it yet. Fixed date (MAP-4157). When the live subscription has a fixed cancellation date (cancel_at set, cancel_at_period_end false), the 409 body also carries cancel_at (unix seconds) and the date is written to the stored subscription (subscription.cancel_at, never onto a canceled row), so the next summary read shows it. A refusal from the stored fixed date (before any Stripe read) carries the same cancel_at. The app then says when the plan ends and to contact us, not "reactivate first". A customer's own cancellation carries no cancel_at in the body. A failed write is logged; the refusal is unchanged.
  • Unreadable 2xx on the upgrade write (MAP-3777). A 2xx answer whose body cannot be read is an unknown outcome, not a refusal: the change record is kept and the subscription is read again. Applied: the normal applied path. Payment pending: as for a readable answer. Provably unchanged: the write is resent once under the same idempotency key (Stripe replays a stored result and never applies it twice); if that answer is unreadable too, 502 with the record kept, no audit and no mail. A 4xx with an unreadable body stays a definitive refusal. (PC-171.)
  • Proration window (MAP-3777). An upgrade commit re-checks proration_date against the live period start as well as the stored one; a quote priced before the live period began answers 409 price_changed. (PC-173.)
  • Live subscription. Before an upgrade preview the gateway reads the live subscription; if it disagrees with the stored one the answer is 502 stripe_unavailable: a different price, seat count or add-on (including the add-on's quantity), a foreign or duplicated item, a status other than active, or a schedule or pending update on the live subscription. A downgrade preview does not read Stripe, but it answers the same 502 when the stored current_period_end is not in the future. The downgrade commit reads the live subscription and requires it to match the stored one as an upgrade does, except that an existing schedule is accepted (it is replaced). The payment method is the subscription's default, else the customer's invoice default, read live; a deleted or unreadable customer or payment method is also 502 stripe_unavailable, while no payment method at all, a detached one or an expired card gives 409 change_blocked (no_payment_method). (Edge-case catalogue: PC-127, PC-157.)
  • Amounts. Preview amounts must be integers in minor units; amount_due is never negative. A malformed amount answers 502 stripe_unavailable, never a guessed number. A malformed period bound is dropped and logged.
  • schedule, pending_update, latest_invoice. A malformed value is treated as unreadable and logged, never as "nothing scheduled" or "nothing pending".
  • Pending payment and dunning (MAP-3777). A failed payment of a proration invoice is a pending payment only while the subscription has a live Stripe pending_update; with none (for example an ops change made in the Stripe dashboard) the failure is an ordinary failed payment with grace and the dunning e-mail. A malformed pending_update is retried by Stripe and writes nothing.
  • Stripe price changes never undo a staff plan. A subscription event whose price did not change does not move a tenant whose plan is not self-serve (enterprise or manual plan, or an unreadable plan name) to a self-serve plan.
  • Payment link. A hosted invoice link must be on invoice.stripe.com (https, no port or user info, printable ASCII only); any other link is dropped and logged.

Errors

Status / code When Body extras
400 invalid_body The body is absent or valid JSON that is not an object ([], "x", 7, true, null). Invalid JSON is 400 malformed_body.
400 malformed_body The body is not valid JSON.
400 missing_field, invalid_seats, invalid_addon, unknown_addon, invalid_expect, unsupported_field Per the input table above. field on missing_field and unsupported_field; max_seats only on an invalid_seats above the plan's maximum (step 13)
403 forbidden The workspace is not self-serve (code self_serve_plan_required), or the caller is neither the owner nor a holder of Buy plans and add budget (code billing_purchaser_only) (all three routes). code
403 impersonation_forbidden An administrator viewing the app as a user (all three routes).
404 Plan changes are not enabled for this workspace (preview and commit only). code route_not_found
409 no_subscription No subscription (a trial): preview and commit once plan changes are enabled for the workspace (else 404), cancel always.
409 noop The target equals the current plan or the scheduled one. On DELETE: nothing is scheduled at Stripe.
409 seats_below_active_users seats is below the workspace's active users and the change is not a pure reduction (see step 15). min_seats
409 above_self_serve_limit The target's monthly net is above the self-serve limit. limit_minor, currency
409 addon_unavailable The add-on cannot be sold for this interval, currency and tax basis.
409 price_changed Commit: expect is stale, out of the window, or the amount due now, currency, monthly net or kind differs. preview (the fresh preview)
409 change_blocked A blocker applies, including no_payment_method from the live check (upgrade only). blocker
409 downgrade_scheduled An upgrade while a downgrade is scheduled — cancel it first. pending_change
409 payment_pending A previous upgrade still waits for payment. pending_payment
409 busy Commit and DELETE only: another change, cancel or checkout for this workspace is in flight, an earlier commit's Stripe update may still be in flight or turned out applied (step 7), or the commit's lock expired while Stripe was slow — re-preview and retry shortly.
501 not_implemented Commit: an upgrade that replaces the add-on with a dearer one (not built yet). Preview and commit: fewer seats with a switch to a dearer add-on. (Removing the add-on with more seats is a mixed change and is split.)
429 rate_limited Preview, commit and cancel: above the per-workspace rate limit — retry shortly.
502 stripe_unavailable A Stripe call failed or timed out (all three routes). The change may have applied: read the summary again, then re-preview before a new commit instead of resending the same expect. A retry of a commit is safe (never charged twice). A commit right after an applied change answers 409 payment_pending instead (step 10), unless the live subscription differs from what that change set.
503 checkout_unavailable Preview and commit: the catalog cannot price the change, or the stored self-serve limit is unreadable or malformed (fails closed, never replaced by the default).
503 { "error": "temporarily unavailable; retry later" } A database fault (all three routes). Nothing changed, or Stripe already accepted the change and the next call completes it; retry.
500 internal error A database fault, or stored seats / interval that are missing or malformed. Preview: also a stored Stripe subscription or customer id, or (downgrade) a stored period end, that is missing or malformed. code admin_handler_failed
401 unauthenticated No signed-in user (all three routes).

Every answer in this table carries a sibling top-level code: for the machine-string rows it equals the string in the first column; 403 forbidden and 500 internal error use the codes named in their rows. The 404 of a workspace without plan changes carries route_not_found (the dispatcher's unknown-route code, see Typed codes on the admin gates); only the storage-fault 503 and the sanitised storage 500 stay without a code. See Typed codes on billing and voucher routes.

A pending payment disappears from the summary once expires_at has passed, or once the invoice is paid and the gateway has handled the resulting customer.subscription.updated (best effort). An invoice that lapsed, was voided, written off or deleted is cleared by the periodic reconciliation, which is also the backstop for a paid one. A scheduled change stays visible, and cancellable, even when plan changes are not enabled for the workspace.

Plan change (staged rollout)

POST /admin/v1/billing/change/preview and POST /admin/v1/billing/change are behind a feature flag and a tenant allowlist: the settings plan_change_enabled and plan_change_tenant_allowlist. A workspace is allowed only when the flag is true and the allowlist is ["*"] or contains its tenant id. An absent or malformed setting means "off".

The checks run in this order, and the first failing one answers:

Situation Response
No session 401
While impersonating 403 impersonation_forbidden — the personal-route refusal, as for the other billing routes
Neither the owner nor a holder of Buy plans and add budget 403 {"error":"forbidden","code":"billing_purchaser_only"}, whatever the flag (a member never learns the rollout state); 503 when the custom-role grant cannot be read
Flag off, or workspace not allowed 404 {"error":"not found","code":"route_not_found"}, the same as a route that does not exist
Allowed The preview answers (POST /billing/change/preview; a workspace without a subscription gets 409 no_subscription, before the body is read). POST /billing/change applies an upgrade and schedules a downgrade (check order above); it answers 501 {"error":"not_implemented","code":"not_implemented"} only for a change that replaces the add-on with a dearer one (an upgrade on the commit; fewer seats plus a dearer add-on on the preview and the commit). A mixed change (MAP-4596) needs no switch of its own: it follows the plan change's availability

DELETE /admin/v1/billing/change is not gated by the flag: it cancels a scheduled change for the owner or a holder (also with the flag off, or the workspace off the allowlist), 403 for anyone else, 403 impersonation_forbidden while impersonating, 401 without a session. The same decision is published to the web app as the boolean plan_change_enabled on GET /admin/auth/me; it is present only for a caller who may buy (the owner or a BILLING_PURCHASE holder) and omitted for any other member and for an account without a workspace; if the caller's custom-role permissions cannot be read, a delegated holder sees the field omitted (the owner is unaffected).

Entitlement enforcement

A self-serve plan is enforced server-side, independent of anything stored in the gateway configuration:

  • Tier position. GET /admin/auth/me reports plan_rank and plan_rank_max, which describe where the workspace's plan sits in the commercial tier order. They let an interface decide whether there is anything above the current plan to upgrade into without hardcoding which plan is the highest. A workspace with plan_rank == plan_rank_max is on the top self-serve tier. Ranks are ordered but not contiguous, and only their order is meaningful — they are not for display. Both fields appear together or not at all; they are omitted whenever the plan carries no self-serve rank, including an unrecognised plan value. Absent means unknown, not lowest — treat it as "cannot determine", and do not offer an upgrade you cannot confirm is available. Like the rest of the billing snapshot on /me, the pair follows the snapshot's gate: a trial member receives it (owner or invited); on a paid workspace the owner and a holder of Buy plans and add budget (see the top of this page) receive the snapshot (plan, subscription_status, the renewal and grace dates, the allowance fields, wallet_usd), whereas any other invited member receives none of it, this pair included — only wallet_usd (for the read-only Wallet tab) and plan (the plan name, for the read-only Your plan; the same audience reads GET /billing/summary). Whether the caller may buy is decided by the server (the shared purchaser decision at the top of this page); the permissions array on /me is informational and does not always match it: an owner whose BILLING_PURCHASE grant is missing is still a purchaser (admitted by role), and the demo account is never one even if a custom role puts the key in its permissions. The rank pair is not reported on GET /admin/v1/billing/summary, which drives a panel with no upgrade decision to make.

  • Payment needs confirmation (payment_action_url, MAP-4776). When an overdue payment failed only because the bank asks the customer to confirm it (3-D Secure: the invoice's PaymentIntent is requires_action), and the invoice is not the gateway's own pending plan change (that one is pending_payment on GET /billing/summary and starts no dunning), the workspace still goes into the normal 7-day grace, and GET /admin/auth/me carries payment_action_url: the invoice's Stripe-hosted page, where the customer confirms the payment. The banner then reads "Your payment needs confirmation" with a Confirm payment link (new tab) instead of "update your payment method", and the payment-failed e-mail is the confirm variant with the same link. Accepted shape: a string https://invoice.stripe.com followed by / or ?, printable ASCII only, at most 2048 bytes, no port, no user info, none of @ \ % [ ] # or whitespace. Rejected: anything else (another scheme or host, a look-alike host such as invoice.stripe.com.evil.example, a port, user info, a non-string). The link comes from Stripe's own invoice (hosted_invoice_url, re-read from Stripe when the webhook arrives) and is checked with this rule three times: before it is stored, by the storage writer, and again when /me reads it; the e-mail template and the workspace UI check it once more. A rejected or missing link always falls back to the "update your payment method" banner and e-mail (fail closed — never a link of an unexpected shape). A stored value that fails the check, or half of the stored pair, is omitted from /me and logged as an error; an empty pair is simply absent. The field is present only for the workspace owner (the grace remedy is the owner's; a holder of Buy plans and add budget does not get it) and only while subscription_status is 50. It disappears when the invoice is paid or voided, when the grace ends (a recovered, cancelled, disputed or refunded subscription), and when a later failure of the same payment is not a 3-D Secure one (e.g. the card was replaced and the retry was declined: the banner goes back to "update your payment method"). A failure of a different invoice (for example a delayed event of an older, since-paid one) leaves it in place. The webhook side is described in Stripe webhooks.

  • Model list. Each plan includes a fixed list of models. A request for a model outside the plan's list is refused with 403 plan_model_not_allowed before any upstream call. The list is also reported to the interface as plan_models on GET /admin/auth/me, so the model picker offers only models the plan includes rather than letting the choice fail at send time. The field is present for every member of a self-serve workspace — including one whose plan the platform does not recognise, where it is an empty list, matching the enforcement, which denies every model for such a workspace — and absent for a manual workspace, which is unrestricted. It is reporting only — the refusal above remains the sole enforcement, so a client that ignores it still gets the 403. On a trial workspace GET /admin/auth/me also carries upgrade_plan_models: the de-duplicated union of the models the paid self-serve plans include. The interface uses it to show a model the trial excludes as locked ("until you upgrade") only when an upgrade really unlocks it; any other hidden model stays hidden. It is absent for every non-trial workspace, empty if the lookup fails (nothing is locked), and reporting only. The list governs every model, including one served by a provider key you added yourself: a third-party key on a self-serve plan is stored and shown as configured, but requests using its models are refused until the workspace is upgraded.

  • EU-governed add-on. A purchased add-on is granted from the subscription (the add-on line it bills), not from a stored entitlement row: its grant (myra_hosted_models) applies while the subscription serves — active, in grace, or inactive before its grace deadline — and ends with it, with no write. See Tenant entitlements — purchased add-on.
  • Subscription status. While a subscription is active, inference works normally. After a failed payment the subscription enters a grace period during which inference still works. Once the grace period ends (or the subscription is cancelled or disputed) inference is blocked with 402 subscription_inactive; the account and billing pages stay reachable so the subscription can be reactivated. The workspace owner sees the state as a banner with its remedy — during the grace period A payment failed — please update your payment method by … (without a date while the deadline is not yet known) with Update payment method, once inactive Your subscription is inactive. with Reactivate (or Update payment method where no new checkout is possible). It shows on every page and, of the billing pages, on Your plan only, where its button opens the billing portal or the reactivation checkout directly; the other billing pages show no billing banner.
  • Spend enforcement (wallet-only). Since the wallet money-model rework, a workspace's spend is enforced against its prepaid wallet, not a plan budget: a turn is admitted while the wallet holds spendable balance and is not frozen; when the wallet is empty (or frozen) requests are refused with 429 quota_exceeded. There is no over-cap efficient-model soft-degrade — the stop is a hard stop, with no model swap. A workspace may also set an optional, self-imposed monthly spend_cap_usd (see PATCH /tenants/{id}) that binds below the wallet; reaching it refuses with the same 429 quota_exceeded. The over-cap state is reported as allowance_state on both GET /admin/auth/me and GET /admin/v1/billing/summary: "wallet" (the spendable balance can carry a turn), "blocked" (the wallet is empty or frozen), or absent on /me (unknown — a failed balance read; on /billing/summary a failed balance read is the retry 503 instead). The app locks the composer only on "blocked": an absent state is not read as an empty wallet (no "allowance used up" notice or over-cap banner) — the next turn is decided by the server, which refuses it with the retryable 503 spend_unverified when it cannot read the balance either, or 429 quota_exceeded when the wallet is empty, and the app re-reads /me after the turn. The retired "degraded" state is gone. On GET /admin/v1/billing/summary, allowance_used_pct reports spend against the self-imposed spend_cap_usd (its spent_usd / cap_usd); it is 0 when no cap is set (the wallet balance is then the only limit). allowance_renewal_date tracks the subscription's allowance reset (~30 days, decoupled from the Stripe invoice cadence — see the two clocks under GET /admin/v1/billing/summary).
  • Free trial. A no-card 7-day trial workspace is on the self_serve_trial plan with a small credit (a lifetime total-period cap). It is provisioned with two pre-configured gateways — internal (Myra fleet) and external (Anthropic Haiku only). The workspace wallet is the single money pool: internal has no per-gateway budget (it is bounded only by the wallet balance), and external carries a flat $3.00 per-gateway cap (budget_period: total), so external vendor spend is bounded separately; see Budgets. While on the trial plan the per-gateway budgets and model restrictions (budget_usd, budget_period, provider_allowlist, provider_allowlist_enforced) are locked (a PATCH that changes them, a POST that replaces a gateway, or a DELETE of a gateway is 403, code trial_gateway_locked; see Tenants & gateways), so the allowance cannot be moved onto real vendor spend. One exception: once the trial workspace has redeemed a voucher, a PATCH that changes only budget_usd is allowed, as long as the budgets of all its gateways together stay within the wallet balance; a gateway may always keep or lower its current budget. Above that the answer is 400 with code trial_gateway_budget_over_balance and max_usd. (Resetting a gateway/tenant spend counter is 403 too, but for a broader reason — it is platform-admin only for every plan — so that 403 does not lift on upgrade for a tenant admin.) A trial ends in one of two distinct ways, both blocking inference with 402 while the account/billing pages stay reachable to upgrade: 402 trial_expired once the 7 days pass, and 402 trial_budget_exhausted once the credit is spent (whichever comes first). The trial credit is a hard cap (there is no over-cap soft-degrade). Upgrading through POST /admin/v1/billing/checkout converts the workspace to a paid plan, clears both limits, and resets both gateways in place — the per-gateway caps and the external model restriction are lifted (Sonnet unlocks if the paid plan entitles it; Haiku stays) and the edit lock releases, without deleting or re-creating either gateway.
  • Seats. A paying workspace's seat cap is the number of seats it bought at checkout (a per-workspace entitlement written when the checkout completes and afterwards kept equal to Stripe's live seat quantity by the customer.subscription.updated items heal (see webhooks); plan_config.max_seats is the most a customer can buy on that plan (a trial uses the plan's cap). The first registrant is seeded as the tenant_admin owner. The owner invites teammates via POST /admin/v1/tenants/:id/users; an add that would exceed the cap is rejected with 403 seat_limit_reached. Restoring a soft-deleted user re-activates a seat, so it is capped the same way — POST /admin/v1/users/:id/restore at the cap is refused 403 seat_limit_reached and the user stays deleted. Moving a user into the workspace (POST /admin/v1/users/:id/move) is capped the same way (403, error and code seat_limit_reached). While a seat reduction is scheduled, the cap for adding users is the lower scheduled count (never the larger current one): the refusal body then also carries scheduled_seats, scheduled_effective_at and a note. The same holds while the seat reduction of a mixed change is paid for but not scheduled yet (for example because Stripe refused the schedule, the subscription is not active or a cancellation is pending) or is being applied late: the cap for adding users is then the change's target seats, with the same refusal body, except that the note says the reduction is pending and scheduled_effective_at (the agreed period end) is present only while that date is still ahead. While the increase of a mixed change still awaits payment, the cap is unchanged. When the reduced target is confirmed live, its current seat cap is committed before the pending record clears: adding users stays bounded throughout that handoff. A failed confirmation keeps the pending bound for retry; a workspace switched to a managed plan keeps that plan's existing cap policy. A scheduled increase never raises the cap before it applies, and a schedule never lowers an unlimited seat cap: a tenant without a seat limit (e.g. one switched to Enterprise while a reduction was still scheduled) stays unlimited. If the subscription cannot be read or the scheduled change is malformed, or, for a workspace with a seat limit, its committed plan change cannot be read or is malformed, the add answers 503 (fail closed). Who may call each billing endpoint on this page — the owner (role admin or tenant_admin), a holder of Buy plans and add budget, a paid member reading the wallet — is set out at the top of this page.

POST /admin/v1/billing/portal

Opens a Stripe Billing Portal session where the owner can update the payment method, view invoices, or cancel (at the end of the period). The portal offers no plan, interval or seat change (see Changing seats and add-on). Session-authenticated, owner-only — the card, billing address, name and tax ID edited there are the owner's, so a holder of Buy plans and add budget receives 403 forbidden too.

Partner-billed workspace: 403 {"error":"forbidden","code":"partner_billed"}, see Partner-billed tenants.

Response 200

{ "url": "https://billing.stripe.com/p/session/..." }

Redirect the browser to url. Each call creates a fresh portal session (no idempotency key — a portal session moves no money and expires within minutes, so a replayed one would be a dead link). Returns 403 forbidden for a non-self-serve workspace (code self_serve_plan_required) or a caller who is not the owner (code billing_owner_only), 500 portal_not_configured if the deployment has no portal configuration, and 502 portal_unavailable when a Stripe call failed or was refused.

GET /admin/v1/billing/summary

A database fault reading the spend or the wallet balance answers 503 { "error": "temporarily unavailable; retry later" } — the summary is never computed without them (it would show 0 % spent, or an over-cap state that ignores the wallet).

Returns the current subscription snapshot for the workspace. Session-authenticated; the owner, a holder of Buy plans and add budget, and every other role of a paid self-serve workspace, read-only (see the top of this page: not the demo account, not a trial, not a manually provisioned workspace — 403 forbidden; an absent or unknown role is denied). The body is the same for all of them except invoices (see below) and, for a member (any role of the paid workspace that is neither the owner nor a holder), the dispute and reactivation state: a member receives the plan, its status, both renewal dates, cancel_at_period_end (the page says "ends on" instead of "renews on") and the balance fields, but dispute_flag and reactivatable are null (withheld — not false, which would read as "not disputed"). The plan-change fields follow the same rule: a member receives pending_change but pending_payment and change_blocker are null. If the custom-role grants cannot be read for a caller who might be a holder, the answer is the retry 503, never the member body.

Response 200

{
  "plan": "self_serve_custom",
  "subscription_status": 100,
  "period_end": 1701000000,
  "allowance_renewal_date": 1699500000,
  "cancel_at_period_end": false,
  "cancel_at": null,
  "dispute_flag": false,
  "reactivatable": false,
  "seats": 25,
  "addon": null,
  "interval": "month",
  "pending_change": { "seats": 20, "addon": null, "effective_at": 1701000000 },
  "pending_payment": null,
  "change_blocker": null,
  "allowance_used_pct": 42.5,
  "allowance_state": "wallet",
  "spent_usd": 2.13,
  "cap_usd": 5,
  "spendable_usd": 37.50,
  "wallet_usd": 12.50,
  "promo_usd": 25.00,
  "promo_expires_at": 1801234567,
  "invoices": [
    { "id": "in_1", "total": 1900, "status": "paid",
      "invoice_pdf": "https://pay.stripe.com/invoice/acct_…/…/pdf", "created": 1700000000, "billing_reason": "subscription_cycle" }
  ]
}

subscription_status is 100 (active), 50 (grace — payment overdue, inference still works), or 0 (inactive — inference blocked). Two clocks, unix seconds: period_end is the subscription period end (the next invoice; up to 12 months out on an annual plan), allowance_renewal_date is when the monthly allowance next resets (~30 days after its last reset, clamped to the period end when that comes first). On a 31-day billing month the 30-day mark falls before the period end, so the reset is deferred to the period end: the allowance refills at the same instant the subscription renews, never a day earlier, and the workspace shows one date. The allowance sweep, /admin/auth/me, this endpoint and the allowance e-mails all use this one rule. (The Retry-After on a 429 quota_exceeded does not follow this instant — it is derived from the budget's calendar period.) It is absent when no reset is scheduled: the subscription is in grace or inactive (the reset sweep only runs for active subscriptions), or it cancels at the period end and no reset falls before that. If a reset is pending — the hourly sweep has not run yet, or the subscription period just rolled over and the renewal invoice is still being paid (Stripe finalises it about an hour after the boundary) — the value is typically within the next hour (one sweep interval). The signed-in user's /admin/auth/me carries the same pair as renewal_date (subscription) and allowance_renewal_date (allowance). For a purchaser (the owner, or a role with Buy plans and add budget) of a free trial or of a paid self-serve workspace, /admin/auth/me also carries active_users — the count of every non-deleted user in the workspace (disabled users included) — the same count POST /billing/checkout's 409 seats_below_active_users uses — an integer >= 0; the upgrade calculator ignores 0 and non-integer values and otherwise never offers fewer seats than this. It is omitted for every other caller, and a client treats a non-integer or < 1 value as absent; the 409 seats_below_active_users (min_seats) at checkout or plan change stays the authority. In plan-change mode the calculator does not apply this floor to a pure reduction (seats at or below the current seats, no add-on added or replaced); it still applies it to a trial or first purchase and to every other change. Every "your allowance renews on …" copy in the workspace reads the allowance one and, when it is absent, says nothing about a reset (the 429 body and the allowance e-mails likewise drop their "renews monthly" sentence). allowance_state reports the wallet-only enforcement state: "wallet" (the frozen-aware spendable balance can carry a turn), "blocked" (the wallet is empty or frozen, so requests are refused with 429 quota_exceeded). On this endpoint it is never absent: a failed balance read answers the retry 503 above (on /me the field is absent instead — unknown; the app does not lock the composer on it, see above). The retired "degraded" state is gone — there is no over-cap efficient-model soft-degrade. The wallet is reported as three views of the one tenant_wallet.balance_micro, all under the same platform wallet gate (wallet_enabled toggle on; /me also carries them for a free trial owner and member so a trial SEES its read-only balance though it cannot top up, and for a non-owner of a paid workspace — the read-only wallet audience): spendable_usd — the frozen-aware spendable balance, the single figure every balance card and the Your plan tile render (all wallet money is spendable); wallet_usd — the refundable cash portion a refund may draw on (log-derived; 0 for a promo-only/grant-only wallet, finite while the wallet is shown); and promo_usd — the promotional credit: the sum of the workspace's still-valid voucher grants (promotional credits that have not expired, are not spent, and are already valid — a credit whose start date is still in the future is not counted, and neither is one with an end date beyond year 9999), with promo_expires_at the soonest end date among them, and (on /me only) promo_expiring_usd — the part of promo_usd that lapses on that date (smaller than promo_usd only when vouchers end on different dates). It is a breakdown of the one balance, not an addition to it, and it is not spendable_usd − wallet_usd: the $9 opening credit and a customer-success grant are non-refundable but are not vouchers, so they are never counted in it. With no live voucher promo_usd is 0 and promo_expires_at is absent; when the promo figure cannot be read (a failed read of the money log) it is never reported as 0: /me and GET /admin/v1/billing/summary omit the promo fields, while GET /admin/v1/billing/overview returns promo_usd and promo_expires_at as JSON null. Each is absent on a failed /me read (this endpoint answers 503 instead); across both endpoints a field's PRESENCE means "the wallet is on offer", not merely "a balance row exists". allowance_state is fed by the frozen-aware spendable balance (computed even while the display gate is off — enforcement never depends on whether the figure is displayed). Since the wallet money-model rework there is no tenant.budget_usd column at all (it was dropped), so no budget figure feeds anything shown on "Your plan". spent_usd and cap_usd are the USD spend and the tenant's self-imposed spend_cap_usd that define allowance_used_pct (its numerator and denominator); they remain on the wire for enforcement and the depletion banners (BillingBanner / ChatMoneyNotice, which read /me) but do not drive the displayed money figure (spendable_usd does). cap_usd is 0 when the workspace has set no spend_cap_usd (the wallet balance is then the only limit, and allowance_used_pct is 0). invoices is an array for the owner and for a holder of Manage billing settings (BILLING_SETTINGS_MANAGE — by default the finance role; empty if the invoice history could not be loaded) and JSON null for everyone else (a holder of Buy plans and add budget alone, a member, a viewer): the list is withheld and no Stripe invoice lookup is made. A client must treat null as "not shown to you", never as "no invoices". Each invoice row is decoded strictly from Stripe's answer: a row without a valid Stripe object id (letters, digits, _, -, at most 128 characters), an integral total (it may be negative, e.g. a credit) and a non-negative integral created, or with a status / billing_reason that is neither absent, null nor a string, is skipped (a warning is logged); if every row is skipped the list is empty. invoice_pdf is present only as an https://pay.stripe.com/... link; any other value is dropped from that row (the row is kept) and a warning is logged. reactivatable is true exactly when POST /reactivate would accept: the subscription has lapsed (Stripe status canceled or incomplete_expired) and the account is not dispute-locked. A client offers Reactivate only then; a subscription in any Stripe state that is neither active nor terminal (past_due, unpaid, paused, incomplete) is fixed by updating the payment method in the portal instead.

Plan-change fields

Six further keys are always present; each is an explicit JSON null when it has nothing to say (never omitted, never 0 or ""). They describe the subscription as it is billed now and any change already scheduled. They are read from the workspace's own subscription row and work with the plan-change feature flag off; nothing on this endpoint writes them. An absent key means an older deployment; a client treats it as null.

A seventh key, pending_mixed, is present only while a committed mixed change is still being finished (MAP-4596; see "In the summary" under the commit). It is never null; a client treats its absence as "no mixed change in progress".

Key Value null means
seats Integer, the seats the live subscription bills (its seat item's quantity). It is not the workspace's effective seat cap: an operator's seat override changes the cap, not this value. Not recorded, or not a positive integer (logged, never a guessed number).
addon String, the add-on slug on the subscription. No add-on, or a malformed slug.
interval "month" or "year". The billing interval could not be determined.
pending_change { "seats": int, "addon": string or null, "effective_at": unix seconds }, a change Stripe has scheduled but not yet applied (a downgrade; effective_at is the period end it applies at). It stays visible after effective_at has passed until Stripe confirms the change, and is shown whether or not plan changes are enabled for the workspace. It follows Stripe's subscription_schedule.* events, and the live schedule at Stripe decides: none of ours clears it, a schedule with a change still ahead rewrites it, and an inert one (its last phase already applied, still attached) leaves it untouched until the items heal clears it or a DELETE (webhooks). No change is scheduled, or the stored group is incomplete or malformed (a partial group is never half shown).
pending_payment { "hosted_invoice_url": "https://invoice.stripe.com/...", "expires_at": unix seconds }, an upgrade whose invoice still waits for payment or 3-D Secure on Stripe's payment page (the link is always Stripe's hosted invoice page, https://invoice.stripe.com/..., with no port or user info, in printable ASCII only; it is payable for about 23 hours). No unpaid invoice, the link has expired, or the stored pair is incomplete or malformed. A stored link that is not on invoice.stripe.com is never offered: it reads as null and is logged.
change_blocker Why a plan change cannot be started now, one of the codes below. Nothing blocks a change.
plan_switch A platform admin's scheduled plan switch (MAP-4701; the trial as target MAP-4702): { "plan": "enterprise" \| "self_serve_trial", "state": "pending" \| "committing" \| "committed", "committed": boolean, "effective_at": unix seconds, "commit_due_at": unix seconds (pending only), "customer_cancelled_at": unix seconds (when the customer cancelled via the § 312k form) }. The workspace keeps its paid plan until effective_at (the fixed cancellation date when one is stored, else the period end) and then moves to plan. Once committed (about 72 hours before the period end), the subscription is set to cancel at that date, so cancel_at_period_end / cancel_at show the cancellation as well; Your plan shows the switch instead of the generic "ends on / Reactivate" copy. Read by every role that reads the summary. See Tenants › scheduled switch. No switch is scheduled (or a recorded one has an unknown state, which is logged).
cancel_at Unix seconds, a fixed cancellation date set outside the app (Stripe dashboard or ops) with cancel_at_period_end false (MAP-4157). It is mirrored from the customer.subscription.updated webhook: an absent field or a malformed value keeps the stored date (and is logged), an explicit null clears it (except for a stored fixed date while the live cancel_at_period_end is not the boolean false: then the date and the stored flag are kept until a well-formed delivery, MAP-4723, see Webhooks), a terminal subscription status writes nothing, and a reactivation clears it. It counts as a pending cancellation: change_blocker is cancel_pending and the allowance does not renew past it. A stored value that is not a positive integer timestamp reads as null, and so does any value of a terminal (canceled) subscription. A fixed date set in Stripe before this field existed is filled by a one-shot backfill at boot (it re-reads each active / past-due subscription that shows no cancellation from Stripe and writes only a valid fixed date; each boot reads a bounded batch and the next boot resumes where it stopped; it records completion and does not run again once a whole pass finished without a Stripe error), and by a plan-change refusal that sees the date live (above). Both of these repairs write only if no customer.subscription.updated changed the cancellation state since they read the row, so a stale Stripe read never brings back a date that was removed. Removing the fixed date (the owner's "Don't cancel" in the Stripe billing portal, or the dashboard) is allowed and alerts ops (fixed_cancel_date_removed); the customer's own cancel-at-period-end undo does not. No fixed date.

For a fixed cancel_at (not a customer cancellation) Your plan says "ends on <date>" and offers "contact us" instead of Reactivate, and the Change plan row and the upgrade blocker panel point to the contact page: the app offers no undo of a date that was set outside the app (the owner contacts us). The Stripe billing portal's "Don't cancel" does remove it: the subscription then renews and ops are alerted (fixed_cancel_date_removed). A customer cancellation (cancel_at_period_end true) keeps the Reactivate flow.

The workspace UI shows pending_change and pending_payment as banners on Your plan. It renders hosted_invoice_url as a link only when it is https://invoice.stripe.com/... with no port or user info; for any other value the banner is shown without a link. A timestamp (effective_at / expires_at) that is not a positive integer representable as a date (above 8.64e12 seconds) is treated as malformed: the banner is degraded and the shape is reported.

change_blocker is the first rung that applies, in this order:

  1. disputed: a payment dispute is open.
  2. lapsed: the Stripe status is canceled or incomplete_expired.
  3. switch_scheduled: a platform admin scheduled a plan switch for the end of the period (plan_switch is set, in any state) — PO decision MAP-4425 (2026-11-17): the admin's switch takes priority; the customer can change plans again once the admin undoes it. It comes before past_due and cancel_pending (the switch itself cancels at period end, so cancel_pending would tell the customer to reactivate, which drops the switch). The same 409 change_blocked with this blocker answers the upgrade / downgrade preview and every commit.
  4. past_due: any Stripe state that is neither active nor terminal, such as past_due, unpaid, paused or incomplete, or one the gateway does not recognise.
  5. cancel_pending: cancel_at_period_end is set, or a fixed cancel_at date is stored (MAP-4157). (A live cancellation - cancel_at set, or cancel_at_period_end true on the live subscription - also blocks the upgrade preview and every commit with this blocker; a downgrade preview is priced offline and the block shows when it is confirmed.)
  6. not_self_serve: the subscription is on a price the self-serve catalog does not sell (legacy, sales-made or archived) — contact us instead. That is: no seat price is recorded, the seat price is not bound to a catalog plan, the plan's row is not sold self-serve, or the seat price is no longer active in Stripe (archived or deleted); or, for the add-on, a slug without its price, a price without its slug, a slug that is not the one its price is bound to, a price bound to no add-on row, an add-on row that is not sold self-serve, or an add-on price that is no longer active. A change is never charged on an archived price. The row's visibility does not matter, so a customer on a retired (no longer public) row is not blocked by it, and neither is one on a held price (Stripe no longer sells it, but it is still active). This is not the same as a workspace that is not self-serve at all, which is 403 forbidden on every billing route.
  7. checkout_open: a Stripe subscription Checkout for this workspace (reactivation or conversion) is still open. A wallet top-up checkout does not count: it does not change the subscription.

no_payment_method is never returned here: only preview and commit answer it, after a live check with Stripe, and only for an upgrade (see Changing seats and add-on). A client treats an unrecognised code as "blocked".

A member (neither the owner nor a holder of Buy plans and add budget) receives seats, addon, interval and pending_change; pending_payment and change_blocker are null (withheld, not "nothing pending" or "nothing blocks"). A trial is still refused (409 no_subscription for the purchaser, 403 for a member). If the open-checkout state cannot be read, the answer is the retry 503. If the catalog cannot say whether the price is self-serve or active (unavailable or ambiguous), change_blocker is not set to not_self_serve (a catalog fault is not "contact sales"; the change endpoints re-check and fail closed) and a WARN is logged.

When this endpoint refuses — the workspace UI branches on these, so they are part of the contract, not incidental error handling:

Status Meaning
403 forbidden The workspace is not on a self-serve plan (it is billed by an account manager), or the caller is neither the account owner nor a holder of Buy plans and add budget and is not in the read-only member audience: a member of a free trial, the demo account (always), or an absent or unknown role. A member of a paid self-serve workspace reads the summary (see above).
409 no_subscription The workspace has no subscription row. This is every free-trial workspace, by design — a trial is created without one. The remedy is not this endpoint; it is the trial-to-paid conversion (POST /admin/v1/billing/checkout).
503 { "error": "temporarily unavailable; retry later" } A database read fault: the subscription lookup, or whether a subscription checkout is open (see the plan-change fields). Nothing changed; retry.

Because a trial legitimately gets 409 and a member legitimately gets 403, a client must not present either as a generic "could not load" — the workspace UI shows a distinct explanation for each, and offers the conversion action for the trial case.

Better still, a client should not send a trial workspace to this endpoint to begin with: the plan is already known from /admin/auth/me, so the conversion action can be offered directly. The workspace UI does exactly that — Organisation › Billing › Plan renders a trial's Your plan page from /admin/auth/me alone and never calls this endpoint for a trial; the trial pill and banner navigate to the Upgrade tab, and only its Continue to payment calls POST /admin/v1/billing/checkout. Above the self-serve limit, or with an EU-governed add-on the catalog cannot sell (Price on request), the calculator offers Discuss requirements instead of Continue to payment.

POST /admin/v1/billing/reactivate

Starts a new Stripe Checkout session for a lapsed subscription, reusing the workspace's existing Stripe customer, at the catalog's current price for the workspace's plan, in the lapsed subscription's own interval (monthly when unknown), for the larger of the last purchased seats and the workspace's active users — the Stripe Checkout shows exactly that before the card is taken. It never creates a second live subscription. No body. Session-authenticated, owner-only (a holder of Buy plans and add budget receives 403 forbidden).

Partner-billed workspace: 403 {"error":"forbidden","code":"partner_billed"}, see Partner-billed tenants.

A leftover schedule is released first. Before the checkout is minted, the reactivation releases any Stripe subscription schedule still attached to the lapsed subscription (a scheduled downgrade is dropped) and clears the pending-change mirror, so the checkout restores the bought seats and add-on, never the scheduled target. A failed release is logged and does not block the reactivation; a failed mirror write answers 503.

The EU-governed add-on comes back too. When the lapsed subscription billed the EU-governed add-on, the new Checkout carries it as the second line (add-on price × the same seats, in the same interval) — it is never dropped silently; when it cannot be offered the route refuses (409 addon_unavailable) and the workspace UI asks the customer to contact us. Reactivation is exempt from the self-serve limit. The add-on is read from the subscription's mirror; when that mirror is still unconfirmed (the items changed since the items heal last read them), the route re-reads the lapsed subscription's items from Stripe first (reusing the read it already makes for a stale, not-yet-ended subscription) and decides as follows:

What the read finds Outcome
A complete item list (with or without the add-on; an add-on item whose quantity is unreadable still counts as present) the add-on (if any) is re-added
Stripe answers a strict 404 on the verified account (the subscription no longer exists) the add-on from the stored mirror is re-added
A transient read error, or a 404 that cannot be verified as the pinned account's 503 checkout_unavailable — retry
Anything structural: an incomplete item list, more than one add-on item, the add-on replaced by an unknown item, no or several plan items 409 addon_unavailable

The add-on is then priced for the subscription's interval: an unhealthy catalog → 503 checkout_unavailable; no sellable add-on price for that interval (for example no annual price) → 409 addon_unavailable.

Response 200

{ "checkout_url": "https://checkout.stripe.com/c/pay/...", "session_id": "cs_...",
  "url": "https://checkout.stripe.com/c/pay/..." }

(url equals checkout_url, kept for existing clients.)

Return URLs. After payment Stripe returns the browser to /billing?reactivated=1: for the workspace owner, Your plan shows Back from Stripe — If you completed the payment, your subscription is reactivated once Stripe confirms it — usually within seconds. If it does not show as active yet, reload this page in a moment. (a static note, no polling; the flag counts only when present exactly once, is removed from the address, and is not shown again on reload or Back; any other viewer — a member, a holder, an impersonating admin — lands on Your plan without it). If the customer leaves Stripe's page by its back link without paying, Stripe returns to /billing?canceled=reactivate, and Your plan says the payment page was left without paying. See Leaving a checkout without paying.

Status / error Meaning
409 subscription_active The subscription is not lapsed (still active, past_due, unpaid, …) — re-checked live with Stripe before refusing. Use the portal to fix payment instead.
409 dispute_flagged The account is locked pending dispute review.
409 seats_below_active_users The workspace has more active users than the plan's seat maximum (min_seats, max_seats in the body).
409 trial_plan_use_checkout The workspace is on the trial plan (a platform admin moved it there; its ended subscription is kept). It buys through the trial conversion checkout.
409 checkout_in_progress / checkout_pending Another checkout for this workspace is being created (retry shortly) / is already paid and being provisioned (wait).
409 addon_unavailable The lapsed subscription billed the EU-governed add-on and it cannot be re-added online (see the table above) — permanent until the catalog or the subscription is fixed; the workspace UI asks the customer to contact us.
403 forbidden Not the owner (a holder of Buy plans and add budget included; code billing_owner_only), or not a self-serve workspace (code self_serve_plan_required).
503 { "error": "temporarily unavailable; retry later" } A lookup failed (subscription, active-user count or wallet read — a database read fault). Nothing changed; retry.
500 { "error": "internal error", "code": "admin_handler_failed" } A database fault. If a Stripe session had already been created it is withdrawn (best effort) and its link is not returned. Retry — normally the retry goes through at once (a failed attempt, this one or a 502, releases its claim); while the database is still failing it may get 409 checkout_in_progress for up to 60 s.
502 / 503 checkout_unavailable A Stripe call failed or was refused (including reading back an existing session) / the catalog cannot offer a price — no or more than one sellable price for the interval, or an unchargeable one — including a price in a currency other than EUR (the admin Catalog page shows which; see Catalog — which price is charged). A held legacy price (still billed, no longer sold) never blocks it: reactivation charges the interval's current price. Also 503 when the add-on check could not complete (see above).

POST /admin/v1/billing/checkout — trial → paid conversion

Starts a Stripe Checkout session that attaches a workspace's first paid subscription — the upgrade path for a free-trial workspace. Session-authenticated; the owner or a holder of Buy plans and add budget (see the top of this page); usable only by a workspace on the trial plan (self_serve_trial) or by a Custom workspace whose subscription has ended (below). A workspace that already pays changes its seats or add-on through Changing seats and add-on, not through this endpoint.

A trial workspace that paid before (MAP-4702). A platform admin can put a workspace back on the trial: a paid Custom workspace at the end of its period (scheduled switch), or an Enterprise workspace whose subscription has ended. Such a workspace keeps its ended subscription record. It buys through this endpoint like any trial: the Checkout uses the workspace's existing Stripe customer (the ended subscription's), and the purchase replaces the ended record, so the workspace has exactly one subscription afterwards and its earlier invoices stay listed. A subscription that has not ended is never replaced: a second paid subscription is recorded as a duplicate and ops are alerted, as before. If that ended subscription still carries an open payment dispute, the checkout is refused with 409 dispute_flagged (the same rule as a reactivation). The workspace counts as a trial in every respect: its trial end alone decides whether it may work (an admin can set a new one), and it is not deleted by the retention sweep for cancelled subscriptions.

A Custom workspace whose subscription has ended (MAP-4937). A Custom workspace whose subscription is stored as ended (canceled or incomplete_expired) can buy a plan through this endpoint, like a trial, instead of only reactivating its old subscription. The Checkout uses the ended subscription's Stripe customer, and the purchase replaces the ended record: the workspace has exactly one subscription afterwards and its earlier invoices stay listed. The workspace stays a Custom workspace, and its spend cap and gateway settings are kept: its monthly spend counter, its per-gateway budgets and provider allowlists are left as they are (a trial's purchase lifts the trial limits instead). Its confirmation email says the subscription is active again and, unlike a trial's, does not mention lifted trial limits. The checkout is refused with 409 dispute_flagged while the subscription carries an open payment dispute, with 409 subscription_active while the subscription has not ended (active, trialing, past due, unpaid, paused, incomplete, or a status the gateway does not know), and with 409 plan_switch_pending while a platform admin's scheduled plan switch is recorded and not yet applied. A Custom workspace that never had a subscription receives 403 trial_plan_required, as does every other plan (Enterprise, Standard, …), ended subscription or not. The decision uses the stored subscription status only; Stripe is not asked. If Stripe's cancellation event was missed, the stored status still reads as live and the checkout answers 409 subscription_active — reactivation, which re-reads the subscription from Stripe, still works then. The payment's webhook re-checks the same rules on the locked record: a subscription that turned live, a dispute or an admin switch recorded in the meantime, a plan changed away from Custom or a deleted workspace is never overwritten — the payment is recorded as a duplicate (or, for a deleted workspace, the delivery fails) and ops are alerted.

The Checkout success URL is /billing?upgraded=1&session_id={CHECKOUT_SESSION_ID}&conv_value=…&conv_currency=… — the conversion value (price × seats) lets the browser report the purchase to the ad platforms (Ad-conversion events).

Accepted body — the same choice as sign-up checkout:

Field Rules
plan Required. A public, purchasable catalog plan slug (^[a-z0-9_-]{1,64}$), e.g. custom. The former starter/pro values are gone (400 unknown_plan).
interval Required. "month" or "year".
seats Required. Integer ≥ the workspace's active users and ≤ the plan's max_seats (the body check refuses anything outside 1 … 100 000 before the catalog is read). The Checkout charges exactly this quantity; after payment the workspace's seat limit is this number.
expect Required. Exactly { "unit_amount", "currency", "tax_behavior" } — the price the page showed; a change → 409 price_changed with the current offer. A fourth key inside it → 400 invalid_expect.
addon Optional. { "slug": "eu_gov", "expect": { "unit_amount", "currency", "tax_behavior" } } — the EU-governed add-on and the add-on price the page showed. Absent or null = no add-on. slug follows the plan-slug rule (^[a-z0-9_-]{1,64}$) and must name a public, self-serve, Stripe-bound add-on row; expect is required inside it. The object holds exactly slug and expect; any other key in it → 400 invalid_addon.
any other key Not accepted. The body holds only the five keys above; every other top-level key (topup, price_id, resume, a typo, …) → 400 unsupported_field with field naming it (a long or control-character name is echoed truncated and sanitized). A wallet top-up is never part of the subscription checkout — it is loaded afterwards (see After paying). A key sent with JSON null counts as sent. The check runs after the body is known to be a JSON object and before any field is validated, so nothing is read, reserved or sent to Stripe for a refused body.
{ "plan": "custom", "interval": "month", "seats": 25,
  "expect": { "unit_amount": 1300, "currency": "EUR", "tax_behavior": "exclusive" },
  "addon":  { "slug": "eu_gov",
              "expect": { "unit_amount": 300, "currency": "EUR", "tax_behavior": "exclusive" } } }

The body carries no model setup. "Bring your own key" and "Mixed setup" are not sold through this endpoint: the calculator routes them to Discuss requirements (a sales quote) and never sends the checkout.

The plan is authoritatively re-derived from the charged Stripe price — a body cannot buy a plan it did not pay for. With an addon, the Checkout carries two lines: the seat price × seats and the add-on price × seats. Before the body is read, the workspace is checked: the purchaser, the plan, the subscription record (a trial with an ended record or a Custom workspace, see above), partner billing, then a dispute and, for Custom, the live-subscription and admin-switch refusals. The body checks then run in this order: the body shape (absent and malformed fields are different answers), the plan offer, seats against the plan's max_seats, the add-on offer, both shown prices (one 409 price_changed carries both current offers), the self-serve limit, then seats against the active users. The Checkout Session reuses the workspace's Stripe customer when the trial already topped up its wallet (else a fresh one) and is tagged metadata.kind=conversion + metadata.tenant_id (the authenticated session's workspace, never a body value). One open conversion checkout per workspace: every POST /billing/checkout retires the previous open session and mints a new one. A session is never handed back, whoever started it, because the payer's role is baked into it. A retried POST (double submit, reload before the redirect) therefore invalidates the earlier checkout_url; the SPA must use the newest one. When the checkout completes, the webhook attaches the subscription, flips the plan, writes the purchased seats, records the bought add-on (its grant applies at once — see webhooks) and clears the trial deadline; a confirmation email is sent.

The same conversion, whoever starts it. The owner and a holder buy the same plan through the same checkout (the one-open-checkout rule is per workspace, not per user). A fresh Stripe customer is always created with the owner's email address and language, never the holder's; that conversion sets the workspace's first billing identity: the billing address, name and tax ID entered on Stripe's page are stored on the new customer, whoever pays. A trial that already has a Stripe customer (one that topped up before trials lost the top-up) converts onto that customer, and there the two differ: the owner's conversion lets Stripe's page update the customer's address, name and tax IDs (customer_update[address|name]=auto); a holder's conversion changes none of them — no customer_update, tax-ID collection off, as for a holder's top-up — so the owner's address, name and tax IDs stay, and Stripe's automatic tax uses the address already stored on the customer. In every case the card the conversion is paid with becomes the subscription's payment method (also when a holder pays); only the owner can change it later, in the Stripe portal. When the owner pays, that card is also recorded as the workspace's saved card (the one Add budget shows and the automatic top-up charges) unless one is already stored; a holder's conversion records none, and a holder's session is opened with the payer's card marked allow_redisplay=unspecified, so it is never kept for later.

Response 200

{ "checkout_url": "https://checkout.stripe.com/c/pay/...", "session_id": "cs_..." }

Return URLs. After payment Stripe returns the browser to /billing?upgraded=1 (the confirming page). If the customer leaves Stripe's page by its back link without paying, Stripe returns to /billing?canceled=upgrade, and the price calculator says the payment page was left without paying (and forgets a remembered top-up amount). See Leaving a checkout without paying.

Status / error Meaning
400 missing_field / invalid_body / invalid_plan / invalid_interval / invalid_seats / invalid_expect Absent vs malformed field (invalid_seats also above the plan maximum, with max_seats). missing_field also for an addon without its expect; invalid_expect also for a malformed addon.expect.
400 invalid_addon addon is present but not a JSON object (an array included), or its slug is missing, not a string, longer than 64 characters or outside ^[a-z0-9_-]+$.
400 unsupported_field A top-level key outside the table above is present (topup: "load the wallet afterwards"); field names it.
400 unknown_plan Not a public, purchasable plan (the trial plan itself is not one).
400 unknown_addon addon.slug is not a public, self-serve, Stripe-bound add-on row.
403 forbidden Neither the owner nor a holder of Buy plans and add budget (the demo account always; a holder whose custom-role grants could not be read is refused too), or neither a trial workspace nor a Custom workspace with an ended subscription (trial_plan_required, also for a Custom workspace that never had a subscription). The code names the reason: billing_purchaser_only, trial_plan_required or caller_has_no_tenant.
403 forbidden The workspace is partner-billed (code partner_billed, AIG_TENANCY_ENABLED on only). See Partner-billed tenants.
409 dispute_flagged The workspace's subscription record (a trial's ended one, or a Custom workspace's) carries an open payment dispute; the account stays locked until it is resolved.
409 subscription_active Custom workspace only: its stored subscription has not ended (message: "the subscription is still active"). Change seats or add-on through Changing seats and add-on.
409 plan_switch_pending Custom workspace only: a platform admin's plan switch is recorded on the ended subscription and not yet applied.
409 seats_below_active_users seats is below the workspace's active users (min_seats in the body).
409 price_changed The plan or the add-on price changed since it was shown — the body carries the current offer ({plan, interval, unit_amount, currency, tax_behavior, max_seats}) and, when an add-on was asked for, addon_offer ({slug, interval, unit_amount, currency, tax_behavior}; never a price id). Show them and ask again.
409 addon_unavailable The add-on cannot be sold with this plan right now: the catalog refuses its interval (for example no annual add-on price for an annual plan), its price is not in EUR (refused by the catalog's verdict, see Which price is charged) or differs from the seat price in tax behaviour, the row grants nothing, or its price does not map back to the row. Permanent until the catalog is fixed — the workspace UI shows the add-on as Price on request with Discuss requirements.
409 above_self_serve_limit The purchase's monthly net is above the self-serve limit. The body carries limit_minor (EUR cents) and currency (EUR — the only currency self-serve sells in). The workspace UI switches to Discuss requirements.
409 checkout_in_progress / checkout_pending A checkout is being created right now (retry shortly) / is already paid and being provisioned (wait).
503 { "error": "temporarily unavailable; retry later" } A lookup failed (subscription, active-user count, wallet read, or the read of the workspace owner — the recipient of the Stripe customer and its emails — a database read fault; a failed owner read is never treated as "no owner"). Nothing changed; retry.
500 { "error": "internal error", "code": "admin_handler_failed" } A database fault. If a Stripe session had already been created it is withdrawn (best effort) and its link is not returned. Retry — normally the retry goes through at once (a failed attempt, this one or a 502, releases its claim); while the database is still failing it may get 409 checkout_in_progress for up to 60 s.
500 no_owner_email The workspace has no owner with an email address and no Stripe customer yet, so there is no owner identity to create the customer from. The payer's own email is never used instead (the payer may be a holder). Not transient: the workspace needs an owner account with an email address.
502 / 503 checkout_unavailable A Stripe call failed or was refused (including reading back an existing session) / the catalog cannot offer a price — no or more than one sellable price for the interval, or an unchargeable one — including a price in a currency other than EUR (the admin Catalog page shows which; see Catalog — which price is charged). A held legacy price (still billed, no longer sold) never blocks it: reactivation charges the interval's current price. 503 also when the catalog is unhealthy for the add-on, and when the stored self-serve limit cannot be read or is malformed (the checkout fails closed — it never falls back to the default; an ERR is logged).

The workspace UI treats 409 above_self_serve_limit and 409 addon_unavailable as newer than its cached catalog feed (the feed body is cached for up to 60 s): it applies the refused limit, or shows the refused add-on as Price on request, until a fetched feed agrees, the feed moves on to a different value, or two minutes pass. The server stays the authority — the UI never sells past a refusal, and a later checkout is re-checked in full.

After paying: the wallet top-up is a second step

The upgrade calculator (Organisation › Billing › Plan › Upgrade) can show an optional wallet top-up next to the subscription, and a Due today figure = the first month (seats + add-on) + the top-up (labelled "+ VAT on the subscription" when the seat price is tax-exclusive: the top-up includes VAT, the subscription does not). The top-up is not part of this checkout: the page remembers the chosen amount in the browser (sessionStorage, bound to the workspace and the user, at most one hour old) right before it redirects to Stripe. After payment, once the subscription is active, the confirming page does not redirect: it shows its done state ("You are on …") and, for a user who can load the wallet (the owner or a holder), a primary button Load the … you chose that opens Add budget with that amount prefilled ("Your plan is active. Load the … you chose into the wallet:"). A reload of the done page still offers the button; opening Add budget uses the remembered amount up, so the done page no longer offers it afterwards. The customer still confirms with Pay, which runs the ordinary top-up checkout — the amount is checked again against the live top-up offer there (a remembered amount that no longer fits is simply not prefilled). Without a valid remembered amount the done state has no such button and is unchanged. The remembered amount is a display hint only; nothing is charged from it.

Pay on Add budget remembers its own amount the same way right before it redirects to Stripe, marked as a payment attempt ("attempt": true; a budget request's attempt also keeps the request's id). The outcome of an attempt is unknown — the customer may have paid on Stripe and never come back — so Add budget fills it in again only on a confirmed return by Stripe's back link (/billing?canceled=wallet, for the viewer that checkout belongs to, never while impersonating). On any other visit the attempt is dropped and nothing is filled in (no request link, no "Your plan is active" notice): the first Pay is an ordinary top-up. The calculator's amount carries no marker and is filled in on any visit; only it is offered on the confirming page's button. Accepted: the marker absent or exactly true; rejected: any other value (false, null, "true", 1, …) — the whole remembered amount is ignored, never treated as the calculator's.

Leaving a checkout without paying

Each hosted Checkout's cancel_url — used by Stripe only when the customer leaves its page by the back link without paying (browser Back or closing the tab never reaches it) — is /billing?canceled=<flow>: wallet (top-up), upgrade (trial conversion) or reactivate (reactivation).

Accepted: exactly one canceled parameter whose value is one of those three names (case-sensitive), for the viewer that checkout belongs to — the owner or holder who tops up, the trial owner or holder (the conversion), the owner of a lapsed workspace (reactivation is the owner's); never while an admin impersonates. The SPA then opens the page where the payment can be retried (Add budget, the price calculator, Your plan) with a Payment not completed notice. The notice never claims that nothing was charged: a second tab can hold the same open checkout session (the top-up key and the one-open-checkout rule hand it back), so it says the page was left without paying and that a payment made in another window takes effect shortly.

Rejected (no notice, lands on Your plan): any other value, an empty value, a repeated parameter, another viewer. The parameter is always removed from the address, and the notice is not shown again on reload or Back. A success return (?upgraded=1, ?wallet=1, ?reactivated=1) present in the same address wins; the success flags follow the same rule — they count only when present exactly once, and a malformed one is removed without effect. It is a display hint only — no payment state is read from it.

When the payment page cannot be opened

What the app says when a Stripe hop (upgrade, reactivation, top-up, billing portal) cannot be started — always something that is true in that case, by the answer's status and code, never its prose:

  • No answer from our server (offline, DNS, the server unreachable): We got no answer from our server. Check your connection and try again. (on Add budget: … Nothing was charged — check your connection and try again.). Not reported as an error (an offline blip).
  • Upgrade / reactivation — a 502, a 503 without checkout_unavailable, a timeout or anything unexpected: The payment page could not be opened. If you already paid in another window, the upgrade is applied shortly. (… the subscription is reactivated shortly.), followed by the app's general explanation of the failure (why, what to do, and a support reference — see error codes). A 503 checkout_unavailable keeps Payment is currently unavailable. Please try again later. These are reported.
  • Add budget — 502 checkout_unavailable / stripe_unavailable: The payment page could not be opened. Nothing was charged — please try again in a moment. (a top-up only creates a hosted card page, so nothing can have been charged); a 502 without our code is the generic failure.
  • Billing portal — any refusal: The billing portal could not be opened., followed by the general explanation and the support reference.

Paid in another window. A second attempt after paying elsewhere is answered from the server's state:

  • an upgrade refused with 403 re-reads /me — if the workspace is already on the paid plan the app opens the confirmation page instead of an error;
  • a reactivation refused with 409 subscription_active re-reads the subscription — active: Your subscription is active.; payment overdue: the overdue sentence; still unpaid: update the payment method; the re-read failed: the generic sentence above. On the full-screen inactive prompt, the prompt simply closes when the re-read shows the subscription is no longer inactive.

While viewing the app as a user (an admin's View as user), the billing reads are refused (403 impersonation_forbidden): Your plan, Invoices and the Wallet say Billing is not available while you are viewing the app as this user., and the full-screen inactive prompt is not shown.

GET /admin/v1/billing/catalog

The product catalog for the signed-in workspace UI (upgrade view, compare plans, trial screens, plan names) — the same shape as the public GET /admin/auth/signup/catalog (public rows, prices = what checkout charges, no Stripe ids). Session-authenticated; any user with a workspace (members too — the trial-ended screen compares plans for everyone); not gated on self-serve. There is no per-caller field — the caller's own plan comes from /admin/auth/me.

It differs from the public feed in one place: this is the conversion audience, the one checkout that sells the EU-governed add-on. Here addons[].checkout.<interval> is true while checkout is possible, at least one plan can check out in that interval, and the add-on prices against every such plan's offer; then addons[].prices.<interval> is exactly the add-on line the conversion checkout charges (shown == charged). Otherwise the flag is false and the price is the catalog's display price. The top-level checkout_monthly_max_minor is the self-serve limit in EUR cents (every checkout-able offer is EUR), or null when the server cannot read it (then the checkout itself answers 503, so the UI shows no client-side limit and follows the server's answer). Both fields are documented with the public feed.

Status Meaning Caching
200 the feed Cache-Control: private, max-age=60
401 not signed in —
403 no_tenant the caller has no workspace (a platform admin not impersonating) no-store
503 catalog_unavailable the catalog cannot be read no-store

Wallet — prepaid credit

A self-serve workspace on the paid plan (Custom) — and a workspace on the manual Standard plan, today's stand-in for Custom below 2000 € — has one prepaid wallet, at the workspace level — never per gateway. The wallet is the spend bound: every turn's full cost is debited from it, and a turn is admitted only while it holds spendable balance and is not frozen — with the plan's full model entitlement (there is no reduced-model/efficient-model window). When the wallet reaches zero, requests are refused with 429 quota_exceeded — a hard stop, no model swap (see Budgets — Wallet); when the balance cannot be read at that moment (a database fault) the request is refused with the retryable 503 spend_unverified instead. A workspace on a manual/enterprise plan is sales-managed and receives 403 forbidden on every self-serve wallet endpoint (/billing/wallet*) — it cannot run a Stripe top-up checkout. Its Wallet tab and "Your plan" tile instead show its live tenant_wallet balance as a read-only figure (there is no organisation-configured budget to display — tenant.budget_usd was dropped in the wallet money-model rework), sourced from GET /billing/overview's spendable_usd. A managed/Enterprise wallet is funded by an operator funding grant, not by Stripe checkout: a one-shot, additive grant_usd on PATCH /admin/v1/tenants/{id} writes an admin-grant wallet credit of exactly that amount (grants are additive-only; there is no decrease/debit), recorded on wallet_ledger under the admin_grant kind with the granting admin's id and NULL Stripe fields. The credit fires only when the grant actually applies — on immediate apply, or on the four-eyes config-approval approval, never at submission of a held change — and is idempotent (the immediate path dedups on the client grant_nonce; the approved path on the approval id, so a re-apply / replayed approval never double-credits). A brand-new tenant reads its $9 opening wallet seed (or 0 once spent down). Myra's operators are notified when an Enterprise wallet runs low or empty — see Low-balance notice for Enterprise wallets. Exception — Standard: unlike the other manual plans, the owner of a Standard workspace uses the wallet endpoints exactly like a Custom owner (balance, card top-up, saved-card automatic top-up), whatever the state of "Offer paid upgrade at signup"; it has no subscription (none is required). On its first top-up the server creates the workspace's Stripe customer (the owner's e-mail, one customer per workspace) and Stripe Checkout collects the billing address (the tax location); the charge currency is the top-up offer's currency, converted to the USD ledger at the workspace's pinned EUR rate when its display currency is EUR. Only the owner role (tenant_admin) may top up or set the automatic top-up: any other role gets 403 there — a holder of Buy plans and add budget included (on Standard only the owner adds budget; a custom-role read fault on that check is the retry 503, as everywhere). Every other role (member, viewer, ki_manager, finance) reads the wallet: GET /billing/wallet answers the member view while the platform wallet is on, and /me carries the balance. Budget requests are not offered on Standard: the budget-request endpoints answer 403 there, for the owner too.

A partner-billed tenant is not wallet-bounded (MAP-4365). With the tenancy API switched on, a tenant whose portal_managed is 1 is billed to its partner: its requests neither read, hold nor debit the wallet, and an empty wallet does not refuse them. Its monthly ceiling on the tenant spend ledger bounds it instead, see Partner-billed tenants. Auto top-up never charges a partner-billed tenant (MAP-4367): the top-up routes refuse it (403 partner_billed) and the automatic top-up sweep parks it as account_blocked:partner_billed instead of charging; see Self-serve billing is refused.

A free trial cannot top up the wallet (CEO ruling 2026-09-15) — neither a manual top-up nor an automatic one. A trial evaluates its allowance for free and converts to a paid plan via POST /admin/v1/billing/checkout; it does not load a prepaid balance. The mutating endpoints (/topup, and /auto-topup when switching on) answer 409 account_blocked with reason: "trial_no_topup". The refusal is server-enforced at one chokepoint the manual top-up, the auto-top-up arming and the auto-top-up sweep all share, and it covers every trial tier — any plan value starting with self_serve_trial — so a future trial variant is refused too rather than slipping through to a top-up; the app hides the top-up controls by the same rule. (Enforcement is unaffected: a workspace that already holds a balance is still served on it — the balance is read directly on the request path, never through this gate.)

A trial SEES its wallet balance, but has no top-up control. A trial owner and its members see the Wallet tab and a read-only balance card (the balance VIEW), while the platform wallet is switched on (the wallet_enabled master toggle — which, is also the sole offer term). Every top-up / auto-top-up / Add-budget control is removed (not disabled) for a trial. /admin/auth/me emits wallet_usd for a trial owner and member accordingly; the SPA reads it from /me (never the wallet summary endpoint, which a trial member would 403).

A paid member reads the wallet, read-only (MAP-2993). Every non-owner role of a workspace on the paid plan — member, finance, viewer, AI manager; not the demo account — sees the Wallet tab while the platform wallet is on: the balance, the automatic top-up notices (in member copy, without their actions), the payments ledger and an "it is set by a workspace admin" note on the Automatic top-up sub-tab. One server predicate decides this audience for both /admin/auth/me (wallet_usd) and GET /billing/wallet. Without Buy plans and add budget they never get a top-up, auto-top-up or card control.

A holder of "Buy plans and add budget" adds budget, but the card and the billing details stay the owner's (MAP-2993). A member whose role grants BILLING_PURCHASE (see the top of this page) may start a top-up and set the automatic top-up, exactly like the owner, with these differences:

  • A holder's top-up pays once and changes nothing on the workspace's Stripe customer. Their card is not saved (the session sets no setup_future_usage), the billing address and name stay the owner's (no customer_update), and Stripe's tax-ID collection is off. Stripe's automatic tax uses the address already stored on the customer; when the customer has no usable tax address yet, Stripe refuses the session and the top-up answers 409 topup_unavailable with reason: "owner_details_required" — only the owner can complete the address (with their own top-up, or in the Stripe portal; a trial conversion also stores one). The owner's top-up is unchanged: it saves the card for the automatic top-up and lets Stripe's page update the address, name and tax IDs.
  • The automatic top-up uses the owner's saved card. A holder can switch it on only when the owner has saved a card (otherwise 409 no_payment_method); they cannot add, replace or remove the card (DELETE /billing/wallet/payment-method is owner-only).
  • The Stripe customer's email and language and every billing email stay the owner's — Stripe's receipts and the automatic top-up's decline email go to the owner, whoever started the payment. The audit log records the actual caller: wallet.topup_started and wallet.auto_topup_settings name the holder when a holder acted.
  • An automatic top-up a holder switched on keeps running after the holder loses the permission. It is a workspace setting, not the holder's: it goes on charging the owner's saved card within its monthly cap until someone who may set it (the owner or another holder) switches it off, or the owner forgets the card. The audit log names who switched it on.
  • The holder reads the wallet in the member view (below) — the card's brand and last four digits are not shown.

All four endpoints are session-authenticated and do not require a subscription row. POST /topup and PUT /auto-topup admit the owner or a holder; DELETE /payment-method is owner-only. POST /topup and switching PUT /auto-topup on refuse a trial (above). The read (GET) is reachable by any self-serve owner (a trial included — the SPA is what hides the surface from a trial) and, read-only, by the paid-member audience above (a holder included).

Money is stored in USD (like the allowance); amounts in requests and responses that carry no _usd suffix are in the workspace's currency (its budget_currency, USD for every self-serve workspace today), converted once at the workspace's pinned reference rate — the identity for USD. Top-up amounts are catalog configuration, not Stripe prices (step 1b): the component-bound wallet_topup row of the product catalog holds the top-up currency (EUR or USD), a min_minor / max_minor range and 1–12 display presets (all in minor units of that currency). The owner or a holder tops up any integer amount within the range; every top-up — manual or automatic — is charged as an inline amount on the ONE tagged "Wallet top-up" Stripe product (which carries the tax code). The client names an amount and the currency it showed it in — never a price, a product or the charged currency. Top-up amounts are not in the workspace currency: they are in the top-up currency (see each field below).

The wallet is offered as soon as a platform admin switches on the wallet_enabled toggle (from the platform-admin Feature flags & settings page) while it is off, enabled is false and the mutating endpoints answer 409 wallet_disabled. The toggle defaults off, so a fresh environment offers no wallet until an admin turns it on. The balance cap has been retired. A tenant with the toggle on but no sellable top-up (the catalog config missing / invalid, or the Stripe product not bound — see topup.reason below) still SEES its wallet — there is simply nothing to buy.

Top-up refusal reasons (one closed vocabulary). Every refusal carries a bounded token; a client must treat an unknown token as generic "unavailable", never as a parse error.

reason Class POST /topup PUT /auto-topup (on) Sweep (auto_topup.status / last_error) GET topup.reason
catalog_unavailable, Stripe unreachable transient 503 topup_unavailable (reason: "transient") same no charge this tick, retried transient
wallet_disabled gate 409 wallet_disabled 409 wallet_disabled not listed wallet_disabled
not_configured, no_topup_row, ambiguous_topup_row, not_public, no_product, ambiguous_product, product_inactive, product_untagged, product_missing, product_tax_code platform 409 topup_unavailable + reason same unavailable / topup_unavailable:<reason> — self-healing, re-evaluated every 10 min the reason
unconvertible platform — (the POST/PUT answer an unconvertible amount with 400 invalid_amount) — unavailable / topup_unavailable:unconvertible — self-healing, re-evaluated every 10 min —
currency_changed (the configured currency is no longer the stored / shown one) owner 409 currency_changed (+ currency) same unavailable / currency_changed —
amount_out_of_range owner 400 amount_range + min_minor, max_minor, currency same unavailable / amount_out_of_range —
settings_diverged (settings written by a previous release) owner — — unavailable / settings_diverged — save the auto top-up again. No longer written: an earlier migration cleared every such row (its stored amount was reset, so it shows needs_amount instead); the token is only still recognised for display —
tax_location_missing (no billing address for tax yet) owner — — unavailable / tax_location_missing — the owner makes one manual top-up (a holder's top-up collects no address) —
owner_details_required (a holder's top-up; the workspace's Stripe customer has no usable tax address) owner 409 topup_unavailable + reason — holder sessions only; the same refusal on an owner's session stays 502 checkout_unavailable — — —
tax_unavailable, tax_mismatch platform — — unavailable / the token (+ an ops alert) —

The 400 answer of a top-up, auto top-up or budget request amount outside the offer was amount_out_of_range before; it is amount_range now, and a client should accept both. The stored state token auto_topup.last_error = amount_out_of_range keeps its spelling (it is stored on the wallet and in the audit log). The owner-class states currency_changed / amount_out_of_range also heal on their own if an admin reverts the config; re-saving the auto top-up always clears them.

GET /admin/v1/billing/wallet

Who may call it. A self-serve owner (trial or paid) and the owner of a Standard workspace receive the owner view below. A non-owner of a paid self-serve workspace or of a Standard workspace (role member, finance, viewer or AI manager — a holder of Buy plans and add budget included) receives the member view while the platform wallet is on: the same body, except

  • payment_method.brand and last4 are always null (saved still says whether a card is on file) — the card is the card holder's; no Stripe lookup is made, so this view never notices (or forgets) a card Stripe no longer has;
  • every movements[].stripe_payment_intent_id is null — the Stripe payment reference is the payer's (a holder of Buy plans and add budget reads the member view too, so it does not see the reference of a top-up it paid itself); the movements themselves are listed;
  • auto_topup.last_error is reduced to an allow-list: account_blocked:<reason> becomes account_blocked:workspace (no dispute or subscription-status reason reaches a member); topup_unavailable:<reason> and the fixed tokens tax_unavailable, tax_mismatch, currency_changed, amount_out_of_range, tax_location_missing, monthly_cap pass unchanged; a card decline code, an internal error code and anything unknown are null.

Everything else — the balance, the top-up offer, the automatic top-up settings and status, and the movements ledger rows including refunds and disputes (they explain the balance the member reads; dispute_flag is in the body anyway) — is the same as the owner's.

Rejected with 403 forbidden: a member of a trial workspace (it keeps the /me balance view), a member while the platform wallet is off, the demo account, a session whose role is absent, empty, unknown or NULL, a workspace with no plan or a non-self-serve plan other than Standard (Enterprise, free), and a session without a tenant. A trial member whose role grants Buy plans and add budget is refused here too (it is not the owner, and a trial has no member view). Of the three mutating endpoints, POST /topup and PUT /auto-topup answer 403 forbidden to anyone but the owner and (on a paid self-serve workspace, not on Standard) a holder, and DELETE /payment-method to anyone but the owner.

Response 200 (owner view)

{
  "enabled": true,
  "currency": "USD",
  "balance_usd": 27.17,
  "balance": 27.17,
  "topup": {
    "available": true, "reason": null, "currency": "EUR",
    "min_minor": 100, "max_minor": 100000, "presets": [5000, 10000, 25000, 50000]
  },
  "payment_method": { "saved": true, "brand": "visa", "last4": "4242" },
  "dispute_flag": false,
  "auto_topup": {
    "enabled": true, "threshold": 5, "monthly_cap": 100,
    "amount_minor": 2500, "amount_currency": "EUR", "needs_amount": false,
    "status": "idle", "last_error": null, "last_attempt_at": null, "pending": false,
    "month_charged": 0
  },
  "movements": [
    { "kind": "topup", "stripe_payment_intent_id": "pi_…", "paid_minor": 2500, "paid_currency": "EUR",
      "fx_rate": 0.92, "requested_usd": 27.173913, "credited_usd": 27.173913, "capped": false,
      "balance_after_usd": 27.173913, "credited_minor": 2500, "created_at": 1757790000 }
  ]
}
  • balance is null when the workspace's stored currency tag is unreadable (the figure is omitted, never guessed). This endpoint shows the raw balance together with dispute_flag; the spendable figure (0 while the wallet is disputed) is spendable_usd on GET /admin/auth/me; /me's wallet_usd is the refundable cash part, replayed from the payment log (0 for a wallet funded only by grants) — its presence is the SPA's balance signal. On GET /admin/auth/me, wallet_usd is present: for a self-serve owner on a paid plan while the platform wallet is enabled (the wallet_enabled toggle on — the top-up offer, toggle-only); and for a trial owner and member while the wallet_enabled master toggle is on (the balance view — a trial cannot top up but still sees its balance). It is also present for a non-owner of a paid workspace (member, finance, viewer, AI manager — the read-only wallet audience above; for a holder of Buy plans and add budget it is part of the paid billing snapshot) while the platform wallet is on. It is omitted while the platform wallet is off (so a client can tell "wallet not configured" apart from a genuine 0 balance), for the demo account and for a member of a manually provisioned workspace other than Standard. /me also carries balance_fx_pin: { "currency": "EUR", "fx_rate": <pinned rate> } for a legacy/managed workspace whose stored currency is EUR with a valid pinned rate (every balance surface then renders euro at that rate), else null. wallet_usd's presence on /me is the SPA's per-session balance signal (canSeeWalletBalance); the separate canManageWallet predicate — a paid owner or holder, or the owner of a Standard workspace — gates every top-up control, and the card controls (forget the card, top up with a new card, add a card) are the owner's alone. The owner of a Standard workspace also gets wallet_usd / spendable_usd (same wallet_enabled gate) plus managed_wallet_topup: true — the server's signal that this owner may top up by card (the SPA's canManageWallet keys on it; a Standard workspace has no subscription_status). No other self-serve field (plan, subscription, allowance) is emitted for it. Every other role of a Standard workspace (member, viewer, AI manager, finance — a holder of Buy plans and add budget included) gets the balance only — wallet_usd, spendable_usd, promo_usd / promo_expires_at, same wallet_enabled gate — and never managed_wallet_topup, plan or a subscription field. On Standard only the owner tops up: a holder of Buy plans and add budget gets 403 there.
  • topup (step 1b) is what can be bought right now: available is true only while the wallet is switched on, the catalog config is valid and the one "Wallet top-up" Stripe product is bound and confirmed live (active, tagged, the expected tax code). Then currency, min_minor, max_minor (the accepted range, minor units of currency) and presets (1–12 ascending suggestions within the range — shortcuts, not a whitelist) are set. Otherwise available is false, reason is a refusal token (wallet_disabled, transient, or a platform reason) and the other fields are null / [].
  • An earlier release removed the one-release compatibility fields topup_products, products_partial and auto_topup.price_id.
  • payment_method.brand / last4 are read from Stripe (60 s cache) and null when unavailable; the platform stores only the payment-method id, never card data. payment_method.saved is false also when Stripe no longer has the card, or it is detached from the workspace's Stripe customer: the stored id is then forgotten (as DELETE /billing/wallet/payment-method does) and automatic top-up is switched off — a card that cannot be charged is never kept — and the audit log records wallet.payment_method_forgotten_gone (actor type system, with the card id and the reason stripe_missing or stripe_detached). While a charge is in flight, or when the lookup fails for any other reason (Stripe unreachable, an unreadable answer), nothing is forgotten: saved stays true with brand / last4 null, and the next read asks again. With no card stored, a subscription's card can be saved as the wallet card again.
  • auto_topup.amount_minor + auto_topup.amount_currency are the stored amount of one automatic top-up and its currency (the top-up currency — the only money field in auto_topup that is not in the workspace currency; threshold, monthly_cap and month_charged are in the workspace currency). Both null when unset. needs_amount is true when automatic top-up is switched on but no amount is stored (a setting saved before variable amounts existed whose price could not be translated, or one armed under a previous release) — such a row is never charged until the owner or a holder saves an amount.
  • auto_topup.status is one of idle, ok, declined, capped, unavailable, error; pending is true while a charge is in flight (a charge already in flight is replayed verbatim at its own amount even if the setting is changed or disabled meanwhile — a replay can never mint a second charge). last_error carries the reason for the current status — and, whatever the current status, it may read account_blocked:<reason> (the sweep found the workspace blocked and charged nothing; it is replaced by the next status the sweep writes, and stays while ticks pass without a write). month_charged is the sum of this calendar month's automatic top-ups, in currency.
  • movements (newest first, at most 20) holds credits (topup, auto_topup), refund / dispute rows (whose paid_minor is the cumulative amount Stripe returned and whose credited_usd is the cumulative amount debited from the wallet so far) and unreconciled rows (a charge that could not be credited — see the runbook). Consumption is not shown here: per-turn usage debits the wallet but appears in the usage views, not as movement rows (the movements list holds only funding and refund/dispute kinds); the part of it that saved agents caused is served per agent and day by GET /admin/v1/billing/wallet/agent-usage. Always an array. Every movement carries credited_minor: for a card row (topup, auto_topup, refund, dispute) the integer amount in minor units of the row's own paid_currency, computed at the rate of the charge (fx_rate) and never at today's rate — on a topup / auto_topup row it is what the owner chose and was charged (paid_minor is the gross, including any fee), on a refund / dispute row it is the charge-rate equivalent of what the wallet was debited; null for every other kind and whenever it cannot be stated exactly (a missing or invalid rate, a missing amount) — never a guess. There is one cumulative row per PaymentIntent and kind. A client shows it only when the row's paid_currency is the currency the balance is shown in, and shows a dash for null. Historical rows from before vouchers were folded into the one balance may not chain (balance_after_usd below the row's credit); clients then fall back to converting credited_usd on its own. The Wallet tab shows this activity list to a free-trial owner as well (the server already admitted the trial owner; a trial member is refused and sees the balance only). Every movement carries opening_grant (boolean): true only for the one-off $9 starting credit every new workspace receives (an admin_grant row with credited_usd 9, paid_minor/paid_currency null and stripe_payment_intent_id null); clients treat an absent or non-boolean value as false. granted_by is never emitted. The balance headline is rendered by the SPA from spendable_usd on GET /admin/auth/me in the viewer's display currency (or at the balance_fx_pin rate, below); the spendable / currency pair of this endpoint is the tenant's stored-currency view. A voucher_grant row — the promotional credit from a redeemed campaign voucher — does appear here: list_ledger filters on the tenant only, and a self-serve workspace that converted after holding promo credit is not 403'd, so a client must handle the kind (an unknown kind degrades to a generic row rather than failing the whole summary). Its Stripe fields are emitted as null, like admin_grant's (the stored column holds the grant's idempotency key). A grant row (voucher_grant, admin_grant) is promotional credit, not a card payment: its paid_minor and paid_currency are null (a client must not render an amount paid or a "Card" line for it), and an owner's voucher_grant row carries voucher_code — the code that was redeemed — or null when it cannot be resolved (a read fault never fails the summary). voucher_code is null for every other kind and in the member view. (The admin_grant kind is a separate, no-Stripe ledger kind. On this self-serve endpoint it is normally only the single opening-grant row (opening_grant: true, above); the exception is an operator grant made while the workspace was on Enterprise, which stays in the list after the workspace moves to a self-serve or Standard plan. An admin_grant row — the opening grant, or an operator grant from when the workspace was on Enterprise — never carries a payment reference: its stripe_payment_intent_id is always null (so is a voucher_grant row's), because the stored value is an internal idempotency token, not a Stripe PaymentIntent id. Any admin_grant row records the granting actor in granted_by (never emitted), with NULL stripe_event_id / fx_rate. Migration 0528 backfills the Starting credit row for every existing workspace that received the opening grant, including ones that already have activity.)

GET /admin/v1/billing/wallet/agent-usage

What saved agents took from the wallet: one row per agent per calendar day of the last 6 days (today and the five days before, in the caller's time zone), newest day first. It is the Wallet Activity tab's Agent usage card, read on its own so it can never slow or break GET /admin/v1/billing/wallet (whose movements stay credits only).

Who may call it. Exactly the audience of GET /admin/v1/billing/wallet (the same gate and the same impersonation refusal): the owner, the owner of a Standard workspace, and the read-only members of a paid or Standard workspace. Rejected with 403 forbidden for everyone that endpoint refuses; while impersonating a user, 403 impersonation_forbidden. Every admitted caller sees the whole day's total (it explains the balance the caller reads), but per-agent detail only for the agents the caller may see in the agents list — a tenant admin (or platform admin) sees every agent of the workspace, anyone else the agents they own or that are shared with them (directly, through a group, or org-wide once approved). Each row is exactly one of:

  • a visible agent: agent_id + agent_name set, agent_deleted: false, hidden_group: false;
  • Other agents: hidden_group: true, agent_id / agent_name null — one row per day that sums the runs and amount_micro of every agent of that day the caller may not see, so neither the id, the name nor the figures of a single hidden agent reach the caller (a day with one hidden agent still says only "Other agents"). It follows that day's other rows;
  • a deleted agent (tenant admin / platform admin only): agent_deleted: true, agent_id / agent_name null, hidden_group: false ("A deleted agent"). A deleted agent is removed for good, together with who owned it, so for every other caller its spend is part of Other agents — also for the member who created it.

Query. tz_offset (optional): the caller's offset in minutes, JavaScript getTimezoneOffset() convention (UTC minus local: Berlin in summer is -120). It moves the day boundaries, so it is read strictly: an optional - and 1–4 digits, between -840 and 720, given once. Absent means UTC. Anything else — a fraction, +60, a blank, an out-of-range value, a repeated or bare parameter — is rejected with 400 { "error": "invalid_tz_offset", "message": "…" } (checked after the audience gate).

Response 200

{
  "available": true, "reason": null,
  "window_days": 6, "first_day": "2026-10-21", "last_day": "2026-10-26", "tz_offset": -60,
  "unit": "charged_usd_micro",
  "rows": [
    { "day": "2026-10-26", "agent_id": "0b1c…", "agent_name": "Ticket triage", "agent_deleted": false, "hidden_group": false, "runs": 4, "amount_micro": 2500000 },
    { "day": "2026-10-26", "agent_id": null, "agent_name": null, "agent_deleted": false, "hidden_group": true, "runs": 3, "amount_micro": 10400 }
  ],
  "truncated": false
}
  • Units. amount_micro is what the balance was charged, in micro-USD (the wallet's own unit, including the platform mark-up, the amount actually taken when the balance ran low): the sum of the wallet's usage_internal / usage_external debits for that agent's requests on that day. It is not the raw provider cost — the agent spend cap and the budgets view count raw provider cost, so the two figures differ. A client converts it for display exactly like the balance (the SPA: the viewer's balance currency, or the workspace's pinned euro rate).
  • runs is the number of the agent's requests (one request log row = one run) whose wallet debits fall on that day; a request whose debits straddle midnight counts on both days. day is the calendar date in the caller's time zone.
  • Day boundaries use the caller's CURRENT offset. Every day of the window is cut at midnight of the one tz_offset the request carries (the SPA sends the browser's offset at the time of the request), not at the offset each day had. Across a daylight-saving change inside the window (for example the last Sunday of October in Berlin, -120 → -60), the days before the change are therefore shifted by that hour: a charge made between 00:00 and 01:00 local summer time is counted on the previous day. The totals of the window do not change, only which of two neighbouring days an hour lands on.
  • rows is always an array when available is true ([] = no agent spent anything from the wallet in the window). At most 500 rows; truncated: true says older or smaller rows were cut.
  • Not attributable. The agent behind a wallet debit is read from the request log. When the workspace's request log cannot cover the window, the answer is 200 with available: false, rows: null (never an empty list) and reason: logging_disabled (request logging is switched off), retention_too_short (request logs are kept for fewer than 7 days — one day longer than the window, see below) or unknown (the setting could not be read). A request made while logging was off has no log row and is not attributed even if logging is on again now.
  • Why 6 days (and not 30). A per-call wallet charge records the wallet claim it settled, and only that claim names the request; settled claims are deleted 7 days after they end, so a window reaching further back would silently drop part of the spend — an understated figure, never shown. That 7-day retention is the basis; the window is one day shorter so that its oldest day can never be partly deleted: its oldest moment is at most 6 × 24 hours old, a full day away from both the claim deletion and a 7-day request-log deletion (whose clock starts when a request starts, which can be earlier than its charge). A longer history of agent spend would need the attribution to be stored with the charge itself; it is a deliberate trade-off against a second copy of the request log.
  • 503 (retry): any read fault — the workspace's log settings, the aggregate, the agent names — and any aggregate row that is not exactly an agent id, a day inside the window, a positive run count and a positive amount. Never a partial list or a zero.

POST /admin/v1/billing/wallet/topup

Starts a Stripe Checkout Session in payment mode for one top-up; completion is delivered by the webhook and credits the wallet. Callable by the owner or a holder of Buy plans and add budget; any other member receives 403 forbidden. The session is always pinned to the workspace's one Stripe customer (minted from the owner's email when the workspace has none yet), and its shape depends on who starts it:

Partner-billed workspace: 403 {"error":"forbidden","code":"partner_billed"}, see Partner-billed tenants.

  • The owner's session saves the card for the automatic top-up (setup_future_usage=off_session, with Stripe's own mandate text on the payment page), offers the cards already saved on the customer (saved_payment_method_options[allow_redisplay_filters] = always and limited — the cards our own flows save are limited, which Stripe's default filter hides) and lets Stripe's page update the customer's billing address, name and tax IDs (customer_update[address|name]=auto, tax-ID collection on).
  • A holder's session pays once and changes nothing on the customer: no setup_future_usage (the card is not saved; the payer's card is sent as payment_method_data[allow_redisplay]=unspecified), the owner's saved cards are not offered, no customer_update, tax-ID collection off. Stripe's automatic tax uses the address already stored on the customer; without one, the top-up answers 409 topup_unavailable / owner_details_required (below). See the holder rules.

The audit entry wallet.topup_started records the caller who started it.

The Checkout success URL is /billing?wallet=1&session_id={CHECKOUT_SESSION_ID}&conv_value=…&conv_currency=… (the top-up amount — see Ad-conversion events); both URLs are part of the request's Idempotency-Key.

Accepted body: { "amount_minor": <integer>, "amount_currency": "EUR" | "USD" } (step 1b) — the amount in minor units (cents) of the currency the client showed it in. The server builds the one Checkout line item itself: an inline price on the bound "Wallet top-up" Stripe product (its tax code), in the configured currency, tax_behavior = inclusive. JSON null counts as absent; other unknown keys are ignored.

  • amount_minor must be a finite integer ≥ 1 (at most 99999999, Stripe's per-charge ceiling) and amount_currency exactly EUR or USD (case-sensitive), and the two come as a pair.
  • The amount must lie within the configured [min_minor, max_minor] and amount_currency must equal the configured currency — a shown currency that no longer matches is refused, never re-stamped (the SPA re-reads the wallet).
  • budget_request_id (optional, MAP-2993) — the id of a member's open budget request this top-up is started from ("Add budget" on the request). Absent or JSON null = an ordinary top-up. When present it must be a UUID string (any case; stored lower-case) — anything else is 400 invalid_budget_request_id (never read as "no request"); a request that is not open in this workspace (unknown, another workspace's, already approved or rejected) is 409 budget_request_closed, checked after the rate limit and before anything reaches Stripe. The id and the starting payer go into the session's metadata (budget_request_id, budget_request_by; never the PaymentIntent's), and the webhook that credits the session approves the request. The amount does not have to equal the requested one.

Response 200: { "checkout_url": "https://checkout.stripe.com/…", "session_id": "cs_…" }. A second call for the same top-up returns the same open session for as long as no top-up has completed since: the idempotency key is wallet_topup:<workspace>: followed by a SHA-256 over the amount, currency, product, number of ledger movements, Stripe customer, owner locale, the two return URLs, whether it is an owner's session and — for a top-up started from a budget request — the request and the payer who started it (an unambiguous JSON-array encoding) — deterministic, so a double-click never mints two; a completed top-up changes it, an abandoned session is replayed for Stripe's 24-hour window. The return URLs and the owner-session flag are part of the key because Stripe refuses a replayed key whose parameters differ (an owner's and a holder's session for the same amount (and the saved-card filters, versioned in the key) differ in the card and customer settings, so they never share a key).

Return URLs. After payment Stripe returns the browser to /billing?wallet=1: the Wallet tab shows Back from Stripe — If you completed the payment, your balance is updated once Stripe confirms the top-up — usually within seconds. If it has not changed yet, reload this page in a moment. — and re-reads the balance for up to 30 seconds. If the customer leaves Stripe's page by its back link without paying, Stripe returns to /billing?canceled=wallet, and Add budget says the payment page was left without paying. See Leaving a checkout without paying.

Rejected (in this order):

  • 400 malformed_body — a body that is valid JSON but not an object (an array, a string, a number, true, null) or is not valid JSON; an absent or blank body is read as no fields.
  • 400 field_retired (+ field, message) — the retired price_id or amount field is present with a value (a stale client fails loudly, never silently). A field that is absent, JSON null or "" counts as not sent, so {"price_id": ""} alone is 400 amount_required.
  • 400 unsupported_field (+ field, message) — any other top-level key than amount_minor, amount_currency and budget_request_id (a typo, enabled, topup, …); field names it (a long or control-character name is echoed truncated and sanitized). A key sent as JSON null or "" still counts as sent. Checked right after field_retired and before the amount is read, so a refused body counts toward no rate limit and reaches neither the wallet nor Stripe.
  • 400 amount_required — no amount pair at all (absent; an empty string "" counts as absent here, so a blank form field gets this answer).
  • 400 invalid_amount — only half of the pair, a non-number / string / fractional / zero / negative / over-ceiling amount (a NaN / Infinity / 1e999 literal is refused earlier by the body parser: 400 malformed_body), or a currency that is not exactly EUR/USD (malformed — never degrades to the absent path); also an amount the platform cannot convert.
  • 400 invalid_budget_request_id — budget_request_id is present but not a UUID string.
  • 409 wallet_disabled — the wallet_enabled platform toggle is off.
  • 503 topup_unavailable (reason: "transient") — the catalog or Stripe could not be read; retry. 409 topup_unavailable + reason — top-ups are paused on the platform side (see the reason table).
  • 409 currency_changed (+ currency, the configured one).
  • 400 amount_range (+ min_minor, max_minor, currency) — the SPA uses these bounds.
  • 409 account_blocked with reason (trial_no_topup — a free trial cannot top up, expired or not; disputed, subscription_inactive (a self-serve plan whose subscription is inactive), deleted, not_self_serve — the plan cannot top up by card (anything but a self-serve plan or Standard), frozen — the workspace's allowance cap is not a positive number: zeroed by dunning / cancellation or an operator, or unknown; a wallet can only fund a workspace with a positive cap, so money is never taken for one an earlier gate would refuse to serve).
  • 429 rate_limited — more than 10 started top-ups per workspace within 60 s. Counted only for requests that passed validation (trying amounts is never throttled); the counter is per server node, so the effective limit is 10 × nodes.
  • 409 budget_request_closed — the budget_request_id names no open request of this workspace (see above); 503 when it cannot be read. The Add budget page meets it when the request is decided between opening Add budget (the request row's Add budget, or Stripe's back link) and PAY; a plain visit no longer re-links a saved request attempt, so the first PAY is not refused after a stale visit (see After paying for the remembered amounts). The page answers it by dropping the request link, clearing the chosen amount and pointing to What was paid on the wallet's Activity tab (the request was usually already paid); a retry is a plain top-up without budget_request_id.
  • 503 fx_unavailable — no usable reference rate to convert the top-up amount.
  • 409 topup_unavailable (reason: "product_inactive") — Stripe refused the bound product between the check and the session (archived meanwhile).
  • 409 topup_unavailable (reason: "owner_details_required") — a holder's session only: Stripe refused it because the workspace's Stripe customer has no usable tax address (Stripe's customer_tax_location_invalid, matched on the error code). Nothing was charged; the workspace owner has to complete the billing address first. On an owner's session the same Stripe refusal is the generic 502.
  • 502 checkout_unavailable — any other Stripe failure.
  • 503 { "error": "temporarily unavailable; retry later" } (the workspace's own records, the owner included, could not be read — retry; also when a concurrent first top-up recorded the Stripe customer and this request could not read it back); 500 { "error": "internal error", "request_id": "…" } when recording a newly created Stripe customer on the wallet fails, when a concurrent first top-up won the customer race but no recorded customer can be read back (inconsistent data — never a second Stripe customer), or when the records cannot be read right after this request recorded it (the write may have landed — retry once the wallet reads back); 500 no_owner_email (the workspace has no Stripe customer yet and no owner with an email address to create one from — a holder's email is never used); 403 forbidden (neither the owner nor a holder).

Every wallet endpoint answers a failed database read with 503 { "error": "temporarily unavailable; retry later" } (nothing written — retry) and a failed write with the sanitised 500 { "error": "internal error", "request_id": "…" } (re-read the wallet before repeating). See Storage faults.

PUT /admin/v1/billing/wallet/auto-topup

Configures the automatic off-session top-up: when the balance drops below threshold, the platform charges the saved card for amount_minor (in amount_currency, the top-up currency; no Checkout, nobody present), at most monthly_cap per calendar month (threshold and monthly_cap in the workspace currency). Callable by the owner or a holder of Buy plans and add budget. The saved card is always the one the owner's top-up saved — a holder's top-up never saves one — and the setting belongs to the workspace: one a holder switched on keeps charging that card after the holder loses the permission, until the owner or another holder switches it off (the audit entry wallet.auto_topup_settings names who changed it).

Partner-billed workspace: enabled: true answers 403 {"error":"forbidden","code":"partner_billed"}; enabled: false is still accepted, see Partner-billed tenants.

Accepted body: { "enabled": true|false, "threshold"?: number, "monthly_cap"?: number, "amount_minor"?: integer, "amount_currency"?: "EUR"|"USD" }.

  • The body must be a JSON object (a body that is valid JSON but not an object — an array, a string, a number, true, null — and invalid JSON both answer 400 malformed_body; an absent or blank body is "no fields" and answers enabled_required). enabled is required and must be a JSON boolean — absent, null, or a string such as "true" is 400 enabled_required (absent and malformed are different answers; malformed never degrades to a default). The retired price_id field → 400 field_retired (with field and message); a price_id that is absent, JSON null or "" is ignored.
  • amount_minor and amount_currency come as a pair with the same shape rules as the top-up body (400 invalid_amount for one half or a malformed value). threshold / monthly_cap are finite numbers, greater than 0 and at most 1000000 (400 invalid_threshold / invalid_monthly_cap).
  • With enabled: true all settings are required (400 threshold_required / monthly_cap_required / amount_required). The amount is then checked against the live top-up offer exactly like a manual top-up — 409 wallet_disabled, 503 / 409 topup_unavailable, 409 currency_changed, 400 amount_range (+ bounds) — and one charge must fit the monthly cap (400 cap_below_amount: the amount, converted, exceeds monthly_cap, which would park the setting capped forever). Switching on is refused with 409 account_blocked and its reason for an account the sweep would not charge — a free trial → trial_no_topup, a disputed / subscription_inactive / deleted / frozen workspace → its reason — the SAME gate the automatic sweep applies before each charge. A saved card is required (409 no_payment_method — the owner makes one manual top-up first; a holder cannot save a card). While a charge is in flight the switch-on is refused (409 pending_charge). On enabling, "" for a setting counts as absent (the *_required answer); on enabled: false it is malformed (invalid_*) and never means "keep the stored value". Half a pair is 400 invalid_amount.
  • With enabled: false nothing is checked against Stripe or the catalog — only the shape of fields that are present (a malformed value is still rejected). Switching off therefore always works, including during a Stripe outage, a pending charge or a paused offer; the response does not read the offer either. Absent fields keep their stored values (applied atomically in the database), so a toggle never loses configuration.
  • Every enabled: true save re-arms a declined or unavailable state (status → idle) — the only re-arm: a later manual top-up does not re-arm by itself. An error state keeps the charge it could not resolve, so it answers 409 pending_charge until an operator has reconciled it (internal runbook); it is never re-armed from the client.
  • A workspace whose currency is EUR with no usable pinned rate cannot store an amount it would have to guess: 503 fx_unavailable; a workspace whose currency tag is unreadable answers 500 currency_unresolved. 403 forbidden for anyone but the owner and a holder.
  • The settings write and its audit entry (wallet.auto_topup_settings) commit in one transaction: both are stored or neither is. If the audit entry cannot be written, nothing is changed: the answer is 503 when nothing was written or the failure was transient (repeat the call), otherwise the sanitised 500 { "error": "internal error", "request_id": "…" }. The cause is logged, never returned.
  • If the settings were saved but reading the wallet back fails, the answer is the sanitised 500 { "error": "internal error", "request_id": "…" } — the settings are stored; re-read the wallet instead of saving again.

Response 200: { "auto_topup": { … } } — the block exactly as GET returns it to the caller: the owner view for the owner, the member view for a holder (last_error reduced to the allow-list).

The sweep runs once a minute. Before every charge it re-validates the stored amount against the current top-up config and the live Stripe product (status unavailable with a reason token otherwise — never a charge in another currency or outside the range). It never exceeds the tenant's monthly cap (status capped; The platform balance cap is retired, so the monthly cap is the only ceiling now; the threshold and the settings are re-checked atomically at the moment the charge is armed, so a manual top-up or a settings change landing in between cancels the charge rather than duplicating it), spaces consecutive charges ten minutes apart, and stops after a decline (declined, with the card network's decline code in last_error — a short token such as insufficient_funds (letters, digits, _, ., -, at most 64 characters); anything else Stripe sends is reported as card_declined — and one email to the owner; a failed email send is logged, not retried) until the setting is saved again. A charge whose outcome could not be learned is never repeated blindly: it is replayed under the same Stripe idempotency key, and after 24 hours it becomes error for an operator to reconcile.

Tax on automatic top-ups (step 1b). A manual top-up is taxed by Stripe Checkout. An automatic top-up is an off-session charge; while the platform setting wallet_autotopup_tax is on, the sweep first asks Stripe Tax for a calculation on the workspace's Stripe customer (the billing address and tax ids the owner's manual top-up, or the trial conversion, saved — a holder's top-up saves none) and attaches it to the charge, so Stripe records the tax transaction and reverses it on a refund. The amount charged does not change (top-ups are tax-inclusive). A customer without a usable tax address parks the setting unavailable / tax_location_missing (no charge) until an owner's manual top-up has collected one.

DELETE /admin/v1/billing/wallet/payment-method

Forgets the saved card and switches automatic top-up off. Owner-only: a holder of Buy plans and add budget receives 403 forbidden. For a workspace without a subscription (a trial) the card is also detached at Stripe; for a subscribed workspace it is not (a subscription's renewal card is managed in the Stripe Billing Portal), so the response says which.

Response 200: { "detached": true|false } — false also when there was no saved card (idempotent).

The forgetting of the card, the switch-off of automatic top-up and their audit entry commit in one transaction. If the audit entry cannot be written, the card is kept and the answer is 503 when nothing was written or the failure was transient (repeat the call), otherwise the sanitised 500 { "error": "internal error", "request_id": "…" }. The cause is logged, never returned. The read GET /billing/wallet that notices a card Stripe no longer has keeps the card on an audit failure and answers 200 as before (it forgets it on the next read).

Rejected: 409 pending_charge while a charge is in flight (the replay needs the card it was built with — checked again atomically when the card is forgotten); 502 stripe_unavailable (the card is already forgotten on the platform side at that point — a remembered-but-detached card would decline forever, a forgotten-but-attached one is harmless; call again once Stripe answers); 403 forbidden (not the owner).

Budget requests

Budget requests exist on a paid self-serve workspace only — on a manual plan (Standard included) every budget-request endpoint answers 403 forbidden, and a trial member cannot send one (403). A member of a paid self-serve workspace who may not add budget (neither the owner nor a holder of Buy plans and add budget) can ask for more: Request additional budget on the Wallet page. A request is a message, never money — nothing is charged, invoiced or credited from it. It is stored and e-mailed to everyone who may add budget (the owner and every holder of Buy plans and add budget, the same people POST /topup admits; a demo account is never mailed); A request is open until it is decided: approved when a top-up started from it is paid, or rejected by one of the payers (no reason is asked for). In the app, Add budget on a request opens the top-up page with the requested amount already chosen (only when it is still in the offer's currency and within today's limits; otherwise nothing is chosen) and links that top-up to the request (budget_request_id) — the payer still checks the amount (they may change it) and presses Pay; when Stripe confirms that payment, the webhook that credits the wallet marks the request approved. Leaving Stripe's page without paying leaves the request open. A member has at most one open request at a time and sees the decision on their own Wallet page (no e-mail). Session-authenticated; the impersonation guard applies. Data handling: requests are erased with the workspace when it is purged and counted in the deletion protocol (Löschprotokoll); like the wallet and its ledger they are billing records, not part of the exit data export. When a member is erased, the note of each of their requests is erased with them; the request itself stays (amount, status) with the requester shown as unknown. Department spend-cap raises (limit requests) share the table but are a separate kind: they never appear in these endpoints, cannot be linked to a top-up or rejected here, and the wallet behaviour is unchanged.

POST /admin/v1/billing/wallet/budget-requests

Body { "amount_minor": 10000, "amount_currency": "EUR", "note": "PO 4711" }. Admits the read-only wallet audience of GET /billing/wallet (a paid self-serve workspace, wallet on, not a demo account) minus those who may add budget themselves.

Partner-billed workspace: 403 {"error":"forbidden","code":"partner_billed"}, see Partner-billed tenants.

Field Accepted Rejected
amount_minor + amount_currency Both present: a positive integer amount of minor units and exactly EUR or USD — the same pair, rules and bounds as POST /topup (the request must be an amount the payer can actually load) 400 amount_required (both absent — an empty string "" counts as absent, so both blank is also amount_required); 400 invalid_amount (one without the other — including one blank "" next to a value — a non-integer / string / ≤ 0 amount, another currency); 409 currency_changed (the top-up currency changed since the page was loaded; the body carries currency); 400 amount_range (outside the top-up offer's min_minor … max_minor)
note Optional. Absent, JSON null or blank = no note. A string of at most 500 characters after clean-up (CR/CRLF → LF, other control characters → a space, surrounding whitespace trimmed) 400 invalid_note (not a string, or invalid UTF-8); 400 note_too_long (over 500 characters — refused, never shortened). Both note errors carry max_chars
body A JSON object (absent or blank = no fields) 400 malformed_body

Other answers: 201 { "notified": <n>, "request": { "id", "amount_minor", "currency", "note", "status": "open", "created_at", "resolved_at": null } } — notified is how many payers are e-mailed (the payers with an address, read before the answer). 0 means no mail goes out (nobody with an address, or they could not be read): the request is still stored and on the payers' Wallet page, and the app tells the member to let the owner know directly instead of saying a mail was sent; 409 account_blocked with reason: "workspace" (the workspace cannot add budget right now — disputed, inactive, frozen; the same check as POST /topup, including the subscription's status and dispute, but the reason is always workspace: no dispute or subscription-status reason reaches a member; nothing is stored, audited or mailed; a fault reading the subscription is the retry 503); 409 can_add_budget (the caller is the owner or a holder — they top up instead); 409 request_open (the caller already has an open request in this workspace — decided by a unique key, so two sends at the same moment cannot both get in; nothing is stored, audited or mailed); 409 wallet_disabled; 409 topup_unavailable / 503 topup_unavailable (no usable top-up offer — as for POST /topup); 429 request_rate_limited (at most 3 requests per member and 10 per workspace per hour, counted per server node; a request refused before the limit is checked — a malformed body, the payer check, the wallet off, no offer, a blocked workspace, a bad note — does not count, but every request that reaches it does: one then refused with 409 request_open counts against both windows, and one refused by the workspace window still uses up one of the member's three); 403 forbidden (outside the audience — a trial, a manual workspace, a demo account, the wallet off). A storage fault follows the storage-fault rule. The e-mail is sent after the answer and best-effort: a mail failure is logged, the stored request stands (the payers also see it on the Wallet page). The audit log records wallet.budget_requested (amount, currency, whether a note was given — not its text).

A partner-billed workspace never gets this far: the route answers 403 partner_billed (above), so nothing is stored and no payer is e-mailed. The mail step also asks the billing-mail gate itself, so no other caller can mail the payers of a partner-billed tenant. See Billing mails.

GET /admin/v1/billing/wallet/budget-requests

Same audience as GET /billing/wallet. A caller who may add budget gets the workspace's open requests, newest first, each with requester (the name, else the e-mail address; null for a removed user): { "scope": "tenant", "requests": [ … ], "more": false } — at most 20; more is true when older open requests exist beyond them (the app says so under the list). Anyone else gets their own requests, open and decided (status open, approved or rejected; resolved_at = when it was decided): { "scope": "mine", "requests": [ … ] } (no requester field). The member's Wallet shows their newest request: open, or its outcome for 30 days after the decision. At most 20 rows; requests is always an array. A failed read answers the retry 503, never an empty list.

POST /admin/v1/billing/wallet/budget-requests/<id>/reject

Rejects an open request of the caller's workspace (no body, no reason). Owner or holder of Buy plans and add budget (else 403). <id> must be a UUID (400 invalid_id); an unknown id, another workspace's request or one already decided answers 404 not_found. 200 { "id", "status": "rejected" }; audited as wallet.budget_request_rejected. There is no approve route: a request is approved only by a paid top-up started from it (below).

Partner-billed workspace: still allowed. A rejection moves no money, and it is the only way to close a request a member sent before the workspace became partner-billed (the top-up that would approve it is refused), see Partner-billed tenants.

The budget request (create, reject) and its audit entry commit in one transaction. If the audit entry cannot be written, nothing is changed: the answer is 503 when nothing was written or the failure was transient (repeat the call), otherwise the sanitised 500 { "error": "internal error", "request_id": "…" }. The cause is logged, never returned.

Approval by payment

POST /topup accepts an optional budget_request_id (see its fields). The id is stored on the Stripe Checkout session's metadata together with the payer who started it; when the checkout.session.completed webhook credits that session (a paid, credited top-up — not an unpaid or uncreditable one), it marks the request approved (resolved_by = that payer, NULL if their account no longer exists). The approval is audited as wallet.budget_request_approved (request_id; the actor is that payer, or the webhook when the session names none) — a failed audit write is logged and never undoes the approval. Idempotent: a redelivered event approves nothing twice (and audits nothing twice); a request rejected meanwhile stays rejected. A failed approval write fails the event so Stripe redelivers it (the credit itself is never repeated).

How a credit is computed

A completed top-up credits the amount charged before tax is split out — the Checkout session's amount_subtotal (a manual top-up) or the PaymentIntent's amount_received (an automatic one); top-up amounts are tax-inclusive, so this is the amount the owner chose — converted once into USD at the workspace's pinned rate when it has one, else the platform's cached reference rate, else a freshly fetched one — never a baked constant; the rate is recorded on the movement. The platform balance cap has been retired, so every credit lands in full — there is no clipping and no wallet.credit_capped audit for new credits (historical capped ledger rows keep their recorded values). Credits are idempotent twice over: a redelivered Stripe event is ignored, and the two events Stripe fires for one payment (checkout.session.completed and payment_intent.succeeded) credit the same PaymentIntent once. A Stripe refund debits the wallet by the refunded share of what was credited (attributed to any clipped overflow first, cumulative across partial refunds) and leaves the subscription untouched; a charge-back debits likewise, flags the wallet (it funds nothing and accepts no top-up until an operator clears it) and locks the subscription when one exists. What that debit can actually take is bounded — see What a refund can draw on below.

What a refund can draw on

A refund or charge-back draws only on money the workspace actually paid. A wallet can hold several kinds of credit — a Stripe top-up (manual or automatic), a promotional voucher grant, a funded trial, a plan allowance, a customer-success grant — and only the top-ups are real money. The refundable figure is derived on demand by replaying the workspace's money log: consumption (usage, over-usage, an expiring credit) is attributed to the non-refundable credits first, soonest-expiring first, and only what is left over lands against the top-ups. Whatever remains on the top-up side is what a refund may take.

Two consequences are worth stating plainly, because they are visible to a workspace:

  • A charge-back cannot consume a grant. If a workspace paid $20, spent it, and was then given a $100 credit, a charge-back on the $20 debits nothing — the $100 is left intact and the uncovered amount is absorbed by Myra (it raises an internal alert, not a customer-facing error).
  • The figure is never stored, so it cannot drift from the displayed balance; it is recomputed from the log each time it is needed. There is no API field for it today — it is an internal control and a support answer.

While the rollout is in progress, the bound is applied only where it can be computed correctly. The money log the figure is derived from starts partway through the wallet's life, so for a workspace whose balance partly predates it, or whose log is missing a movement — in short, whenever the log's credits minus its debits do not equal the live balance — the log cannot reconstruct the wallet, and the refund falls back to the balance bound alone, exactly as it behaved before. That is deliberate: a figure derived from an incomplete history does not under-report safely, it makes money the workspace did pay look like money nobody paid, and the refund of their own top-up would be refused. Which condition applied is recorded internally on every such refund, and it raises an internal alert whenever money actually moved without the bound. All of it disappears once the historical balances are backfilled into the log.

A refund is still bounded by the live balance as well, so the amount debited is the smaller of the refunded share, the balance, and the refundable figure. (For a workspace with an exceptionally long spend history the refundable figure can be unavailable; the refund is still applied, bounded by the balance alone, and an internal alert records that it was.) Partial refunds are cumulative: each Stripe event moves only the part not already taken, and a redelivered event moves nothing.

POST /public/billing/cancel — cancellation button (public)

A public, login-free cancellation endpoint (Germany's § 312k BGB Kündigungsbutton requirement). The contract holder cancels by email without signing in. The endpoint is reachable same-origin on the app host (the cancellation page posts it directly) as well as on the API host — both routes serve the identical handler.

A cancellation first releases any Stripe subscription schedule attached to the subscription (a scheduled downgrade is dropped; Stripe's live schedule wins over the stored id) and then sets cancel-at-period-end. A failed release alerts ops (kuendigung_schedule_release_failed) and never blocks the cancellation. A Stripe 4xx on the release (the schedule is already released or gone) is expected and does not alert; a 5xx or a transport error does.

A cancellation is applied only after the requester enters a confirmation code mailed to the account's address — proof of control of that mailbox. Both steps use this ONE url; the body selects the step.

Step 1 — request the code

{ "email": "owner@example.com" }

Mail cap. At most 5 cancellation mails (the confirmation code or the status mail) per hour per address, cluster-wide (fixed hourly window: a burst across the boundary can briefly reach twice that). Earlier codes stay valid. Above the cap the endpoint gives its normal answer with no mail (neither a code nor a status mail) and no new code. A per-node brake of 120 mails per minute across all code-mail routes behaves the same way. A fault in the cap check answers 503 and writes an ERR log line. Limits (accepted side effects). A stranger who keeps sending 5 requests per hour for a victim's address can keep the victim from getting a new cancellation code for that hour (the cancellation codes already sent stay live, § 312k); and the per-node emergency brake (120 mails per minute) can be used up by requests for about two dozen known addresses, after which no cancellation mails (code or status) go out from that node for the rest of the minute.

Response 200 — always the same generic body, whether or not the email matches an account (anti-enumeration; no account existence is ever revealed in the 200 response — an existing account is told by e-mail instead — see the transient-fault 503 note below for the one narrow caveat):

{ "ok": true }

Nothing is cancelled by this step and Stripe is never called. What happens depends on the address, and is told only by email, to that address:

The address… The mail
is the account owner of a self-service workspace with an active (or payment-overdue) subscription a 6-digit confirmation code (valid for the platform's one-time-code lifetime, 15 minutes by default)
belongs to a member who is not the account owner (of a self-service workspace) a status mail: only the account holder can cancel
belongs to a workspace on a contract agreed directly with Myra (not self-service), owner or member a status mail: cancel through your account manager
is a free trial a status mail: a trial is not a contract and ends by itself (with the date). Because the generic screen tells everyone a code was mailed, this mail also states plainly that no confirmation code will be sent for a trial and that the recipient can close the code-entry window — otherwise a trial recipient is stranded on the code-entry step waiting for a code that never comes
has no subscription, or one that already ended, or one already scheduled to cancel a status mail saying so (with the end date where one is known)
matches no account nothing (there is no mailbox to write to)

A disabled owner account can still request and confirm (a disabled customer may still cancel their contract). Requesting a code never invalidates an earlier, still-valid code for the same address (a third party who knows the address cannot kill the owner's code by requesting codes); every wrong guess counts against every live code of the address, a code whose five guesses are spent is dead, and confirming with any one of them retires the others. Stated residual: a guess is tested against every live code, so with the five codes an hour the request cap allows, one guess has five chances in a million instead of one — still far below any practical bound, and each extra code is a mail the owner sees.

Step 2 — confirm

{ "email": "owner@example.com", "code": "123456" }

Response 200 { "ok": true } — the subscription is set to cancel at the end of the current billing period at Stripe and a written (Textform) confirmation email is sent stating the receipt date, the termination date (Stripe's answer for the current period end, else the stored period end when Stripe's answer carries none — a date earlier than the receipt date is never sent; the confirmation is withheld and an operator alert fires instead) and a reactivation link. Access continues until the termination date; no further payments are charged after the current period. Where the account cannot be cancelled automatically (an operator alert fires and support completes it by hand) the customer receives a status mail saying so instead of the confirmation. If the subscription's state changed since the code was requested (it ended, or is already cancelling) the matching status mail is sent and nothing is cancelled twice. A "code": null is the same as an absent code — the request step.

Rejected:

Status error Meaning
401 invalid_otp (formerly code_invalid) the code is wrong, expired, already used, or there is no live code for the address — byte-identical for a known address with a live code, a known address without one, and an unknown address
429 code_attempt_cap this address's five guesses are spent — request a new code (a new code is a new budget, and requesting one also clears the no-code counter)
429 code_failure_cap twenty rejected attempts for the address within an hour (wrong guesses and code_attempt_cap answers alike) — wait; a new code does not lift it; it is cleared by a successful confirm. A transient database fault answers 503 with nothing counted or consumed; the one exception is a fault between the two guess-counting statements after a wrong guess, which can leave that wrong guess counted on the code row — the guess was wrong, so the next answer may be code_attempt_cap instead of invalid_otp

This cancellation confirm step deliberately does not carry the 24-hour database budget that the sign-in codes have (it is not a sign-in surface): its limits are the five guesses per code and the twenty per hour above.

On ONE node the sequence of answers for six wrong guesses is the same for every address (401 ×5, then 429 code_attempt_cap), so the confirm step is not an account-existence oracle. Stated residuals: the guess budget is site-global (the code row) while the no-code counter is per node, so across two nodes of an active-active deployment a known address WITH a live code can be told apart from an unknown one within the code window (the same residual the sign-in route documents); a known address performs more reads before the check than an unknown one (a timing difference of a few database round-trips); and twenty wrong guesses from anyone lock the confirm step for that address for the hour, and five code requests from anyone spend the address's hourly request cap so the owner gets no further code that hour (both caps, like the no-code counter, are per node: on an active-active deployment the bounds — and the mail lever — are multiplied by the number of nodes) — as on the sign-in route, a per-IP bound is not possible while the client controls X-Forwarded-For. Neither touches the contract (before this change the same five requests cancelled it); a code already mailed stays valid through the request cap, so the owner enters it on the confirmation page (the page opens it even when a request was refused); the login-gated Cancel subscription action on the Billing page is unaffected. The per-IP bucket (IPv6: per /64 — see How the public rate limits behave) is keyed on the client address the front layer forwards, so where that header is forgeable, twenty forged requests can hold the button for one shared egress address for an hour (the sign-in route has no per-IP cap for that reason; this route keeps its documented one). The per-address bound is also the bound on mail: five mails an hour per node to any registered address, members included.

Accepted input / rejected input (both steps)

email goes through the one address boundary: a non-empty ASCII string of at most 254 bytes, trimmed, with exactly one @ and no inner whitespace or control bytes; it is canonicalised to lower case, so a case or padding variant shares the address's limits. code is optional; when present it must be a string or a JSON number that reads as exactly six ASCII digits after trimming ("123456" or 123456).

Status error Input
400 email_required email absent, null, empty, or not a string
400 invalid_email email malformed (non-ASCII, control byte, inner whitespace, over-long, not exactly one @)
400 invalid_code code present but not a string/number, or not exactly six digits — never hashed, never counted as a guess
400 malformed_body unparseable JSON, an absent or blank body, or a non-object body (a scalar, null, or any JSON array including []); also a number literal that is not finite, such as 1e400
400 duplicate_key an object in the body repeats a key at any depth; nothing is sent or recorded — send each key once
405 method_not_allowed not a POST
413 body_too_complex more than 2,048 structural elements ({, [, , and strings) — not a legitimate cancel request
413 payload_too_large body over 16 KB
429 rate_limited 20 requests per hour per client IP (IPv6: per /64 — see How the public rate limits behave) — both steps share this bucket (checked after the method check and before the body is read)
429 code_request_cap 5 code requests per hour per address (request step only; checked before any lookup, so it never signals account existence). A code already mailed stays valid and the confirm step is not gated by this cap — the page opens the confirmation step on it. This cap is also the bound on how much mail the endpoint sends to any registered address
503 temporarily unavailable, try again the request body could not be read; nothing was sent or recorded — retry (see the transient-fault section below)

While the server is starting (a schema migration is still running), every request answers 503 with Retry-After and { "error": { "code": "service_starting", … }, "code": "service_starting" }, before the method check — never the generic 200.

An owner whose subscription row cannot be processed automatically (a corrupt status, or an active subscription without a Stripe id) also receives a confirmation code; only after the code is confirmed does the operator alert fire and the status mail say that support completes the cancellation.

Transient backend fault → 503. If a transient database/backend fault prevents the step from being processed (the account, subscription or code could not be read), the endpoint returns a retryable 503 with body { "ok": false, "error": "temporarily unavailable, try again" } — not the generic 200. A 200 {ok:true} here would falsely confirm a § 312k cancellation (or a mailed code) that never happened. On the confirm step a fault before the code check leaves the code live, so the retry succeeds. The response body is fixed text and never echoes the error. The dominant identity-lookup fault fires independently of whether the email is registered; the narrow cases where the 503 is reachable only for a registered email are a billing-store-only partial fault, a fault in the mail-cap check, and a fault storing the code (the last two only for an address that would otherwise get a mail) — an accepted tradeoff over falsely confirming a cancellation that never ran.

Retention and deletion after cancellation (GDPR)

When a self-serve subscription has fully ended (the Stripe subscription is cancelled and any grace period has elapsed), the workspace enters a 90-day retention window. During this window the account stays reactivatable: signing in and reactivating the subscription restores full service with all data intact.

After the window, the workspace is permanently and irreversibly deleted by an automated retention job — the account, all conversations, projects, uploaded documents, settings, and the stored billing identifiers. The deletion is recorded in an audit Löschprotokoll (category counts only, never content), including evidence of the warnings below.

  • Two warning emails are sent to the workspace owner before deletion: 14 days and 1 day before the deletion date. Each email states the earliest possible deletion date; the actual deletion never happens before the date stated in an email. Both emails point at the self-service data export (GET /admin/v1/me/export) so a copy of all personal data can be downloaded first.
  • The retention window is configurable per deployment (default 90 days, minimum 15 — the warnings need their runway).
  • Disputed accounts are exempt: a workspace with an open payment dispute is retained until the dispute is resolved (GDPR Art. 17(3)(e) — establishment, exercise or defence of legal claims) and only then enters the normal deletion schedule.
  • Stripe-side records: the Stripe customer object and invoices are retained by Myra for the statutory commercial/tax retention periods (GDPR Art. 17(3)(b)); they are not part of the workspace deletion.
  • Expired, never-completed sign-up attempts (signup_intent rows) are deleted automatically 14 days after creation; webhook-ledger entries are deleted after 90 days.