TurnstileTask / Cloudflare Challenge
All Turnstile subtypes are automatically supported: manual, non-interactive и invisible. Therefore, there is no need to specify a subtype for a normal captcha.
Attention!
If you solve Turnstile on the cloudflare 5s challenge pages, don’t forget to specify cloudflareTaskType
and related fields. userAgent is required.
Object structure
Parameter | Type | Required | Value |
type | String | yes | TurnstileTask |
websiteURL | String | yes | The page address, where the captcha is solved |
websiteKey | String | yes | Turnstile key |
proxyType | String | yes | http - regular http/https proxy |
proxyAddress | String | yes | The IP address of the IPv4/IPv6 proxy. Not allowed:
|
proxyPort | Integer | yes | Proxy port |
proxyLogin | String | no | Proxy login |
proxyPassword | String | no | Proxy password |
cloudflareTaskType | String | no | cf_clearance - if cookies are required; |
htmlPageBase64 | String | yes, if cloudflareTaskType is equal to cf_clearance | Base64 encoded html page with captcha. |
userAgent | String | yes, if cloudflareTaskType is specified. | Only the latest UAs from Chrome are supported. |
pageAction | String | yes, if cloudflareTaskType is equal to token | The |
data | String | yes, if cloudflareTaskType is equal to token | The value of the data field can be taken from the |
pageData | String | yes, if cloudflareTaskType is equal to token | The value of the pageData field can be taken from the |
Proxy for token method is not required.
These parameters are in the object that is passed during captcha creation in window.turnstile.render(el, paramsObj)
function. You can get them, for example, by executing JavaScript before loading other scripts:
(function () {
const obj = {
render: function () {
const { action, cData, chlPageData } = arguments[1];
const params = [
["action", action],
["data", cData],
["pageData", chlPageData],
];
console.table(params)
}
};
Object.defineProperty(window, "turnstile", {
get: () => {
return obj;
},
});
})();
Request examples
Normal Turnstile:
Address https://api.capmonster.cloud/createTask
{
"clientKey":"dce6bcbb1a728ea8d871de6d169a2057",
"task":
{
"type":"TurnstileTask",
"websiteURL":"http://tsmanaged.zlsupport.com",
"websiteKey":"0x4AAAAAAABUYP0XeMJF0xoy"
"proxyType":"http",
"proxyAddress":"8.8.8.8",
"proxyPort":8080,
"proxyLogin":"proxyLoginHere",
"proxyPassword":"proxyPasswordHere"
}
}
Response example
{
"errorId":0,
"taskId":407533072
}
Cloudflare challenge
Address https://api.capmonster.cloud/createTask
{
"clientKey":"dce6bcbb1a728ea8d871de6d169a2057",
"task":
{
"type":"TurnstileTask",
"websiteURL":"https://nowsecure.nl",
"websiteKey":"0x4AAAAAAADnPIDROrmt1Wwj"
"proxyType":"http",
"proxyAddress":"8.8.8.8",
"proxyPort":8080,
"proxyLogin":"proxyLoginHere",
"proxyPassword":"proxyPasswordHere",
"cloudflareTaskType": "cf_clearance",
"htmlPageBase64": "PCFET0NUWVBFIGh0...vYm9keT48L2h0bWw+",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"
}
}
Getting a result
Use the getTaskResult method to get the Turnstile solution. Depending on the system load, you will receive a response after a time ranging from 5 to 20 seconds.
Property | Type | Description |
cf_clearance | String | Special cloudflare cookies, that you can set |
token | String | Pass this token to the callback function |
When specify cloudflareTaskType
and when not? Or how to distinguish a normal Turnstile from a Cloudflare Challenge.
Cloudflare Challenge may look different.
Simple variant:
Stylized variants:
To finally verify the presence of Cloudflare, you can open the developer tools, see the traffic, examine the page code and see the characteristic features:
The first request to the site returns a 403 code:
The form with the id challenge-form has an action attribute, containing the
__cf_chl_f_tk=
parameter:There are two similar
<script>
tags on the page that create a new value in thewindow
object: