comecerodocs

Turn a customer's automatic top-up on or off

PATCH
/customers/{customer_id}/usage/{subscription_id}/auto_top_up

On: send enabled true with a quote_id from POST .../auto_top_up/quotes and consent_accepted true. Only the customer's own login can turn it on, since it is their consent to the quote's terms; the consent (the exact consent_text, the amounts, the card, who and from where) is kept as evidence, and the top-up is bound to that card. Accepting the same quote again changes nothing and answers the same. Accepting a new quote while it is on changes its amounts. Off: send enabled false; you or the customer may turn it off, and turning off what is off changes nothing. expected_revision is required, so a change made since you read it is never overwritten. The Idempotency-Key header is required: the request is kept (its body, then its answer, for a day) before anything changes, so a retry with the same key and body answers as the first did and changes nothing twice, and the same key with another body is refused.

Authorization

headerAuthorizationBearer <token>

A secret, trusted or limited token. See Authentication.

Path Parameters

customer_id*string

The Comecero customer id, or me.

subscription_id*string

The customer's subscription.

Header Parameters

Idempotency-Key*string

Required. Names one change: the same request again with the same key (after a timeout, say) changes nothing more and answers as the first one did, for a day. 1 to 128 printable ASCII characters, sent once; missing or empty is refused (400, reference UbV150). Use a new random key, such as a UUID, for each change you mean to make. The same key with another body is refused (409, reference UbV151).

Match^[ -~]{1,128}$
Length1 <= length <= 128

Request Body

application/json
  1. body

Turning automatic top-up on (enabled true, with a quote_id and consent_accepted true) or off (enabled false, with only expected_revision needed; quote_id and consent_accepted are then ignored). No other field may be sent (400, reference UbV158).

enabled*boolean
quote_id*string

A quote from POST .../auto_top_up/quotes, unexpired and unused (409, reference UbV167, when missing).

Lengthlength <= 64
consent_accepted*boolean

Exactly true, from the customer's own login after they read the quote's consent_text (400, reference UbV164).

expected_revision*integer

The revision read with GET; the quote must have been made on it too.

Range0 <= value

Response Body

The automatic top-up now.

application/json
  1. response

A customer's automatic top-up of one subscription's prepaid credit: while it is on and the credit falls below below_amount, one top-up of add_amount is bought (giving principal of credit), charged to the saved card the customer accepted, and not again until the credit is back at or above below_amount and falls below it again. Each top-up is tried once and never retried. A failed or unknown payment, a chargeback or a change of the default card turns it off, and only the customer's fresh consent turns it on again. While the shop does not offer it (it stopped top-up or credit sales), no top-up is made and an accepted consent shows as paused: it starts again by itself once offered again, and can still be turned off. Comecero switching usage billing off for the shop, or the subscription's last usage plan ending, turns it off instead. Amounts are decimal strings in currency.

object?string
subscription_id?string
currency?string

The currency of the subscription's usage plans, which every amount is in. With no single usage plan left, the currency the top-up was saved in.

offered?boolean

Whether the shop offers automatic top-up now (usage_customer_settings.auto_top_up.enabled, with credit sales on).

enabled?boolean

Whether it is on. False whenever it is not offered.

paused?boolean

The customer's consent stands but the shop does not offer it now (it stopped top-up or credit sales): nothing is charged, it starts again by itself once offered again, and it can still be turned off. Show the customer a way to turn it off. Comecero switching usage billing off turns it off instead, and so does the subscription's last usage plan ending (within the hour, paused or not).

status?string

off: never turned on, or turned off by the customer. active: on, and it tops up the next time the credit falls below below_amount. awaiting_rearm: on, it topped up, and waits for the credit to be back at or above below_amount first. cap_reached: on, but this month's caps are used up until next_reset_at. disabled: stopped for disabled_reason.

Value in"off""active""awaiting_rearm""cap_reached""disabled"
disabled_reason?|

Why it was stopped, while it is off. merchant_disabled also while the shop does not offer it (it comes back on when the shop offers it again). disputed: a credit purchase was charged back. payment_method_changed: the default card is no longer the one the customer agreed to. payment_failed, payment_unknown: a top-up's payment failed, or its result is not known yet. price_changed: one top-up would now give other credit or charge more than the customer agreed to (a new price or tax). subscription_ended: the subscription ended.

Value in"customer_disabled""merchant_disabled""disputed""payment_method_changed""payment_failed""payment_unknown""price_changed""subscription_ended"null
below_amount?|

Top up when the credit is below this. Null before it was ever turned on.

add_amount?|

The amount each top-up buys, as its invoice line is priced (tax included where prices include tax).

principal?|

The credit one top-up gives, as the customer accepted it: the price before tax, so less than add_amount where prices include tax. Null before it was ever turned on.

authorized_max_gross?|

The most one top-up may charge, tax included, as the customer accepted it. A later price above it is not charged.

monthly_max_count?|

The most top-ups this month in force now, the lower of the cap the customer accepted and the shop's now (a shop's raise never grows a consent). Null when not offered and never set up.

monthly_max_amount?|

The most top-ups may charge this month, tax included, the lower of the cap the customer accepted and the shop's now; null for no cap.

month?string

The UTC month the caps count in, as YYYY-MM.

month_count?integer

The top-ups this month across the customer's subscriptions in this currency, those under way too.

month_amount?string

What they charge, tax included.

next_reset_at?string

When the monthly caps start again (the first of next month, UTC).

Formatdate-time
payment_method?|

The saved card a top-up charges, as the customer may see it. No vault or gateway ids.

last_attempt?|

The latest top-up, with its state, gross, currency and trigger_at only. See the attempts route for the rest.

revision?integer

Goes up by one with every change; 0 before any. Send it back as expected_revision.

Range0 <= value
date_modified?|
Formatdate-time
Example Request
curl -X PATCH 'https://api.comecero.com/api/v1/customers/string/usage/string/auto_top_up' \  -H 'Idempotency-Key: 3f2b6c1e-9d4a-4e8b-a1f7-5c0d2e9b8a64' \  -H 'Content-Type: application/json' \  -d '{  "enabled": true,  "quote_id": "uaq_5d2f8a1c9e7b4036a1f2c8d4e6b9a703",  "consent_accepted": true,  "expected_revision": 0}'
Example Response
{  "object": "usage_auto_top_up",  "subscription_id": "SB0123456789",  "currency": "USD",  "offered": true,  "enabled": true,  "status": "active",  "disabled_reason": null,  "below_amount": "10",  "add_amount": "20",  "principal": "16.67",  "authorized_max_gross": "20",  "monthly_max_count": 3,  "monthly_max_amount": "200",  "month": "2026-11",  "month_count": 1,  "month_amount": "20",  "next_reset_at": "2026-12-01T00:00:00Z",  "payment_method": {    "type": "credit_card",    "brand": "Visa",    "ending": "4242"  },  "last_attempt": null,  "revision": 1,  "date_modified": "2026-11-15T12:00:00Z"}