Skip to content

API reference: Quotas

The quotas API manages per-user and per-group usage limits. Quotas enforce daily and monthly caps on token consumption, request count, and cost. When a quota is exceeded, subsequent requests from the affected user or group return HTTP 429.

All endpoints require admin authentication.

Base path: /api/admin


MethodPathDescription
GET/api/admin/users/{user_id}/quotaGet quota for a user
PUT/api/admin/users/{user_id}/quotaCreate or update quota for a user
DELETE/api/admin/users/{user_id}/quotaRemove quota for a user
GET/api/admin/groups/{group_id}/quotaGet quota for a group
PUT/api/admin/groups/{group_id}/quotaCreate or update quota for a group
DELETE/api/admin/groups/{group_id}/quotaRemove quota for a group

Used when creating or updating a quota. All fields are optional — omit any limit you do not want to enforce.

FieldTypeDescription
daily_token_limitinteger | nullMaximum tokens per day. null = no limit.
monthly_token_limitinteger | nullMaximum tokens per calendar month. null = no limit.
daily_request_limitinteger | nullMaximum requests per day. null = no limit.
monthly_request_limitinteger | nullMaximum requests per calendar month. null = no limit.
daily_cost_limit_usdfloat | nullMaximum spend per day (USD). null = no limit.
monthly_cost_limit_usdfloat | nullMaximum spend per calendar month (USD). null = no limit.

Returned by GET and PUT endpoints.

FieldTypeDescription
scopestring"user" or "group"
idUUIDUUID of the user or group this quota applies to
limitsobjectThe configured limits (same fields as QuotaConfig)
usageobjectCurrent period usage (see below)

usage object:

FieldTypeDescription
daily_tokensintegerTokens consumed today (resets at UTC midnight)
monthly_tokensintegerTokens consumed this calendar month
daily_requestsintegerRequests made today
monthly_requestsintegerRequests made this calendar month
daily_cost_usdfloatSpend today (USD)
monthly_cost_usdfloatSpend this calendar month (USD)

Get the quota configuration and current usage for a user.

Path parameters:

ParameterTypeDescription
user_idUUIDThe user’s UUID

Response 200 OK:

{
"scope": "user",
"id": "usr_01abc123-...",
"limits": {
"daily_token_limit": 100000,
"monthly_token_limit": 2000000,
"daily_request_limit": 500,
"monthly_request_limit": null,
"daily_cost_limit_usd": null,
"monthly_cost_limit_usd": 50.0
},
"usage": {
"daily_tokens": 34820,
"monthly_tokens": 890200,
"daily_requests": 120,
"monthly_requests": 3450,
"daily_cost_usd": 1.24,
"monthly_cost_usd": 31.80
}
}

Response 404 Not Found: User not found or user has no quota configured.


Create or update the quota for a user. This is an upsert — if the user has no quota, one is created; if they do, it is replaced with the new values.

Path parameters:

ParameterTypeDescription
user_idUUIDThe user’s UUID

Request body: QuotaConfig object.

PUT /api/admin/users/usr_01abc123-.../quota
Authorization: Bearer <admin_token>
Content-Type: application/json
{
"daily_token_limit": 100000,
"monthly_token_limit": 2000000,
"daily_request_limit": 500,
"monthly_request_limit": null,
"daily_cost_limit_usd": null,
"monthly_cost_limit_usd": 50.0
}

Response 200 OK: The updated QuotaResponse object.

Response 404 Not Found: User does not exist or does not belong to the admin’s tenant.


Remove the quota for a user. After deletion, the user has no usage limits unless a group quota applies.

Path parameters:

ParameterTypeDescription
user_idUUIDThe user’s UUID

Response 204 No Content: Quota deleted.

Response 404 Not Found: User not found or user has no quota configured.


Get the quota configuration and current usage for a group.

Path parameters:

ParameterTypeDescription
group_idUUIDThe group’s UUID

Response 200 OK:

{
"scope": "group",
"id": "grp_01abc123-...",
"limits": {
"daily_token_limit": null,
"monthly_token_limit": 10000000,
"daily_request_limit": null,
"monthly_request_limit": 20000,
"daily_cost_limit_usd": null,
"monthly_cost_limit_usd": 500.0
},
"usage": {
"daily_tokens": 120400,
"monthly_tokens": 4200000,
"daily_requests": 480,
"monthly_requests": 9800,
"daily_cost_usd": 5.80,
"monthly_cost_usd": 210.40
}
}

Response 404 Not Found: Group not found or group has no quota configured.


Create or update the quota for a group.

Path parameters:

ParameterTypeDescription
group_idUUIDThe group’s UUID

Request body: QuotaConfig object (same as user quota).

Response 200 OK: The updated QuotaResponse object.

Response 404 Not Found: Group does not exist or does not belong to the admin’s tenant.


Remove the quota for a group.

Path parameters:

ParameterTypeDescription
group_idUUIDThe group’s UUID

Response 204 No Content: Quota deleted.

Response 404 Not Found: Group not found or group has no quota configured.


When both a user quota and a group quota are configured for the same user, the stricter limit applies. For example, if a user has a monthly token limit of 2,000,000 and their group has a monthly token limit of 1,000,000, the effective limit is 1,000,000.

When a user’s usage reaches or exceeds a configured limit, subsequent requests return:

HTTP/1.1 429 Too Many Requests
Retry-After: <seconds until reset>

Response body:

{
"error": "quota_exceeded",
"limit_type": "monthly_token_limit",
"limit_value": 2000000,
"current_usage": 2001450,
"reset_at": "2026-04-01T00:00:00Z"
}

Daily limits reset at UTC midnight. Monthly limits reset on the first day of each calendar month at UTC midnight.

Quota status is included in response headers for every successful request:

HeaderDescription
X-RateLimit-Limit-Tokens-DayDaily token limit
X-RateLimit-Remaining-Tokens-DayRemaining tokens today
X-RateLimit-Limit-Tokens-MonthMonthly token limit
X-RateLimit-Remaining-Tokens-MonthRemaining tokens this month
X-RateLimit-Reset-DayUTC timestamp when the daily window resets
X-RateLimit-Reset-MonthUTC timestamp when the monthly window resets

Headers for unset limits are omitted.