Documentation menu

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"
  }
}
FieldMeaning
typeThe kind of failure; it fixes the status (below)
codeA stable, machine-readable reason within the type, such as insufficient_credits. Branch on this
messageA sentence for the developer reading it. It may change: do not parse it or show it to end users
paramThe 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#

typeStatusMeaningRetry?
invalid_request400The request is malformed or fails validationNo: fix it
unauthenticated401No valid key or tokenNo
payment_required402A wallet or spend limit does not allow the requestAfter credit is added
permission_denied403The key, token or customer may not do thisNo
not_found404No such resource in this environmentNo
conflict409The request conflicts with the resource's state or an earlier requestDepends on code
rate_limited429Too many requestsYes, after retry-after
unavailable503A dependency cannot be reachedYes, with backoff
internal500An unexpected failure on our side; details are logged, never returnedYes, 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#

codeTypeWhere
invalid_api_key, expired_api_key, api_key_requiredunauthenticatedAny call: see Authentication
management_scope_requiredpermission_deniedManagement API with an inference-only key
project_key_required, role_not_allowedpermission_deniedThe key may not make this call: see Authentication
environment_required, environment_not_foundinvalid_request, not_foundA project key's x-hixel-environment is missing, or names no environment of its project
invalid_cursorinvalid_requestA cursor that no page of this list gave
invalid_rangeinvalid_requestfrom not before to, or a range too long
invalid_idempotency_keyinvalid_requestA malformed Idempotency-Key header
idempotency_key_reused, idempotency_key_in_useconflictSee Idempotency
credit_idempotency_key_reusedconflictSee Grants and credits
project_archived, environment_archivedconflictA write to an archived project or environment
insufficient_credits, spend_limit_reachedpayment_requiredThe 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.