Credit grants
A credit grant adds credits in a credit currency to a customer’s balance. Most grants come from the prices your customer buys: a credit bundle grants credits each interval, and a top-up grants them once. You can also grant credits by hand, for goodwill or compensation. Each grant carries its own expiry, rollover and refill, so one balance can mix credits with different lifetimes and Paid still spends them in a fair, predictable order.
Use a credit grant to:
- Sell credits with a recurring or one-time price that carries
grants. See Grants from prices. - Give a usage allowance that resets, such as 50 messages every 4 hours, with a refill.
- Make things right with goodwill or compensation credits, by granting credits by hand.
- Track what’s left of each grant, and when it expires, by listing grants.
How grants work
- A grant arrives from a price on an order, at the start of each interval by default, or when you create one by hand.
- It adds an
amountof credits to the customer’s shared balance, or to one seat’s balance. - Usage spends it in the spend order: scoped grants first, then the credits forfeited soonest, then the oldest.
- It ends when it expires, after any rollover, or when you void it. Credits left at the end are forfeited with a ledger entry, so the ledger always reconciles.
Credit amounts are in the credit currency, as decimal strings with up to 15 decimal places.
Grants from prices
Add grants to a recurring or one-time price to make it grant credits. Adatum sells a yearly credit bundle on a sliding scale: 70¢ a credit up to 50,000, 65¢ up to 100,000 and 60¢ above that. One price covers every bundle size, because the order line’s quantity sets both the number of credits and the price on the curve.
API
Dashboard
Create a price in money, with a grants entry in the credit currency. grants on prices, and the credit grant endpoints, are in the credits=v1 beta; send Paid-Beta: credits=v1.
The price’s amounts are in cents, and amountPerUnit is in credits: one credit for each unit of the order line’s quantity.
An order line with quantity: 120000 on this price grants 120,000 credits each year, and costs:
Each entry in grants, up to 5, becomes its own credit grant on the order:
A one-time price with grants is a top-up: it grants credits once, when it’s bought, such as by an amendment or an auto top-up.
A grant from a price names where it came from in source. grant is the index of the entry in the price’s grants list that made it, counting from 0:
Change the quantity mid-interval
When an amendment raises a bundle line’s quantity mid-interval, the extra credits are granted straight away for each entry in the price’s grants, prorated by day for the rest of the interval. They arrive as that entry’s grantedOn says. Each prorated grant expires and rolls over with the interval’s grant, and its source.order.amendment names the amendment.
Brightrail raises its yearly bundle from 20,000 to 30,000 credits with 73 days of the 365-day year left:
Prorated credits are rounded down to 15 decimal places. Lowering the quantity never takes back credits already granted: the next interval’s grant uses the new quantity. A refilling grant gets no prorated grant: the new quantity sets its amount from its next window.
Refills
A grant with refill resets to its full amount every every, such as every 4 hours, until it expires. Unspent credits don’t carry over: the grant goes back to its amount, never above it. every is a whole number of hours, days or weeks, from 1 hour to 1 year.
Lucerne’s monthly plan gives each subscriber 2,000 messages a month plus 50 every 4 hours. One price carries both grants:
The 4-hour allowance is spent first, because its credits are lost soonest. A subscriber who sends 70 messages in one window spends:
A window with no spend writes no ledger entry. A grant’s refilledAt and nextRefillAt say when its current window started and when it refills next, so you can show “refills in 1h 20m” in your app. refill can’t be combined with rollover or unlimited.
Grant credits by hand
Adatum gives Brightrail 5,000 credits of onboarding goodwill:
API
Dashboard
Create a credit grant with an Idempotency-Key header, which is required, so a retry never grants twice.
startsAt defaults to now and can be in the future. Leave out expiresAt, or send null, for credits that never expire. A manual grant can also set scope, rollover and refill.
The credit currency must not be archived. Manual grants are spent in the same order as grants from prices.
Track grants
List credit grants by customer, creditCurrency, seat, status, source.type (manual or order) or order to see each grant’s amount, what’s used and what’s available. For a refilling grant, used counts since its last refill.
How it bills
Brightrail renews its yearly bundle for 2027 with a quantity of 25,000, on the price above: 12 months’ expiry, and everything rolls over for 3 months.
Brightrail pays only for the bundles. Credits spent are never invoiced again, and nothing is billed as overage while the balance covers the usage.
Change or end a grant
Update a grant to change its reason or metadata, or to move its expiresAt later. expiresAt can’t move earlier, and an expired grant can’t be revived. The amount, credit currency, startsAt and refill can’t change: void the grant and create a new one instead.
Void a grant to end it early. What’s left is forfeited with a void ledger entry, so voiding a grant with credits left needs forfeitRemaining: true.