Skip to main content
Are you experiencing issues obtaining the token?
Contact support

Cloudflare Turnstile

CapMonster Cloud MCP
CapMonster Cloud MCP can also be used to detect and solve CAPTCHA

Cloudflare Turnstile widget states: “Verify you are human” checkbox, “Verifying...” spinner and green “Success!” mark, each with the Cloudflare logo.

You are required to solve a regular Turnstile captcha, like this one. Please note that captchas on Cloudflare pages may look identical. See how to distinguish a regular Turnstile from a Cloudflare Challenge.

After solving the CAPTCHA, you receive a token that must be inserted into a designated field on the page. All Turnstile subtypes are automatically supported: manual, non-interactive, and invisible. Therefore, you do not need to specify a subtype for a standard captcha.

More on the topic in our blog
More on the topic in our blog
Attention!
  • CapMonster Cloud uses built-in proxies by default — their cost is already included in the service. You only need to specify your own proxies in cases where the website does not accept the token or access to the built-in services is restricted.

  • If you are using a proxy with IP authorization, make sure to whitelist the address 65.21.190.34.

  • After solving, you will receive a token to confirm captcha completion.

Request parameters​


IMPORTANT: some parameter values are dynamic — they change with each render of the page using Cloudflare Turnstile.
Extract them immediately before creating the task to avoid errors during solving.
See examples of automatic parameter extraction in the section How to find all required parameters for task creation.


type<string>required

TurnstileTask


websiteURL<string>required

The URL of the page where the captcha is solved


websiteKey<string>required

Turnstile site key
It should have the following format: 0x4AAAAAAABUYP0XeMJF0xoy


userAgent<string>optional

Browser User-Agent. Use the current value supported by CapMonster Cloud: userAgentPlaceholder

You can get the latest value at: https://capmonster.cloud/api/useragent/actual.


pageAction<string>optional

The action field found in the callback function when the captcha is loaded


data<string>optional

The value of the data field, taken from the cData parameter.


proxyType<string>optional

http - standard http/https proxy;
https - try this if "http" doesn't work (needed for some custom proxies);
socks4 - socks4 proxy;
socks5 - socks5 proxy.


proxyAddress<string>optional

IP address of the proxy (IPv4/IPv6). Not allowed:

  • using transparent proxies (those exposing the client IP);
  • using local machine proxies.


proxyPort<integer>optional

Proxy port.


proxyLogin<string>optional

Proxy login.


proxyPassword<string>optional

Proxy password.


Create task method​

POST
https://api.capmonster.cloud/createTask

Request example

{
"clientKey": "API_KEY",
"task": {
"type": "TurnstileTask",
"websiteURL": "https://yourwebsite.com/page-with-turnstile",
"websiteKey": "your-website-key"
}
}

Response example

{
"errorId": 0,
"taskId": 407533072
}

Get task result method​

Use the getTaskResult method to retrieve the Turnstile solution. Depending on system load, the response can take between 5 and 20 seconds.

POST
https://api.capmonster.cloud/getTaskResult

Request example

{
"clientKey": "API_KEY",
"taskId": 407533072
}

Response example

{
"errorId": 0,
"cost": 0.0013,
"status": "ready",
"solution": {
"userAgent": "userAgentPlaceholder",
"token": "0.iGX3xsyFCkbGePM3jP4P4khLo6TrLukt8ZzBvwuQOvbC...f61f3082"
}
}
PropertyTypeDescription
tokenStringUse the token in an input field or when calling a callback function

How to differentiate Cloudflare Turnstile from Cloudflare Challenge​

Differences between Turnstile and Challenge

Cloudflare verification types can appear in different ways.

Standard Turnstile:

Standard Turnstile example: a Cloudflare page “Checking if the site connection is secure” with a “Verify you are human” checkbox widget and a “Why am I seeing this page?” link.

Stylized variants:

Stylized Turnstile example: a page titled “Captcha Challenge” with the “Verify you are human” Cloudflare checkbox widget integrated into the site design.

The challenge is seamlessly integrated into the website

A page that looks like a normal Turnstile: a “Verify you are human” Cloudflare checkbox on a blank page, although it is actually a Cloudflare challenge.

Looks like a normal Turnstile captcha, but it is actually a Cloudflare challenge

To confirm Challenge presence, open developer tools, inspect network traffic, and check the page source for typical signs:

  • The first request to the site returns a 403 status code:

Chrome DevTools, Network tab, Headers: the first request to the site returns Status Code 403 (red dot), which indicates a Cloudflare Challenge; the Request URL is blurred.

  • The form with id challenge-form has an action attribute (not to be confused with Turnstile captcha action) containing the parameter __cf_chl_f_tk=:

DevTools Elements: form#challenge-form with an action attribute containing __cf_chl_f_tk= (highlighted), next to a “Verify you are human” widget; the page is searched for “action”. Small image, details hard to read.

  • The page contains two similar <script> tags that create new values in the window object:

Animation: a “Verify you are human” Turnstile widget next to the DevTools Elements panel, on DevTools search in DOM for “cvId” returns two results - two similar scripts.


How to find all required parameters for task creation​

Manually​

  1. Open your website where the captcha appears in the browser.
  2. Right-click on the captcha element and select Inspect.

websiteKey​

Can be found in Elements:

DevTools Elements: div id=’cf-turnstile’ class=’cf-turnstile’ with data-sitekey=’3x00000000000000000000FF’ framed in red; this is the Turnstile websiteKey.

DevTools Elements: iframe src from challenges.cloudflare.com with the sitekey 0x4AAAAAAABUYP0XeMJF0xoy framed in red inside the URL path; this is the Turnstile websiteKey.

pageAction​

Action and sitekey can also be found in the callback function:

DevTools Network tab, Response: turnstile.render with sitekey “0x4AAAAAAABUYP0XeMJF0xoy”, action “login” and a callback function; the request “tsmanaged.zlsupport.com” is framed in red.

Automatically​

To automate parameter extraction, you can retrieve them via a browser (regular or headless, e.g., using Playwright) or directly from HTTP requests. Since dynamic parameter values are short-lived, it is recommended to use them immediately after retrieval.

Important!

The provided code snippets are basic examples for learning how to extract the required parameters. The exact implementation will depend on your captcha page, its structure, and the HTML elements and selectors used.

Show code (for browser)
// Function to check for the presence of window.onloadTurnstileCallback
const checkTurnstileCallback = () => {
return new Promise((resolve, reject) => {
const timeout = setTimeout(() => reject('Callback timeout'), 30000);

const interval = setInterval(() => {
if (window.onloadTurnstileCallback !== undefined) {
clearInterval(interval);
clearTimeout(timeout);

const callbackDetails = window.onloadTurnstileCallback.toString();
const sitekeyMatch = callbackDetails.match(/sitekey: ['"]([^'"]+)['"]/);
const actionMatch = callbackDetails.match(/action: ['"]([^'"]+)['"]/);

resolve({
sitekey: sitekeyMatch ? sitekeyMatch[1] : null,
action: actionMatch ? actionMatch[1] : null,
});
}
}, 500);
});
};

// Try to find any element with data-sitekey
const turnstileElement = document.querySelector('[data-sitekey]');

if (turnstileElement) {
// Extract the data-sitekey attribute value
const sitekey = turnstileElement.getAttribute("data-sitekey");
console.log("Turnstile Sitekey (from element):", sitekey);
} else {
console.log("Turnstile element not found. Checking via callback...");

// If the element is not found, check via window.onloadTurnstileCallback
checkTurnstileCallback()
.then((data) => {
console.log("Turnstile Params (from callback):", data);
})
.catch((error) => {
console.error(error);
});
}

Use the SDK library​

Show code (for browser)
// https://github.com/CapMonsterCloud/capmonster-nodejs-captcha-solver

import {
CapMonsterCloudClientFactory,
ClientOptions,
TurnstileRequest
} from "@zennolab_com/capmonstercloud-client";

document.addEventListener("DOMContentLoaded", async () => {

const API_KEY = "YOUR_API_KEY"; // Specify your CapMonster Cloud API key

const client = CapMonsterCloudClientFactory.Create(
new ClientOptions({ clientKey: API_KEY })
);

// Basic example without proxy
// CapMonster Cloud automatically uses its own proxies
let turnstileRequest = new TurnstileRequest({
websiteURL: "https://yourwebsite.com/page-with-turnstile",
websiteKey: "your-website-key",
});

// Example using your proxy
// Uncomment this block if you want to use your own proxy
/*
const proxy = {
proxyType: "https",
proxyAddress: "123.45.67.89",
proxyPort: 8080,
proxyLogin: "username",
proxyPassword: "password",
};

turnstileRequest = new TurnstileRequest({
websiteURL: "https://yourwebsite.com/page-with-turnstile",
websiteKey: "your-website-key",
proxy,
});
*/

// You can check your balance if necessary
const balance = await client.getBalance();
console.log("Balance:", balance);

const result = await client.Solve(turnstileRequest);
console.log("Solution:", result.solution);
});
Show code (Node.js)
// https://github.com/CapMonsterCloud/capmonster-nodejs-captcha-solver

const {
CapMonsterCloudClientFactory,
ClientOptions,
TurnstileRequest,
} = require("@zennolab_com/capmonstercloud-client");

const API_KEY = "YOUR_API_KEY"; // Specify your CapMonster Cloud API key

async function solveTurnstile() {
const client = CapMonsterCloudClientFactory.Create(
new ClientOptions({ clientKey: API_KEY }),
);

// Basic example without proxy
// CapMonster Cloud automatically uses its own proxies
let turnstileRequest = new TurnstileRequest({
websiteURL: "https://yourwebsite.com/page-with-turnstile",
websiteKey: "your-website-key",
});

// Example using your proxy
// Uncomment this block if you want to use your own proxy
/*
const proxy = {
proxyType: "https",
proxyAddress: "123.45.67.89",
proxyPort: 8080,
proxyLogin: "username",
proxyPassword: "password",
};

turnstileRequest = new TurnstileRequest({
websiteURL: "https://yourwebsite.com/page-with-turnstile",
websiteKey: "your-website-key",
proxy,
});
*/

// You can check your balance if necessary
const balance = await client.getBalance();
console.log("Balance:", balance);

const result = await client.Solve(turnstileRequest);
console.log("Solution:", result.solution);
}

solveTurnstile().catch(console.error);