curl --request POST \
--url https://api.example.com/v1/balances.track \
--header 'Content-Type: application/json' \
--data '
{
"customer_id": "<string>",
"feature_id": "<string>",
"event_name": "<string>",
"entity_id": "<string>",
"value": 123,
"properties": {}
}
'{
"customer_id": "<string>",
"entity_id": "<string>",
"event_name": "<string>",
"value": 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": {}
},
"balances": {},
"error": {
"message": "<string>",
"code": "<string>"
}
}curl --request POST \
--url https://api.example.com/v1/balances.track \
--header 'Content-Type: application/json' \
--data '
{
"customer_id": "<string>",
"feature_id": "<string>",
"event_name": "<string>",
"entity_id": "<string>",
"value": 123,
"properties": {}
}
'{
"customer_id": "<string>",
"entity_id": "<string>",
"event_name": "<string>",
"value": 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": {}
},
"balances": {},
"error": {
"message": "<string>",
"code": "<string>"
}
}Authorization header:
Authorization: Bearer YOUR_SECRET_KEY
event_name is not provided.feature_id when multiple features should be tracked from a single event. Either feature_id or event_name must be provided.balance.feature: Include full feature object in the balance responseevent_name was used instead of feature_id.event_name that affects multiple features.expand=balance.feature was used.event_name affects multiple features. Only present when using event_name.curl -X POST https://api.autumnai.com/v1/balances.track \
-H "Authorization: Bearer YOUR_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"customer_id": "cus_123",
"feature_id": "messages",
"value": 1
}'
curl -X POST https://api.autumnai.com/v1/balances.track \
-H "Authorization: Bearer YOUR_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"customer_id": "cus_123",
"event_name": "ai_chat_request",
"value": 1
}'
curl -X POST https://api.autumnai.com/v1/balances.track \
-H "Authorization: Bearer YOUR_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"customer_id": "cus_123",
"feature_id": "seats",
"value": -1
}'
{
"customer_id": "cus_123",
"value": 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_id": "cus_123",
"event_name": "ai_chat_request",
"value": 1,
"balance": null,
"balances": {
"ai_tokens": {
"feature_id": "ai_tokens",
"granted": 1000,
"remaining": 950,
"usage": 50,
"unlimited": false,
"overage_allowed": true,
"max_purchase": null,
"next_reset_at": 1773851121437
},
"ai_requests": {
"feature_id": "ai_requests",
"granted": 100,
"remaining": 85,
"usage": 15,
"unlimited": false,
"overage_allowed": false,
"max_purchase": null,
"next_reset_at": 1773851121437
}
}
}
customer_not_found: The specified customer doesn’t existfeature_not_found: The specified feature doesn’t existinvalid_inputs: Request validation failed (e.g., both feature_id and event_name provided)entity_not_found: The specified entity doesn’t existinsufficient_balance: Customer doesn’t have enough balance for the usage amountinvalid_event_name: The specified event name is not configured{
"error": {
"message": "Either feature_id or event_name must be provided",
"code": "invalid_inputs"
}
}