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

# Errors

> HTTP status codes and error handling

## Error Format

Errors return JSON with a `detail` field:

```json theme={"theme":"github-dark"}
{
  "detail": "Invalid or missing API key."
}
```

Validation errors (422) include field-level details:

```json theme={"theme":"github-dark"}
{
  "detail": [
    {
      "loc": ["body", "query"],
      "msg": "Field required",
      "type": "missing"
    }
  ]
}
```

## Status Codes

| Code  | Meaning          | Action                                                                                 |
| ----- | ---------------- | -------------------------------------------------------------------------------------- |
| `200` | Success          |                                                                                        |
| `401` | Unauthorized     | Check your API key and `Authorization` header                                          |
| `402` | Payment Required | Check your account dashboard.                                                          |
| `404` | Not Found        | Resource does not exist                                                                |
| `422` | Validation Error | Check request body for missing or invalid fields                                       |
| `429` | Rate Limited     | Back off and retry with exponential backoff                                            |
| `500` | Internal Error   | Retry after a brief delay. [Contact support](mailto:contact@vaquill.ai) if it persists |

## Rate Limiting

Limits are enforced per API key and scale with your plan. Every `429` response includes a `Retry-After` header.

| Plan         | Per minute | Per hour | Per day |
| ------------ | ---------- | -------- | ------- |
| API          | 30         | 500      | 2,000   |
| API Business | 150        | 2,500    | 10,000  |

On `429`, implement exponential backoff:

```python theme={"theme":"github-dark"}
import time
import requests

def search_with_retry(query, max_retries=3):
    for attempt in range(max_retries):
        response = requests.post(
            "https://api.vaquill.ai/api/v1/statutes/search",
            headers={"Authorization": "Bearer vq_key_..."},
            json={"query": query}
        )
        if response.status_code == 429:
            time.sleep(2 ** attempt)
            continue
        return response
    raise Exception("Max retries exceeded")
```

## Troubleshooting

<AccordionGroup>
  <Accordion title="401 but my key is correct">
    Include the `Bearer` prefix: `Authorization: Bearer vq_key_...`. The key alone is rejected.
  </Accordion>

  <Accordion title="422 validation error">
    Set `Content-Type: application/json`. Check the `loc` field in the response to find the problematic field.
  </Accordion>
</AccordionGroup>
