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

Cloudflare Turnstile

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

Request parameters

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.

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.

type<string>required

TurnstileTask


websiteURL<string>required

The URL of the page where the captcha is solved


websiteKey<string>required

Turnstile site key


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

{
"clientKey": "API_KEY",
"task": {
"type": "TurnstileTask",
"websiteURL": "http://tsmanaged.zlsupport.com",
"websiteKey": "0x4AAAAAAABUYP0XeMJF0xoy"
}
}

Response

{
"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

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

Response

{
"errorId": 0,
"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:

Stylized variants:

The challenge is seamlessly integrated into the website

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:

  • 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=:

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


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:

sitekeyTurnstile

sitekeyTurnstile1

pageAction

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

callbackTurnstile

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/ZennoLab/capmonstercloud-client-js

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

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

document.addEventListener("DOMContentLoaded", async () => {
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: "http://tsmanaged.zlsupport.com", // URL of the page with the captcha
websiteKey: "0x4AAAAAAABUYP0XeMJF0xoy" // Replace with the correct value
});

// Example of using your own 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: "http://tsmanaged.zlsupport.com",
websiteKey: "0x4AAAAAAABUYP0XeMJF0xoy",
proxy,
userAgent: "userAgentPlaceholder"
});
*/

// Optionally, you can check the balance
const balance = await client.getBalance();
console.log("Balance:", balance);

const result = await client.Solve(turnstileRequest);
console.log("Solution:", result);
});
Show code (Node.js)
// https://github.com/ZennoLab/capmonstercloud-client-js

import { CapMonsterCloudClientFactory, ClientOptions, TurnstileRequest } from '@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: "http://tsmanaged.zlsupport.com", // URL of the page with the captcha
websiteKey: "0x4AAAAAAABUYP0XeMJF0xoy" // Replace with the correct value
});

// Example of using your own 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: "http://tsmanaged.zlsupport.com",
websiteKey: "0x4AAAAAAABUYP0XeMJF0xoy",
proxy,
userAgent: "userAgentPlaceholder"
});
*/

// Optionally, you can check the balance
const balance = await client.getBalance();
console.log("Balance:", balance);

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

solveTurnstile().catch(err => console.error("Error:", err));