# Errors

> What the HTTP status codes of the Quenza API mean, what the error responses contain, and how your integration should handle each one.

Source: https://quenza.com/help/api/errors/

When a request fails, Quenza answers with a status code of 400 or higher and a JSON body with a `message` in English:

```json
{ "message": "Workspace is not active." }
```

The message is meant for you, not for your users: show your own text in your app, and log Quenza's message.

| Status | Meaning | Try again? |
| --- | --- | --- |
| `401` | The token is missing or wrong. | No, fix the token. |
| `402` | The workspace has no active subscription or trial. | No. |
| `403` | The workspace's plan does not include the API. | No. |
| `404` | The ID in the URL matches nothing in your workspace. | No. |
| `406` | The request does not accept JSON. | No, fix the headers. |
| `415` | The body is not sent as JSON. | No, fix the headers. |
| `422` | A field is missing or wrong, or a limit is reached. | After you fix the data. |
| `429` | Too many requests in a short time. | Yes, after waiting. |

## 401 Unauthenticated

The `Authorization` header is missing, or the token is wrong, regenerated or not an API token. [Authentication](https://quenza.com/help/api/authentication/#when-authentication-fails) lists the messages.

## 402 Workspace not active

```json
{ "message": "Workspace is not active." }
```

The workspace has no active subscription and no trial. The API works again once the subscription is active.

## 403 Not on your plan

```json
{ "message": "This feature is not available on your current plan.", "upgrade_required": true }
```

The API is included in the Collective and Beyond plans. See [Plans and pricing](https://quenza.com/help/billing/plans-and-pricing/).

## 404 Not found

The ID in the URL belongs to no client, group or member in the token's workspace. IDs from another workspace also answer with `404`.

## 406 Not acceptable

```json
{ "message": "The Accept header must be application/json." }
```

Send `Accept: application/json` with every request. Without any `Accept` header, some errors answer with a redirect to the Quenza login page instead of JSON, so always send it.

## 415 Wrong content type

```json
{ "message": "The Content-Type header must be application/json." }
```

Every `POST` and `PATCH` needs `Content-Type: application/json`, also [Archive a client](https://quenza.com/help/api/clients/archive-a-client/) and [Unarchive a client](https://quenza.com/help/api/clients/unarchive-a-client/), which have no body.

## 422 Validation error

A field is missing or has a value Quenza does not accept. `errors` lists every problem by field name:

```json
{
  "message": "The email has already been taken. (and 1 more error)",
  "errors": {
    "email": ["The email has already been taken."],
    "timezone": ["The selected timezone is invalid."]
  }
}
```

Each endpoint lists its fields and their limits. A taken email is the most common case: the client or member is already in your workspace. [Sync clients from your CRM](https://quenza.com/help/api/guides/sync-clients/) shows how to find them.

`422` also means a limit of your plan is reached, for example when you create a client while all client places are taken:

```json
{ "message": "Limit reached for App\\Models\\Client", "limit": 100 }
```

`limit` is the number your plan includes. Archived and invited clients count too, so archiving does not free a place: delete clients you no longer need in Quenza, or change your plan. See [Client limits](https://quenza.com/help/billing/client-limits/). For team members the message ends in `Professional`; see [Professional seats](https://quenza.com/help/billing/professional-seats/).

## 429 Too many requests

You sent too many requests in a short time. Wait the number of seconds in the `Retry-After` header, then send the request again. The limit is high enough for normal integrations; it is usually reached by a loop that never stops.
