What is Auto-refill?
When you bill usage against Customer Credits with a prepaid usage price, a customer’s bucket eventually runs dry. Auto-refill is what happens next:- Exhaustion notice. The first settlement that a bucket cannot cover emails the customer and sends you a
customer_credits.exhaustedwebhook, once per exhaustion rather than once per refused request. - Automatic top-up. If the customer has opted in, Creem re-purchases the credit top-up product they chose, using the payment method saved from their earlier checkout. The product’s own fulfilment grants the credits, and settlement resumes.
Auto-refill applies to usage that Creem settles for you through a prepaid usage price, described
in Step 5 of Usage-based Billing. Debits you make yourself
through the API that exceed the balance simply fail with
422 and the error code
insufficient_balance, so your own code decides what to do.Requirements
- A credit top-up product. A product with a
customerCreditsfeature that grants credits into the bucket your usage price debits. This is the product Creem re-purchases. Its price at the time of the refill is what the customer pays, so re-pricing it applies to future refills automatically. - A prepaid usage price on the customer’s plan that debits the same bucket.
- A previous checkout by the customer on your store. The refill is charged to the payment method saved during that checkout, and the customer’s tax location comes from their most recent checkout as well. Without both, Creem does not attempt a charge.
- The customer’s consent, described below. Auto-refill is opt-in per customer and per bucket, and never charges anyone who has not agreed to it.
Exhaustion Notices
An exhaustion is an episode: the stretch between two grants into a bucket. Within one episode the customer gets one email and you get onecustomer_credits.exhausted webhook, no matter how many settlements are refused. Any credit that reaches the bucket, whether a top-up purchase, a subscription renewal, an auto-refill, or a grant through the API, ends the episode. If the bucket runs dry again after that, you are notified again.
The webhook carries the bucket, the unit label, and shortfall_minor_units, the amount the refused settlement was short. Use it to prompt the customer in your own product, pause the feature that consumes credits, or trigger your own top-up flow. When an auto-refill succeeds, the exhaustion is resolved before any notice goes out, so you receive credits.auto_recharged and credits.granted instead of customer_credits.exhausted.
See the payload in the webhook reference.
Consent and Guardrails
Consent belongs to the customer. It names the credit top-up product to re-purchase and the limits the customer accepts, and the customer can revoke it at any time. Revoking keeps the configured limits, so opting back in does not reset them.
A refill that would break a guardrail is skipped and nothing is charged. The exhaustion notice still goes out, so the customer knows to top up by hand.
Consent is stored per customer and bucket on Creem. The switch for customers to opt in from the
hosted customer portal is not available yet. If you want to offer
auto-refill to your customers today, contact support@creem.io.
How a Refill Is Charged
A refill is a purchase, not a bare card charge, so it appears in your dashboard, reports, and payouts like any other order.- Nothing is charged without consent and a saved payment method. Both are checked first, along with the guardrails.
- Tax is calculated from the customer’s most recent checkout location, and the customer pays the product price plus that tax. The price is the product’s current price, not the price at the time of consent.
- An order is opened before the charge and completed only when the payment is confirmed. If a charge ends in an ambiguous state, there is always a record to reconcile against, and the customer is never charged again for the same refill.
- The saved payment method is charged off-session. A payment that needs the customer’s confirmation, such as 3-D Secure, is left pending rather than retried.
- The product’s fulfilment grants the credits, exactly as it would after a checkout. Settlement of the customer’s usage picks up from there.
What You Receive
See the webhook reference for the payloads.
When a Refill Fails
In every case the customer can still buy credits through a normal checkout, and any grant ends the exhaustion episode.
Related Features
Usage-based Billing
Meters, event ingestion, and prepaid usage prices that settle against credits
Transactions
Credit, debit, and reverse balances through the API
Webhooks
Every credits event, with sample payloads
Customer Portal
Where customers manage their purchases and payment methods