# Errors and limits

> What can go wrong, what to do about it, and every limit, read from the server.

Every error the API can return, what to do about it, and every limit, read from the server.

## The shape of an error

Every error is JSON with a code you can branch on and a sentence written for a person:

```json
{ "error": { "code": "bad_space", "message": "A space is up to 128 letters, digits, dots, dashes or underscores, and starts with a letter or a digit." } }
```

| Status | Code | When |
| --- | --- | --- |
| 401 | `bad_key` | No key, a malformed key, or a key that was revoked |
| 403 | `wrong_key` | A key that is not a personal Geniffy key |
| 403 | `out_of_scope` | The key cannot reach that memory |
| 404 | `not_found` | No memory or source with that id, in that space |
| 413 | `too_large` | A file over 25 MB |
| 422 | `invalid_request` | A field missing or out of range; the message names it |
| 422 | `bad_space` | A space name with characters a space cannot have |
| 422 | `bad_kind` | A kind other than `people`, `plan`, `pref` or `detail` |
| 422 | `empty` | Nothing to add, or nothing to ask |
| 422 | `unreadable` | A file or page that could not be read, with the reason |
| 422 | `too_many` | A conversation of more than 500 messages in one call; send the rest in another |
| 429 | `busy` | Too many requests at once; try again shortly |
| 502 | `memory_unavailable` | The memory did not answer in time; try again |
| 503 | `not_ready` | The service is starting; try again shortly |

The SDKs raise these as typed errors: `AuthenticationError`, `NotFoundError`, `BadRequestError`,
`UnreadableError`, `RateLimitError`, `InternalServerError` and `APIConnectionError`.

## Retries

The SDKs retry reads twice on a network error, 408, 429 and 5xx, waiting a little longer each time and
honouring `Retry-After`. Adding is retried only when the request never reached Geniffy, or on 429, so a
retry never saves a note twice. Change it with `max_retries` and `timeout` (Python) or `maxRetries` and
`timeout` (TypeScript) on the client.

## Limits

| What | Limit |
| --- | --- |
| A note | 2,000,000 characters |
| A file | 25 MB, PDF or Word `.docx`; a scan with no text layer is refused, never guessed at |
| A web page | Public addresses only, 5 MB; a link to a PDF is read as a PDF |
| A batch | Up to 100 items |
| A conversation | Up to 500 messages in one call |
| A question | 2,000 characters |
| `context` limit | 1 to 50 memories, default 12 |
| `search` limit | 1 to 50 memories, default 10 |
| A space name | 128 characters |

## Request ids

Every response carries an `X-Request-ID`, and every SDK error carries it. See [Request ids](https://docs.geniffy.com/request-ids) for
finding any call again.

Source: https://docs.geniffy.com/errors
