Skip to content

Errors

Afi uses conventional HTTP response status codes to indicate the success or failure of an API request. In general:

  • Status codes in the 2xx range indicate success.
  • Status codes in the 4xx range indicate an error that failed given the information provided and current state (e.g., a required parameter was omitted, invalid value was sent, etc.).
  • Status codes in the 5xx range indicate an error with the Afi services (these errors are rare).

HTTP status codes summary:

HTTP status codeDescription
200 OKCall succeeded.
400 Bad RequestThe request failed, often due to missing a required parameter, invalid parameter or their combination.
401 UnauthorizedNo valid API key provided.
403 ForbiddenThe API key doesn't have permissions to perform the request.
404 Not FoundThe requested resource doesn't exist.
429 Too Many RequestsToo many requests hit the API too quickly. Caller should use exponential backoff of its requests.
5xx - Internal Server ErrorSomething went wrong on the Afi side (these errors are rare). Request can be retried with an exponential backoff.

Note, Status codes 429 and 5xx can be retried with an exponential backoff.

To enable troubleshooting and automatic error handling in the application logic, errors include a JSON body with the following details:

Error JSON fieldDescription
status (integer)HTTP status code.
code (string)An error code string that uniquely identifies the error type reported.
message (string)Human readable error message.