Errors
HTTP status codes and error response format.
The API uses standard HTTP status codes and returns errors as JSON with an error field.
Error format
All errors follow this shape:
{
"error": "Human-readable error message"
}Some validation errors on usage submission include per-event details:
{
"accepted": 0,
"rejected": 1,
"events": [
{
"event_id": "evt-001",
"status": "rejected",
"error": "Metric 'unknown_metric' not in pricing program"
}
]
}Status codes
| Code | Meaning | When |
|---|---|---|
200 | Success | Request completed successfully |
400 | Bad Request | Invalid request body or parameters |
401 | Unauthorized | Missing, invalid, or expired API key |
404 | Not Found | Resource doesn't exist or doesn't belong to your account |
500 | Internal Server Error | Something went wrong on our end |
Common errors
Authentication errors (401)
| Error | Cause |
|---|---|
Missing API key | No Authorization or X-Api-Key header |
Invalid API key | Key doesn't match any active key |
API key expired | Key has passed its expiration date |
Usage submission errors
POST /v1/billing/usage validates events individually — a bad row never rejects the rest of the batch. Only an invalid batch envelope (empty events or >100 items) returns HTTP 400.
Per-event failures appear in the events array with status: "rejected" (if event_id itself is missing or invalid, event_id is reported as index:<position>):
| Error | Cause |
|---|---|
<field>: <validation error> | Malformed event payload (e.g. invalid ISO timestamp, negative quantity/fee_amount, or missing required field) |
Contract not found or has no customer | The external_contract_id doesn't match any active contract |
No approved pricing program | The contract doesn't have an approved pricing program yet |
Metric 'X' not in pricing program | metric is not on that contract. Use GET /v1/billing/contracts → metrics[], or apply the catalog / add a usage rule |
Not found errors (404)
Returned when looking up a specific resource:
{
"error": "Not found"
}This means either the resource doesn't exist or it belongs to a different company.
Retry guidance
- 401 — Don't retry. Fix your API key.
- 404 — Don't retry. Check the resource ID.
- 400 — Don't retry. Fix the request.
- 500 — Safe to retry with exponential backoff. Usage submissions are idempotent via
event_id.