# Errors

The Didomi API uses standard HTTP response codes to indicate that an API request is a success or a failure. In general, the codes act as follows:

* `2xx` codes indicate a success
* `4xx` codes indicate an error in the parameters sent to the server (e.g., the authentication information is invalid, a required parameter is missing, etc.)
* `5xx` codes indicate a Didomi server-side error

When an error happens, you can look at the JSON response body to find more about the reason. The body will be an object with the following properties:

| Property  | Description                                                                   | Example                            |
| --------- | ----------------------------------------------------------------------------- | ---------------------------------- |
| `code`    | The HTTP response code                                                        | 400                                |
| `name`    | The name of the error (tied to the response code)                             | BadRequest                         |
| `message` | An explanation of the error                                                   | Invalid authentication information |
| `errors`  | An array containing more errors if multiple errors have been batched together |                                    |

Example:

```javascript
{
    "code": 400,
    "errors": {},
    "message": "Invalid authentication information",
    "name": "BadRequest"
}
```
