You’ll need a secret key (
upay_sk_…) from the dashboard and the base URL https://api.useunitpay.com/v1. See Authentication.Set up your catalog
Your catalog needs a credit currency, a plan that grants credits, and a feature to spend them on. The fastest way is to let Asterix build it from your pricing page:Or build it by hand — a credit currency (
POST /v1/credit-currencies) and a free plan with a monthly credit grant rule (POST /v1/plans). See Billing for the catalog API and Credits for grant rules.For this walkthrough you need a free plan (
$0) that grants credits each cycle and a feature (e.g. ai-generation) that costs credits — so nothing has to be charged to see credits move.Create a customer
The customer’s id is your own user or org id — pass your own
externalId if you like.Response
Subscribe them to the plan
Put the customer on your free plan. Because it’s
$0, the subscription is created with no charge and the plan’s credits are granted on activation.Response
Self-serve subscriptions default to
salesMotion: "self_serve" and collectionMethod: "charge_automatically". On a paid plan the response is charged_inline (card charged, first invoice paid) or requires_form (collect a card in the browser first) — that’s the Billing flow.Track usage — spend credits
Report that the customer used the feature. UnitPay resolves the credit cost and deducts it. This is the write that moves credits.
Response
See it in the ledger
The balance is derived from the ledger — an append-only record of every grant and deduction. Read it back:You’ll see the plan grant (
+100) and your usage deduction (−10), with the running balance at 90. The live per-wallet balance is at GET /v1/credit-accounts?customerId=cus_123.Credits granted → consumed → recorded. That’s the whole credit path working end to end.
Next steps
Charge cards & invoices
Paid plans, the card-on-file flow, and invoices.
Credits in depth
Denominations, grant priority, wallets, and top-ups.
Build the UI
Render balances, gates, and checkout with the React hooks.
How it works
The model behind both billing paths.