# Overview

> The base URL, every endpoint, and the shape of every response.

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

## Base URL [#base-url]

```txt
https://api.peak.fo
```

Every request goes over HTTPS. Request bodies are JSON, and so is every response.

## Endpoints [#endpoints]

| Method | Path                            | What it does                     | Needs a key |
| ------ | ------------------------------- | -------------------------------- | ----------- |
| `POST` | [`/solve`](/docs/api/solve)       | Solves a task.                              | Yes         |
| `POST` | [`/feedback`](/docs/api/feedback) | Reports whether a solve's result worked.    | Yes         |
| `GET`  | [`/balance`](/docs/api/balance)   | Returns what your key can spend.            | Yes         |
| `GET`  | [`/health`](/docs/api/health)     | Checks that the API is up.                  | No          |

Send your key in the `X-API-Key` header. See [Authentication](/docs/authentication).

Moving from 2Captcha, Anti-Captcha, CapMonster or CapSolver? The same base URL also answers their `createTask` API: `/createTask`, `/getTaskResult`, `/getBalance`, `/reportIncorrect`, `/reportCorrect` and `/feedbackTask`. See [Switch from another solver](/docs/compat).

The whole API is also described in an [OpenAPI 3.1 spec](/openapi.json), for code generators and AI agents. See [Build with AI](/docs/ai).

## Responses [#responses]

`/solve` and `/balance` always answer with the same envelope:

| Field        | Type      | Description                                                                                             |
| ------------ | --------- | ------------------------------------------------------------------------------------------------------- |
| `success`    | `boolean` | `true` if the request worked.                                                                           |
| `data`       | `object`  | The result. Only when `success` is `true`.                                                              |
| `cost`       | `number`  | What the solve was charged, in USD. Only on a successful `/solve`.                                      |
| `error`      | `string`  | What went wrong, in words. Only when `success` is `false`.                                              |
| `error_code` | `string`  | What went wrong, as a stable code. Only when `success` is `false`. See [Error codes](/docs/api/errors). |
| `task_id`    | `string`  | The solve's id. On `/solve`, when a solve was tried, whether it worked or not. Send it to [`/feedback`](/docs/api/feedback), or to support. |

```json tab="Success"
{
  "success": true,
  "data": {
    "token": "0.AgAAAB..."
  },
  "cost": 0.0009,
  "task_id": "5f0c2b1e-8a4d-4c3e-9b7a-2d6e1f4a8c90"
}
```

```json tab="Failure"
{
  "success": false,
  "error": "Challenge was flagged - try using a different proxy with a cleaner IP reputation",
  "error_code": "challenge_flagged",
  "task_id": "5f0c2b1e-8a4d-4c3e-9b7a-2d6e1f4a8c90"
}
```

<Callout title="Handle errors by error_code">
  The `error` text is for people and its wording can change. `error_code` stays the same, so
  check that in your code.
</Callout>

## HTTP status codes [#http-status-codes]

| Status | Meaning                                                                                                          |
| ------ | ---------------------------------------------------------------------------------------------------------------- |
| `200`  | The request worked, or a solve was tried and failed. Check `success`.                                            |
| `400`  | The body isn't valid JSON, `task_type` is unknown, a required field is missing, or the proxy fields are invalid. |
| `401`  | The API key is missing, wrong, turned off, or expired, or the account is suspended.                              |
| `402`  | Not enough balance, the package is used up, or the key can't solve this task type.                               |
| `403`  | The target site or sitekey is blocked, or blocked for trial credit until you top up.                             |
| `404`  | `/feedback` only: no recent solve on your account has that `task_id`.                                            |
| `413`  | The body is over 4 MB.                                                                                           |
| `429`  | You're over your key's rate limit. See [Rate limits](#rate-limits).                                              |
| `500`  | Something went wrong on our side. Retry.                                                                         |
| `503`  | The task type is turned off for now, or no proxyless capacity is available. Retry later.                         |

You're only charged for a successful solve. Failed solves and rejected requests cost nothing.

## Rate limits [#rate-limits]

Each API key can start a set number of solves per minute. If you go over, your request waits in line for its turn, so a short burst usually just runs a little slower.

If the wait would be longer than 10 seconds, the request is rejected with HTTP `429`, the `rate_limited` error code, and a `Retry-After` header with the seconds to wait (currently always `1`). It isn't charged. The same happens if the whole service is over its limit, which is rare.

```json title="HTTP 429"
{
  "success": false,
  "error": "Rate limit exceeded - slow down or contact support for a higher limit",
  "error_code": "rate_limited"
}
```

Need a higher limit? [Contact support](/docs/support).
