> For the complete documentation index, see [llms.txt](https://ajaib.gitbook.io/coin-exchange/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ajaib.gitbook.io/coin-exchange/getting-started/errors.md).

# Errors

Ajaib uses conventional HTTP response codes to indicate the success or failure of an API request. In general: codes in the `2xx` range indicate success. Codes in the `5xx` range indicate an error with Ajaib's servers.&#x20;

Errors to bad requests respond with codes in the `4xx` range. Typically, this indicate an error which failed given the information provided (e.g., a required parameter was omitted, insufficient wallet balance, etc).&#x20;

Such errors include a body that contains a `message` parameter which further indicates the specific cause. Your program should be configured to read the message field from the body so errors could be handled programmatically

## Response Codes&#x20;

<table data-header-hidden data-full-width="false"><thead><tr><th width="122"></th><th width="184"></th><th></th></tr></thead><tbody><tr><td><strong>200</strong></td><td>OK</td><td>Everything worked as expected. May contain an optional body. If the response has a body, it is documented under each page. </td></tr><tr><td><strong>400</strong></td><td>Bad Request</td><td>The request was unacceptable, often due to missing a required parameter. </td></tr><tr><td><strong>401</strong></td><td>Unauthorized</td><td>No valid API key provided.</td></tr><tr><td><strong>402</strong></td><td>Request Failed</td><td>The parameters were valid but the request failed. </td></tr><tr><td><strong>403</strong></td><td>Forbidden</td><td>The API key doesn't have the permissions to perform the request. </td></tr><tr><td><strong>404</strong></td><td>Not Found</td><td>The requested resource doesn't exist. </td></tr><tr><td><strong>409</strong></td><td>Conflict</td><td>The request conflicts with another request (perhaps due to using the same idempotent key). </td></tr><tr><td><strong>429</strong></td><td>Too Many Requests</td><td>Too many requests hit the API too quickly. Use an exponential backoff on your request. </td></tr><tr><td><strong>500, 502, 503, 504</strong></td><td>Server Errors</td><td>Something went wrong on Ajaib's end. </td></tr></tbody></table>

## Error Body Sample&#x20;

```
{
    "error": "invalid_request" 
}
```

## Error Messages

<table><thead><tr><th width="256">Enum</th><th>Cause</th></tr></thead><tbody><tr><td><code>invalid_request</code></td><td>Invalid request means your request has missing required or invalid parameters. </td></tr><tr><td><code>invalid_client</code></td><td>Invalid authorization</td></tr><tr><td><code>insufficient_wallet</code></td><td>Insufficient balance in the exchange client's wallet</td></tr><tr><td><code>api_error</code></td><td>API errors cover any other type of problem e.g. a temporary problem with Ajaib's servers.  </td></tr></tbody></table>
