Skip to Content
Peak Solutions

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

  1. Load the page through your proxy. Cloudflare answers with the challenge page.
  2. Send it to Peak Solutions, with the same proxy and user-agent.
  3. Complete the challenge. Add the returned cookies, then post the returned form fields back to the page.
  4. 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

FieldTypeRequiredDescription
task_typestringYescloudflare5stask
urlstringYesThe page that shows the challenge.
proxystringYesA sticky proxy, as protocol://user:pass@host:port or in proxy parameters. The same one your code uses.
user_agentstringNoThe user-agent your code sends. Must be a Windows Chrome user-agent.
htmlstringNoThe challenge page you already loaded in step 1. Saves a request, so solves faster.
Terminal
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

FieldTypeDescription
data.cookiesobjectCookies to add for the site, such as cf_clearance.
data.headersobjectHeaders to send on every request from now on. Names are lowercase.
data.attributesobjectForm fields to post back to the page, to complete the challenge.
data.cf_rtstringChallenge token. Goes in the Referer of that post, as __cf_chl_tk.
costnumberWhat the solve was charged, in USD.
errorstringOn failure: what went wrong, in words.
error_codestringOn 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: POST to the same url you solved.
  • Body: attributes as a URL-encoded form (application/x-www-form-urlencoded).
  • Cookies: everything in cookies.
  • Headers: everything in headers, plus a Referer of your url with __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_codeWhat to do
no_challengeThe page isn't showing the challenge, or the url is wrong.
ip_blockedRetry with a different proxy.
unsupported_user_agentSend a Windows Chrome user-agent.
invalid_htmlCheck the url, and that html is the challenge page itself.
invalid_request_dataCheck the url format, such as https://example.com/.
challenge_flaggedRetry with a proxy that has a cleaner IP.
turnstile_failedRetry with a different proxy.
invalid_sitekeyThe Turnstile inside the challenge has a sitekey the solver can't use. Retry, or contact support.
invalid_actionThe Turnstile inside the challenge rejected the action. Retry.
invalid_cdataThe Turnstile inside the challenge rejected the cdata. Retry.
no_serversNo solver is free right now. Retry in a few seconds.
proxy_errorCheck the proxy format, that it's reachable, and that it's sticky. Also returned when the proxy fails during the challenge's Turnstile step.
timeoutRetry, or use a faster proxy closer to the site.
solve_failedRetry with a different proxy.
solver_errorRetry 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.

On this page