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.

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.
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);
from sursolver import SurSolver, TaskType
API_KEY = "YOUR_API_KEY"
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"
)
client = SurSolver(API_KEY)
result = client.solve(
{
"type": TaskType.CloudflareChallengeCookie,
"websiteURL": "https://example.com/login",
"userAgent": USER_AGENT,
"proxy": "http://user:password@203.0.113.10:8000",
}
)
print(result.solution["cf_clearance"])
package main
import (
"context"
"fmt"
"log"
sursolver "github.com/sursolver/sursolver-go"
)
const (
APIKey = "YOUR_API_KEY"
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36"
)
func main() {
client, err := sursolver.New(APIKey)
if err != nil {
log.Fatal(err)
}
result, err := client.Solve(context.Background(), sursolver.Task{
"type": sursolver.TaskTypeCloudflareChallengeCookie,
"websiteURL": "https://example.com/login",
"userAgent": UserAgent,
"proxy": "http://user:password@203.0.113.10:8000",
})
if err != nil {
log.Fatal(err)
}
fmt.Println(result.Solution["cf_clearance"])
}
use serde_json::json;
use sursolver::{Client, task_types};
const API_KEY: &str = "YOUR_API_KEY";
const USER_AGENT: &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36";
#[tokio::main]
async fn main() -> Result<(), sursolver::Error> {
let client = Client::new(API_KEY)?;
let result = client
.solve(&json!({
"type": task_types::CLOUDFLARE_CHALLENGE_COOKIE,
"websiteURL": "https://example.com/login",
"userAgent": USER_AGENT,
"proxy": "http://user:password@203.0.113.10:8000",
}))
.await?;
println!("{}", result.solution["cf_clearance"]);
Ok(())
}
<?php
require __DIR__ . '/vendor/autoload.php';
use SurSolver\Client;
use SurSolver\TaskTypes;
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';
$client = new Client(API_KEY);
$result = $client->solve([
'type' => TaskTypes::CLOUDFLARE_CHALLENGE_COOKIE,
'websiteURL' => 'https://example.com/login',
'userAgent' => USER_AGENT,
'proxy' => 'http://user:password@203.0.113.10:8000',
]);
echo $result->solution['cf_clearance'];
require "sursolver"
API_KEY = "YOUR_API_KEY"
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"
client = SurSolver::Client.new(API_KEY)
result = client.solve(
"type" => SurSolver::TaskTypes::CLOUDFLARE_CHALLENGE_COOKIE,
"websiteURL" => "https://example.com/login",
"userAgent" => USER_AGENT,
"proxy" => "http://user:password@203.0.113.10:8000"
)
puts result.solution["cf_clearance"]
import com.sursolver.SolveResult;
import com.sursolver.SurSolverClient;
import com.sursolver.TaskTypes;
import java.util.Map;
public class QuickStart {
static final String API_KEY = "YOUR_API_KEY";
static final String 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";
public static void main(String[] args) throws InterruptedException {
SurSolverClient client = SurSolverClient.create(API_KEY);
SolveResult result = client.solve(Map.of(
"type", TaskTypes.CloudflareChallengeCookie,
"websiteURL", "https://example.com/login",
"userAgent", USER_AGENT,
"proxy", "http://user:password@203.0.113.10:8000"));
System.out.println(result.solution().get("cf_clearance"));
}
}
using System.Text.Json.Nodes;
using SurSolver;
const string ApiKey = "YOUR_API_KEY";
const string UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36";
var client = new SurSolverClient(ApiKey);
var result = await client.SolveAsync(new JsonObject
{
["type"] = TaskTypes.CloudflareChallengeCookie,
["websiteURL"] = "https://example.com/login",
["userAgent"] = UserAgent,
["proxy"] = "http://user:password@203.0.113.10:8000",
});
Console.WriteLine(result.Solution["cf_clearance"]);
// cloudflare-challenge-playwright.js - solve Cloudflare Challenge and open the protected page
// with the cf_clearance cookie.
// Install: npm install playwright && npx playwright install chromium
// Run: node cloudflare-challenge-playwright.js
const { chromium } = require('playwright');
const { setTimeout: sleep } = require('node:timers/promises');
// Your SurSolver API key.
const CLIENT_KEY = 'sur_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
// The challenged page, exactly as it shows the challenge.
const TARGET_URL = 'https://example.com/page';
// The proxy for the solve and the replay: http://user:pass@host:port or socks5://host:port.
const PROXY_URL = 'http://username:password@proxy.example.com:8080';
// The User-Agent the solve runs with; send the result with this same user agent.
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';
// A selector that matches only after the site accepted the result.
const SUCCESS_SELECTOR = '.PASTE_ACCEPTED_SELECTOR';
const API = 'https://api.sursolver.com';
const POLL_ATTEMPTS = 60;
// API errors are HTTP 200 with errorId 1; anything else is a transport failure.
async function call(path, body) {
const res = await fetch(`${API}${path}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
if (data.errorId !== 0) throw new Error(`${data.errorCode}: ${data.errorDescription}`);
return data;
}
async function solve(task) {
const created = await call('/createTask', { clientKey: CLIENT_KEY, task });
for (let attempt = 0; attempt < POLL_ATTEMPTS; attempt += 1) {
const result = await call('/getTaskResult', {
clientKey: CLIENT_KEY,
taskId: created.taskId,
});
if (result.status === 'ready') return result.solution;
await sleep(3000);
}
throw new Error(`task ${created.taskId} was not ready in ${POLL_ATTEMPTS} polls`);
}
// Optional task fields are sent only when they have a value.
function withoutEmpty(fields) {
return Object.fromEntries(
Object.entries(fields).filter(([, value]) => value !== undefined && value !== ''),
);
}
// Chromium takes the proxy as a server plus credentials rather than one URL.
// It cannot send credentials to a SOCKS5 proxy; use an http:// proxy for browser runs.
function proxyOption(proxyUrl) {
const url = new URL(proxyUrl);
return {
server: `${url.protocol}//${url.host}`,
...(url.username
? { username: decodeURIComponent(url.username), password: decodeURIComponent(url.password) }
: {}),
};
}
// Public cookies are a name-to-value object; apply them to the protected origin.
function browserCookies(cookies, url) {
return Object.entries(cookies).map(([name, value]) => ({
name, value, url: new URL(url).origin,
}));
}
async function main() {
const browser = await chromium.launch({ proxy: proxyOption(PROXY_URL) });
try {
const solution = await solve({
type: 'CloudflareChallengeCookie',
websiteURL: TARGET_URL,
userAgent: USER_AGENT,
proxy: PROXY_URL,
});
const cookies = {
...(solution.cookies ?? {}),
'cf_clearance': solution['cf_clearance'],
};
// Replay with the user agent the solve ran with, through the same proxy.
const context = await browser.newContext({ userAgent: USER_AGENT });
await context.addCookies(browserCookies(cookies, TARGET_URL));
const page = await context.newPage();
await page.goto(TARGET_URL, { waitUntil: 'domcontentloaded' });
await page.locator(SUCCESS_SELECTOR).first().waitFor({ timeout: 15000 });
console.log('The site served the protected page.');
} finally {
await browser.close();
}
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});