SurSolver

Cloudflare Turnstile solver API

Turnstile is an embedded challenge that returns a short-lived token. Here is how to recognise it, send its parameters to the API and submit the token correctly.

Updated

$0.20 / 1K tasksCharged when a task is accepted

On this page

What is Cloudflare Turnstile and how to recognise it

Turnstile is a challenge a site embeds in its own page — a login, signup or checkout form — instead of an image puzzle. Verification is usually silent, and depending on the mode the site configured (managed, non-interactive or invisible) it may show a single checkbox. A page that renders Turnstile usually contains a cf-turnstile element and loads the Turnstile script from challenges.cloudflare.com/turnstile/v0/api.js.

Cloudflare Turnstile in the registration form of a XenForo community

Do not confuse it with a Cloudflare challenge page. The element lives on a page that loads normally; a challenge page is the full-page interstitial served instead of the page you asked for, and it takes different inputs and returns a different result. If the first request comes back with HTTP 403 and a page that only says "Just a moment…", you are looking at a challenge page, not this element.

Solving Turnstile returns a token of up to 2048 characters. The token is single-use and expires after about five minutes, so it is meant to be used immediately in the request you are about to send.

How to find the Turnstile sitekey

Open the page in a browser and inspect the element that renders the challenge. The sitekey is the data-sitekey attribute of the cf-turnstile element, or the sitekey argument of the turnstile.render(...) call when the page renders it from JavaScript. Sitekeys always start with 0x.

The Turnstile widget element in the Elements panel, with its data-sitekey attribute holding the sitekey

If the same element carries data-action or data-cdata, copy those values exactly as they appear — they are optional, and a verifier that checks them rejects a token that was solved for a different value. When the page renders the challenge from JavaScript, the same values are the action and cData arguments of turnstile.render. chlPageData is not supported by this task; use the Cloudflare Challenge guide for a full-page interstitial.

The page URL you send must be the page that renders the element, including its path — not the site root.

Where the token goes

Place the returned token in the page and submit the form. Most sites use a hidden input named cf-turnstile-response; a site that enabled reCAPTCHA-compatibility mode uses g-recaptcha-response instead. Some pages never create the field and instead pass a callback to turnstile.render: in that case invoke the callback with the token.

The hidden cf-turnstile-response input holding the token the widget returned

In a browser-automation script, set the field with page.evaluate() or the equivalent DOM call and then submit, using the user agent you sent in the task. Submit promptly: the token is single-use.

Common mistakes

The most common failure is solving a challenge page with the Turnstile task: the two are different products with different inputs and outputs. The second is sending a guessed action or cData — a verifier that checks them rejects the token, and guessing is worse than omitting the field. A token that was already submitted, or one that sat unused for more than a few minutes, comes back as timeout-or-duplicate from the site's own verification.

Invisible mode is easy to misread: the page shows no checkbox, so a form that fails silently usually means the token field was empty when the submit ran. Check that the field is populated before submitting, and check the submit path — a redirect or a retry can redeem the token twice.

Pooling or pre-solving tokens does not work for Turnstile. Solve inline, with the same parameters the page declares, and send the result immediately. Caller proxies are not supported for this task; both accepted names use SurSolver-managed egress.

Solve it with SurSolver

Send the page URL, the sitekey and your browser userAgent to createTask with the task type TurnstileTokenProxyLess or TurnstileToken, then poll getTaskResult until the status is ready. Neither name uses a caller proxy. The solution carries the token. Both calls are plain HTTP with a JSON body — the accepted names and parameters are listed by the public catalog (GET /v1/task-types).

Examples in your language

The official client wraps createTask and polling in one solve call. Each language tab is the Quick start of that client: it creates the client, solves the Turnstile task and returns solution.token, which you submit as the cf-turnstile-response form field. The Playwright, Puppeteer and Selenium tabs run the whole flow in a browser instead: they read the sitekey from the page, solve, fill the field and submit.

quickstart.ts
npm install sursolver
import { SurSolver, TaskType } from 'sursolver';

const API_KEY = 'YOUR_API_KEY';
const USER_AGENT =
  'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36';

const client = new SurSolver(API_KEY);

const { solution } = await client.solve({
  type: TaskType.TurnstileTokenProxyLess,
  websiteURL: 'https://example.com/login',
  websiteKey: '0x4AAAA...',
  userAgent: USER_AGENT,
});
console.log(solution.token);

The full walkthrough — callback handling, the Puppeteer alternative and the failure modes — is in the Cloudflare Turnstile solver API guide.

FAQ

How do I tell a Turnstile element from a Cloudflare challenge page?

A Turnstile element lives in a page that loads normally and renders a cf-turnstile element. A challenge page is served instead of the page you asked for — usually a full-page interstitial with HTTP 403 — and needs a different task type.

Which parameters does a Turnstile task need?

websiteURL, websiteKey and userAgent are required. Send action and cData only when the widget declares them. chlPageData is not supported by this task; a full Cloudflare challenge page uses a separate task type.

Do I need a proxy for Turnstile?

No. Both TurnstileToken and TurnstileTokenProxyLess use SurSolver-managed egress. Caller proxy fields are ignored, not stored or forwarded.

Where does the token go?

Into the hidden cf-turnstile-response input — or g-recaptcha-response when the site runs reCAPTCHA-compatibility mode — or into the callback the page registered.

Can I reuse a token?

No. A token is accepted once and expires after about five minutes, so solve inline with the request you are about to make.