# createTask

> POST /createTask creates a captcha task. Request fields (clientKey, task, softID), the order of checks, asynchronous types return a taskId and synchronous types return the solution; the balance must be above 10 points.

Source: https://docs.yescaptcha.com/en/api/create-task/ · Last verified: 2026-10-15

`createTask` creates a recognition task; `task.type` says which captcha to solve. Asynchronous types return a `taskId` that you then pass to [`getTaskResult`](https://docs.yescaptcha.com/en/api/get-task-result/); synchronous types return the result directly. The task is charged when it is created successfully, and your balance must be above 10 points.

- POST `https://api.yescaptcha.com/createTask` (Global endpoint)
- POST `https://cn.yescaptcha.com/createTask` (China endpoint)

## Request fields

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `clientKey` | string | Yes | Your account key, copied from the [yescaptcha.com](https://yescaptcha.com/) dashboard |
| `task` | object | Yes | The task object. It must contain `type`; other fields depend on the task type (see each task type page) |
| `softID` | integer | No | A developer ID. Include yours when other people use your software to receive a revenue share; see [Developer revenue share](https://docs.yescaptcha.com/en/account/developer/) |

## Request examples

Read an image captcha (synchronous):

```json
{
  "clientKey": "YOUR_CLIENT_KEY",
  "task": {
    "type": "ImageToTextTaskOcrBase",
    "body": "BASE64_IMAGE"
  }
}
```

Get a reCAPTCHA v2 token (asynchronous):

```json
{
  "clientKey": "YOUR_CLIENT_KEY",
  "task": {
    "type": "NoCaptchaTaskProxyless",
    "websiteURL": "https://www.google.com/recaptcha/api2/demo",
    "websiteKey": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-"
  }
}
```

The `task` fields of each type are on the pages under [Task types and pricing](https://docs.yescaptcha.com/en/tasks/).

## Response

Asynchronous types:

```json
{ "errorId": 0, "taskId": "61138bb6-19fb-11ec-a9c8-0242ac110006" }
```

Keep the `taskId` and start calling `getTaskResult` 5 seconds later.

Synchronous types:

```json
{
  "errorId": 0,
  "status": "ready",
  "taskId": "2376919c-1863-11ec-a012-94e6f7355a0b",
  "solution": { "text": "LMResm" }
}
```

Failure:

```json
{ "errorId": 1, "errorCode": "ERROR_TASK_NOT_SUPPORTED", "errorDescription": "任务类型不正确或不受支持" }
```

## Order of checks

The server checks a request in this order and returns the first error it finds. None of these are charged:

1.  The body is valid JSON: `ERROR_REQUEST_FORMATS`
2.  `clientKey` is present: `ERROR_REQUIRED_FIELDS`
3.  `clientKey` exists: `ERROR_KEY_DOES_NOT_EXIST`
4.  The key is not paused: `ERROR_IP_BLOCKED_5MIN` (see [Rate limits](https://docs.yescaptcha.com/en/api/rate-limits/))
5.  The balance is above 10 points: `ERROR_ZERO_BALANCE`
6.  `task` is present: `ERROR_TASK_ABSENT`
7.  `task.type` exists: `ERROR_TASK_NOT_SUPPORTED`
8.  All required fields are present: `ERROR_REQUIRED_FIELDS` (`errorDescription` names the missing field)
9.  For image tasks, the image is valid: `ERROR_ZERO_CAPTCHA_FILESIZE`, `ERROR_IMAGE_TYPE_NOT_SUPPORTED` and others

## Complete example

Create a task and poll for the result (asynchronous type):

**curl**

```bash
curl -s https://api.yescaptcha.com/createTask \
  -H 'Content-Type: application/json' \
  -d '{
  "clientKey": "YOUR_CLIENT_KEY",
  "task": {
    "type": "NoCaptchaTaskProxyless",
    "websiteURL": "https://www.google.com/recaptcha/api2/demo",
    "websiteKey": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-"
  }
}'
curl -s https://api.yescaptcha.com/getTaskResult \
  -H 'Content-Type: application/json' \
  -d '{"clientKey": "YOUR_CLIENT_KEY", "taskId": "TASK_ID"}'
```

**Python**

solve.py

```python
import os
import time

import requests

API = "https://api.yescaptcha.com"
CLIENT_KEY = os.environ["YESCAPTCHA_CLIENT_KEY"]  # Read the clientKey from an environment variable

def call(method, payload):
    r = requests.post(f"{API}/{method}", json={"clientKey": CLIENT_KEY, **payload}, timeout=30)
    data = r.json()
    if data.get("errorId"):
        raise RuntimeError(f"{data.get('errorCode')}: {data.get('errorDescription')}")
    return data

def solve(task):
    task_id = call("createTask", {"task": task})["taskId"]
    for _ in range(36):  # Poll every 5 seconds, for up to about 3 minutes
        time.sleep(5)
        result = call("getTaskResult", {"taskId": task_id})
        if result.get("status") == "ready":
            return result["solution"]
    raise TimeoutError(task_id)

solution = solve({
    "type": "NoCaptchaTaskProxyless",
    "websiteURL": "https://www.google.com/recaptcha/api2/demo",
    "websiteKey": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
})
print(solution["gRecaptchaResponse"])
```

**Node.js**

solve.mjs

```js
const API = 'https://api.yescaptcha.com';
const CLIENT_KEY = process.env.YESCAPTCHA_CLIENT_KEY; // Read the clientKey from an environment variable

async function call(method, payload) {
  const res = await fetch(`${API}/${method}`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ clientKey: CLIENT_KEY, ...payload }),
  });
  const data = await res.json();
  if (data.errorId) throw new Error(`${data.errorCode}: ${data.errorDescription}`);
  return data;
}

async function solve(task) {
  const { taskId } = await call('createTask', { task });
  for (let i = 0; i < 36; i++) { // Poll every 5 seconds, for up to about 3 minutes
    await new Promise((r) => setTimeout(r, 5000));
    const result = await call('getTaskResult', { taskId });
    if (result.status === 'ready') return result.solution;
  }
  throw new Error(`timeout: ${taskId}`);
}

const solution = await solve({
  type: "NoCaptchaTaskProxyless",
  websiteURL: "https://www.google.com/recaptcha/api2/demo",
  websiteKey: "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
});
console.log(solution.gRecaptchaResponse);
```
