Auto top-ups
When a customer’s credits run low, a credit auto top-up buys more by adding a top-up to the customer’s order and invoicing it. It watches the same available balance your customer sees, so the top-up arrives before the work that needs the credits, not after, and usage stays paid from credits rather than running into overage.
How they work
- You set a threshold on a credit currency: a number of credits, or a percentage of what’s been granted.
- Paid watches the balance. When
availablefalls to the threshold or below it, the balance has crossed it. - The rule buys once per crossing. It doesn’t buy again until the balance has recovered above the threshold.
Because available already leaves out credits reserved by credit holds, a hold can cross a threshold before anything is spent.
Thresholds
An auto top-up’s threshold takes one of two types:
A percentage keeps working as the customer’s grants grow.
Set up an auto top-up
An auto top-up buys a one-time top-up price when a customer’s balance falls below a threshold. Adatum first creates a top-up price that grants one credit for each credit bought, at 70¢:
Then it sets Brightrail up to buy 5,000 credits whenever 1,000 or fewer are left, at most 3 times a month:
API
Dashboard
Create a credit auto top-up with the customer, their order, the top-up price and the quantity to buy.
The response is the rule, with a ctu_ ID, status: "active", and lastTriggeredAt and lastAmendment set to null until its first purchase.
chargeAutomatically depends on payment methods in the v1 API, which aren’t available yet. Use sendInvoice until they are.
Each purchase is added to the order by amendment and invoiced, so it shows on the order’s history and its invoice like anything else your customer buys. When the credits arrive follows the price’s grantedOn: activation, the default, grants them straight away, and invoicePaid waits until the invoice is paid.
A customer can have one enabled auto top-up per credit currency: creating or enabling a second fails with auto_top_up_conflict. Only one purchase is in progress at a time, and a purchase that still leaves the balance below the threshold doesn’t trigger another.
How it bills
Brightrail has 1,200 credits available when an event spends 250 of them:
The rule records the purchase in lastTriggeredAt and lastAmendment, and is ready to buy again once the balance has recovered above 1,000 and fallen back to 1,000 or below.
Change or retire
An auto top-up’s status is active, paused with a pausedReason, or ended when its order ends. Three failed collection attempts in a row pause it with pausedReason: "paymentFailed". Update the rule with only the fields to change, and send enabled: true to resume a paused rule. It checks the balance straight away, and buys if the balance is still below the threshold and the monthly limit allows. Archive it to stop it for good. Purchases it already made stay on the order.