Skip to content

Multi-provider v2 API

Provider-neutral v2 endpoints for connections, catalog, routing, checkout, entitlements, and financials.

Country routing is opt-in per project

Country routing is disabled by default for every project, including existing projects. Ordinary checkout uses the configured default payment connection. An existing customer pin keeps its connection; an unavailable pinned or default connection fails instead of choosing another provider. Direct checkout requires neither country input nor a confirmation token, and does not evaluate country-based rules. Provider bindings, authenticated webhook and fulfillment readiness, verified prices, explicit pauses and checkout idempotency still apply.

Read GET /api/billstack/v2/teams/{teamId}/projects/{projectId}/routing-settings (billing:GetBilling). Explicitly opt in with PATCH on that path and { "countryRoutingEnabled": true } (billing:UpdateBilling, live credential or dashboard session). Set it to false to return to direct checkout. The setting covers both environments of that project; team-wide rollout flags or checkout request fields cannot enable it.

SDK equivalents are billing.checkout.getRoutingSettings() and billing.checkout.updateRoutingSettings({ countryRoutingEnabled: true }). Only opted-in projects need the country-confirmation flow documented below. They retain routing rollout/canary controls, signed customer-bound tokens and single-use enforcement. country-advisory.manualConfirmationRequired reports the project's current setting.

The v2 API is available under:

/api/billstack/v2

All v2 routes below require a private Bearer credential unless noted otherwise. Runtime calls (checkout, entitlements, customers, subscriptions, catalog reads) use the project's bs_ API key:

Authorization: Bearer bs_...

Setup calls use a personal access token (bsu_), which acts as you:

Authorization: Bearer bsu_...

Setup calls are the projects routes and the catalog writes (create, update, archive, link and publish products and prices). Changed on 2026-12-01: a bs_ key created from now on cannot make them and gets 403 USER_TOKEN_REQUIRED. Keys created earlier keep working unchanged (shown as Full access (legacy) in the dashboard). See API keys and Personal access tokens.

Keys must belong to the {teamId} in the path. Project-scoped keys must also be allowed for the {projectId} in project routes. Session-based team or project permissions may be used by the dashboard. Publishable pk_ keys are not accepted by these private v2 routes.

OpenAPI specification

Yes, the v2 API has an OpenAPI 3.1 description. It covers every v2 route: the ones on this page and the entitlement, subscription, purchase, customer, referral, credit, payout and outbound webhook routes. For each operation it lists the path, parameters, request body, responses, error shape and the permission it needs.

  • Download: GET https://billing.w3dev.app/api/billstack/v2/openapi.json. It is JSON and needs no authentication.
  • Browse: the v2 reference group of this tab renders every operation with a request playground.

Use it to generate a client for a language the SDK does not cover, to import the API into a tool such as Postman or Insomnia, or to give a coding agent the exact request and response shapes. The TypeScript SDK remains the typed client for JavaScript and TypeScript. The pages in this section explain the behaviour behind the routes; the specification is checked against the route handlers in CI, so a route cannot be added without being described in it.

Provider connections

Team-scoped connections hold provider credentials and test/live account slots. Create and list connections, inspect one, and manage its lifecycle:

GET  /teams/{teamId}/provider-connections
POST /teams/{teamId}/provider-connections
GET  /teams/{teamId}/provider-connections/{connectionId}
POST /teams/{teamId}/provider-connections/{connectionId}/verify
POST /teams/{teamId}/provider-connections/{connectionId}/rotate
POST /teams/{teamId}/provider-connections/{connectionId}/disable
POST /teams/{teamId}/provider-connections/{connectionId}/disconnect

verify and rotate require a mode of test or live. A connection webhook URL is the canonical provider ingress for one immutable account incarnation:

POST /teams/{teamId}/provider-connections/{connectionId}/webhooks/{mode}/{incarnationId}

This webhook route is not authenticated with a BillStack API key. The provider must sign the delivery using the secret stored for that connection slot.

Project bindings

Bindings select a team connection and mode for a project without copying credentials into the project:

GET   /teams/{teamId}/projects/{projectId}/provider-bindings
POST  /teams/{teamId}/projects/{projectId}/provider-bindings
PATCH /teams/{teamId}/projects/{projectId}/provider-bindings/{bindingId}
POST  /teams/{teamId}/projects/{projectId}/provider-bindings/{bindingId}/verify
POST  /teams/{teamId}/projects/{projectId}/provider-bindings/{bindingId}/disconnect

Projects

Create and list projects with a dashboard session or a whole-team personal access token. A bs_ or pk_ key, and a project-scoped token, are refused: a key gets 403 USER_TOKEN_REQUIRED.

GET  /teams/{teamId}/projects
POST /teams/{teamId}/projects

GET needs project:ListProjects on the team and answers 200 { "projects": [...] } with the projects the caller may see. POST needs project:CreateProject, takes { "name": string, "slug"?: string, "description"?: string } and answers 201 { "project": {...} }. The slug is lowercase letters, digits and single hyphens, up to 63 characters; it defaults to one built from the name. Errors: 409 PROJECT_SLUG_TAKEN, 400 PROJECT_SLUG_RESERVED, and 400 INVALID_REQUEST for a bad body or a name that yields no slug. The token's environment does not matter for these routes.

GET /teams/{teamId}/projects/{projectId}/overview (project:GetProject, each section by its own list permission) counts customers, entitlements, subscriptions, checkouts, webhook health and the catalog, and adds invoices, the project's invoice count (invoice:ListInvoices), from the same source the project invoices list uses. Where that source is the team's Stripe account copy, only a team-level credential gets a number. In every other case, and whenever no source answered, count is null and reason says why. A source that is not known to hold every invoice yet (the Stripe sync is running, pending or failed, or no canonical invoice projection has completed) also answers null with reason: "sync-incomplete", never 0 or an undercount; 0 means a source known to be complete holds no invoice of the project. If the count itself cannot be read, the rest of the overview is still returned with an unknown count. A section the caller may not read is null and is not queried.

Canonical catalog

Products and provider-neutral price variants are project-scoped. Provider price links are verified against a connection account. Reading the catalog (GET) works with a runtime bs_ key. Writing it (POST and PATCH below) needs a personal access token, a dashboard session or a legacy full-access key; a new bs_ key gets 403 USER_TOKEN_REQUIRED.

GET  /teams/{teamId}/projects/{projectId}/catalog/products
POST /teams/{teamId}/projects/{projectId}/catalog/products
PATCH /teams/{teamId}/projects/{projectId}/catalog/products/{productId}
GET  /teams/{teamId}/projects/{projectId}/catalog/price-variants
POST /teams/{teamId}/projects/{projectId}/catalog/price-variants
POST /teams/{teamId}/projects/{projectId}/catalog/price-variants/{priceVariantId}/links
POST /teams/{teamId}/projects/{projectId}/catalog/price-variants/{priceVariantId}/publish
POST /teams/{teamId}/projects/{projectId}/catalog/products/{productId}/archive
POST /teams/{teamId}/projects/{projectId}/catalog/price-variants/{priceVariantId}/archive

Publish creates the variant's price in a provider account instead of linking an existing one. Body: { "mode"?: "test" | "live", "provider"?: string }. The mode defaults to the caller's environment, and an API key may only publish to its own. The target account is the one the project's active provider binding for that mode was verified against; provider is needed only when the project binds more than one provider in that mode. BillStack creates the provider product once per account (idempotency key bprod:{productId}:{incarnationId}) and the price (key bprice:{priceVariantId}:{incarnationId}), validates it, and saves a verified link. The response is 201 { providerLink, created: true }, or 200 with created: false when the variant was already published to that account. Stripe objects carry project_id, billstack_product_id and billstack_price_variant_id metadata. Errors: 409 PROVIDER_BINDING_MISSING (no active binding in that mode), 409 PROVIDER_ACCOUNT_UNAVAILABLE (the binding's account is no longer active; verify the binding again), 409 CAPABILITY_UNSUPPORTED (Razorpay and RevenueCat: link an existing price instead), 409 PRICE_VARIANT_INACTIVE / PRODUCT_UNAVAILABLE (archived), 502 *_FAILED (Stripe refused the request), 503 PROVIDER_WRITE_UNKNOWN (the outcome is unknown; publish again, which reuses the idempotency key). Publishing needs price:CreatePrice.

A price variant has a billingScheme: standard (the default) or consumable. A consumable is a one-time price (interval: "one_time"; any other interval is 400 INVALID_REQUEST) for things that are bought and used up, such as credit packs. Paying for one records the purchase but never grants access (see Reading checkouts and Entitlements). Send billingScheme when you create the variant; it cannot be changed later, so create a new variant to sell a consumable. Any other value is 400 INVALID_REQUEST. Variants are returned with their billingScheme and tierAlias.

Price variants are immutable, and archiving is the only change one takes. Archiving a variant makes checkout refuse it with 409 CANONICAL_PRICE_UNAVAILABLE, and publishing it fails with 409 PRICE_VARIANT_INACTIVE; to sell at a new amount, create a new variant. Archiving a product also archives all its variants. Neither can be undone. The archive routes need price:UpdatePrice, plus product:UpdateProduct for a product.

Update a product with PATCH .../catalog/products/{productId} (needs product:UpdateProduct). Body: { "name"?: string, "description"?: string | null, "metadata"?: object | null } with at least one field; any other field is 400 INVALID_REQUEST, and an archived product is 409 PRODUCT_UNAVAILABLE. The canonical product is updated first. name and description are then pushed to every verified Stripe product link the caller can see: an API key syncs only the links of its own environment (a bs_test_ key never edits live Stripe products), a dashboard session syncs both, and links to an inactive or historical account are skipped. metadata stays in BillStack and is never sent to a provider. The 200 response is { product, sync }: sync.status is complete, partial or none (no eligible link), and sync.results[] lists each provider product with outcome (synced, failed or skipped) and, when not synced, a code such as PROVIDER_PRODUCT_MISSING, PROVIDER_WRITE_UNKNOWN, ACCOUNT_INACTIVE, LINK_NOT_VERIFIED or CAPABILITY_UNSUPPORTED. A partial result is still 200 because the canonical product already changed; repeat the same PATCH to retry. Each product entry in providerLinks has a syncState (in_sync, out_of_sync, or unknown until the first update reaches it). Each update writes a catalog_product_updated row to the team audit log.

The link endpoint requires provider, connectionId, mode, and externalPriceId. For Stripe, externalProductId is also required: supply the independently selected expected Stripe Product ID. Missing, blank, or non-string Stripe Product IDs return 400 EXPECTED_PRODUCT_REQUIRED before database or provider work. BillStack verifies the actual Price parent against this expectation; it does not infer the expectation from the Price itself. Other providers keep externalProductId optional; provider metadata remains optional. It validates the provider object before persisting the link. A link imported by a backfill starts unverified; linking the same provider price again through this endpoint validates it and promotes the link to verified. A link to a different provider price, or one that is quarantined, is never overwritten and returns 409 PROVIDER_PRICE_LINK_CONFLICT.

Each entry in a product's or price variant's providerLinks carries the mode (test or live) of the provider account it belongs to. An API key sees only the links of its own environment: a bs_test_ key never sees live links, and a live key never sees test links. A dashboard session sees both, so it can show which environments a price is available in.

Lifetime deals

Stepped-price lifetime deals on a one-time Catalog price. Reads work with a runtime bs_ key; creating, editing, launching, ending and revoking need a personal access token or a dashboard session (a runtime key gets 403 USER_TOKEN_REQUIRED), and revoking refuses every API key. A publishable key reads the public offers. Every route runs in its credential's own environment. The guide walks through the flow.

GET   /teams/{teamId}/projects/{projectId}/lifetime-deals                                   price:ListPrices
POST  /teams/{teamId}/projects/{projectId}/lifetime-deals                                   price:CreatePrice (idempotencyKey required)
GET   /teams/{teamId}/projects/{projectId}/lifetime-deals/public                            publishable key
GET   /teams/{teamId}/projects/{projectId}/lifetime-deals/{dealId}                          price:GetPrice
PATCH /teams/{teamId}/projects/{projectId}/lifetime-deals/{dealId}                          price:UpdatePrice
PUT   /teams/{teamId}/projects/{projectId}/lifetime-deals/{dealId}/steps                    price:CreatePrice
POST  /teams/{teamId}/projects/{projectId}/lifetime-deals/{dealId}/launch                   price:CreatePrice
POST  /teams/{teamId}/projects/{projectId}/lifetime-deals/{dealId}/end                      price:UpdatePrice
GET   /teams/{teamId}/projects/{projectId}/lifetime-deals/{dealId}/sales                    invoice:ListInvoices
GET   /teams/{teamId}/projects/{projectId}/lifetime-deals/{dealId}/payment-rejections       invoice:ListInvoices
POST  /teams/{teamId}/projects/{projectId}/lifetime-deals/{dealId}/sales/{saleId}/revoke    price:UpdatePrice

Routing rules

Hand-written routing rules are explicit and project-scoped. They are evaluated only in a team with one region. Once a team has more than one region, country is the only routing input: hand-written rules are kept but not evaluated, and POST, PATCH and activate return 409 ROUTING_RULES_FROZEN_MULTI_REGION (DELETE and validate still work).

GET    /teams/{teamId}/projects/{projectId}/routing-rules
POST   /teams/{teamId}/projects/{projectId}/routing-rules
PATCH  /teams/{teamId}/projects/{projectId}/routing-rules/{ruleId}
DELETE /teams/{teamId}/projects/{projectId}/routing-rules/{ruleId}
POST   /teams/{teamId}/projects/{projectId}/routing-rules/{ruleId}/validate
POST   /teams/{teamId}/projects/{projectId}/routing-rules/{ruleId}/activate
POST   /teams/{teamId}/projects/{projectId}/routing-rules/{ruleId}/deactivate

Regions

A region is one payment-provider connection plus the countries it serves; the team's default region serves every country no other region claims. Regions are team-wide (all projects, both environments), so they are not project routes. Concepts and an end-to-end example: Regions.

GET    /teams/{teamId}/regions
POST   /teams/{teamId}/regions
GET    /teams/{teamId}/regions/{regionId}
PATCH  /teams/{teamId}/regions/{regionId}
DELETE /teams/{teamId}/regions/{regionId}
GET    /teams/{teamId}/regions/{regionId}/coverage?mode=
POST   /teams/{teamId}/regions/{regionId}/activate
POST   /teams/{teamId}/regions/{regionId}/deactivate
POST   /teams/{teamId}/regions/{regionId}/make-default
RoutePermissionBody and result
GET /regionsbilling:GetProviders{ regions, multiRegion }.
POST /regionsbilling:ManageProviders{ name, connectionId, countries? } creates a draft region on a Stripe or Razorpay connection that has none. 201 { region, warnings }.
GET /regions/{regionId}billing:GetProviders{ region }.
PATCH /regions/{regionId}billing:ManageProviders{ name?, countries? }; countries replaces the whole list. { region }.
DELETE /regions/{regionId}billing:ManageProviders{ deleted: true } for a non-default region that nothing references.
GET /regions/{regionId}/coverage?mode=billing:GetProviders{ coverage }. mode defaults to the key's environment.
POST /regions/{regionId}/activatebilling:ManageProviders{ mode }. { region, coverage, warnings, pausedCampaigns }.
POST /regions/{regionId}/deactivatebilling:ManageProviders{ mode }. { region, warnings }.
POST /regions/{regionId}/make-defaultbilling:ManageProviders (dashboard session only){ region, warnings }. An API key of any kind gets 403 UNAUTHORIZED.

Merchant entities

A merchant entity is the legal merchant behind one or more of a team's provider accounts. Every team has one default entity (named after the team until you change it), and each new provider connection attaches to it. Entities are team-wide, like regions. Region.entity and Region.entityId, and ProviderConnection.entityId, tell you which entity sits behind an account; connection slots also carry accountCountry and accountCurrency where the provider exposes them (Stripe does; Razorpay and RevenueCat return null, as do accounts connected before entities existed).

GET    /teams/{teamId}/entities
GET    /teams/{teamId}/entities/{entityId}
PATCH  /teams/{teamId}/entities/{entityId}
RoutePermissionBody and result
GET /entitiesbilling:GetProviders{ entities }, default first.
GET /entities/{entityId}billing:GetProviders{ entity } with id, teamId, legalName, country, defaultCurrency, isDefault, createdAt, updatedAt. 404 ENTITY_NOT_FOUND.
PATCH /entities/{entityId}billing:ManageProviders{ legalName?, country?, defaultCurrency? }; country is ISO 3166-1 alpha-2 and defaultCurrency ISO 4217 (null clears). 400 INVALID_ENTITY_NAME, INVALID_ENTITY_COUNTRY, INVALID_ENTITY_CURRENCY. A test API key gets 403 ENVIRONMENT_MISMATCH.

country and defaultCurrency start empty and are filled from the first provider account that reports them; a value you set is never overwritten. The SDK equivalent is BillStackV2Client.entities.

An API key is held to its own environment for activate, deactivate and coverage (another mode is 403 ENVIRONMENT_MISMATCH). A test API key may read regions but gets 403 ENVIRONMENT_MISMATCH on create, update and delete, because they affect both environments; use a live key or a dashboard session. make-default also changes the team's default payment provider, so it takes a dashboard session only: no API key can call it, live or test. The SDK equivalent is BillStackV2Client.regions.

A region object has id, name, connectionId, provider, isDefault, countries (ISO 3166-1 alpha-2; empty for the default region), status and availability per environment, routing per environment and connection (status, serves). status is the stored choice (draft or active); availability is what customers experience:

availabilityMeaning
draftNot activated in this environment. It claims no countries; the default region serves them.
activeServing its countries.
unavailableActivated, but its connection cannot serve the environment (or the default region is down). Checkout for its countries fails with PROVIDER_UNAVAILABLE; it never falls back to the default region. Reconnecting makes it serve again; deactivating sends the countries to the default.

The coverage report lists, for the region's provider and environment: sellable price variants and how many are covered by a verified link, gaps (variants the provider can charge but that have no verified link; these block activation of a non-default region and make-default), notOffered (currencies the provider cannot charge, information only; Razorpay sells INR only), handWrittenRules that stop applying, and lifetimeCampaigns that activation would pause.

Activation needs a usable key slot for the environment (409 MODE_NOT_CONNECTED), an active default region in that environment for a non-default region (409 DEFAULT_REGION_UNAVAILABLE) and no coverage gaps (409 REGION_COVERAGE_GAPS, first 20 in fieldErrors). Warning: LIFETIME_CAMPAIGNS_PAUSED. Creating the second region warns ROUTING_RULES_FROZEN_MULTI_REGION with the number of hand-written rules that stop applying. Deactivation warns COUNTRIES_REROUTE_TO_DEFAULT and PINNED_CUSTOMERS_UNROUTABLE. Make default moves the region that serves unclaimed countries; pinned customers stay where they are. It warns UNPINNED_CUSTOMERS_REROUTED, PINNED_CUSTOMERS_ON_PREVIOUS_DEFAULT and COUNTRY_LIST_RELEASED, and fails with DEFAULT_REGION_MODE_GAP if the new default's connection does not serve an environment the old default serves.

Region errors

CodeStatusMeaning
REGION_NOT_FOUND404No such region in the team.
CONNECTION_NOT_FOUND404The connection is not one of the team's.
INVALID_REGION_NAME400Names are 1 to 80 characters.
INVALID_COUNTRY400Not an ISO 3166-1 alpha-2 code (UK is GB).
INVALID_MODE400mode must be test or live.
NOT_A_PAYMENT_PROVIDER400Only Stripe and Razorpay connections can back a region.
DEFAULT_REGION_OWNS_NO_COUNTRIES400The default region serves every unclaimed country and has no list.
REGION_ALREADY_EXISTS409The connection already has a region.
COUNTRY_CONFLICT409Another region owns the country (named in the message).
DEFAULT_REGION_UNAVAILABLE409The team has no active default region (in this environment).
DEFAULT_REGION_PROTECTED409The default region cannot be deleted or deactivated; make another region the default.
DEFAULT_REGION_MODE_GAP409The new default would not serve an environment the old default serves.
REGION_ALREADY_DEFAULT409The region already is the default.
LEGACY_PROVIDER_CONNECTION_REQUIRED409A provider is configured only through legacy project settings; connect it as a provider connection first.
MODE_NOT_CONNECTED409The connection has no usable key slot for the environment.
REGION_COVERAGE_GAPS409Price variants without a verified link (see fieldErrors; full report on coverage).
REGION_IN_USE409Pinned customers, subscriptions, checkouts or provider accounts reference the region; deactivate it instead.
ROUTING_RULES_FROZEN_MULTI_REGION409A hand-written routing rule was created or changed in a multi-region team.
ENVIRONMENT_MISMATCH403A test key tried a team-wide change, or named the other environment.

Connecting a second account of a provider the team already has is 409 CONNECTION_ALREADY_EXISTS: a team has one account per payment provider.

Country confirmation and checkout

Country advisory is informational and always requires manual confirmation. The confirmation is then submitted to checkout:

GET  /teams/{teamId}/projects/{projectId}/country-advisory
POST /teams/{teamId}/projects/{projectId}/country-confirmations
POST /teams/{teamId}/projects/{projectId}/checkout

POST country-confirmations requires country and customerExternalId and returns a token that is bound to that customer, expires after one hour and can pay for one checkout. It runs in the calling key's environment.

Checkout requires externalId, priceVariantId, idempotencyKey, successUrl, and cancelUrl. For projects with country routing enabled, also send countryConfirmation and its bound customerExternalId. A test API key may send an unsigned top-level country instead; a live key requires a signed token. Token failures use the COUNTRY_TOKEN_* codes (REQUIRED, CUSTOMER_REQUIRED, CUSTOMER_MISMATCH, INVALID, EXPIRED as 400 and ALREADY_USED as 409). It can also accept customerExternalId, mode, quantity, string-valued metadata, and routing context such as productId, currency, and requiredCapability. The customer's region comes from their pin (set by their first confirmed payment; the country is then ignored), otherwise from the confirmed country. Keys starting with billstack_ are reserved and dropped from metadata. metadata.billing_scheme is also reserved: it is rejected with 400 INVALID_METADATA because it would let a caller mint a lifetime grant (plan and lifetime status come from the price variant). plan, tier and tier_alias are ignored for the same reason. No eligible provider returns an error; v2 does not silently switch providers.

CodeStatusMeaning
PROVIDER_UNAVAILABLE409The customer's region cannot take payments now. Never re-routed.
NO_ELIGIBLE_PROVIDER409No rule or region applies.
PRICE_UNAVAILABLE_IN_REGION422The region has no verified price link for the variant. Returned before the token is spent.
REGION_PIN_MISMATCH409Retry of a failed checkout whose customer is now pinned to another region.
CHECKOUT_EXPIRED409The checkout was closed because the customer paid in another region.

A team whose test environment runs on the BillStack sandbox checks out through its sandbox with a bs_test_ key: routing by country, rule and region does not apply, the returned url is a BillStack test checkout, and the Sandbox API pays it without a browser.

Checkout options

A price-variant checkout also accepts these optional fields:

FieldTypeMeaning
trialDaysinteger, 1 to 730Free trial before the first charge. Recurring variants only. The customer's card is still collected up front.
allowPromotionCodesbooleanShow the provider's promotion-code box on the hosted page.
promotionCodestring, 1 to 64 charactersA merchant promotion code the customer already typed. It is looked up on the account that will sell and applied as the checkout's discount.
referral{ code?: string }Apply the referral discount. code omitted uses the customer's existing referral attribution.

allowPromotionCodes: true, promotionCode and referral are mutually exclusive: a checkout carries one discount, or the promotion-code box, never both (400 CHECKOUT_OPTIONS_CONFLICT). A malformed value is 400 INVALID_REQUEST. A campaign checkout takes none of these fields.

Options are applied only where the customer's region sells through a provider that supports them, which today means Stripe. In a Razorpay region (or any other provider) the request is refused with 422 CHECKOUT_OPTION_UNSUPPORTED rather than sold without the option, so read the region from the country confirmation first or retry without the option. The options are resolved after the customer is routed and before the country token is spent, so a refused request does not spend the token. They are saved with the checkout: retrying the same request with the same idempotencyKey sends the provider exactly what the first attempt did, and a retry with different options is 409 IDEMPOTENCY_CONFLICT.

A referral runs the same resolution as POST referrals/checkout-resolution (code rules, program limits and first-touch attribution) on the price being sold, and records the customer's attribution when they have none. Because it writes the attribution, sending referral needs referral:ApplyCode on the key in addition to checkout:CreateCheckout (without it the request is 403). The customer needs an email on record (set it through the customers API first). Use referral for BillStack referral codes and promotionCode for merchant codes created in your payment account; a referral code sent as promotionCode is refused so the referrer is never left uncredited. A product restriction on the referral program is enforced only by the discount in the provider for catalog prices, not by BillStack.

CodeStatusMeaning
CHECKOUT_OPTIONS_CONFLICT400allowPromotionCodes, promotionCode and referral were combined.
CHECKOUT_OPTION_UNSUPPORTED422The customer's region cannot apply the option (not a Stripe region).
TRIAL_REQUIRES_RECURRING_PRICE422trialDays was sent for a one-time variant.
PROMOTION_CODE_NOT_FOUND422No active promotion code matches.
PROMOTION_CODE_INVALID422The code exists but can no longer be redeemed (expired, redemption limit reached or its discount is no longer valid).
PROMOTION_CODE_IS_REFERRAL422The code belongs to the referral program; send it as referral.code.
REFERRAL_REJECTED422The referral does not apply. fieldErrors carries the reason: not_found, inactive, expired, max_uses, plan_not_allowed, period_not_allowed, self_referral, not_first_time, not_synced or disabled. Nothing is recorded for a rejected referral.
REFERRAL_EMAIL_REQUIRED422The customer has no email on record.
REFERRAL_NOT_APPLICABLE422A referral discount applies to recurring variants only.
REFERRAL_TRIAL_DISCOUNT_WASTED422The program's discount lasts one invoice, which the free trial would use up. Drop the trial or give the program a repeating discount.

A default trial on the price variant itself is not available; send trialDays with each checkout.

Lifetime campaigns

Send campaignTier (the tier alias of the campaign's step prices) instead of priceVariantId to sell a tier's lifetime campaign; send exactly one of the two. The customer is routed to a region exactly as for a price variant (their pin, else the confirmed country) and is sold that region's price for the campaign's current step: the step's Stripe price in a Stripe region, a Razorpay payment link at the step's regional alternate in a Razorpay region. The response has the same shape as a price-variant checkout. A campaign checkout sells one unit and accepts no quantity, metadata, providerCustomerId, productId, currency, requiredCapability, trialDays, allowPromotionCodes, promotionCode or referral.

CodeStatusMeaning
PRICE_UNAVAILABLE_IN_REGION422The customer's region has no price for the campaign (a Razorpay region without a regional alternate for the current step, or a sold-out campaign whose fallback is another region's price). Another region's price is never shown.
CAMPAIGN_UNAVAILABLE409No lifetime offer is on sale for the tier: no active campaign (draft or paused) and no regular lifetime price, or the campaign is sold out with no fallback. A campaign checkout never sells a subscription price.
LIFETIME_ALREADY_OWNED409The customer already owns the lifetime offer.

A refused request does not spend the country token. Step accounting, the sold-out fallback and entitlement grants are the ones campaigns use through the v1 API.

Reading checkouts

Read back the checkouts you started, to see what was bought, what was paid and whether it was refunded. mode follows the same rule as entitlements (it defaults to the environment of your API key, and a key may only name its own):

GET /teams/{teamId}/projects/{projectId}/checkouts/{checkoutId}
GET /teams/{teamId}/projects/{projectId}/checkouts

checkoutId is the id the checkout call returned. The list is newest first and takes customerExternalId, idempotencyKey, priceVariantId, status, cursor and limit (1 to 200). Reading needs checkout:GetCheckout for one checkout and checkout:ListCheckouts for the list. The built-in Owner, Admin, Billing, Developer and ReadOnly policies allow both reads. A project API key created since 2026-12-01 (app runtime) allows both reads and creating checkouts, and an older full-access key with no IAM attachments keeps its admin-equivalent access. For roles, creating a checkout (checkout:CreateCheckout) stays with Owner and Admin; a key on the Billing or Developer policy needs a custom policy that adds it. Custom policies need the read actions added explicitly.

The checkout's quantity and the metadata you sent are saved with it and returned unchanged (keys starting with billstack_ and plan, tier and tier_alias are not stored back, as they are not sent to the provider).

Razorpay allows at most 15 notes on an object and BillStack sets 11 of them itself, plus one more when the quantity is above 1. A checkout routed to Razorpay can therefore carry about four metadata keys (three with a quantity above 1); one that would exceed the limit is refused with 400 and INVALID_METADATA before anything is sent to Razorpay, and the message says how many keys fit. Stripe has no such limit in practice.

FieldMeaning
checkoutId, externalId, idempotencyKeyThe checkout id, your order id and the idempotency key of the request.
statusopen (waiting for the customer), completed (a payment was confirmed), expired (the session lapsed, or the customer paid in another region), failed or unknown (the provider checkout could not be created).
paymentStatusunpaid, paid or refunded.
kind, consumableone_time or subscription; consumable is true for a consumable price.
priceVariantId, tierAlias, unitAmountMinorWhat was sold and the catalog price of one unit.
quantityUnits bought; 1 when the request did not send one.
amountMinor, currencyWhat was actually paid (upper-case ISO code); null until the payment event has been processed.
paymentId, sessionId, providerThe provider payment id (pi_..., pay_...; null until paid), the provider session id and the provider.
customerExternalId, metadataThe customer and the metadata from the request.
createdAt, completedAtWhen the checkout was created and when its payment was confirmed.

A completed checkout means a payment was confirmed by a signed provider event, so a success redirect alone never completes one. A Stripe checkout the customer abandoned reports expired once Stripe says the session expired. Amount, payment id and refund state come from provider events, so they can trail the redirect by a few seconds: poll with backoff until status is completed. A partial refund is not reported; refunded means the payment's grant was revoked.

CodeStatusMeaning
CHECKOUT_NOT_FOUND404No such checkout in this project and environment.
INVALID_FILTER400Unknown status, mode or limit.
INVALID_CURSOR400The cursor was not issued by this endpoint.

Entitlements

Read one entitlement by app external ID or list project entitlements. mode defaults to the environment of your API key (live for legacy and bs_live_ keys, test for bs_test_ keys); a key may only name its own environment, otherwise the request fails with 403 ENVIRONMENT_MISMATCH (for example a live key that names mode=test):

GET /teams/{teamId}/projects/{projectId}/entitlements/{externalId}
GET /teams/{teamId}/projects/{projectId}/entitlements

The list endpoint supports externalId, status, cursor, and limit query parameters. limit is between 1 and 200.

Each entry in grants carries priority, reason and grantedBy (set on manual grants, otherwise 0, null and null), quantity (units bought, or null when BillStack did not record it), isEntitled, consumable, checkoutId (the checkout a payment grant settled, else null), trialing and trialEndsAt. A consumable purchase is a grant with consumable: true and isEntitled: false: it records the purchase but never affects effective. A grant on a free trial is entitled (status: "active") with trialing: true and the end of the trial in trialEndsAt; both clear when the subscription converts or the trial ends. See Entitlements.

Manual (complimentary) grants

Give a customer a plan without a payment, list the grants behind a customer's access, and withdraw a manual grant later. mode follows the rule above (it defaults to the environment of your API key, and a key may only name its own):

POST   /teams/{teamId}/projects/{projectId}/entitlements/{externalId}/grants
GET    /teams/{teamId}/projects/{projectId}/entitlements/{externalId}/grants
GET    /teams/{teamId}/projects/{projectId}/entitlements/{externalId}/grants/{grantId}
DELETE /teams/{teamId}/projects/{projectId}/entitlements/{externalId}/grants/{grantId}

externalId is the customer's external id, and the customer must already exist in the environment (404 CUSTOMER_NOT_FOUND). The create body takes:

FieldMeaning
priceVariantId or tierAliasExactly one. A price variant grants its tier alias (or, with no alias, its id) as the plan. A tierAlias grants that alias and must exist on an active price variant of the project (404 TIER_NOT_FOUND). An archived variant and a consumable variant are 400 INVALID_REQUEST; an unknown variant is 404 PRICE_VARIANT_NOT_FOUND.
startsAtISO 8601 instant; defaults to now. May be in the future.
endsAtISO 8601 instant in the future, after startsAt. Leave it out (or send null) for an open-ended grant.
priorityInteger from 0 to 100, default 0. A higher priority wins effective regardless of end date; see how the effective plan is chosen.
reasonRequired, 1 to 500 characters. Kept on the grant and in the team audit log.
idempotencyKeyRequired, 1 to 200 characters. A retry of the same request returns the same grant; the same key with a different request is 409 IDEMPOTENCY_CONFLICT.

The response is { "grant", "effective" }: the grant as it appears in grants of the entitlement read, and the customer's effective access after the call. A new grant answers 201, an idempotent replay 200. The grant has sourceKind: "manual", sourceExternalId: "manual:<idempotencyKey>", provenance: "verified", priority, reason and grantedBy ({ "type": "api" | "user", "id" }: the API key or the dashboard user who made it). A grant by tier alias has commercialKey: "tier:<alias>"; one by variant has the variant id. Access takes effect immediately and expires on its own at endsAt.

GET .../grants returns { "items", "nextCursor": null } with every grant of the customer, whatever its source (subscription, payment, manual), oldest first. Filters: status and sourceKind; an unknown value is 400 INVALID_FILTER. GET .../grants/{grantId} returns { "grant" } (404 GRANT_NOT_FOUND for an id that is not this customer's in this environment).

DELETE soft-revokes a manual grant and answers 200 with { "grant", "effective" }. The body is optional: { "reason": "..." }. The grant stays in grants with status: "revoked", isEntitled: false and its period untouched, and who revoked it and why is kept. Revoking a grant that is already revoked changes nothing. A subscription, payment, lifetime or referral grant cannot be revoked here (409 GRANT_NOT_MANUAL); change those at the payment provider.

CodeStatusMeaning
CUSTOMER_NOT_FOUND404No such customer in this project and environment.
PRICE_VARIANT_NOT_FOUND, TIER_NOT_FOUND404The variant or tier alias does not exist in this project.
GRANT_NOT_FOUND404No such grant for this customer in this environment.
GRANT_NOT_MANUAL409Only manual grants can be revoked.
IDEMPOTENCY_CONFLICT409The idempotencyKey was used for a different request.
INVALID_REQUEST400Bad body, a window that is not in the future or has endsAt before startsAt, or an archived or consumable variant.
INVALID_FILTER400Unknown status, sourceKind or mode.

Creating needs entitlement:CreateGrant, listing and reading need entitlement:ListGrants, and revoking needs entitlement:RevokeGrant. The built-in Owner, Admin and Billing policies allow all three, and a key with no IAM attachments keeps its admin-equivalent access. The Developer and ReadOnly policies can list and read grants but not create or revoke them. Manual grants are not available through the MCP server. They feed the v2 entitlement read only, not the legacy snapshot API.

Provider portal

Create a provider portal session for a project customer. The server resolves the provider customer from customerExternalId; callers cannot supply providerCustomerId:

POST /teams/{teamId}/projects/{projectId}/portal

The request accepts customerExternalId, an optional provider, an optional regionId and an optional returnUrl. With several accounts the pinned region's account is used; a customer with accounts at more than one provider and no pin is 409 CUSTOMER_PROVIDER_ACCOUNT_AMBIGUOUS until provider or regionId is sent. An unknown regionId is 404 REGION_NOT_FOUND.

To change the plan of, cancel or resume a customer's subscription from your server rather than through a portal, see Subscription management.

Team metrics

Revenue, subscriber and churn metrics are team-scoped and read-only:

GET /teams/{teamId}/metrics/overview
GET /teams/{teamId}/metrics/saas
GET /teams/{teamId}/metrics/series

overview returns the numbers of the team home (MRR, customer and subscription counts with sparklines, 365 days of net volume with the previous 365 days as the compare overlay, cash collection and the plan breakdown). saas returns ARR, ARPA, LTV, net revenue retention, the churn breakdown and ARPA by tier. series returns one to five of ten named time series (mrr, arr, mrr-growth, mrr-growth-rate, net-volume, subscribers, new-subscribers, trials, churn, collections) over one range, with an optional compare range. All three need analytics:GetAnalytics and accept mode; overview and saas accept window (7, 30, 60 or 90 days).

Today the numbers come from the synced copy of the team's Stripe account and are US dollar amounts only; other currencies are skipped, never converted or added. Each answer lists its sources next to the others and never merges them, and uncovered names connected providers (for example razorpay) whose revenue is not included. A team with no Stripe data for the mode gets 200 with state: "no_source" and no sources, not zeros. On the BillStack sandbox the numbers are simulated and sources[].info.simulated is true.

These routes are team-wide: a project-bound API key (including a runtime key) or token is refused with 403, and projectId or sandboxId is 400 INVALID_FILTER. In overview, the sections that carry customer or payment data are left out unless the caller also holds the matching action: recentCustomers needs customer:ListCustomers, recentPayments, payouts, needsAttention.openDisputes and needsAttention.failedWebhooks need billing:GetBilling, and needsAttention.pastDueInvoices needs invoice:ListInvoices.

Invoice actions

Void an open invoice or mark it uncollectible at the provider, from the team or from one project. Stripe is the first provider: another provider answers 409 PROVIDER_ACTION_UNSUPPORTED and nothing is called, and the BillStack native sandbox answers 409 NATIVE_SANDBOX_UNSUPPORTED.

GET  /teams/{teamId}/invoices/{invoiceId}
POST /teams/{teamId}/invoices/{invoiceId}/void
POST /teams/{teamId}/invoices/{invoiceId}/mark-uncollectible
GET  /teams/{teamId}/projects/{projectId}/invoices/{invoiceId}
POST /teams/{teamId}/projects/{projectId}/invoices/{invoiceId}/void
POST /teams/{teamId}/projects/{projectId}/invoices/{invoiceId}/mark-uncollectible

Neither change can be undone from BillStack, and only open invoices can be changed. GET reads the invoice live from the provider with the actions that apply to it, for a confirmation. The permissions are invoice:VoidInvoice and invoice:MarkUncollectible, evaluated in the environment of the request; the live read needs invoice:GetInvoice and one of them. Runtime keys are always denied both write actions, so they are refused on all six routes. A write runs only in the environment of the credential: a body mode that names the other one is 403 ENVIRONMENT_MISMATCH.

The body is { "idempotencyKey": string, "reason"?: string, "mode"?: "test" | "live", "provider"?: "stripe" } and idempotencyKey is required. The invoice is always read live right before the write, so a stale list row answers 409 INVOICE_STATUS_CONFLICT with the live status in error.currentStatus. An invoice that already has the requested end status answers 200 with unchanged: true and nothing is written, so a retry after an unconfirmed write and two callers changing the same invoice both end in one change. 504 PROVIDER_OUTCOME_UNKNOWN is safe to retry with the same key. An intent row is written to the team audit log before the provider is called (503 AUDIT_UNAVAILABLE and nothing sent when it cannot be), and an outcome row follows.

Team scope needs a team-level credential: a project-bound key or token, and a member whose policy names one project, are refused. Project scope acts only on an invoice the project's own invoice list shows. Where canonical invoice reads are on for the project, the invoice must be a canonical record of this project, synced from the same provider account as the key that acts. Otherwise the project's invoices come from the team's Stripe account copy, which is team data: only a team-level credential may act (403 TEAM_ACCESS_REQUIRED before any provider call for anyone else), and the invoice's customer must be linked to this project and to no other. An invoice of another project and an invoice that does not exist answer the same 404 INVOICE_NOT_FOUND. In the SDK these are client.invoiceActions and client.projectInvoiceActions.

Stripe account records

While canonical reads are not enabled for a team, the dashboard lists its money from the synced copy of the team's Stripe account. The same data is available over the API, team-scoped and read-only:

GET /teams/{teamId}/stripe-account/{resource}
GET /teams/{teamId}/stripe-account/{resource}/{id}
GET /teams/{teamId}/stripe-account/invoices/{id}/pdf

resource is balance, payouts, payments, disputes, customers, invoices, subscriptions, products or webhook-events for the list, and payments, disputes, customers, invoices or subscriptions for one object (the Stripe id). The list takes mode, cursor and limit (up to 200) and the filters of its resource, for example status and date on payments, tab and query on customers and customerId on invoices. The permission is customer:ListCustomers for customers, invoice:ListInvoices for invoices, subscription:ListSubscriptions for subscriptions, product:ListProducts for products and billing:GetBilling for the rest. products lists the account's Stripe products (search, status of all, active or archived, and project) and says which project owns each one. Ownership comes from the project's provider-product claims of the connection's active Stripe account, never from a legacy table: a claim decides the project, otherwise product metadata that names one of the team's projects, otherwise the product is unassigned. project is a project id or unassigned; an unknown project and one the caller may not read are the same 400 INVALID_FILTER. The answer adds owners (by product id), projects (the team's projects the caller may name, which needs project:ListProjects on the team and project:GetProject on the project; a project the caller may not read shows projectId: null) and link (the connection and account incarnation a product is adopted into a project through, or null without a canonical Stripe connection). The dashboard's "Link to a project" action adopts an unowned active product through the project's Stripe product route; it is not an API key operation here. webhook-events lists the Stripe deliveries BillStack recorded for the mode, newest first, 25 to a page by page number, with total, stats and the webhookUrl to register in Stripe; the payloads are the raw Stripe events.

Every answer carries a state. ready means the copy answered; pending_first_sync means keys exist but the first sync has not created the copy; no_source means the team has no Stripe keys for the mode (with a reason); native_sandbox means test mode on the BillStack sandbox, which has no Stripe account. Outside ready the page is empty. A customer answers with the customer and, for each action the caller also holds, its subscriptions, invoices, payments and event timeline. The PDF route retrieves the invoice from Stripe with the team's own key and streams it, and needs invoice:GetInvoice.

These routes are team-wide: a project-bound API key (including a runtime key) or token is refused with 403, and projectId or sandboxId is 400 INVALID_FILTER. A key can only name its own environment. Amounts keep the currency of the row and are never added across currencies.

Stripe sync (dashboard session only)

GET /teams/{teamId}/stripe-account/sync
POST /teams/{teamId}/stripe-account/sync
POST /teams/{teamId}/stripe-account/sync/reset
PATCH /teams/{teamId}/stripe-account/preferences

These belong to the dashboard's Stripe sync page and accept a signed-in team admin's session only: an API key or access token is refused with 403, however privileged. GET returns the sync status of the environment, one checkpoint per entity and the preferences. POST queues a backfill (kind of fresh or resume, optionally limited by objects and createdAfter) for the environment the session is in, and a running sync is 409 SYNC_IN_PROGRESS unless a fresh start is confirmed. reset puts a stuck syncing or failed status back to pending. PATCH preferences changes cash-backed MRR, the churn threshold and the contractor diagnostics window, team-wide.

Stripe webhook endpoint and disconnect (dashboard session only)

GET  /teams/{teamId}/stripe-account/webhook-endpoint
POST /teams/{teamId}/stripe-account/webhook-endpoint
GET  /teams/{teamId}/stripe-account/disconnect
POST /teams/{teamId}/stripe-account/disconnect

Both pairs belong to the dashboard's Integrations and Stripe sync pages. They accept a signed-in dashboard session only: an API key, access token or runtime key is refused with 403, however privileged. The two pairs check different things. The webhook endpoint needs a team admin session that also holds billing:ManageProviders. The disconnect needs a dashboard session that holds billing:ManagePaymentProvider and makes no separate team admin check, so a member with the managed Billing role can preview and run it through the API (the dashboard offers it on the team admin Stripe sync page). Each acts on one environment (mode defaults to the environment the session is viewing), a POST is bound to that environment so a session viewing test cannot act on live, and the permission is evaluated in the environment acted on.

webhook-endpoint needs billing:ManageProviders and a team admin. GET previews what the setup would do without changing anything: the URL BillStack registers (always the team URL, /api/webhooks/stripe/{teamId}, with /test for the test environment), the events, the endpoint already at that URL, and the plan (create, update or none). A state that cannot be made safe is returned as blocked with a code and a reason, for example a Stripe key whose account BillStack has not recorded (a placeholder identity is never used), another BillStack endpoint of the team in the same Stripe account, or a key held in two stores. POST carries the previewHash of the preview the admin confirmed. It reuses an endpoint that is already at the URL instead of creating a duplicate, stores the signing secret straight into the key's credential store, and never returns, logs or audits the secret. BillStack never deletes an endpoint in Stripe. A refusal is 409 with the code of the state, a stale preview is 409 PREVIEW_STALE, and a run that created the endpoint but could not store its secret is finished by running the setup again.

disconnect needs billing:ManagePaymentProvider, which runtime keys are explicitly denied. GET previews what removing the key of the environment deletes (the synced copy, with its records per type) and what stops (checkouts and webhooks that depend on it), whether the other environment keeps its key and data, and whether an earlier removal stopped half way. POST takes { "confirmation", "previewHash" }: the server compares confirmation with the team slug it reads itself (trimmed, exact, case-sensitive) and the hash with a fresh preview. The removal drops the synced copy of that one environment and cannot be undone; the other environment is never touched, and the run verifies that. Your Stripe account is not changed, and the webhook endpoint stays in Stripe, so delete it there if you no longer want it. Only the key stored with the team's Stripe settings can be removed here; a key added in Integrations is disconnected there, which keeps the synced copy. An intent row is written to the audit log before anything is removed, and 503 AUDIT_UNAVAILABLE means nothing was.

Query the Stripe account

POST /teams/{teamId}/stripe-account/query
GET /teams/{teamId}/stripe-account/query

POST runs a read-only BillingQL query over the same synced copy for mode (customers, subscriptions, invoices, products, prices and payments, the account's charges). The body is { "query": "...", "mode": "execute" | "validate" | "explain", "parameters": {} }. It needs query:Execute plus the action of every dataset the query reads, and a missing one is 403 FORBIDDEN naming it. A rejected query is 400 with a QUERY_* code, 409 QUERY_MIRROR_NOT_SYNCED means the copy for the mode does not exist yet, and SOURCE_NOT_AVAILABLE means the team has no Stripe account for the mode (404) or is on the BillStack sandbox (409). Every run is recorded in the team audit log. GET answers with the state of the copy a query would read, without reading any row. Both are team-wide, like the lists above.

Project insights

Project analytics, invoices, payments, diagnostics, inbound provider events and BillingQL read a project's own records. All of them take mode (a key can only name its own environment) and are scoped to the project in the path:

GET /teams/{teamId}/projects/{projectId}/analytics
GET /teams/{teamId}/projects/{projectId}/invoices
GET /teams/{teamId}/projects/{projectId}/payments
GET /teams/{teamId}/projects/{projectId}/diagnostics
GET /teams/{teamId}/projects/{projectId}/provider-events
GET /teams/{teamId}/projects/{projectId}/query
POST /teams/{teamId}/projects/{projectId}/query

analytics (analytics:GetAnalytics) returns subscriptions by status with the churn rate, recurring revenue at list price as one line per currency (a subscription without a catalog price is counted apart, never guessed), customer growth, the provider-event inbox, outbound webhook health and the referral report. Sections that carry other data need that data's permission (billing:GetBilling for the events and the webhook health, referral:GetReport for referrals) and are null without it. coverage.canonicalSince says when BillStack began recording provider events for the project: a subscription that began earlier can be missing. byStatus uses the grant statuses (active, canceling, billing_issue, expired, canceled, revoked, unknown), not the provider's: billing counts active and canceling (a subscription set to cancel at period end still bills), atRisk counts billing_issue (a failed payment), and the churn rate counts canceled, expired and revoked over all subscriptions.

invoices (invoice:ListInvoices) names its source. canonical is the project's canonical invoice records, used where canonical invoice reads are enabled. Otherwise stripe-account lists the invoices of your synced Stripe account whose customer BillStack linked to this project; a Stripe customer linked to more than one project is attributed to none and counted in excludedSharedCustomers. The Stripe account is team data, so that source needs a team-level credential holding invoice:ListInvoices on the team: a project-bound key or token, a runtime key and a member whose policy names one project get source: "none" with team-access-required. No query parameter selects another project or a customer. Amounts keep their currency and stats has one entry per currency. accountSync is the sync status of the team's Stripe account copy (status, and copyExists, false before the first sync created it). It is set only when the copy was opened, so it is null for canonical rows, with no provider, and for every caller that may not read the team's account data. A team admin starts that sync from the dashboard (see Stripe sync above).

payments (billing:GetBilling) works the same way for the project's payments. canonical is the project's payment records, used where canonical payment reads are enabled; it is always partial (unattributed-payments-excluded) because a payment event that carried no project is not attributed. Otherwise stripe-account lists the charges of your synced Stripe account whose customer BillStack linked to this project, by the same rule as invoices: a customer linked to more than one project is attributed to none and counted in excludedSharedCustomers, and a payment without a customer is attributed to no project. Opening the Stripe account needs a team-level credential holding billing:GetBilling on the team; anyone else gets source: "none" with team-access-required. status is succeeded, pending or failed (400 INVALID_FILTER otherwise). On canonical records each word covers the provider's own statuses (for example succeeded includes Razorpay captured, pending includes processing and authorized, and failed includes canceled), and the per-currency collected total counts the succeeded group. A row carries the payment id, status, amount and refunded amount, the project's own customer id, the invoice it paid and whether it was refunded or disputed (null when the source does not say); it never carries a customer email or name, a Stripe customer id, a payment method or a failure detail. stats has one entry per currency.

diagnostics (diagnostics:GetProjectDiagnostics, and nothing else) is built for a contractor: provider bindings and their health, the inbox (counts by status, retries, the oldest unprocessed event, stuck effects), customers without a provider account, recent checkouts and failing outbound endpoints, with identifiers masked and no customer identity, amounts, payloads or error text. provider-events (billing:GetBilling) lists the inbound events BillStack recorded, never their payload.

POST query runs BillingQL (query:Execute plus the list permission of every dataset) over customers, subscriptions, products, prices and, where canonical invoices are enabled, invoices; GET query lists the datasets and whether each is available. Customers are identified by external_id, and payments is refused: a project query is one canonical statement and cannot read the Stripe account copy, so project payments are listed by the payments route above.

SDK

BillStackV2Client has one resource for each group above: client.metrics (overview, saas, series), client.stripeAccount (list, get, querySource, query) and client.projectInsights (analytics, providerEvents, diagnostics, invoices, payments, queryDatasets, query, for the project the client is configured with). client.invoiceActions and client.projectInvoiceActions (describe, void, markUncollectible) cover the invoice actions.

const { data } = await client.metrics.overview({ windowDays: 30 });
if (data.state === "no_source") {
  // No Stripe keys for this environment: there are no numbers, not zeros.
} else {
  for (const source of data.sources) console.log(source.info.provider, source.overview.kpis.mrr);
}

The invoice PDF download and the dashboard-session routes (sync, webhook endpoint setup, disconnect) are not part of the SDK.

Team financials

Financial reads are team-scoped and support optional filters including provider, accountIncarnationId, mode, currency, status, projectId, from, to, cursor, and limit:

GET /teams/{teamId}/financials/overview
GET /teams/{teamId}/financials/{resource}
GET /teams/{teamId}/financials/{resource}/{externalId}

{resource} is one of balances, payments, payouts-settlements, disputes, customers, invoices, or subscriptions. A project filter is enforced against project-scoped API keys.

Revenue by currency

GET /teams/{teamId}/financials/currency-report

Collected payments, fees, net and refunds per provider account, grouped by currency, with each account's region and merchant entity. It needs the same billing:GetBilling permission as the other financial reads and accepts mode, projectId, from and to. Amounts are minor units in the currency of each group; currencies are never converted or added together.

The report applies only to a team with more than one region enabled in the requested mode. Otherwise the response is 200 with enabled: false, the enabledRegionCount, and no currencies. Each entry in currencies has currency (uppercase ISO 4217), totals (paymentCount, grossMinor, feeMinor, netMinor, refundCount, refundedMinor) and rows, one per provider account with connectionId, provider, regionId, regionName, entityId and entityName.