Skip to content

createTask

createTask creates a recognition task; task.type says which captcha to solve. Asynchronous types return a taskId that you then pass to getTaskResult; synchronous types return the result directly. The task is charged when it is created successfully, and your balance must be above 10 points.

POSThttps://api.yescaptcha.com/createTaskGlobal endpoint
POSThttps://cn.yescaptcha.com/createTaskChina endpoint
Field Type Required Description
clientKey string Yes Your account key, copied from the 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

Read an image captcha (synchronous):

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

Get a reCAPTCHA v2 token (asynchronous):

{
"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.

Asynchronous types:

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

Keep the taskId and start calling getTaskResult 5 seconds later.

Synchronous types:

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

Failure:

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

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)
  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

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

终端窗口
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-"
}
}'
# Returns {"errorId":0,"taskId":"..."}; then poll every 5 seconds:
curl -s https://api.yescaptcha.com/getTaskResult \
-H 'Content-Type: application/json' \
-d '{"clientKey": "YOUR_CLIENT_KEY", "taskId": "TASK_ID"}'