customerId and pass that ID to every call. A subscription is the customer’s plan: attaching a plan creates one, and it grants what the plan includes each period.
Customers
- Your ID is the key. Use the user or organization ID your app already has. It’s unique per environment: the same ID in Sandbox and Live is two separate customers.
- Attaching a plan grants its balances. Attach one at signup, usually the free one. Creating customers covers it.
- Ledger creates the Stripe customer at the customer’s first paid purchase, or you link one they already have.
- Entities split one customer’s credits between its users, seats or workspaces, each with its own credit allowance or cap, and each can hold plans of its own billed on the customer’s invoice. See Entities.
Subscriptions
A customer holds one base plan per group, so each product line has its plan, plus any recurring add-ons and the plans of its entities. Every paid one rides on one Stripe bill, with any seat licenses and prepaid quantities the customer bought; an add-on bought first starts that bill and a paid plan joins it. A custom deal gives one customer their own terms on a plan.GET /v1/customers returns the default group’s plan as currentPlan, with its period, and a features list with each feature’s balance across every plan the customer holds. listCustomerSubscriptions returns every plan they’ve had, newest first.
A customer on the free plan keeps it as
currentPlan until a new paid plan is paid for.
The life of a subscription
- Start. A free plan starts on attach. A paid plan starts when Stripe’s signed webhook confirms the first payment; then the free plan in its group ends, with its unspent credits. See Checkout and attach.
- Renew. Stripe renews a paid plan each interval; Ledger renews a free plan itself. Each renewal grants a fresh period. See Renewals and lifecycle.
- Change. An upgrade bills now and starts a new period; a downgrade waits for the period end by default. See Upgrades and downgrades. Seats and prepaid quantities change on their own (seat count, quantity), and a plan’s version moves with a migration.
- Use. Usage limits cap uses per day, week or month, and usage alerts send a webhook at a threshold, set on the plan or one customer.
- End. Cancelling at the period end keeps the plan until then; cancelling an add-on ends just that item. When the subscription ends, its grants end, and Ledger bills any remaining overage. Credit packs stay.
Rules
checkandtrackwork on existing customers: an unknowncustomerIdreturns404 customer_not_found, so create the customer at signup.- Attach starts a customer’s first paid plan in a group, over a free one in that group. After that, move them with an upgrade or downgrade within the group: attaching over any other current plan in the group returns
409 subscription_exists. - Treat a
statusvalue you don’t recognise as not paid up, so new values stay safe.
Next steps
Balances
What the subscription’s grants add up to.
Checkout and attach
Start a plan, free or paid.