CAPTCHA basics
How to handle several CAPTCHAs in one flow
Multi-step forms and long journeys often meet more than one CAPTCHA, sometimes of different types. The trick is to know which answers can be prepared in parallel and which must wait for the step before them.
Where several CAPTCHAs show up
A single journey can hit more than one challenge. Common patterns:
- Edge check, then form widget. A full-page check guards the site, and a Turnstile or reCAPTCHA widget guards the form behind it.
- Multi-step forms. A search form with one widget leads to a results page whose "next" or detail request needs another token.
- Different types per action. A site may use an invisible reCAPTCHA v3 score on browsing and a reCAPTCHA v2 checkbox on submit, each with its own site key.
- Batch jobs. A monitor that runs the same flow for hundreds of items, each needing its own token.
All of these use the same API calls. The work is in ordering them correctly and making sure each answer is fresh when it is used.
Map the flow first
Walk through the journey once in a normal browser with the network tab open and write down, for each step: the URL, the challenge type, the site key or other parameters, which field or cookie receives the answer, and whether the step depends on something the previous step produced (a session cookie, a CSRF value, a server-issued id). That table decides everything else.
| Step | Challenge | Answer goes to | Depends on |
|---|---|---|---|
| Open site | Cloudflare Challenge | cf_clearance cookie | Nothing |
| Search form | Cloudflare Turnstile | cf-turnstile-response field | Clearance cookie |
| Detail request | reCAPTCHA v3 action "detail" | token header in the API call | Search session |
Sequential versus parallel
A step whose challenge parameters are known in advance can be solved before you reach it. A step whose parameters come from the previous response, like a GeeTest v3 challenge value issued per attempt, must wait. In the example above, the Turnstile and v3 site keys are fixed on the site, so their tasks can start while the clearance task is still running. The tokens just have to be used before they expire.
Because there is no limit on concurrent tasks, starting several at once costs nothing extra. Each is charged only if solved.
Solve independent challenges in parallel
A small helper that wraps create and poll in one promise makes parallel solving straightforward in Node.js 18 or newer:
const GS = "https://gatesolver.com";
const nap = (delay) => new Promise((done) => setTimeout(done, delay));
async function gsCall(path, extra) {
const res = await fetch(GS + path, {
method: "POST",
headers: { "Content-Type": "application/json", "User-Agent": "multi-step-runner/1.0" },
body: JSON.stringify({ clientKey: process.env.GS_KEY, ...extra }),
});
const parsed = await res.json();
if (parsed.errorId) throw new Error(`${parsed.errorCode} ${parsed.errorDescription ?? ""}`);
return parsed;
}
async function solveOne(task, everyMs = 3000) {
const { taskId } = await gsCall("/createTask", { task });
for (let waited = 0; waited < 125000; waited += everyMs) {
await nap(everyMs);
const r = await gsCall("/getTaskResult", { taskId });
if (r.status === "ready") return { ...r.solution, taskId, at: Date.now() };
if (r.status === "failed") throw new Error(`task ${taskId} failed`);
}
throw new Error(`no answer for ${taskId} within the limit`);
}
With that in place, start the independent tasks together and wait for all of them:
const page = "https://example.com/search";
const [clearance, widget, detailToken] = await Promise.all([
solveOne({ type: "AntiCloudflareTask", websiteURL: page,
proxy: process.env.STICKY_PROXY, userAgent: process.env.BROWSER_UA }),
solveOne({ type: "AntiTurnstileTaskProxyLess", websiteURL: page,
websiteKey: "0x4AAAAAAA_example" }),
solveOne({ type: "ReCaptchaV3TaskProxyLess", websiteURL: page,
websiteKey: "6Lc_example_key", pageAction: "detail" }),
]);
console.log(clearance.cookies.cf_clearance.slice(0, 12), widget.token.length);
If one task can fail without spoiling the rest, use Promise.allSettled and retry only the rejected one. Pass a shorter interval, about one second, to solveOne for image tasks.
Keep answers fresh
Parallel solving saves time but raises a timing question: a token produced at the start of a long flow may expire before the step that uses it. Tokens last about two minutes for reCAPTCHA and a few minutes for Turnstile. Three rules cover it:
- Record when each answer arrived (the helper adds
at) and check its age before use. - Start the task for a late step only when the flow is close to that step, not at the very beginning, if the steps between are slow.
- Never reuse a token. If a step must be repeated, solve again.
Cookies behave differently. A clearance cookie lasts for the session and serves every later request from the same address and user agent, so one solve at the start covers the whole flow.
Keep the session consistent across steps
Every step should go out through the same proxy, user agent and cookie jar. If the clearance was earned through a sticky proxy, the form submits must use it too. If a token solution includes a userAgent, send that string on the request that carries the token when the site checks it. Mixing identities between steps is the most common reason a multi-step flow fails at step two after step one succeeded.
Many flows at once
For batch jobs, run several flows concurrently, each with its own session. The limit to watch is 600 API requests per minute per key, which includes polling. Twenty flows each polling three tasks every three seconds come to about 1,200 requests per minute, over the limit; poll less often, stagger task starts, or reduce the number of flows in flight. A small semaphore around solveOne keeps the total under control.
When one step fails
Decide in advance what a failure at each step means for the whole flow. If the clearance task fails, nothing after it can work, so stop that run and retry from the start with a fresh session. If a late token fails, the earlier answers may still be valid; solve only the failed step again, provided the session is still alive. Writing this down as a small table next to the flow map keeps retries cheap and prevents a single failed task from restarting an entire journey that was otherwise fine.
One balance for every type
All tasks in a flow draw on the same prepaid balance, whatever their type, so you do not need to manage budgets per challenge. To see what a flow costs, read the cost field on each ready result and sum per flow. At the time of reading, the example above costs one Cloudflare Challenge ($0.84 per 1,000), one Turnstile ($0.84 per 1,000) and one v3 token ($0.70 per 1,000) per run.
Common questions
Can I solve two CAPTCHAs for the same page at the same time?
Yes. There is no limit on concurrent tasks, and each is charged only if it is solved.
Should I solve every challenge in a flow at the start?
Only those whose parameters are known and whose answers will still be fresh when used. Tokens expire in minutes, so start late-step tasks close to the step.
Does each CAPTCHA type need its own balance?
No. One prepaid balance pays for every type, and each task's cost field shows what it used.
Why does step two fail after step one passed?
Usually the session changed between steps: a different proxy, user agent or cookie jar. Keep all three fixed for the whole flow.
How do I stay under the rate limit with many flows?
Count polling calls too. Poll token tasks every three seconds, stagger starts, and cap the number of flows in flight.
Keep reading
- Solving CAPTCHAs in web scraping pipelinesAn architecture for scrapers that meet CAPTCHAs: detect challenges as their own outcome, solve in a separate stage, retry with clear limits.
- What is the request limit per API key?Each key may send 600 requests per minute across all calls, while the number of tasks running at once is not limited.
- ConcurrencyRunning many requests or solving tasks at the same time, and how per host limits and backpressure keep it under control.
- API docscreateTask, getTaskResult, getBalance, error codes and the in.php format.