5-Second Challenge (WAF)
Pass Cloudflare's "Just a moment..." browser check.
Passes Cloudflare's browser check, the "Just a moment..." page that runs before a site loads. Peak Solutions returns the clearance cookies, the headers to send, and the form fields that complete the challenge.
How it works
- Load the page through your proxy. Cloudflare answers with the challenge page.
- Send it to Peak Solutions, with the same proxy and user-agent.
- Complete the challenge. Add the returned cookies, then post the returned form fields back to the page.
- Keep going with the same proxy, cookies and headers. Cloudflare now lets you through.
Use a sticky proxy
Cloudflare ties the clearance to the IP that solved it. Use a sticky (session) proxy, and keep the same session from step 1 to step 4. Start a new proxy session for each solve.
Request
POST https://api.peak.fo/solve
| Field | Type | Required | Description |
|---|---|---|---|
task_type | string | Yes | cloudflare5stask |
url | string | Yes | The page that shows the challenge. |
proxy | string | Yes | A sticky proxy, as protocol://user:pass@host:port or in proxy parameters. The same one your code uses. |
user_agent | string | No | The user-agent your code sends. Must be a Windows Chrome user-agent. |
html | string | No | The challenge page you already loaded in step 1. Saves a request, so solves faster. |
curl https://api.peak.fo/solve \
-H "X-API-Key: pk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"task_type": "cloudflare5stask",
"url": "https://example.com/",
"proxy": "http://user:pass@1.2.3.4:8080",
"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"
}'Response
| Field | Type | Description |
|---|---|---|
data.cookies | object | Cookies to add for the site, such as cf_clearance. |
data.headers | object | Headers to send on every request from now on. Names are lowercase. |
data.attributes | object | Form fields to post back to the page, to complete the challenge. |
data.cf_rt | string | Challenge token. Goes in the Referer of that post, as __cf_chl_tk. |
cost | number | What the solve was charged, in USD. |
error | string | On failure: what went wrong, in words. |
error_code | string | On failure: what went wrong, as a stable code. |
{
"success": true,
"data": {
"cookies": {
"cf_clearance": "Kx9...",
"__cf_bm": "aB3..."
},
"headers": {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) ..."
},
"attributes": {
"md": "Zq1...",
"r": "7Hk..."
},
"cf_rt": "Wm2..."
},
"cost": 0.001
}Complete the challenge
After the solve, post attributes back to the page:
- Method and URL:
POSTto the sameurlyou solved. - Body:
attributesas a URL-encoded form (application/x-www-form-urlencoded). - Cookies: everything in
cookies. - Headers: everything in
headers, plus aRefererof yoururlwith__cf_chl_tk=<cf_rt>added to its query string.
Cloudflare checks the TLS fingerprint as well as the headers, so use an HTTP client that looks like Chrome. A plain HTTP library gets challenged again.
This full example runs all four steps. Install the client for your language:
- Python: wreq,
pip install wreq(Python 3.11+) - JavaScript: wreq-js,
npm install wreq-js - Go: tls-client,
go get github.com/bogdanfinn/tls-client(Go 1.27+)
import asyncio
from datetime import timedelta
from urllib.parse import urlencode
from wreq import Client, Cookie, Emulation, Platform, Proxy
API_KEY = "pk_your_api_key"
USER_AGENT = (
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
"(KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36"
)
async def solve(url: str, proxy: str, html: str) -> dict:
"""Sends the challenge page to Peak Solutions and returns the solution."""
async with Client(timeout=timedelta(seconds=120)) as client:
resp = await client.post(
"https://api.peak.fo/solve",
headers={"X-API-Key": API_KEY},
json={
"task_type": "cloudflare5stask",
"url": url,
"proxy": proxy,
"user_agent": USER_AGENT,
"html": html,
},
)
body = await resp.json()
if not body["success"]:
raise RuntimeError(f"{body['error_code']}: {body['error']}")
return body["data"]
async def main() -> None:
url = "https://example.com/"
proxy = "http://user:pass@1.2.3.4:8080" # a sticky session
async with Client(
emulation=Emulation(Emulation.Chrome154, Platform.Windows),
user_agent=USER_AGENT,
proxies=[Proxy.all(proxy)],
cookie_store=True,
timeout=timedelta(seconds=60),
) as browser:
# 1. Load the page. Cloudflare answers with the challenge.
page = await browser.get(url)
# 2. Send it to Peak Solutions.
solution = await solve(url, proxy, await page.text())
# 3. Add the cookies, then post the form fields back.
for name, value in solution["cookies"].items():
browser.cookie_jar.add(Cookie(name, value), url)
separator = "&" if "?" in url else "?"
referer = url + separator + urlencode({"__cf_chl_tk": solution["cf_rt"]})
await browser.post(
url,
form=solution.get("attributes", {}),
headers={**solution["headers"], "referer": referer},
)
# 4. You're through. Keep using the same browser and headers.
page = await browser.get(url, headers=solution["headers"])
print(page.status, await page.text())
if __name__ == "__main__":
asyncio.run(main())Errors
A failed solve returns HTTP 200 with "success": false, and is not charged.
error_code | What to do |
|---|---|
no_challenge | The page isn't showing the challenge, or the url is wrong. |
ip_blocked | Retry with a different proxy. |
unsupported_user_agent | Send a Windows Chrome user-agent. |
invalid_html | Check the url, and that html is the challenge page itself. |
invalid_request_data | Check the url format, such as https://example.com/. |
challenge_flagged | Retry with a proxy that has a cleaner IP. |
turnstile_failed | Retry with a different proxy. |
invalid_sitekey | The Turnstile inside the challenge has a sitekey the solver can't use. Retry, or contact support. |
invalid_action | The Turnstile inside the challenge rejected the action. Retry. |
invalid_cdata | The Turnstile inside the challenge rejected the cdata. Retry. |
no_servers | No solver is free right now. Retry in a few seconds. |
proxy_error | Check the proxy format, that it's reachable, and that it's sticky. Also returned when the proxy fails during the challenge's Turnstile step. |
timeout | Retry, or use a faster proxy closer to the site. |
solve_failed | Retry with a different proxy. |
solver_error | Retry with a different proxy. |
A request missing url or proxy is rejected with HTTP 400 and missing_fields. For rejections like insufficient_balance, see Error codes.