NEWStandard createTask and in.php APIs. Change the address and you are connected.View API docs
GATESOLVER

Cloudflare

How to find the Turnstile site key, action and cData

A Turnstile task needs the site key, and some sites also expect the action and cData values they attached to the widget. All three are readable from the page once you know where to look.

The three values and why they matter

The site key identifies the widget configuration in the owner's Cloudflare account. Turnstile site keys start with 0x4, which makes them easy to tell apart from reCAPTCHA keys. The task cannot run without it.

The action is a short label, such as login or signup, that the site can attach to a widget to tell apart widgets on different pages. Cloudflare returns it when the site verifies the token, and a careful back end compares it with the value it expects. The cData ("customer data") is a free form string, often a session or request identifier, returned the same way. Both are optional for the site to use; when a site does use them, a token made without them can be refused. In a GateSolver task they go into metadata as action and cdata.

Implicit rendering: read the attributes

The simplest integration is a div that the Turnstile script finds and renders on its own:

<div class="cf-turnstile"
     data-sitekey="0x4AAAAAAAExampleKey"
     data-action="newsletter"
     data-cdata="sess-7f3a"
     data-callback="onTurnstileOk"></div>

Search the Elements panel for cf-turnstile or data-sitekey. The attributes map directly: data-sitekey to websiteKey, data-action to metadata.action, data-cdata to metadata.cdata. data-callback is not a task field, but note it: it names the global function that receives the token, which your automation may need to call. Other attributes such as data-theme, data-size or data-appearance only change how the widget looks.

Explicit rendering: read the render call

When the script is loaded as https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit, the page creates widgets itself:

turnstile.render('#ts-slot', {
  sitekey: '0x4AAAAAAAExampleKey',
  action: 'checkout',
  cData: orderDraft.id,
  callback: (token) => store.setTurnstile(token),
});

Search all loaded scripts (Ctrl+Shift+F in Chrome developer tools) for turnstile.render or for 0x4. Note the spelling of the option: cData with a capital D in the render options, while the HTML attribute is data-cdata. When the value is a variable, as in the example, static search shows only its name. Set a breakpoint on the line and trigger the form, or use the logger below to see the real value at run time.

A console logger for render calls

Paste this in the console before the widget appears (for example, before opening a modal that contains it), or add it as an init script in your automation. It reports every widget the page renders, with its options.

(() => {
  const report = (o, how) =>
    console.table([{ how, sitekey: o.sitekey, action: o.action ?? '', cData: o.cData ?? '',
      callback: typeof o.callback === 'function' ? (o.callback.name || '(anonymous)') : String(o.callback ?? '') }]);
  document.querySelectorAll('.cf-turnstile[data-sitekey]').forEach((el) =>
    report({ sitekey: el.dataset.sitekey, action: el.dataset.action, cData: el.dataset.cdata,
      callback: el.dataset.callback }, 'attribute'));
  const tsApi = window.turnstile;
  if (tsApi && !tsApi.__logged) {
    const real = tsApi.render.bind(tsApi);
    tsApi.render = (el, opts = {}) => { report(opts, 'render()'); return real(el, opts); };
    tsApi.__logged = true;
  }
})();

Widgets already on the page are listed from their attributes; widgets rendered after you run the snippet are listed as they appear. If window.turnstile does not exist yet, the script has not loaded; run the snippet again once it has.

The network tab as a cross check

Turnstile loads its widget from challenges.cloudflare.com. Filter the Network panel by that host and open the widget's frame request: in current versions the site key appears as one of the path segments of the iframe address. This is handy when the widget sits inside a shadow root or a third party iframe that the Elements search does not reach. Treat it as a cross check rather than a primary method, since Cloudflare can change those internal URLs.

Where the token goes

While you are looking at the widget, also note how the page consumes the token, because it decides how you deliver the answer later:

  • A hidden input named cf-turnstile-response inside the form (the default for implicit rendering). Posting the form with that field set is enough.
  • A data-callback or callback option. The page may keep the token in its own state; call the callback with the solved token.
  • A custom field name set with response-field-name or data-response-field-name. Fill that input instead of the default one.

Widgets inside modals and iframes

Many sites only render Turnstile when a dialog opens or a step of a checkout begins. Nothing shows up in the Elements panel until then, which can make it look as if the page has no widget at all. Open the dialog first, then search. If the form itself is served from another origin inside an iframe, switch the developer tools context to that frame (the dropdown at the top of the Console panel) before running the logger, and use the frame's own address as websiteURL.

Building the task

With the values in hand, the task object looks like this (send it with your clientKey to /createTask):

{"type": "AntiTurnstileTaskProxyLess", "websiteURL": "https://shop.example.org/newsletter",
 "websiteKey": "0x4AAAAAAAExampleKey", "metadata": {"action": "newsletter", "cdata": "sess-7f3a"}}

Use the address of the page that shows the widget as websiteURL, not the endpoint the form posts to. Leave metadata out when the page sets neither value. cData values that look like session identifiers change per visit, so read them from the same page load you will submit from.

Common mistakes

  • Confusing the widget with the challenge page. A full screen "Just a moment" check has no site key to find; it needs the Cloudflare challenge task and your proxy. See how to tell Cloudflare protections apart.
  • Using a reCAPTCHA key. Pages sometimes load both. Only 0x4 keys belong to Turnstile.
  • Stale cData. Reusing a value from an earlier visit can make the site reject the token.
  • Missing action. If the widget declares an action, send it, even if the form seems to work without it during testing.

Language guides take it from here: Turnstile in Python and Turnstile in Node.js. Fields are listed on the Turnstile task page.

Common questions

How can I recognise a Turnstile site key?

It starts with 0x4 followed by letters and digits, for example 0x4AAAAAAA plus more characters.

Are action and cData required in the task?

Only when the page sets them. If the widget declares either value, send it in metadata so the site's checks match.

Why is it cData in one place and cdata in another?

The JavaScript render option is cData, the HTML attribute is data-cdata, and the task metadata field is cdata. They hold the same value.

What does render=explicit in the script URL mean?

The page creates widgets itself with turnstile.render, so the values are in that call rather than in HTML attributes.

Can the site key change between visits?

Rarely. cData, on the other hand, often changes per visit, so read it fresh each time.

Keep reading