cURL
curl --request POST 'https://api.integrateledger.com/v1/customers/controls?customerId=user_123' \
-H "Authorization: Bearer $LEDGER_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"usageLimits":[{"featureId":"chat","limit":200,"interval":"day"}]}'import ledger from "integrateledger";
const client = new ledger({ apiKey: process.env.LEDGER_API_KEY ?? "" });
await client.setCustomerControls({ customerId: "user_123", body: { usageLimits: [{ featureId: "chat", limit: 200, interval: "day" }] } });import os
from integrateledger import ledger
client = ledger(api_key=os.environ["LEDGER_API_KEY"])
client.set_customer_controls(customer_id="user_123", controls={"usageLimits": [{"featureId": "chat", "limit": 200, "interval": "day"}]}){
"customerId": "<string>",
"entityId": "<string>",
"usageLimits": [
{
"interval": "<string>",
"filter": {},
"limit": 123,
"scope": "customer",
"source": "entity",
"used": 123,
"remaining": 123,
"windowStart": "2023-11-07T05:31:56Z",
"resetsAt": "2023-11-07T05:31:56Z",
"featureId": "<string>",
"creditPool": true,
"anchor": "<string>"
}
],
"usageAlerts": [
{
"name": "<string>",
"type": "<string>",
"threshold": 123,
"scope": "customer",
"source": "entity",
"firedAt": "2023-11-07T05:31:56Z",
"featureId": "<string>",
"creditPool": true,
"usageLimit": {
"interval": "<string>",
"filter": {}
}
}
],
"overage": [
{
"allowed": true,
"freeUnits": 123,
"billOverage": true,
"source": "entity",
"billed": 123,
"unbilled": 123,
"freeLeft": 123,
"featureId": "<string>",
"creditPool": true
}
]
}{
"error": "<string>",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment.",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
]
}{
"error": "<string>",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment.",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
]
}{
"error": "insufficient_permissions",
"requiredScope": "customers:read",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment."
}{
"error": "<string>",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment.",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
]
}{
"error": "payload_too_large",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment."
}{
"error": "rate_limited",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment."
}Customers
Set a customer's controls
Usage limits, usage alerts and overage controls for one customer or entity.
POST
/
v1
/
customers
/
controls
cURL
curl --request POST 'https://api.integrateledger.com/v1/customers/controls?customerId=user_123' \
-H "Authorization: Bearer $LEDGER_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"usageLimits":[{"featureId":"chat","limit":200,"interval":"day"}]}'import ledger from "integrateledger";
const client = new ledger({ apiKey: process.env.LEDGER_API_KEY ?? "" });
await client.setCustomerControls({ customerId: "user_123", body: { usageLimits: [{ featureId: "chat", limit: 200, interval: "day" }] } });import os
from integrateledger import ledger
client = ledger(api_key=os.environ["LEDGER_API_KEY"])
client.set_customer_controls(customer_id="user_123", controls={"usageLimits": [{"featureId": "chat", "limit": 200, "interval": "day"}]}){
"customerId": "<string>",
"entityId": "<string>",
"usageLimits": [
{
"interval": "<string>",
"filter": {},
"limit": 123,
"scope": "customer",
"source": "entity",
"used": 123,
"remaining": 123,
"windowStart": "2023-11-07T05:31:56Z",
"resetsAt": "2023-11-07T05:31:56Z",
"featureId": "<string>",
"creditPool": true,
"anchor": "<string>"
}
],
"usageAlerts": [
{
"name": "<string>",
"type": "<string>",
"threshold": 123,
"scope": "customer",
"source": "entity",
"firedAt": "2023-11-07T05:31:56Z",
"featureId": "<string>",
"creditPool": true,
"usageLimit": {
"interval": "<string>",
"filter": {}
}
}
],
"overage": [
{
"allowed": true,
"freeUnits": 123,
"billOverage": true,
"source": "entity",
"billed": 123,
"unbilled": 123,
"freeLeft": 123,
"featureId": "<string>",
"creditPool": true
}
]
}{
"error": "<string>",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment.",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
]
}{
"error": "<string>",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment.",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
]
}{
"error": "insufficient_permissions",
"requiredScope": "customers:read",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment."
}{
"error": "<string>",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment.",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
]
}{
"error": "payload_too_large",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment."
}{
"error": "rate_limited",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment."
}Saves the customer’s own controls, or one entity’s with
entityId. Each kind you send (usageLimits, usageAlerts, overage) replaces that kind’s entries at this level; a kind you leave out is untouched; null clears it back to the plan’s.
A customer’s entry replaces the plan’s entry with the same key whole: a usage limit by its target, interval and filter; an alert by its target and name; an overage entry by its target. Every level’s usage limit applies at once: an entity’s own limit counts only that entity, inside the customer’s.
Refusals: 400 invalid_usage_limit (a limit on a held or boolean feature, a duplicate), invalid_alert (a percentage alert without an allowance, an alert on a boolean feature), invalid_overage_control (an entry on a credits, held or boolean feature, or allowed: true without an overage price or freeUnits), each with issues; 404 customer_not_found, entity_not_found.
The response is what Get a customer’s controls returns. Needs the Customers permission.Authorizations
Query Parameters
Body
application/json