Skip to main content
The Turnstile API allows you to manage challenge widgets that provide bot protection without the frustration of traditional CAPTCHAs. Turnstile uses machine learning to validate users with minimal friction.

Initialize the Turnstile resource

Widget management

Manage Turnstile widgets for your applications.

Create widget

Create a new Turnstile widget for bot protection.
string
required
Account identifier
string[]
required
List of domains where the widget will work. Accepts hostnames or IPv4/IPv6 addresses. The widget will work on these domains and their subdomains.
string
required
Widget mode. Options:
  • non-interactive - No user interaction required
  • invisible - Invisible challenge, minimal user interaction
  • managed - Adaptive challenge based on risk
string
required
Human readable widget name. This should be a meaningful string to identify your widget and where it is used.
boolean
When set to true, Cloudflare issues computationally expensive challenges in response to malicious bots (Enterprise only).
string
If Turnstile is embedded on a Cloudflare site, this determines the challenge clearance level. Options: no_clearance, jschallenge, managed, interactive
boolean
Return the Ephemeral ID in /siteverify (Enterprise only).
boolean
Do not show any Cloudflare branding on the widget (Enterprise only).
string
Region where this widget can be used. Options: world, china. This cannot be changed after creation.

Update widget

Update the configuration of an existing widget.

List widgets

List all Turnstile widgets in your account.
string
Direction to order widgets. Options: asc, desc
string
Field to order widgets by. Options: id, sitekey, name, created_on, modified_on
number
Page number of paginated results
number
Number of items per page

Get widget

Retrieve a single widget configuration by sitekey.

Delete widget

Delete a Turnstile widget.

Rotate secret

Generate a new secret key for a widget.
boolean
If set to false, the previous secret will remain valid for two hours. Otherwise, the secret is immediately invalidated and requests using it will be rejected.
By default, the previous secret remains valid for 2 hours during rotation, allowing for a graceful transition. Note that secrets cannot be rotated again during this grace period.

Response types

Widget

A Turnstile widget configuration.
string
required
Widget item identifier tag
string
required
Secret key for this widget (only returned on creation and rotation)
string
required
Human readable widget name
string[]
required
List of domains where the widget will work
string
required
Widget mode: non-interactive, invisible, or managed
boolean
required
Whether bot fight mode is enabled
string
required
Challenge clearance level
boolean
required
Whether ephemeral ID is enabled
boolean
required
Whether Cloudflare branding is hidden
string
required
Region where widget can be used: world or china
string
required
When the widget was created
string
required
When the widget was last modified