# createTask

> POST /createTask starts a solve and returns its taskId, in the 2Captcha, Anti-Captcha, CapMonster and CapSolver format.

Source: https://docs.peak.fo/docs/compat/create-task

`POST https://api.peak.fo/createTask`

Checks the task, starts the solve and returns a `taskId` straight away. Then poll [getTaskResult](/docs/compat/get-task-result) for the result.

The body is JSON. It's read as JSON even if your client sends another `Content-Type`.

## Request [#request]

| Field         | Type     | Required | Description                                                                                              |
| ------------- | -------- | -------- | -------------------------------------------------------------------------------------------------------- |
| `clientKey`   | `string` | Yes      | Your Peak Solutions API key, which starts with `pk_`.                                                    |
| `task`        | `object` | Yes      | The task. Its fields are below.                                                                          |
| `appId`       | `string` | No       | Your app ID, if you build a tool on Peak Solutions. See [App IDs](/docs/earn#app-ids).                   |
| `softId`      | any      | No       | Accepted and ignored.                                                                                    |
| `languagePool`| `string` | No       | Accepted and ignored.                                                                                    |
| `callbackUrl` | `string` | No       | Accepted and ignored. Peak Solutions doesn't call back, so poll `getTaskResult`.                         |

### Task fields [#task-fields]

| Field                | Type               | Used by            | Description                                                                                                                  |
| -------------------- | ------------------ | ------------------ | ---------------------------------------------------------------------------------------------------------------------------- |
| `type`               | `string`           | All                | The task type. See [What each task type solves](/docs/compat#what-each-task-type-solves).                                    |
| `websiteURL`         | `string`           | All                | The page with the challenge. Required.                                                                                       |
| `websiteKey`         | `string`           | Turnstile          | The widget's sitekey. Required for Turnstile. See [Find the sitekey](/docs/find-sitekey).                                    |
| `action`             | `string`           | Turnstile          | The widget's `data-action`. Also read from `pageAction` (CapMonster) and `metadata.action` (CapSolver).                       |
| `cData`              | `string`           | Turnstile          | The widget's `data-cdata`. Also read from `data` (2Captcha, CapMonster) and `metadata.cdata` (CapSolver).                     |
| `proxyType`          | `string`           | With a proxy       | `http`, `https`, `socks4` or `socks5`. Defaults to `http`.                                                                   |
| `proxyAddress`       | `string`           | With a proxy       | The proxy's host name or IP.                                                                                                 |
| `proxyPort`          | `number`, `string` | With a proxy       | The proxy's port.                                                                                                            |
| `proxyLogin`         | `string`           | With a proxy       | The proxy username, if it has one.                                                                                           |
| `proxyPassword`      | `string`           | With a proxy       | The proxy password, if it has one.                                                                                           |
| `proxy`              | `string`           | With a proxy       | Or the whole proxy in one string, as CapSolver sends it: `host:port:user:pass`, `scheme:host:port:user:pass`, `host:port`, or a URL such as `http://user:pass@host:port`. Used instead of the fields above if set. |
| `userAgent`          | `string`           | 5-second challenge | The Windows Chrome user-agent your code sends.                                                                               |
| `htmlPageBase64`     | `string`           | 5-second challenge | The challenge page you loaded, base64-encoded (CapMonster).                                                                  |
| `html`               | `string`           | 5-second challenge | Or the challenge page as plain text (CapSolver).                                                                              |
| `cloudflareTaskType` | `string`           | CapMonster         | `cf_clearance` turns a `TurnstileTask` into a 5-second challenge solve.                                                       |

The 5-second challenge always needs your proxy, and the cookies only work from that proxy's IP. See [5-Second Challenge (WAF)](/docs/tasks/cloudflare-5s) for what to send.

## Examples [#examples]

```json tab="2Captcha / Anti-Captcha"
{
  "clientKey": "pk_your_api_key",
  "task": {
    "type": "TurnstileTaskProxyless",
    "websiteURL": "https://example.com/login",
    "websiteKey": "0x4AAAAAAA..."
  }
}
```

```json tab="CapMonster (cf_clearance)"
{
  "clientKey": "pk_your_api_key",
  "task": {
    "type": "TurnstileTask",
    "cloudflareTaskType": "cf_clearance",
    "websiteURL": "https://example.com/",
    "websiteKey": "xxxxxxxxxx",
    "htmlPageBase64": "PCFET0NUWVBFIGh0bWw+...",
    "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36",
    "proxyType": "http",
    "proxyAddress": "1.2.3.4",
    "proxyPort": 8080,
    "proxyLogin": "user",
    "proxyPassword": "pass"
  }
}
```

```json tab="CapSolver"
{
  "clientKey": "pk_your_api_key",
  "task": {
    "type": "AntiTurnstileTaskProxyLess",
    "websiteURL": "https://example.com/login",
    "websiteKey": "0x4AAAAAAA...",
    "metadata": { "action": "login" }
  }
}
```

```bash tab="cURL"
curl https://api.peak.fo/createTask \
  -H "Content-Type: application/json" \
  -d '{
    "clientKey": "pk_your_api_key",
    "task": {
      "type": "TurnstileTaskProxyless",
      "websiteURL": "https://example.com/login",
      "websiteKey": "0x4AAAAAAA..."
    }
  }'
```

## Response [#response]

```json tab="2Captcha, Anti-Captcha, CapMonster"
{
  "errorId": 0,
  "taskId": 4826153907261
}
```

```json tab="CapSolver"
{
  "errorId": 0,
  "taskId": "5f0c2b1e-8a4d-4c3e-9b7a-2d6e1f4a8c90"
}
```

```json tab="Error"
{
  "errorId": 10,
  "errorCode": "ERROR_ZERO_BALANCE",
  "errorDescription": "insufficient balance"
}
```

For 2Captcha, Anti-Captcha and CapMonster code, `taskId` is a number below 2<sup>53</sup>, so JavaScript reads it exactly. For CapSolver code (a `type` starting with `AntiTurnstile`, or `AntiCloudflareTask`), it's a UUID string.

Before a task is created, it gets every check the native API runs: the task is turned on, your balance covers it, the fields are there, the site isn't blocked, the proxy is valid, and you're under your rate limit. If a check fails, you get the error straight away and no task is created. See [Error codes](/docs/compat/errors).
