# Errors and rate limits

> The error envelope, the error codes you can rely on, and how fast each credential may call the API.

Every response outside the 2xx range uses the same envelope:

```json
{
  "error": {
    "code": "invalid_request",
    "message": "Invalid request",
    "requestId": "9f0c1c2e-6a4b-4d3e-8f2a-1b0c9d8e7f6a",
    "docs": "https://reminix.com/docs/errors/#invalid_request",
    "details": [{ "path": "name", "message": "Required" }]
  }
}
```

| Field       | What it is                                                                       |
| ----------- | -------------------------------------------------------------------------------- |
| `code`      | One of a small, stable set of codes. Branch on this.                             |
| `message`   | A sentence for people. It may change, so don’t parse it.                         |
| `requestId` | Matches the `X-Request-Id` response header. Include it when you contact support. |
| `details`   | Only on validation errors: one entry per field, with its `path` and `message`.   |
| `docs`      | A link to the code’s entry on this page.                                         |

## Successful responses

A request that works returns one of these:

| Status | When                                                                                        |
| ------ | ------------------------------------------------------------------------------------------- |
| `200`  | The request worked, and the body holds the result.                                          |
| `201`  | The request created something. The body is the new resource, and `Location` holds its path. |
| `202`  | We accepted the request and finish it in the background.                                    |
| `204`  | The request worked, and there’s nothing to return, such as after a removal.                 |

Starting a run returns one of two:

* `201` with the finished run, whether it succeeded or failed.
* `202` with a run that is still in progress or waits for a person’s approval. A [long run](/docs/long-runs/) always returns `202`.

`Location` is a path under `/v1`, such as `/v1/runs/run_620f14ad-32e8-4f5e-89fd-1c80de7e9124`. Send a `GET` to it to read the resource again. Starting a run sends `Location` with both statuses.

## Error codes

We may add new codes over time. Treat a code you don’t recognise as `internal_error`.

### `unauthorized`

`401`. The credential is missing, malformed, invalid, revoked or expired. Send `Authorization: Bearer <key or token>` with a working credential. If someone revoked the credential or it has expired, create a new one.

### `forbidden`

`403`. The credential is valid but isn’t allowed to do this. There are three possible causes:

* The credential doesn’t have the endpoint’s [scope](/docs/authentication/#permissions).
* Your role in the workspace doesn’t allow the action.
* A personal access token can’t act in the workspace named by `X-Workspace`.

Use a credential with the access it needs. The `message` names the missing scope.

### `not_found`

`404`. The resource doesn’t exist, or it isn’t yours to see. Check the path and the id. An id from another workspace also counts as not found.

### `method_not_allowed`

`405`. The path exists, but not with this method. Use one of the methods in the `Allow` response header.

### `invalid_request`

`400`. The request didn’t pass validation. `details` lists each invalid field with its `path` and `message`. If the request body is larger than the endpoint accepts, the API returns `413` with the same code.

### `rate_limited`

`429`. Something is busy for now, and waiting helps. There are three possible causes:

* The credential has used up its quota. [API rate limits](#api-rate-limits) has the numbers.
* You’re starting a run, and the workspace already has as many runs in progress as its plan allows at once: 1 on Free, 5 on Pro and 15 on Business. [Plan limits](/docs/plans/) has the details.
* You’re starting a [long run](/docs/long-runs/), and the workspace already has as many long runs in progress as its plan allows at once: 2 on Pro and 5 on Business.

Wait the number of seconds in `Retry-After`, then retry.

### `plan_limit_reached`

`402`. The request needs more than the workspace’s plan includes. There are two possible causes:

* The workspace has used up a monthly allowance, such as runs or long-run minutes. The message says which allowance ran out and when it resets.
* The request asks for something the plan doesn’t include, such as a long run on Free or a file larger than the plan accepts. The message says which.

We email and notify the workspace’s owners when it reaches 80% of a monthly allowance, and again at 100%. To carry on, upgrade the plan under **Settings → Billing** or wait for the month to reset. Retrying before then gets the same response.

### `workspace_suspended`

`403`. We paused the workspace. We do this only in rare cases, such as abuse of the service, as our [terms](/terms/) describe. Nothing in it is deleted, and its owners have an email from us explaining why. While it’s paused, its schedules and triggers skip their times, and a run waiting for approval waits until we lift the pause. To ask about it, write to the address in the `message`.

### `idempotency_key_reused`

`409`. This `Idempotency-Key` was already used for a different request. Use a new key for each new operation, and reuse a key only to retry the same request. [Idempotency](/docs/idempotency/) explains how keys work.

### `idempotency_in_progress`

`409`. A request with the same `Idempotency-Key` is still running. Wait the number of seconds in `Retry-After`, then retry with the same key.

### `conflict`

`409`. The request is valid, but it clashes with the current state of what it changes. For example, another script already has the slug, or the run you’re cancelling has already ended. The `message` says what clashed. Read the resource again, then decide what to do. Retrying the same request gets the same error.

### `internal_error`

`500`. Something failed on our side. Retry with backoff, and if the error keeps happening, contact support with the `requestId`.

### `unavailable`

`503`. We couldn’t serve the request right now, for example because we couldn’t check your API key for a moment. Nothing happened. The response always carries `Retry-After`. Wait that many seconds, then retry the same request.

## API rate limits

Every authenticated request counts against a quota for its credential:

| Endpoints           | Quota counted per                                                    |
| ------------------- | -------------------------------------------------------------------- |
| Workspace endpoints | API key, personal access token or connected app, in each environment |
| `/v1/user/*`        | Token                                                                |

Each credential may make up to 100 requests a minute. Each of Cloudflare’s locations keeps its own count, so the limit is approximate. Requests that reach two locations count separately. When the quota runs out, the API returns `429` with `code: "rate_limited"`:

```http
HTTP/1.1 429 Too Many Requests
Retry-After: 15
```

`Retry-After` is the number of seconds left until the quota’s minute starts again, so it is between 1 and 60. Wait that long, then retry. Each credential has its own limit, so one busy integration never slows down another.
