# Error codes

> Every error_code the API can return, and what to do about it.

Source: https://docs.peak.fo/docs/api/errors

Every failed response has an `error_code`, along with an `error` message:

```json
{
  "success": false,
  "error": "IP address is blocked by CloudFlare - use a different proxy with cleaner reputation",
  "error_code": "ip_blocked"
}
```

Check `error_code` in your code. It stays the same, while the `error` wording can change.

None of these are charged.

## Rejected requests [#rejected-requests]

The request was turned down before any solving, with a `4xx` or `5xx` status.

| `error_code`            | HTTP  | What happened                                                     | What to do                                                                      |
| ----------------------- | ----- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| `missing_api_key`       | `401` | No API key was sent.                                              | Send it in the `X-API-Key` header.                                              |
| `invalid_api_key`       | `401` | The key doesn't exist.                                            | Copy the key again from the dashboard.                                          |
| `api_key_inactive`      | `401` | The key was turned off, or its package expired or ran out of solves. | Use an active key.                                                           |
| `account_suspended`     | `401` | Your account is suspended.                                        | [Contact support](/docs/support).                                               |
| `auth_error`            | `401` | We couldn't check the key.                                        | Retry.                                                                          |
| `invalid_request_body`  | `400` | The body isn't valid JSON.                                        | Send a valid JSON body.                                                         |
| `request_too_large`     | `413` | The body is over 4 MB.                                            | Send a smaller body.                                                            |
| `invalid_task_type`     | `400` | `task_type` isn't a known task.                                   | Use a task type from [Solve](/docs/api/solve#request).                          |
| `missing_fields`        | `400` | A field the task needs is missing.                                | Add the fields that `error` lists.                                              |
| `invalid_proxy`         | `400` | The proxy parameters can't make a proxy.                     | Fix the field that `error` names. See [Proxies](/docs/proxies#proxy-parameters). |
| `task_not_authorized`   | `402` | This package key can't solve this task type.                      | Check `allowed_tasks` on [Balance](/docs/api/balance).                          |
| `insufficient_balance`  | `402` | Your balance is below the task's price.                           | [Top up](https://peak.fo/dashboard/topup).                                      |
| `package_exhausted`     | `402` | The package has no solves left. A few seconds later, the same key answers `api_key_inactive` instead. | Renew the package, or use a pay-per-solve key.                |
| `task_blocked`          | `403` | The target site or sitekey is blocked. If `error` says "for trial credits", it's only blocked until you top up. | [Top up](https://peak.fo/dashboard/topup) to unlock a trial block. Otherwise [contact support](/docs/support) if you think it's a mistake. |
| `task_not_found`        | `404` | [`/feedback`](/docs/api/feedback) only: no solve on your account in the last 24 hours has that `task_id`. | Check the `task_id`. A solve from the last few seconds may not be found yet. |
| `rate_limited`          | `429` | You're sending solves faster than your key's limit.               | Wait for `Retry-After`, then retry. See [Rate limits](/docs/api#rate-limits).   |
| `task_disabled`         | `503` | The task type is turned off for now.                              | Retry later.                                                                    |
| `proxyless_unavailable` | `503` | Proxyless solving isn't available right now.                      | Retry later, or use `turnstiletask` with your own proxy.                        |
| `billing_error`         | `500` | The solve worked, but charging failed, so the result wasn't sent. | Retry. You weren't charged.                                                     |
| `internal_error`        | `500` | Something went wrong on our side.                                 | Retry.                                                                          |

## Failed solves [#failed-solves]

Peak Solutions tried to solve the task and couldn't. These come back as HTTP `200` with `"success": false`.

| `error_code`             | Tasks               | What happened                                              | What to do                                                        |
| ------------------------ | ------------------- | ---------------------------------------------------------- | ----------------------------------------------------------------- |
| <span id="proxy_error" className="scroll-m-28" />`proxy_error`            | All                 | Your proxy failed or was rejected.                         | Check the [format](/docs/proxies#format) and that it's reachable. |
| <span id="timeout" className="scroll-m-28" />`timeout`                | All                 | The solve didn't finish in time.                           | Retry, or use a faster proxy closer to the site.                  |
| <span id="solve_failed" className="scroll-m-28" />`solve_failed`           | All                 | The solver couldn't produce a result.                      | Retry, if needed with a different proxy.                          |
| <span id="no_servers" className="scroll-m-28" />`no_servers`             | All                 | No solver for this task is free right now.                 | Retry in a few seconds.                                           |
| <span id="proxy_required" className="scroll-m-28" />`proxy_required`         | All                 | The task needed a proxy and none was available.            | Retry.                                                            |
| <span id="solver_error" className="scroll-m-28" />`solver_error`           | All                 | The solver ran into an error.                              | Retry.                                                            |
| <span id="unknown" className="scroll-m-28" />`unknown`                | All                 | Something else went wrong.                                 | Retry. [Contact support](/docs/support) if it keeps happening.    |
| <span id="challenge_flagged" className="scroll-m-28" />`challenge_flagged`      | Turnstile, 5-second | The challenge flagged the request, usually the proxy's IP. | Retry with a proxy that has a cleaner IP.                         |
| <span id="invalid_sitekey" className="scroll-m-28" />`invalid_sitekey`        | Turnstile, 5-second | The sitekey is wrong for that site.                        | Check the sitekey belongs to the page.                            |
| <span id="invalid_action" className="scroll-m-28" />`invalid_action`         | Turnstile, 5-second | `action` doesn't match the site.                           | Send the exact `data-action`, or leave it out.                    |
| <span id="invalid_cdata" className="scroll-m-28" />`invalid_cdata`          | Turnstile, 5-second | `cdata` doesn't match the site.                            | Send the exact `data-cdata`, or leave it out.                     |
| <span id="no_challenge" className="scroll-m-28" />`no_challenge`           | 5-second            | The page isn't showing a challenge.                        | Check the `url`, and that the page is challenged right now.       |
| <span id="ip_blocked" className="scroll-m-28" />`ip_blocked`             | 5-second            | Cloudflare blocked the proxy's IP.                         | Retry with a different proxy.                                     |
| <span id="unsupported_user_agent" className="scroll-m-28" />`unsupported_user_agent` | 5-second            | The user-agent isn't supported.                            | Send a Windows Chrome user-agent.                                 |
| <span id="invalid_html" className="scroll-m-28" />`invalid_html`           | 5-second            | The page couldn't be read.                                 | Check the `url`, and that `html` is the challenge page.           |
| <span id="invalid_request_data" className="scroll-m-28" />`invalid_request_data`   | 5-second            | The request data was rejected.                             | Check the `url` format, such as `https://example.com/`.           |
| <span id="turnstile_failed" className="scroll-m-28" />`turnstile_failed`       | 5-second            | The Turnstile inside the challenge failed. If that step timed out or the proxy failed, you get `timeout` or `proxy_error` instead. | Retry with a different proxy. |
