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 code | Description |
---|---|
200 OK | Call succeeded. |
400 Bad Request | The request failed, often due to missing a required parameter, invalid parameter or their combination. |
401 Unauthorized | No valid API key provided. |
403 Forbidden | The API key doesn't have permissions to perform the request. |
404 Not Found | The requested resource doesn't exist. |
429 Too Many Requests | Too many requests hit the API too quickly. Caller should use exponential backoff of its requests. |
5xx - Internal Server Error | Something 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 field | Description |
---|---|
status (integer) | HTTP status code. |
code (string) | An error code string that uniquely identifies the error type reported. |
message (string) | Human readable error message. |