curl --request POST \
--url https://api.example.com/v1/balances.check \
--header 'Content-Type: application/json' \
--data '
{
"customer_id": "<string>",
"feature_id": "<string>",
"entity_id": "<string>",
"required_balance": 123,
"send_event": true,
"properties": {},
"with_preview": true
}
'{
"allowed": true,
"customer_id": "<string>",
"entity_id": "<string>",
"required_balance": 123,
"balance": {
"feature_id": "<string>",
"granted": 123,
"remaining": 123,
"usage": 123,
"unlimited": true,
"overage_allowed": true,
"max_purchase": 123,
"next_reset_at": 123,
"breakdown": [
{
"id": "<string>",
"plan_id": "<string>",
"included_grant": 123,
"prepaid_grant": 123,
"remaining": 123,
"usage": 123,
"unlimited": true,
"reset": {
"interval": "<string>",
"resets_at": 123
},
"price": {},
"expires_at": 123
}
],
"feature": {}
},
"preview": {},
"error": {
"message": "<string>",
"code": "<string>"
}
}curl --request POST \
--url https://api.example.com/v1/balances.check \
--header 'Content-Type: application/json' \
--data '
{
"customer_id": "<string>",
"feature_id": "<string>",
"entity_id": "<string>",
"required_balance": 123,
"send_event": true,
"properties": {},
"with_preview": true
}
'{
"allowed": true,
"customer_id": "<string>",
"entity_id": "<string>",
"required_balance": 123,
"balance": {
"feature_id": "<string>",
"granted": 123,
"remaining": 123,
"usage": 123,
"unlimited": true,
"overage_allowed": true,
"max_purchase": 123,
"next_reset_at": 123,
"breakdown": [
{
"id": "<string>",
"plan_id": "<string>",
"included_grant": 123,
"prepaid_grant": 123,
"remaining": 123,
"usage": 123,
"unlimited": true,
"reset": {
"interval": "<string>",
"resets_at": 123
},
"price": {},
"expires_at": 123
}
],
"feature": {}
},
"preview": {},
"error": {
"message": "<string>",
"code": "<string>"
}
}Authorization header:
Authorization: Bearer YOUR_SECRET_KEY
allowed: false if the customer’s balance is below this value.required_balance value is used as the usage amount. This combines check + track in one call.send_event is true. Accepts any key-value pairs.balance.feature: Include full feature object in the balance responseexpand=balance.feature was used.with_preview was true and allowed is false.curl -X POST https://api.autumnai.com/v1/balances.check \
-H "Authorization: Bearer YOUR_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"customer_id": "cus_123",
"feature_id": "messages"
}'
curl -X POST https://api.autumnai.com/v1/balances.check \
-H "Authorization: Bearer YOUR_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"customer_id": "cus_123",
"feature_id": "messages",
"required_balance": 3,
"send_event": true
}'
{
"allowed": true,
"customer_id": "cus_123",
"entity_id": null,
"required_balance": 1,
"balance": {
"feature_id": "messages",
"granted": 100,
"remaining": 72,
"usage": 28,
"unlimited": false,
"overage_allowed": false,
"max_purchase": null,
"next_reset_at": 1773851121437,
"breakdown": [
{
"id": "cus_ent_39qmLooixXLAqMywgXywjAz96rV",
"plan_id": "pro_plan",
"included_grant": 100,
"prepaid_grant": 0,
"remaining": 72,
"usage": 28,
"unlimited": false,
"reset": {
"interval": "month",
"resets_at": 1773851121437
},
"price": null,
"expires_at": null
}
]
}
}
customer_not_found: The specified customer doesn’t existfeature_not_found: The specified feature doesn’t existinvalid_inputs: Request validation failedentity_not_found: The specified entity doesn’t existinsufficient_balance: Customer doesn’t have enough balance (when send_event is true){
"error": {
"message": "Customer has insufficient balance",
"code": "insufficient_balance"
}
}