# Errors and limits

> What each status means, which requests are safe to repeat, and the rate limits.

Source: https://lernexa.com/docs/developers/language-test/errors-and-limits

Every answer is JSON. An error is one sentence that says what to fix:

```json
{ "error": "Check email (a valid email address)." }
```

| Status | Meaning                                                                                         | What to do                         |
| ------ | ----------------------------------------------------------------------------------------------- | ---------------------------------- |
| `400`  | The request is not what the route takes: not JSON, a field missing, wrong or unknown.          | Fix the fields the sentence names. |
| `401`  | No key, an unknown key or a revoked key.                                                        | Check the key.                     |
| `404`  | No such route, or no test with that `externalId` in your school.                                | Check the path and the id.         |
| `422`  | Understood, but refused: a language the test does not cover, say.                               | Read the sentence. Do not retry.   |
| `429`  | Too many requests.                                                                              | Wait, then retry. See below.       |
| `5xx`  | Something failed on our side.                                                                   | Retry later.                       |

## Safe to repeat

- `GET` requests: always.
- `POST /tests` **with an `externalId`**: always. A repeat returns the first test and emails nobody.
  See [Retrying safely](https://lernexa.com/docs/developers/language-test/creating-tests#retrying-safely).
- `POST /tests` without an `externalId`: a repeat creates another test.

A sensible client retries `5xx` with a growing pause (1, 2, 4, 8 seconds…) and gives up after a
few tries. On `429`, it waits a full minute before trying again, as the limits count by the minute,
or an hour after "Too many tests created with this key in an hour". It never retries `400`, `401`
or `422` unchanged.

## Rate limits

| Limit                       | Value                                      |
| --------------------------- | ------------------------------------------ |
| Requests per key            | 600 a minute                               |
| Requests from one address   | 1,200 a minute, whatever the key           |
| Tests created per key       | 1,000 an hour                              |

Zapier sends every account's requests from a shared set of addresses, so the per-address limit
counts more than your own requests there. It is far above what one school needs.
