Python SDK
import os
from integrateledger import ledger
client = ledger(api_key=os.environ["LEDGER_API_KEY"])
client.set_customer_overage_cap(customer_id="user_123", cap_cents=5000)curl --request POST 'https://api.integrateledger.com/v1/customers/overage-cap?customerId=user_123' \
-H "Authorization: Bearer $LEDGER_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"capCents":5000}'import ledger from "integrateledger";
const client = new ledger({ apiKey: process.env.LEDGER_API_KEY ?? "" });
await client.setCustomerOverageCap({ customerId: "user_123", body: { capCents: 5000 } });{
"customerId": "<string>",
"capCents": 1,
"overage": {
"credits": 1,
"costCents": 1,
"unitAmountCents": 123,
"billingUnits": 123,
"capCents": 1,
"capSource": "customer",
"remainingCents": 1,
"source": "plan",
"override": {
"planId": "<string>",
"unitAmountCents": 123,
"billingUnits": 123,
"capCents": 1,
"effectiveFrom": "2023-11-07T05:31:56Z"
},
"periodStart": "2023-11-07T05:31:56Z",
"periodEnd": "2023-11-07T05:31:56Z"
}
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Customers and usage
Set a customer's overage cap
Set or clear the monthly overage spend limit for one customer.
POST
/
v1
/
customers
/
overage-cap
Python SDK
import os
from integrateledger import ledger
client = ledger(api_key=os.environ["LEDGER_API_KEY"])
client.set_customer_overage_cap(customer_id="user_123", cap_cents=5000)curl --request POST 'https://api.integrateledger.com/v1/customers/overage-cap?customerId=user_123' \
-H "Authorization: Bearer $LEDGER_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"capCents":5000}'import ledger from "integrateledger";
const client = new ledger({ apiKey: process.env.LEDGER_API_KEY ?? "" });
await client.setCustomerOverageCap({ customerId: "user_123", body: { capCents: 5000 } });{
"customerId": "<string>",
"capCents": 1,
"overage": {
"credits": 1,
"costCents": 1,
"unitAmountCents": 123,
"billingUnits": 123,
"capCents": 1,
"capSource": "customer",
"remainingCents": 1,
"source": "plan",
"override": {
"planId": "<string>",
"unitAmountCents": 123,
"billingUnits": 123,
"capCents": 1,
"effectiveFrom": "2023-11-07T05:31:56Z"
},
"periodStart": "2023-11-07T05:31:56Z",
"periodEnd": "2023-11-07T05:31:56Z"
}
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Pass the exact
customerId as a URL-encoded query value. capCents is the most the customer can spend on overage in one billing period, in cents. It replaces the plan’s default overageCapCents for this customer, so it can be higher or lower than the default, and 0 turns overage off for them. Send { "capCents": null } to clear it and restore the plan default. There is no delete route.
Call this from your own billing page when a customer changes their limit. The cap only matters while the customer’s active paid plan has overage. You can set it at any time, and it applies to the current period straight away: Track usage compares the period’s overage cost with the new cap on the next request.
The response returns the saved cap and the customer’s overage for the current period, or null when their plan has no overage. Unknown customers return 404 customer_not_found. The key needs the customers:write permission.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Query Parameters
Required string length:
1 - 255Body
application/json
The customer's monthly overage cap in cents. It replaces the plan default, higher or lower. Null clears it and restores the plan default.
Required range:
0 <= x <= 2147483647