Skip to Content
AnySolver logo
AnySolver
Sync

solveTask

Create a CAPTCHA task and receive its result in one request with solveTask, which waits up to 80 seconds and charges exactly as createTask does.

solveTask takes the createTask body, waits up to 80 seconds for the task to finish, and answers with the getTaskResult body. It charges exactly as createTask does.

POSThttps://api.anysolver.com/solveTask

Sync or async

solveTask creates the same task createTask would, with the same charge, routing, Auto Retry, Auto Fallback and limits. Only the way you collect the result changes:

How a task's result reaches you with createTask and getTaskResult, compared with solveTask
Async: createTask + getTaskResult
Recommended default
  1. POST /createTaskreturnstaskId
    answers at once
  2. POST /getTaskResultreturnsprocessing
    repeat, as often as every 0.5 s
  3. POST /getTaskResultreturnsready + solution
    on the first poll after the solve
Sync: solveTask
Lowest latency
  1. POST /solveTaskreturnsconnection held
    while the task runs
  2. same requestreturnsready + solution
    the moment the task finishes
  3. after about 80 sreturnsprocessing + taskId
    then poll getTaskResult
FlowUse it when
createTask, then getTaskResultBy default. No connection stays open while a task runs, a network drop or restart on your side loses nothing, and any HTTP client timeout works.
solveTaskA user or a browser session waits on the solve. The answer arrives when the task finishes, with no polling interval added.

Authentication

Send your API key as clientKey in the JSON body, with the header Content-Type: application/json. A missing clientKey returns VALIDATION_ERROR, and an unknown key returns ERROR_KEY_DOES_NOT_EXIST.

Request body

The body is the same as for createTask. Every field, settings option and proxy format works as described on createTask, and each task type's fields are on its page under Tasks.

FieldTypeRequiredDescription
clientKey*
stringYes

Your API key. Create one in a workspace of the AnySolver dashboard.

task*
objectYes

The task body. Required fields depend on the task type. See Tasks for per-task schemas.

settings
objectNo

Per-request settings for routing, Auto Retry, Auto Fallback, proxy reuse, response statistics and detailed analytics. Each field overrides the API key's value. See Routing modes.

solveTask accepts a body of up to 32 MiB, the same as createTask (Request size lists every endpoint). A larger body returns VALIDATION_ERROR with Request body exceeds the maximum allowed size., before any charge.

Example

{
    "clientKey": "YOUR_API_KEY",
    "task": {
        "type": "ReCaptchaV2TokenProxyLess",
        "websiteURL": "https://example.com",
        "websiteKey": "6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI",
        "pageTitle": "Example Domain"
    }
}

Response body

The body is the same as for getTaskResult. Branch on status:

statusMeaningNext step
readyThe task is solved. solution and cost are set.Use the solution.
failedThe task failed, or the request was refused before a task existed. A refused request has no taskId.Read errorCode; see Errors.
processingThe wait ended before the task finished; see How long it waits.Poll getTaskResult with taskId.
FieldTypeRequiredDescription
status*
Yes

Task status: "processing", "ready", or "failed".

Example: ready

errorId*
Yes

0 on success; 1 or 2 on an error. Branch on errorCode: Error IDs explains the two error groups.

Example: 0

taskId
stringNo

Unique identifier returned when the task was created.

Example: 01KFNDF328KAN2AJ3BNHCQYE88

errorCode
No

Machine-readable error code.

Example: CAPTCHA_UNSOLVABLE

errorDescription
stringNo

Human-readable error message with resolution hints.

Example: The captcha could not be solved.

cost
numberNo

Actual cost charged for this task in USD.

Example: 0.002

taskType
No

The type of CAPTCHA task to solve.

Example: ReCaptchaV2TokenProxyLess

provider
No

Provider that handled this task. While processing, the provider currently solving it.

Example: Multibot

How long it waits

solveTask holds the request for up to 80 seconds from its arrival, then answers with status: "processing" and the taskId. The wait also ends early, with the same answer, when the AnySolver server restarts. The task keeps running either way and finishes within the same 30-minute lifetime as any other task.

Still processing after the wait
{
    "errorId": 0,
    "status": "processing",
    "taskId": "01KFNDF328KAN2AJ3BNHCQYE88"
}

Set your HTTP client's timeout to at least 90 seconds, so the connection stays open until AnySolver answers.

Set your HTTP timeout to at least 90 seconds

If your client closes the connection before AnySolver answers, you never receive the taskId. The task still runs and is still charged if it succeeds. Many HTTP clients default to 30 or 60 seconds.

Full example

This program calls solveTask with a 90-second timeout, and polls getTaskResult when the answer is processing:

const API_URL = 'https://api.anysolver.com';
const API_KEY = 'YOUR_API_KEY';
// Longer than solveTask's wait of about 80 seconds, so its answer always arrives.
const SOLVE_TIMEOUT_MS = 90_000;
const POLL_INTERVAL_MS = 1_000;
const POLL_TIMEOUT_MS = 31 * 60_000;

const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

async function call(endpoint, params, timeoutMs = 30_000) {
    const response = await fetch(`${API_URL}/${endpoint}`, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ clientKey: API_KEY, ...params }),
        signal: AbortSignal.timeout(timeoutMs),
    });
    const data = await response.json();
    if (data.errorId !== 0) throw new Error(`${data.errorCode}: ${data.errorDescription}`);
    return data;
}

async function solve(task) {
    let result = await call('solveTask', { task }, SOLVE_TIMEOUT_MS);
    // Still running after the wait: continue exactly like the createTask flow.
    const deadline = Date.now() + POLL_TIMEOUT_MS;
    while (result.status === 'processing' && Date.now() < deadline) {
        await sleep(POLL_INTERVAL_MS);
        result = await call('getTaskResult', { taskId: result.taskId });
    }
    if (result.status !== 'ready') throw new Error(`Task ${result.taskId} did not finish in time`);
    return result.solution;
}

solve({
    type: 'ReCaptchaV2TokenProxyLess',
    websiteURL: 'https://www.google.com/recaptcha/api2/demo',
    websiteKey: '6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-',
    pageTitle: 'ReCAPTCHA demo',
}).then((solution) => console.log('Token:', solution.token));

Errors

A refused request returns the same codes as createTask, with status: "failed" added and no taskId. A refused request is not charged. A task that fails returns the same codes as getTaskResult, with its taskId. Errors arrive with HTTP 200, so branch on errorId and status. Every code: Error handling.