Skip to main content
Add funds: any amount from $5 to $500. Auto-recharge: add $25 when your balance falls below $1.
Top-ups let customers add exactly the credit they want, and auto top-ups refill the balance with their saved card when it runs low, so a customer never runs dry mid-task. A credit pack sells a fixed number of credits for a fixed price. A top-up sells credits for any amount the customer picks, within your bounds. An auto top-up buys a pack or an amount with the customer’s saved card when their balance falls below a threshold. Top-up credits join the shared pool, never expire, and are spent with packs, after plan credits (spend order).

The catalog

topUps sets the least and most one top-up may charge, in cents, and how many credits a dollar buys. A plan’s autoTopUp is the default for its subscribers.
A top-up of amountCents buys amountCents × creditsPerUsd / 100 credits, rounded down: $25 buys 2,500 credits here. On a [dollar balance](/pricing/dollar-balance) (the catalog's own `creditsPerUsd`), top-ups buy at the balance's rate, `topUps` needs only `minCents` and `maxCents`, and invoices read "Balance top-up: $25.00”. An auto top-up is part of the plan’s version, so changing it publishes a new version and current subscribers keep the terms they signed up to. A plan’s default applies to active subscriptions.

Top up any amount

Send the amount the customer picked. By default the answer has a Stripe Checkout URL, and the credits land when the customer pays:
With paymentMethod: "saved", Ledger charges the customer’s default card at once and answers the top-up succeeded, credits granted:
Response
A saved-card top-up is a one-item Stripe invoice, paid at once, so the customer gets a receipt and, with Stripe Tax on, tax. When the saved card can’t be charged, send the customer through Checkout: a declined card is 402 payment_failed, a bank that wants the customer present is 402 authentication_required, and no saved card is 400 no_payment_method.

Auto top-up per customer

A customer’s own setting replaces their plan’s default whole. Let customers pick their threshold and amount on your billing page, then save it:
  • enabled: false turns auto top-ups off for the customer, plan default included.
  • autoTopUp: null clears the customer’s setting, so their plan’s applies again.
GET /v1/customers/auto-top-up answers the setting that applies with its source (customer or plan), what one top-up buys, whether failures hold it back, and the customer’s last 10 top-ups.

When it buys

The use that takes the balance below the threshold (a track, a reserve or a settle) queues the auto top-up, and Ledger buys a few seconds later. A burst of tracks buys once: one auto top-up is pending per customer at a time, and the next one waits for the next crossing. Ledger also tops up a customer who is already below the threshold, even at zero with every use refused:
  • When it’s turned on. Saving an enabled setting for a customer whose balance is below the threshold buys at once, with no use needed.
  • When a wait ends. After a declined top-up’s 24-hour wait, or once a new period lifts maxPerPeriod or maxAmountCentsPerPeriod, Ledger buys again for a customer still below the threshold. Another decline starts another wait.
The top-up and auto top-up endpoints have every field. Each outcome sends a webhook: auto_top_up.succeeded, beside credits.granted, or auto_top_up.failed with its failureReason: no_payment_method, card_declined, authentication_required, payment_incomplete or stripe_unavailable.

Rules

  • An auto top-up buys one of addOnId or amountCents. Sending both returns 400 invalid_auto_top_up.
  • Failures back off. After a failed auto top-up, Ledger waits 24 hours, then tries again. After three in a row it suspends auto top-ups until the setting is saved again or the customer’s default card changes. GET shows suspended and coolingDownUntil.
  • Period limits hold. Once maxPerPeriod or maxAmountCentsPerPeriod is reached, auto top-ups resume in the next billing period.
  • Refunds happen in Stripe. A full refund or a lost dispute of a top-up expires its unused credits, as for a pack. Credits already spent stay spent.