# Errors

## Success

Every success is HTTP 200 in the v2 envelope. `profiler` is always an empty array.

```json
{ "code": 200, "version": 2, "success": true, "message": null, "data": { "entries": [] }, "profiler": [] }
```

## Business errors

A business error keeps the envelope, with HTTP 409, `message` set to `error` and the reason in `data.data`:

```json
{ "code": 409, "version": 2, "success": false, "message": "error", "data": { "data": "No deliveries found" }, "profiler": [] }
```

Each operation in the [reference](https://cademi.dev/legacy/v2/reference.md) lists its reasons.

## Other errors

Authentication, routing and validation errors use a shorter body, with the text in `message`. The text starts with a space.

| HTTP | When |
|---|---|
| 401 | `Authorization` missing, or the key does not exist or was deleted |
| 404 | No route matches |
| 405 | Wrong HTTP method for the path |
| 409 | Validation failed: `message` lists every problem, separated by commas |

```json
{ "code": 409, "success": false, "message": " O campo \"name\" é obrigatório" }
```
