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

# Error Codes

> All error codes returned by the AmbientMeta API

## Error Response Format

All errors return a consistent format with actionable suggestions.

```json theme={null}
{
  "error": {
    "code": "error_code",
    "message": "Human-readable description",
    "suggestion": "How to fix it"
  }
}
```

## Error Reference

| Code                    | HTTP | Description                          | Suggestion                                  |
| ----------------------- | ---- | ------------------------------------ | ------------------------------------------- |
| `invalid_api_key`       | 401  | API key missing or invalid           | Check your API key in the dashboard         |
| `unauthorized`          | 401  | Could not resolve organization       | Verify your API key is valid                |
| `rate_limited`          | 429  | Too many requests                    | Wait and retry, or upgrade your plan        |
| `extension_daily_limit` | 429  | Chrome extension daily limit reached | Upgrade to Pro for unlimited use            |
| `session_not_found`     | 404  | Session ID doesn't exist             | Check the session\_id from sanitize         |
| `session_expired`       | 410  | Session has expired                  | Sessions last 24 hours, re-sanitize         |
| `empty_text`            | 400  | Text field is empty                  | Provide text to sanitize                    |
| `text_too_large`        | 413  | Text exceeds 100KB                   | Split into smaller chunks                   |
| `invalid_request`       | 400  | Malformed request body               | See API docs for the correct request format |
| `invalid_pattern`       | 400  | Regex pattern is invalid             | Check your pattern syntax                   |
| `pattern_not_found`     | 404  | Pattern ID doesn't exist             | List patterns to find valid IDs             |
| `insight_not_found`     | 404  | Insight ID doesn't exist             | List insights to find valid IDs             |
| `internal_error`        | 500  | An unexpected error occurred         | Try again or contact support                |

## Rate Limits

| Plan     | Requests/minute |
| -------- | --------------- |
| Free     | 20              |
| Pro      | 600             |
| Pro Plus | 2,000           |

## Rate Limit Headers

| Header                  | Description                      |
| ----------------------- | -------------------------------- |
| `X-RateLimit-Limit`     | Your rate limit                  |
| `X-RateLimit-Remaining` | Requests remaining               |
| `X-RateLimit-Reset`     | Unix timestamp when limit resets |

## Handling Errors in Python

```python theme={null}
from ambientmeta import AmbientMeta
from ambientmeta.exceptions import RateLimitError, NotFoundError

client = AmbientMeta(api_key="am_live_xxx")

try:
    result = client.sanitize(text)
except RateLimitError as e:
    print(f"Rate limited: {e.message}")
except NotFoundError:
    print("Session not found or expired, re-sanitize")
```
