Billing
Checkout, your subscription, plan changes, cancellation and orders.
Billing lets a customer buy a plan, see the subscription, change or cancel it, and read past orders. Payments run on the payment provider's hosted pages. The API never takes card details. Every call needs a token. Calls that change something or start a checkout also need a username.
Entitlements read the subscription that Renzo has stored, not the provider. The subscription exists only after the provider confirms the payment. List the plans in Products.
Endpoints
| Operation | What it does | Auth |
|---|---|---|
GET/ | Your live subscription and first page of orders in one call. | Token |
GET/ | Read your live subscription. | Token |
GET/ | List your orders and payments, newest first. Cursor-paginated. | Token |
GET/ | Show what a checkout charges now and at the next bill: ?price_id=.... | Token and username |
POST/ | Start a hosted checkout. Answers 201. Declares Idempotency-Key. | Token and username |
POST/ | Quote a move to another price. | Token and username |
PUT/ | Make the move. Declares Idempotency-Key. | Token and username |
PUT/ | Cancel at the end of the period. | Token and username |
DELETE/ | Undo a cancellation. | Token and username |
POST/ | Open the provider's billing portal. Answers 201. | Token and username |
Without a username, calls that need one answer 409 profile_incomplete. See Account. Checkout uses a durable provider key for the pending purchase; plan changes also use provider idempotency. Any mutating call accepts it. See Idempotency.
Example: buy a plan
Pick a price id from GET /api/v1/products. Preview the charge first:
curl "$BASE/api/v1/billing/checkout-sessions/preview?price_id=e20b39bd-9326-5178-9074-9c31733f3a2f" \
-H "Authorization: Bearer $TOKEN"{
"full_price_cents": 1900,
"referral_discount_percent": 20,
"discount_cents": 380,
"amount_today_cents": 1520,
"grant_days_left": 12,
"grant_credit_cents": 760,
"next_bill_at": "2026-12-04T13:30:00Z",
"next_bill_cents": 1140
}Then start the checkout. The answer is 201:
curl -X POST "$BASE/api/v1/billing/checkout-sessions" \
-H "Authorization: Bearer $TOKEN" \
-H "Idempotency-Key: 3c8e1f52-7b9d-4a60-8e14-d25f6a0b9c71" \
-H "Content-Type: application/json" \
-d '{"price_id": "e20b39bd-9326-5178-9074-9c31733f3a2f"}'{
"id": "cs_test_a1B2c3D4e5F6g7H8",
"url": "https://checkout.stripe.com/c/pay/cs_test_a1B2c3D4e5F6g7H8",
"expires_at": "2026-11-04T14:00:00Z"
}Send the reader to url. When they return, poll GET /api/v1/billing/subscription. Do not assume the payment worked.
Example: upgrade a subscription
Quote the change:
curl -X POST "$BASE/api/v1/billing/subscription/price/preview" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"price_id": "026b9c9b-b877-592c-9954-cc9d8ee8e9d1"}'{
"change": "upgrade",
"price": {
"id": "026b9c9b-b877-592c-9954-cc9d8ee8e9d1",
"product_id": "52108830-cd62-51b4-9ce3-f0051ed42666",
"product_code": "premium",
"product_name": "Premium",
"amount_cents": 19000,
"currency": "USD",
"interval": "year"
},
"takes_effect_at": "2026-11-04T13:30:00Z",
"currency": "USD",
"lines": [
{ "description": "Unused time on Premium (monthly)", "amount_cents": -1500 },
{ "description": "Premium (yearly)", "amount_cents": 19000 }
],
"subtotal_cents": 17500,
"tax_cents": 0,
"amount_due_cents": 17500,
"next_billing_at": "2027-11-04T13:30:00Z",
"next_amount_cents": 19000,
"proration_date": "2026-11-04T13:30:00Z"
}Confirm it. Send the proration_date back:
curl -X PUT "$BASE/api/v1/billing/subscription/price" \
-H "Authorization: Bearer $TOKEN" \
-H "Idempotency-Key: 8a4d2b17-5e60-4c93-b1f8-6d09e3a7c254" \
-H "Content-Type: application/json" \
-d '{"price_id": "026b9c9b-b877-592c-9954-cc9d8ee8e9d1", "proration_date": "2026-11-04T13:30:00Z"}'The answer is 200 with the subscription:
{
"id": "cf4b1077-d871-5ff7-82f3-9a9bbe9514d3",
"status": "active",
"source": "provider",
"referral_grant": false,
"product_code": "premium",
"price": {
"id": "026b9c9b-b877-592c-9954-cc9d8ee8e9d1",
"product_id": "52108830-cd62-51b4-9ce3-f0051ed42666",
"product_code": "premium",
"product_name": "Premium",
"amount_cents": 19000,
"currency": "USD",
"interval": "year"
},
"current_period_start": "2026-11-04T13:30:00Z",
"current_period_end": "2027-11-04T13:30:00Z",
"cancel_at_period_end": false,
"scheduled_price": null,
"payment_url": null
}Rules and edge cases
- One live subscription. Checkout is refused while you have one. It answers
409subscription_already_active. Change its price instead. - Price must be for sale. A retired price answers
409product_price_not_for_sale. An unknown price ID answers404product_price_not_found. The checkout preview has the same three answers. - Checkout preview. It changes nothing. It shows the referral discount and any referral credit.
referral_discount_percentisnullwhen no code applies. See Referrals. - Checkout URL.
expires_atis when the payment page stops working. It isnullwhen the page does not expire. - Return path. Send
return_to, a path on the Renzo site such as/en/articles/fed-cut, to bring the reader back there after payment. It must start with one/. A full URL, another host (//host), a backslash, a space or a control character answers422checkout_return_to_invalid. Its limit is 512 characters. After payment the provider sends the reader to the Renzo success page with?return_to=and the encoded path. - One open checkout. Starting a checkout for the same price and
return_toagain answers the same open page. A different price orreturn_tocloses the open page first, so its URL stops working. If another checkout of your account is still starting, you get409checkout_in_progress. Retry shortly. - Subscription status.
statusistrialing,activeorpast_due.sourceisproviderfor a paid plan andmanualfor a grant.referral_grantistruefor a grant earned by referring. A purchase ends it. A grant can havepriceasnulland no period dates. - No subscription.
GET /api/v1/billing/subscriptionanswers404subscription_not_found.GET /api/v1/billinganswers200withsubscriptionasnull. - Orders.
GET /api/v1/billing/ordersand theorderspart ofGET /api/v1/billinghold orders withpayments. An orderstatusispending,paid,failed,void,refundedorpartially_refunded. Refunds showamount_cents,currency,statusandcreated_at. Failed payments may includefailure_message. Provider IDs and staff refund notes are not included. Amounts are in cents.limitdefaults to 20 and may not pass 100. See Pagination. - Upgrade and downgrade. A dearer price is an upgrade. It charges the quoted amount now. A cheaper price is a downgrade. It applies at the period end and shows as
scheduled_priceon the subscription. The preview fieldchangeisupgrade,downgrade,noneorclear_pending. - Fresh quote. An upgrade needs a
proration_datefrom a preview made at most 15 minutes before. With none, or an old one,PUT /api/v1/billing/subscription/priceanswers409subscription_price_quote_stale. Preview again and retry. - Yearly lock. A yearly plan cannot move to a monthly price mid-term. It answers
409subscription_interval_locked. - Declined card. An upgrade whose card is refused answers
402billing_payment_declined, and nothing changes. - Payment needs approval. When the bank asks the reader to approve the charge, or the charge does not go through at once, the answer is
200with apayment_url. Send the reader there. The price stays the same until the payment is made. - Cancelling.
PUTon the cancellation cancels at the period end. Access stays untilcurrent_period_end, with no refund, and a booked downgrade is dropped.cancel_at_period_endturnstrue.DELETEkeeps the subscription. A subscription that was not set to cancel comes back unchanged. - Not changeable. A subscription that cannot be changed here, such as a staff grant, answers
409subscription_not_changeable. - Busy. If another change to the subscription is still running, you get
409subscription_change_in_progress. Retry shortly. - Provider failures.
502billing_provider_failedmeans the provider refused or failed the call, and nothing was saved.502billing_provider_outcome_unknownmeans the result is not known. Retry with the sameIdempotency-Key, then read the subscription. - Portal.
POST /api/v1/billing/portal-sessionsreturns a short-livedurlof the provider's portal, to update the card and download invoices. Each call opens a new session. Without a subscription it answers404subscription_not_found.
Errors
| Code | Status | When |
|---|---|---|
subscription_already_active | 409 | You already have a live subscription, so a new checkout is refused. |
checkout_in_progress | 409 | Another checkout request of this account is still running. |
checkout_return_to_invalid | 422 | return_to is not a path on this site. |
subscription_not_found | 404 | You have no live subscription. |
subscription_not_changeable | 409 | The subscription cannot be changed here, for example a staff grant. |
subscription_change_in_progress | 409 | Another change to this subscription is still running. |
subscription_interval_locked | 409 | A yearly plan cannot switch to a monthly price mid-term. |
subscription_price_quote_stale | 409 | An upgrade needs a recent quote and there is none. |
product_price_not_found | 404 | No price has this ID. |
product_price_not_for_sale | 409 | The price is retired or cannot be bought. |
billing_payment_declined | 402 | The card was declined. |
billing_provider_failed | 502 | The payment provider refused or failed the call. Nothing was saved. |
billing_provider_outcome_unknown | 502 | The provider did not answer, so the result is not known. |
profile_incomplete | 409 | The account has no username yet. |
Sign-in and request errors, such as token_expired and validation_failed, can come from any call. See Errors.