Key Quota
Endpoint
Section titled “Endpoint”GET https://api.bve.me/admin/api-keys/:id/quotaAuthorization: Bearer admin_bve_YOUR_ADMIN_KEYReturns the live quota status for a single API key — current request counts for each rate-limit window (minute, day, month), remaining headroom, and when each window resets. Counts come directly from the Durable Object (minute/day/month requests) and D1 (monthly tokens), so values are accurate to within a few seconds.
Authentication
Section titled “Authentication”Admin Bearer token required. See Admin API Overview for authentication details.
Path parameters
Section titled “Path parameters”| Parameter | Description |
|---|---|
id | The API key ID (UUID returned when the key was created) |
Response
Section titled “Response”HTTP/1.1 200 OKContent-Type: application/json{ "key_id": "01924d3f-1a2b-7c3d-8e4f-5a6b7c8d9e0f", "status": "active", "limits": { "rpm": 60, "rpd": 1000, "monthly_requests": 50000, "monthly_tokens": 10000000 }, "current": { "minute": { "count": 5, "remaining": 55, "reset_at": "2026-05-23T14:32:00.000Z", "reset_in_seconds": 47 }, "day": { "count": 312, "remaining": 688, "reset_at": "2026-05-24T00:00:00.000Z", "reset_in_seconds": 34547 }, "month": { "request_count": 14820, "request_remaining": 35180, "token_count": 2841093, "token_remaining": 7158907, "reset_at": "2026-06-01T00:00:00.000Z" } }, "checked_at": "2026-05-23T14:31:13.000Z"}Response fields
Section titled “Response fields”| Field | Type | Description |
|---|---|---|
key_id | string | UUID of the API key |
status | string | Key lifecycle status: active, suspended, or revoked |
limits.rpm | integer | Requests-per-minute cap for this key |
limits.rpd | integer | Requests-per-day cap for this key |
limits.monthly_requests | integer | null | Monthly request cap, or null if uncapped |
limits.monthly_tokens | integer | null | Monthly token cap, or null if uncapped |
current.minute.count | integer | Requests made in the current minute window |
current.minute.remaining | integer | Requests remaining before the minute cap is hit |
current.minute.reset_at | ISO 8601 | When the current minute window resets |
current.minute.reset_in_seconds | integer | Seconds until the minute window resets |
current.day.count | integer | Requests made since midnight UTC |
current.day.remaining | integer | Requests remaining in the current day |
current.day.reset_at | ISO 8601 | When the current day window resets (midnight UTC) |
current.day.reset_in_seconds | integer | Seconds until the day window resets |
current.month.request_count | integer | Requests recorded in D1 for the current calendar month |
current.month.request_remaining | integer | null | Requests remaining in the month, or null if uncapped |
current.month.token_count | integer | Tokens recorded in D1 for the current calendar month |
current.month.token_remaining | integer | null | Tokens remaining in the month, or null if uncapped |
current.month.reset_at | ISO 8601 | When the monthly window resets (first of next month, UTC) |
checked_at | ISO 8601 | Timestamp of when this response was generated |
cURL example
Section titled “cURL example”curl https://api.bve.me/admin/api-keys/01924d3f-1a2b-7c3d-8e4f-5a6b7c8d9e0f/quota \ -H "Authorization: Bearer admin_bve_YOUR_ADMIN_KEY"Common errors
Section titled “Common errors”| Status | Code | Cause |
|---|---|---|
| 401 | missing_api_key | No Authorization header |
| 401 | invalid_api_key | Admin key does not match the configured ADMIN_API_KEY secret |
| 404 | not_found | No API key exists with the given ID |
Use cases
Section titled “Use cases”Check if a key is approaching its limit before a batch job:
QUOTA=$(curl -s https://api.bve.me/admin/api-keys/$KEY_ID/quota \ -H "Authorization: Bearer $ADMIN_KEY")REMAINING=$(echo "$QUOTA" | jq '.current.minute.remaining')echo "Remaining this minute: $REMAINING"Monitor a key’s monthly token burn rate:
import OpenAI from "openai";
const res = await fetch(`https://api.bve.me/admin/api-keys/${keyId}/quota`, { headers: { Authorization: `Bearer ${adminKey}` },});const quota = await res.json();const tokenPct = quota.current.month.token_count / quota.limits.monthly_tokens;console.log(`${(tokenPct * 100).toFixed(1)}% of monthly token budget used`);Reset quota counters
Section titled “Reset quota counters”POST https://api.bve.me/admin/api-keys/:id/reset-quotaAuthorization: Bearer admin_bve_YOUR_ADMIN_KEYResets the Durable Object request counters for one or all rate-limit windows of a specific API key. Useful when a key has hit its limit due to a runaway process and you need to unblock it immediately, or during testing to reset state between runs.
Request body
Section titled “Request body”Optional JSON body. If the body is absent or window is not specified, all three windows are reset.
{ "window": "all"}| Field | Type | Required | Description |
|---|---|---|---|
window | string | No | Which window to reset: "minute", "day", "month", or "all" (default) |
Response
Section titled “Response”HTTP/1.1 200 OKContent-Type: application/json{ "key_id": "01924d3f-1a2b-7c3d-8e4f-5a6b7c8d9e0f", "window": "all", "reset": true}cURL examples
Section titled “cURL examples”Reset all windows (default):
curl -X POST https://api.bve.me/admin/api-keys/01924d3f-1a2b-7c3d-8e4f-5a6b7c8d9e0f/reset-quota \ -H "Authorization: Bearer admin_bve_YOUR_ADMIN_KEY"Reset only the per-minute window:
curl -X POST https://api.bve.me/admin/api-keys/01924d3f-1a2b-7c3d-8e4f-5a6b7c8d9e0f/reset-quota \ -H "Authorization: Bearer admin_bve_YOUR_ADMIN_KEY" \ -H "Content-Type: application/json" \ -d '{"window": "minute"}'Common errors
Section titled “Common errors”| Status | Code | Cause |
|---|---|---|
| 400 | validation_error | window is not one of "minute", "day", "month", "all" |
| 404 | not_found | No API key exists with the given ID |