ErrorsΒΆ
Afi uses conventional HTTP response status codes to indicate the success or failure of an API request. In general:
- Status codes in the
2xxrange indicate success. - Status codes in the
4xxrange indicate an error that occurred given the information provided and current state (e.g., a required parameter was omitted, an invalid value was sent, etc.). - Status codes in the
5xxrange 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 a missing required parameter, an invalid parameter, or a combination of both. |
| 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. The caller should use exponential backoff of its requests. |
| 5xx - Internal Server Error | Something went wrong on the Afi side (these errors are rare). The request can be retried with an exponential backoff. |
Note that 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. |