Every API error on the /v1 endpoints renders as a single, stable JSON shape so integrators can branch on it programmatically. The one exception is a URL that does not exist, which returns an HTML page (see Errors that are not JSON).

Error Fields

string
The broad category of the error. Common types include:
  • invalid_request_error
  • authentication_error
  • permission_error
  • not_found_error
  • conflict_error
  • rate_limit_error
  • api_error
string
A short string providing a specific machine code for the error. Useful for programmatic branching (e.g. resource_not_found, idempotency_conflict, validation_error). Branch on code, not on message.
string
A human-readable summary of the error.
object
Optional. Present on validation errors (type=invalid_request_error, code=validation_error) and on 409 duplicate_reference_id errors. On a validation error it contains keys matching the request fields that failed validation, with arrays of error strings. On duplicate_reference_id it contains invoice_id, the id of the existing invoice.
integer
Optional. Present on 429 responses (code=rate_limited). The number of seconds to wait before you try again. It is the same number as the Retry-After header.

Examples

Error codes

Read the wait time from the Retry-After header (in seconds) and back off: wait at least that long before you send the next request, and slow down so you do not hit the limit again.

Errors that are not JSON

Endpoint paths end with /, and the API does not redirect a path that is missing it. GET /v1/products and POST /v1/products (no trailing slash) return an HTML 404 Not Found page, not a JSON error. The same happens for any path that does not exist. If your client always parses error bodies as JSON, check the HTTP status and the Content-Type first.
404