SurSolver

Cloudflare Challenge solver API

The Cloudflare challenge is a full-page interstitial that ends in a cf_clearance cookie bound to an IP and a user agent. Here is how to recognise it, solve it through the API and replay the cookie correctly.

Updated

$0.30 / 1K tasksCharged when a task is accepted

On this page

What is the Cloudflare challenge page and how to recognise it

The Cloudflare challenge — also called the interstitial or "Just a moment…" page — is a full-page check that Cloudflare serves instead of the page you asked for, usually with HTTP 403. Some variants clear themselves after scripted checks; others show a "Verify you are human" checkbox, possibly over more than one round. When the check passes, Cloudflare sets a cf_clearance cookie (often together with __cf_bm), and requests carrying it are served normally until it expires or is revoked.

The Cloudflare "Just a moment…" interstitial returned instead of the requested page

Do not confuse it with Turnstile. Turnstile is a widget a site embeds in its own page, it needs a sitekey and returns a token. The challenge page needs no sitekey, takes the URL that is being challenged, and its useful result is the cookie. If your first request returns 403 and a page that only says "Just a moment…", this is the right type; if a normal page contains a cf-turnstile element, use the Turnstile task instead.

Which URL, proxy and page HTML to send

There is no sitekey to find. The task needs the URL that actually returns the challenge: use the route that served the interstitial, not the site root, because challenges apply per route. If a solve reports that no challenge is present, the wrong route was sent.

userAgent is required: send the User-Agent of the client that will replay the cookie. The solve presents it, and cf_clearance is bound to it. One optional parameter helps. pageData is the HTML of the challenged URL as you fetched it, through the same proxy; the <script> tags that load /cdn-cgi/challenge-platform/ are enough. With it the solver does not fetch the page itself. In a browser you can read the challenge type from window._cf_chl_opt.cType (managed, interactive or non-interactive), which is a useful hint when a solve takes longer than expected.

The proxy is required: static or sticky, and kept for at least about three minutes. Transparent and localhost proxies do not work.

Where the cookies go

Set solution.cf_clearance as the cf_clearance cookie on the challenged origin, and solution.__cf_bm as __cf_bm when it is present. Apply the other name-to-value entries in solution.cookies too. Use the same proxy and the userAgent from your task.

In a browser-automation script, add the cookies to the browser context before navigating and run the browser through the same proxy. Cookie lifetime is reported to range from about half an hour to a few hours, and Cloudflare may revoke it earlier when the traffic pattern changes: re-solve when you are challenged again instead of retrying with the old cookie.

Common mistakes

The most common mistake is changing the IP. cf_clearance is bound to the exit IP and the user agent; rotating proxies, a different exit or a different user agent makes Cloudflare treat the client as cookieless again. Use one static proxy for the solve and every replayed request.

The second is the client itself. A plain HTTP library has a TLS fingerprint that differs from a real browser, and a valid cookie may still be refused; use a client that presents a browser-accurate fingerprint. Third, sending an old pageData: the challenge in a page fetched earlier, or through another proxy, no longer matches, so fetch the page again for every attempt.

Finally, do not treat a failed solve as a parameter problem. If a solve fails, the proxy IP may be blocked, and the fix is a different proxy rather than different parameters. Interactive challenges take longer than managed ones, so set your polling timeout for the slow case instead of the average.

Solve it with SurSolver

Send the challenged URL, your static proxy and the replay browser's userAgent to createTask with CloudflareChallengeCookie. Add pageData when you already fetched the page, then poll getTaskResult until ready. The result contains cf_clearance, not token, plus __cf_bm and a cookies object when the solver returns them.

The official client wraps createTask and polling in one solve call; each language tab is its Quick start with this captcha's request, and prints cf_clearance. Replay the returned cookies (including cf_clearance) with the task's user agent through the same proxy. The Playwright tab launches Chromium through that proxy, solves for the challenged URL, adds the returned cookies to the context with the task's user agent and waits for the protected page. The Cloudflare Challenge Playwright guide walks through the full flow.

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.CloudflareChallengeCookie,
  websiteURL: 'https://example.com/login',
  userAgent: USER_AGENT,
  proxy: 'http://user:password@203.0.113.10:8000',
});
console.log(solution.cf_clearance);

FAQ

How do I tell the challenge page from Turnstile?

The challenge page is served instead of the page you requested, usually with HTTP 403 and the text "Just a moment…". Turnstile is an element embedded in a page that loads normally. They need different task types.

What does the task return?

solution.cf_clearance is the clearance cookie value. solution.__cf_bm is also returned when the solve produced it. solution.cookies is an optional name-to-value object of all returned cookies. Replay with the proxy and userAgent you sent in the task.

Do I need a proxy?

Yes, this type has no proxyless form. cf_clearance is bound to the exit IP and the user agent, so the solve and every later request must use the same static proxy.

Why does Cloudflare challenge me again after I send the cookie?

Usually the IP or user agent differs from the solve, the proxy rotated, or the client has a different TLS fingerprint from a real browser. Cloudflare can also revoke a cookie early, so solve again when you are challenged.

What do I send as pageData?

The HTML of the challenged URL as you fetched it, through the same proxy: the "Just a moment..." page, or a normal page that carries the challenge script. The script tags that load /cdn-cgi/challenge-platform/ are enough. The solver then skips fetching the page. The field is optional.