Errors
One error shape for every failure, with a stable code to branch on.
Every error Hixel produces, from the management API or from the gateway itself, has the
same JSON body and an HTTP status that follows its type:
{
"error": {
"type": "conflict",
"code": "credit_idempotency_key_reused",
"message": "This idempotency key already credited this wallet with another kind, amount or expiry. Use a new key for a new credit.",
"param": "idempotency_key"
}
}| Field | Meaning |
|---|---|
type | The kind of failure; it fixes the status (below) |
code | A stable, machine-readable reason within the type, such as insufficient_credits. Branch on this |
message | A sentence for the developer reading it. It may change: do not parse it or show it to end users |
param | The request field at fault, such as limits.spend.0.limit_micros or Idempotency-Key; for the gateway's spend_limit_reached, the id of the limit that refused the request; else null |
Types and statuses#
type | Status | Meaning | Retry? |
|---|---|---|---|
invalid_request | 400 | The request is malformed or fails validation | No: fix it |
unauthenticated | 401 | No valid key or token | No |
payment_required | 402 | A wallet or spend limit does not allow the request | After credit is added |
permission_denied | 403 | The key, token or customer may not do this | No |
not_found | 404 | No such resource in this environment | No |
conflict | 409 | The request conflicts with the resource's state or an earlier request | Depends on code |
rate_limited | 429 | Too many requests | Yes, after retry-after |
unavailable | 503 | A dependency cannot be reached | Yes, with backoff |
internal | 500 | An unexpected failure on our side; details are logged, never returned | Yes, with backoff |
New codes can be added within a type. Handle the codes you care about and fall back on type
for the rest.
Every response, error or not, carries x-hixel-request-id. Quote it when you ask us about a
failure: each refused request is logged under it.
Not found means not found#
A resource in another environment, project or organization reads exactly like one that does not
exist: 404. A key can never learn whether another tenant's customer or key exists.
Common codes#
code | Type | Where |
|---|---|---|
invalid_api_key, expired_api_key, api_key_required | unauthenticated | Any call: see Authentication |
management_scope_required | permission_denied | Management API with an inference-only key |
project_key_required, role_not_allowed | permission_denied | The key may not make this call: see Authentication |
environment_required, environment_not_found | invalid_request, not_found | A project key's x-hixel-environment is missing, or names no environment of its project |
invalid_cursor | invalid_request | A cursor that no page of this list gave |
invalid_range | invalid_request | from not before to, or a range too long |
invalid_idempotency_key | invalid_request | A malformed Idempotency-Key header |
idempotency_key_reused, idempotency_key_in_use | conflict | See Idempotency |
credit_idempotency_key_reused | conflict | See Grants and credits |
project_archived, environment_archived | conflict | A write to an archived project or environment |
insufficient_credits, spend_limit_reached | payment_required | The gateway: see Gateway errors |
Each guide lists the codes of its own calls.
Errors from providers#
The gateway passes a provider's own errors through with the provider's status and body, in the format you called. They do not have this shape. See Gateway errors.
Request ids#
Every response, from the gateway and from the management API, carries x-hixel-request-id. Log
it with your own request, and include it when you contact support. For a gateway request, it also
finds the request's usage record.