# Errors (/docs/api/errors)
A failed request returns a non-2xx status and a JSON body that says what went wrong. Match on the status first, then on the error code when there is one.

## Status codes [#status-codes]

| Status | Meaning | Retry |
| --- | --- | --- |
| `200` | Success. | |
| `207` | Ingest only. Some events were stored and some were rejected. | Fix the rejected events |
| `400` | The request is malformed, such as an ID that isn't a valid UUID. | No |
| `401` | The API key is missing, malformed, revoked, paused, or expired. | No |
| `402` | Your plan's monthly limit is used up. | No |
| `403` | The key isn't allowed this request. | No |
| `404` | The engine or memory space doesn't exist in the key's workspace, or the route doesn't exist. | No |
| `409` | The request conflicts with the current state. | Yes |
| `413` | The body is too large. | No |
| `422` | A field failed validation, or every event in an ingest was rejected. | No |
| `429` | A rate limit was hit. | Yes, after `Retry-After` |
| `500`, `502`, `503`, `504` | Docklee couldn't complete the request. | Yes |

## Error bodies [#error-bodies]

Most errors carry a `detail` message:

```json
{
  "detail": "Invalid API key."
}
```

Errors from ingest also carry a machine-readable code:

```json
{
  "detail": {
    "error": "ke_runtime_denied",
    "message": "API key does not enable the KE runtime."
  }
}
```

Validation errors list each field that failed:

```json
{
  "detail": [
    {
      "loc": ["body", "top_k"],
      "msg": "Input should be less than or equal to 50",
      "type": "less_than_equal"
    }
  ]
}
```

## Error codes [#error-codes]

| Code | Status | Meaning |
| --- | --- | --- |
| `missing_destination` | `422` | An ingest named neither a `container` nor a `memory_space_id`. |
| `invalid_memory_space_id` | `400` | The `memory_space_id` isn't a valid UUID. |
| `ke_runtime_denied` | `403` | The key doesn't include the Knowledge Engines runtime. |
| `rate_limit_exceeded` | `429` | An ingest rate limit was hit. |

## Per-event errors [#per-event-errors]

An ingest reports each rejected event in `errors`, with the event's `index`:

| Code | Meaning |
| --- | --- |
| `duplicate_event` | The same content arrived within 60 seconds. |
| `memory_space_not_authorized` | The key can't write to the memory space. |
| `ke_ingestion_failed` | The event couldn't be stored in the container. The `message` says why. |
| `dum_ingestion_failed` | The event couldn't be stored in the memory space. The `message` says why. |

## In the SDKs [#in-the-sdks]

Each status maps to its own error class, such as `AuthenticationError` for `401` and `RateLimitError` for `429`. See [Errors and retries](/docs/sdks/errors-and-retries).

## Next steps [#next-steps]

You can read every error. Learn how much traffic a key can send next.

<Cards>
  <Card title="Rate limits" href="/docs/api/rate-limits" description="Request limits and the Retry-After header." />
  <Card title="Ingest events" href="/docs/api/ingest" description="Where per-event errors come from." />
  <Card title="Errors and retries" href="/docs/sdks/errors-and-retries" description="How the SDKs handle errors." />
</Cards>
