Get Task Result
Code
POST https://solvercf.com/token/extension/getTaskResult
Polls a task created via Create Task. Call this repeatedly until status becomes ready, failed, or expired.
Request
| Field | Type | Required | Description |
|---|---|---|---|
clientKey |
string | yes | Your account API key |
taskId |
string | yes | The taskId returned by createTask |
JSON
{
"clientKey": "YOUR_CLIENT_KEY",
"taskId": "b2e1c1b0-..."
}
Response
| Field | Type | Description |
|---|---|---|
taskId |
string | Echoes the requested task |
status |
string | See Status values below |
cost |
number | Amount deducted from your balance for this task — only meaningful once status is ready |
solution.type |
string | token or cookie |
solution.token |
string | The solved token, when solution.type is token |
solution.cookie |
string | The solved cookie, when solution.type is cookie |
solution.userAgent |
string | User agent the task was solved with — submit the token together with this UA |
errorId |
int | 0 = success, 1 = failed |
errorCode / errorDescription |
string | Present when errorId is 1 — see Errors |
JSON
{
"taskId": "b2e1c1b0-...",
"status": "ready",
"cost": 0.0009,
"solution": {
"type": "token",
"token": "0.AbC123...",
"userAgent": "Mozilla/5.0 ..."
},
"errorId": 0
}
Important: always submit the solved token together with the
solution.userAgentreturned here — Cloudflare/Google validate the token against the user agent it was solved with. Using a different user agent when submitting the token will cause verification to fail.
Status values
status |
Meaning | Keep polling? |
|---|---|---|
created |
Waiting for a worker to pick it up | yes |
processing |
A worker has claimed it and is solving | yes |
ready |
Solved — solution is populated |
no, done |
failed |
A worker attempted it but couldn't solve it | no, create a new task |
expired |
No worker claimed it within 1 minute | no, create a new task |
Polling strategy
- Poll every 1–1.5 seconds. Polling faster doesn't make the task solve any quicker and just adds load.
- Give it a ~60–90 second budget. Per the task lifecycle, unclaimed tasks expire after 1 minute and claimed-but-unsolved tasks fail after 3 minutes — if you haven't gotten
ready/failed/expiredback by then, stop polling and treat it as a failure rather than looping forever. - Stop immediately on
failedorexpired— retrying the sametaskIdwon't help, since it's a terminal state. Create a new task instead.
Code examples
Example: cURL
cURL
curl -X POST https://solvercf.com/token/extension/getTaskResult \
-H "Content-Type: application/json" \
-d '{ "clientKey": "YOUR_CLIENT_KEY", "taskId": "TASK_ID_FROM_CREATE_TASK" }'
Run this once per poll — call it again every 1–1.5s (see Polling strategy above) until status is ready, failed, or expired.
Example: Python
Python
import time
import requests
def wait_for_result(task_id, client_key, timeout_seconds=90):
deadline = time.time() + timeout_seconds
while time.time() < deadline:
response = requests.post("https://solvercf.com/token/extension/getTaskResult", json={
"clientKey": client_key,
"taskId": task_id,
}).json()
if response["status"] == "ready":
return response["solution"]
if response["status"] in ("failed", "expired"):
raise Exception(f"task {response['status']}: {response.get('errorDescription')}")
time.sleep(1.5)
raise TimeoutError("gave up waiting for task result")
Example: JavaScript
JavaScript
async function waitForResult(taskId, clientKey, timeoutMs = 90_000) {
const deadline = Date.now() + timeoutMs;
while (Date.now() < deadline) {
const response = await fetch("https://solvercf.com/token/extension/getTaskResult", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ clientKey, taskId }),
}).then((r) => r.json());
if (response.status === "ready") return response.solution;
if (["failed", "expired"].includes(response.status)) {
throw new Error(`task ${response.status}: ${response.errorDescription ?? ""}`);
}
await new Promise((r) => setTimeout(r, 1500));
}
throw new Error("gave up waiting for task result");
}
Example: C#
C#
using var client = new HttpClient();
async Task<JsonElement> WaitForResultAsync(string taskId, string clientKey, TimeSpan timeout)
{
var deadline = DateTime.UtcNow + timeout;
while (DateTime.UtcNow < deadline)
{
var response = await client.PostAsJsonAsync("https://solvercf.com/token/extension/getTaskResult", new { clientKey, taskId });
var json = await response.Content.ReadFromJsonAsync<JsonElement>();
var status = json.GetProperty("status").GetString();
if (status == "ready") return json.GetProperty("solution");
if (status is "failed" or "expired") throw new Exception($"task {status}");
await Task.Delay(1500);
}
throw new TimeoutException("gave up waiting for task result");
}