Errors and Debugging

Diagnose validation, authentication, credit, and upstream issues.

Error Codes

NameTypeRequiredDescription
400
Bad RequestInvalid schema or parameters.
401
UnauthorizedMissing/invalid API key.
402
Payment RequiredInsufficient credits.
404
Not FoundUnknown route or resource.
429
Too Many RequestsRate limited.
500
Internal Server ErrorGateway internal failure.
502
Bad GatewayUpstream/provider failure.
503
Service UnavailableTemporary service outage.

Standard Error Shape

json
{
  "error": {
    "message": "Rate limit exceeded",
    "type": "rate_limit_error",
    "code": 429,
    "param": null
  }
}

402 Extended Error Shape

json
{
  "error": {
    "type": "insufficient_credits",
    "message": "Insufficient credit balance",
    "code": "insufficient_credits",
    "balance": {
      "current": 2.5,
      "threshold": 5,
      "currency": "credits"
    },
    "actions": {
      "top_up_url": "/v1/customer/credits/packages",
      "support_url": "/support"
    }
            }
}

This 402 payload is an extension that adds error.balance and error.actions. The extension may use a semantic code value ("insufficient_credits") while standard errors use the canonical {message, type, code, param} shape.

Debugging Headers

NameTypeRequiredDescription
x-request-id
response headerCanonical request identifier for support/debugging.
Retry-After
response headerSeconds to wait before retrying a 429 response.
502 Type
502 responses use api_error in the error type field.