Skip to Content
AffFast

Errors

The form of an error response, the error types and how to handle them.

When a request fails, the API returns an HTTP status code of 400 or more and a JSON body with the same form each time:

{
  "error": {
    "type": "invalid_request_error",
    "code": "parameter_invalid",
    "message": "The limit must be between 1 and 100.",
    "param": "limit",
    "doc_url": "https://docs.afffast.com/errors/parameter-invalid",
    "request_id": "req_3kQ9x7WmZpL2vNd8TfYb4A"
  }
}
FieldMeaning
typeThe class of the error. See the table below.
codeA stable code in snake_case. Use it in your code. It never changes for the same problem.
messageA text for a developer. It can change. Do not parse it.
paramThe name of the parameter or the field that caused the error. It can be missing.
doc_urlA link to the page of the code with the causes and the fix.
request_idThe ID of the request. It is also in the response header Request-Id. Send it to support.
detailsA list of places that caused the error. A file import lists the rows (100 at most).
request_log_urlA link to the request in the logs of the dashboard. It can be missing.

Error types

TypeStatus codesMeaning
invalid_request_error400, 404, 409, 422The request is not valid, or the object does not exist.
authentication_error400, 401The key is missing, not valid, or in the URL.
permission_error403The key cannot do this: a scope, a role, a mode or a plan limit.
rate_limit_error429Too many requests. See Rate limits.
idempotency_error400, 409A problem with the Idempotency-Key. See Idempotency.
api_error500An error on our side.

The status codes mean:

  • 400: the API cannot read the request (not JSON, a key in the URL, an unknown Api-Version, a bad Idempotency-Key).
  • 404: the object or the URL does not exist.
  • 409: the request conflicts with the state of the data or with an earlier request.
  • 422: a value is not valid. param names it.

Handle errors

  1. Switch on error.code, not on the message or on the status code alone.
  2. Do not retry a 4xx error. Fix the request. The only exception is 429: wait for Retry-After seconds.
  3. Retry a 5xx error with a growing wait. Use an Idempotency-Key on a POST, and send a new key for a new try (see Idempotency).
  4. Keep request_id in your logs. Send it to support when you ask for help.

The API validates a request before it runs. A request that is not valid never changes data.

All error codes are in Error codes.

On this page