Skip to content

Cloudflare overview

We solve two kinds of Cloudflare challenges:

  • A challenge page: the 403 “Just a moment…” page of a managed, non-interactive or interactive challenge, or Under Attack mode. Getting through sets the cf_clearance cookie.
  • A Turnstile widget

Getting through takes a browser about eight requests in a row. To solve it you need you send us each part, we’ll give you the payload to submit using your TLS client.

One of those requests is Turnstile’s api.js, from challenges.cloudflare.com. We read it to build the widget’s frame. On a widget page it is always the first request. On a challenge page we ask for it only the first time we see that version of it, so most solves skip it.

Challenges and blocks tells a challenge from a block or a widget. Examples with httpcloak has a whole client in Python, Go and JavaScript.

Base URL: https://cf.antibotapi.com. We solve as Chrome 155 on Windows: send your client’s User-Agent as user_agent.

  1. Request the site and get the challenge page (or the page with the widget).
  2. POST /solves with the address, the page’s HTML and your User-Agent. Keep the id.
  3. Take the request: wait wait_ms, then send its method, url, headers (in that order, with your cookies in the cookie one) and body. Give up after timeout_ms if it is not 0.
  4. POST /solves/{id}/next with the status, headers and body (Base64) that came back, whatever they were. Status 0 if you gave up.
  5. Repeat 3–4 until the answer has done.

A challenge page ends with "cleared": true, and its cf_clearance cookie is in your jar. A widget ends with token: post it as the page’s form would (its cf-turnstile-response field, unless the page names another).

let { id, request } = await api('/solves', { url, html, user_agent: UA });
for (;;) {
await sleep(request.wait_ms);
const res = await send(request.method, request.url, request.headers, request.body, request.timeout_ms);
const next = await api(`/solves/${id}/next`, { status: res.status, headers: res.headers, body: base64(res.body) });
if (next.done) return next; // { done, cleared } or { done, token }
request = next.request;
}

A 422 means we could not take the next step, usually because a response was not what it should be (a 403 where a 200 was due). The solve is over; start a new one. A 404 on /next means the solve has ended or expired, and a 400 on /solves that we do not solve as your User-Agent (the body lists the ones we do).