> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anonalabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Errors

# Error Reference

## Error Response Format

Every error follows this shape:

```json theme={null}
{
  "error": {
    "code": "error_code",
    "message": "Human-readable message",
    "request_id": "req_abc123"
  }
}
```

Include `request_id` when contacting support - it identifies the exact request server-side.

## HTTP Status Codes

| Code | Meaning                                                |
| ---- | ------------------------------------------------------ |
| 400  | Bad Request - invalid parameters or body               |
| 401  | Unauthorized - missing or invalid API key              |
| 403  | Forbidden - access denied to resource                  |
| 404  | Not Found - resource doesn't exist                     |
| 409  | Conflict - resource already exists / conflicting state |
| 422  | Unprocessable Entity - request fails schema validation |
| 429  | Too Many Requests - rate limit or quota exceeded       |
| 500  | Internal Server Error                                  |
| 503  | Service Unavailable - temporary degradation            |

***

## Error Codes

### `bad_request` (400)

Invalid request parameters or malformed body. Check required fields and types against the endpoint docs.

### `unauthorized` (401)

Missing or invalid API key.

```bash theme={null}
# ✅ Correct
Authorization: Bearer anona_live_YOUR_KEY

# ❌ Wrong
Authorization: anona_live_YOUR_KEY   # missing "Bearer"
X-API-Key: YOUR_KEY                  # wrong header
```

### `forbidden` (403)

The authenticated organization doesn't own the requested space or resource.

### `not_found` (404)

Memory, space, or resource doesn't exist, or the ID is misspelled.

### `conflict` (409)

Resource already exists or is in a conflicting state.

### `validation_error` (422)

Request body fails schema validation - check field types and required parameters.

### `rate_limited` (429)

Rate limit or quota exceeded. Retry with exponential backoff or upgrade your plan.

### `internal_error` (500)

Unexpected server error. Retry, and contact support with the `request_id` if it persists.

### `service_unavailable` (503)

Temporary degradation. Retry after a short delay.

***

## Retry Strategy

Retry `429`, `500`, and `503` with exponential backoff:

```python theme={null}
import time, random

def retry_with_backoff(func, max_retries=3):
    for attempt in range(max_retries):
        try:
            return func()
        except Exception:
            if attempt == max_retries - 1:
                raise
            time.sleep(2 ** attempt + random.uniform(0, 1))
```

## Handling Errors (Python SDK)

```python theme={null}
from anona import AnonaClient, AnonaError

client = AnonaClient(api_key="anona_live_YOUR_KEY")

try:
    results = client.search(space_id="spc_a1b2c3d4", query="Where does Alice work?")
except AnonaError as e:
    print(e.status_code, e.detail)
```

`AnonaError` has two attributes: `.status_code` (int) and `.detail` (the parsed error body, or raw text if not JSON).

***

## Next Steps

<CardGroup cols={2}>
  <Card title="API Reference" icon="rectangle-terminal" href="/api-reference/authentication">
    All API endpoints
  </Card>

  <Card title="Support" icon="headset" href="mailto:support@anonalabs.com">
    Contact support
  </Card>
</CardGroup>
