> ## Documentation Index
> Fetch the complete documentation index at: https://docs.scrapely.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Cloudflare Challenge

> Solve Cloudflare's 5-second wait (IUAM) challenges automatically.

Bypass Cloudflare's "I'm Under Attack Mode" (IUAM) and interactive challenges automatically. This endpoint returns the cleared cookies and user-agent needed to make subsequent requests to the target site.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.scrapely.io/v2/tasks/create \
    -H "Content-Type: application/json" \
    -H "X-API-Key: YOUR_API_KEY" \
    -d '{
      "crawler": {
        "websiteURL": "https://example.com",
        "return_page_cookies": true,
        "return_user_agent": true
      }
    }'
  ```

  ```python Python SDK theme={null}
  from scrapely import Scrapely

  client = Scrapely(api_key="YOUR_API_KEY")

  task = client.cloudflare.challenge(
      website_url="https://example.com"
  )

  # Extract cookies and user-agent to use in your own HTTP client
  print("Cookies:", task.result.cookies)
  print("User-Agent:", task.result.user_agent)
  ```
</CodeGroup>

## Request fields

### crawler

| Field        | Type   | Required | Description                                                                                      |
| ------------ | ------ | -------- | ------------------------------------------------------------------------------------------------ |
| `websiteURL` | string | Yes      | URL of the page protected by Cloudflare. Must start with `http://` or `https://`. Max 254 chars. |

### proxy (optional)

<Info>
  We highly recommend using proxies when solving Cloudflare challenges to maintain the reputation of the solving IP. The cookies returned will be tied to the IP used to solve the challenge.
</Info>

| Field      | Type    | Required | Description                           |
| ---------- | ------- | -------- | ------------------------------------- |
| `scheme`   | string  | Yes      | Proxy scheme (e.g. `http`, `socks5`). |
| `host`     | string  | Yes      | Proxy host.                           |
| `port`     | integer | Yes      | Proxy port.                           |
| `username` | string  | No       | Proxy username.                       |
| `password` | string  | No       | Required if `username` is provided.   |

## Response

```json theme={null}
{
  "success": true,
  "task_id": "52989a12-a43c-4bf9-ba1d-8ab1e1509169",
  "status": "completed",
  "created_at": "2026-04-06T10:54:56.652354+00:00",
  "result": {
    "html": "",
    "text": "",
    "screenshot": "",
    "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)...",
    "cookies": {
      "cf_clearance": "abc123xyz..."
    },
    "metadata": {},
    "instructions": []
  },
  "completed_at": "2026-04-06T10:55:08.312452+00:00"
}
```

<Info>
  The `cf_clearance` cookie must be used alongside the exact same `user_agent` returned in the response for subsequent requests to the target site.
</Info>
