# Errors

The Claid API provides standard HTTP status codes. Every successful responses are indicated with a 200-series and error responses with non-200-series HTTP code.

Error reasons can vary, but the structure of the response always looks the following:

### Error response structure

```json
{
    "error_code": "9000",
    "error_type": "validation",
    "error_message": "name: ensure this value has at most 50 characters. parameters.credentials.access_key: field required.",
    "error_details": {
        "name": [
            "ensure this value has at most 50 characters"
        ],
        "parameters.credentials.access_key": [
            "field required"
        ],
}
```

#### Error response  attributes:

* **`error_code`** *<mark style="color:blue;">string</mark>*\
  &#x20;Claid internal error identifier.
* **`error_type`** *<mark style="color:blue;">string</mark>*\
  &#x20;Claid errors are grouped by topics and this field returns the name of that group.
* **`error_message`** *<mark style="color:blue;">string</mark>*\
  A human-readable description of the error. \
  If there were several reasons for failure - they will be concatenated as separate sentences, divided with `.` (dot).
* **`error_details`** *<mark style="color:blue;">object</mark>*\
  If there is a request validation error with `key:value` pairs - this field represents a nicely formatted version of `error_message`. Otherwise it can be an empty object - `{}`.

Error response example with an empty **`error_details`**

```json
{
    "error_code": "111",
    "error_type": "auth",
    "error_message": "Authorization is required.",
    "error_details": {}
}
```

#### How to get error reason

If you want to get a human-readable error message, then it is best to always get data from the **`error_message`** attribute.

If you prefer to represent the error yourself according to the `key:value` pairs of errored fields,  use **`error_details`**. Note: It can be an empty object if there was no validation error associated with the field. In this case, you can get the message from the **`error_message`** attribute.

### HTTP status codes summary

**`200-2xx`**  *<mark style="color:blue;">OK</mark>*

Everything worked as expected

&#x20;**`400`**  *<mark style="color:blue;">Bad Request</mark>*

Since this is a generic error, there can be several reasons why we get it, such as when we can't get the object from storage, or can't even parse JSON payload when it's invalid.&#x20;

In any case, you can get the error reason from `error_message` attribute. See the [How to get error reason](#strategy-to-get-error-reason) above.

**`401`**  *<mark style="color:blue;">Unauthorized</mark>*

You are unauthorized to access the requested resource. Learn how to [authenticate via API key](/authentication.md).

**`402`**  *<mark style="color:blue;">No API calls left</mark>*

Your account has run out of API calls. Purchase more API call credits to continue using [Claid.ai](http://claid.ai/).

**`403`**  *<mark style="color:blue;">Forbidden</mark>*

The API key doesn't have permissions to perform the request. We recommend checking the scopes and correctness of the API key.

**`404`**  *<mark style="color:blue;">Not Found</mark>*

The requested resource doesn't exist.&#x20;

**`409`**  *<mark style="color:blue;">Conflict</mark>*

The request can't be processed, because of conflict in the current state of the resource.

**`422`**  *<mark style="color:blue;">Unprocessable Entity</mark>*

The error indicates that the payload has logical or validation issues. The concrete reasons can be found in `error_message` and `error_details` fields.&#x20;

**`429`**  *<mark style="color:blue;">Too Many Requests</mark>*

Request cannot be served due to the API's rate limit. See [Rate Limits](/rate-limits.md) page for more information.

**`500`**  *<mark style="color:blue;">Internal Server Error</mark>*

Temporary error, which indicates that we experiencing an internal error.

This is a rare case but if you continue to receive this error, please [reach out to API support](#get-help) with request details.

### Get help

In case of any issues with image processing, you can reach out to our [technical support](mailto:support@claid.ai) and provide them details with `x-request-id` header value (see the API reference).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.claid.ai/errors.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
