# Errors

The format of errors, all codes and what to do about them.

Every error has the same format and a matching HTTP status:

```json
{
  "error": {
    "code": "no_tokens",
    "message": "You have no tokens left today. They renew at midnight UTC."
  }
}
```

In your program check `code`. It does not change, and `message` may.

## Access

| Status | Code | Meaning |
| --- | --- | --- |
| 401 | `unauthorized` | The API key is missing, wrong or revoked |
| 403 | `forbidden` | Your role in the team does not allow this |

## Request

| Status | Code | Meaning |
| --- | --- | --- |
| 422 | `invalid_request` | A field or parameter is missing or wrong, `message` says which one |
| 422 | `invalid_filter` | A [filter](/docs/guides/filters) has a wrong field, operator or value |
| 422 | `invalid_selector` | The CSS selector is not valid |
| 404 | `not_found` | There is no such result in your team |
| 409 | `crawl_not_ready` | The crawl has no results yet |
| 409 | `retry_in_progress` | Pages of this crawl are already being retried |

## Limits

| Status | Code | What to do |
| --- | --- | --- |
| 429 | `rate_limited` | Wait the number of seconds from `Retry-After` |
| 429 | `no_tokens` | Wait until midnight UTC, `Retry-After` says how many seconds |
| 429 | `too_many_crawls` | Wait for one of 3 crawls to end, or stop it |

## Page could not be fetched

A token is returned in all these cases.

| Status | Code | Meaning |
| --- | --- | --- |
| 422 | `invalid_url` | This is not a valid http or https address |
| 422 | `url_not_allowed` | A private or local address, or a port other than 80 and 443 |
| 422 | `dns_error` | The domain was not found |
| 422 | `too_many_redirects` | The page redirects more than 10 times |
| 422 | `unsupported_content` | The page uses an unsupported content encoding |
| 502 | `fetch_failed` | The server refused or dropped the connection |
| 504 | `timeout` | The page did not respond in 20 seconds |

In a crawl the same codes are in the `error` field of a page. A crawl that failed has a code in its own `error` field, where two more are possible: `robots_blocked`, when robots.txt does not allow the start page, and `sitemap_not_found`.

## On our side

Repeat the request after a moment.

| Status | Code | Meaning |
| --- | --- | --- |
| 503 | `busy` | The service is at capacity |
| 503 | `scraper_unavailable` | The scraper does not respond |
| 503 | `unavailable` | The service is temporarily unavailable |
| 500 | `internal_error` | An unexpected error |
