Set an auto-reload
“When my credit falls to ₦5,000, buy ₦20,000 with my card.” Sets the
customer’s rule in currency, replacing one that is there (200), or
creating it (201).
The rule compares projectedAvailable (see the credit balance) with
threshold after every movement on the customer’s credit and every
usage event. At or below it, it buys amount of prepaid credit the
way POST /customers/{id}/credit-purchases does with automatic
collection, charged to paymentMethod, or the customer’s default
card. One fall buys once: it buys again only after the credit has
been back above the threshold, and never while the last top-up’s
charge is still unknown. A rule set on while the credit is already
at or below the threshold buys at once.
A failed charge voids that top-up, turns the rule off
(disabledReason: payment_failed) and emails the customer that
automatic top-ups are off, with the credit they have left. Nothing
is retried. The rule also turns itself off with no email when there
is no card left to charge (no_payment_method) or the purchase is
refused before any charge (purchase_refused).
Refused up front when the customer has no saved card, the card is
not theirs or is from the other mode, or the amount can’t be sold
(below the minimum, or no VAT timing chosen for prepaid credit).
Needs credits:write on a restricted key. Emits
credit_auto_reload.created or credit_auto_reload.updated.
Authorizations
Use a Bouclay secret key (sk_test_..., sk_live_...) or restricted key
(rk_test_..., rk_live_...).
A secret key can call every endpoint. A restricted key can only call the
endpoints its scopes cover. A scope is {resource}:{access}, for example
customers:read or refunds:write, and write includes read. GET
requests need read access and everything else needs write, except
POST /subscriptions/{id}/items/{item}/preview, which only needs
subscriptions:read. A request outside the key's scopes gets 403 permission_denied naming the missing scope, and its Idempotency-Key
is not used up.
Publishable keys (pk_...) are rejected by server-side API endpoints. A
key's mode scopes what it can see and charge: a test key can never reach
a live card.
Headers
Required for POST and PATCH requests. Replays identical method + path + body requests and rejects mismatched re-use.
1 - 255Path Parameters
Body
Buys when the projected credit is at or below this, in major units.
x >= 05000
What each top-up costs and the credit it gives, in major units. At least the minimum charge.
20000
Defaults to the customer's.
"NGN"
A saved card of this customer's. Left out or null, their default card when it buys.
How long the credit it buys lasts, from payment. Null never expires.
1 <= x <= 120