# Set a customer's spending limit (/api/usage/set-customer-spend-limit)

`PUT https://api.comecero.com/api/v1/customers/{customer_id}/usage/{subscription_id}/spend_limit`

Sets or clears the customer's own spending limit on one subscription's usage. The limit covers usage charges only, before tax (not the plan's regular price); 0 means no usage spend. Usage past it is neither billed nor drawn from prepaid credit. The shop must let customers set one (`allow_spend_limit` in `usage_customer_settings`); this holds for your own tokens too. Every change is logged with who made it, when and from where. Raising the limit may bill usage already recorded this period that the old limit held back. A new limit applies at once to usage not billed yet; what this period's bills already committed still counts, so a limit below it means no more usage spend this period. `expected_revision` is required, so a change made since you read it is never overwritten. Send an `Idempotency-Key` header so a retry is harmless: for a day, the same key with the same `amount` and `expected_revision` changes nothing and answers what the first request answered (the limit and `revision` as that change left them), even after a later change; the key with another body is refused. The key is noted before the change is made, so a retry of a request that never answered never makes the change twice. An empty header counts as none. Setting the same amount again changes nothing. A shopper's token sets only its own customer's (`me` works). To raise a limit with the customer's recorded consent, quote it (`POST .../spend_limit/quotes`) and accept it with `PATCH`.

## Parameters

- `Idempotency-Key` (header): Makes a retry harmless: the same request again with the same key (after a timeout, say) changes nothing more and answers as the first one did. 1 to 128 printable ASCII characters, sent once (`400`, reference `UbV150`); an empty header counts as none. 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`).

Request body: the `usage_spend_limit_request` schema.

Responses: 200, 400, 401, 403, 404, 409, 500.

Full schemas: operation `set_customer_spend_limit` in /openapi.json.