- Positive
creditsadd a new grant that never expires, unless you setexpiresAt. It’s spent after plan credits, alongside packs (spend order). - Negative
creditsremove credits in spend order and never take the balance below zero: asking for more returns409 insufficient_creditswith theavailableCreditsyou can remove. reasonis required. It shows on the customer’s page and in billing history, with who made the change.idempotencyKeyis required, per customer. A retry with the same key and body returns the first adjustment and changes nothing; the same key with a different body returns409 idempotency_key_reused.
billing:write permission.
Grant a payment Ledger didn’t
If a customer paid and Ledger granted nothing, for example an invoice with a coupon that Ledger refused, add the credits with the payment’sstripeInvoiceId, or stripeCheckoutSessionId for a pack. Ledger checks with Stripe that the payment is paid and belongs to this customer, then marks it granted so it can’t be granted twice (409 stripe_object_already_granted). Adjust a customer’s balance lists every error.