Skip to main content

widgets

Creates, updates, deletes, gets or lists a widgets resource.

Overview

Namewidgets
TypeResource
Idcloudflare.turnstile.widgets

Fields

The following fields are returned by SELECT queries:

Turnstile Widget Details Response

NameDatatypeDescription
namestringHuman readable widget name. Not unique. Cloudflare suggests that you set this to a meaningful string to make it easier to identify your widget, and where it is used. (example: blog.cloudflare.com login form)
ephemeral_idbooleanReturn the Ephemeral ID in /siteverify (ENT only).
bot_fight_modebooleanIf bot_fight_mode is set to true, Cloudflare issues computationally expensive challenges in response to malicious bots (ENT only).
clearance_levelstringIf Turnstile is embedded on a Cloudflare site and the widget should grant challenge clearance, this setting can determine the clearance level to be set (no_clearance, jschallenge, managed, interactive) (example: interactive)
created_onstring (date-time)When the widget was created. (example: 2014-01-01T05:20:00.123123Z)
domainsarray
modestringWidget Mode (non-interactive, invisible, managed) (example: invisible)
modified_onstring (date-time)When the widget was modified. (example: 2014-01-01T05:20:00.123123Z)
offlabelbooleanDo not show any Cloudflare branding on the widget (ENT only).
regionstringRegion where this widget can be used. This cannot be changed after creation. (world, china) (default: world)
secretstringSecret key for this widget. (example: 0x4AAF00AAAABn0R22HWm098HVBjhdsYUc)
sitekeystringWidget item identifier tag. (example: 0x4AAF00AAAABn0R22HWm-YUc)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectaccount_id, sitekeyShow a single challenge widget configuration.
listselectaccount_idpage, per_page, order, direction, filterLists all turnstile widgets of an account.
createinsertaccount_id, name, mode, domainspage, per_page, order, direction, filterLists challenge widgets.
updatereplaceaccount_id, sitekey, name, mode, domainsUpdate the configuration of a widget.
deletedeleteaccount_id, sitekeyDestroy a Turnstile Widget.
rotate_secretexecaccount_id, sitekeyGenerate a new secret key for this widget. If invalidate_immediately is set to false, the previous secret remains valid for 2 hours. Note that secrets cannot be rotated again during the grace period.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
account_idstringThe Cloudflare account ID.
sitekeystring
directionstring
filterstringFilter widgets by field using case-insensitive substring matching. Format: field:value Supported fields: - name - Filter by widget name (e.g., filter=name:login-form) - sitekey - Filter by sitekey (e.g., filter=sitekey:0x4AAA) Returns 400 Bad Request if the field is unsupported or format is invalid. An empty filter value returns all results.
orderstring
pagenumber
per_pagenumber

SELECT examples

Show a single challenge widget configuration.

SELECT
name,
ephemeral_id,
bot_fight_mode,
clearance_level,
created_on,
domains,
mode,
modified_on,
offlabel,
region,
secret,
sitekey
FROM cloudflare.turnstile.widgets
WHERE account_id = '{{ account_id }}' -- required
AND sitekey = '{{ sitekey }}' -- required
;

INSERT examples

Lists challenge widgets.

INSERT INTO cloudflare.turnstile.widgets (
bot_fight_mode,
clearance_level,
domains,
ephemeral_id,
mode,
name,
offlabel,
region,
account_id,
page,
per_page,
order,
direction,
filter
)
SELECT
{{ bot_fight_mode }},
'{{ clearance_level }}',
'{{ domains }}' /* required */,
{{ ephemeral_id }},
'{{ mode }}' /* required */,
'{{ name }}' /* required */,
{{ offlabel }},
'{{ region }}',
'{{ account_id }}',
'{{ page }}',
'{{ per_page }}',
'{{ order }}',
'{{ direction }}',
'{{ filter }}'
RETURNING
errors,
messages,
result,
result_info,
success
;

REPLACE examples

Update the configuration of a widget.

REPLACE cloudflare.turnstile.widgets
SET
bot_fight_mode = {{ bot_fight_mode }},
clearance_level = '{{ clearance_level }}',
domains = '{{ domains }}',
ephemeral_id = {{ ephemeral_id }},
mode = '{{ mode }}',
name = '{{ name }}',
offlabel = {{ offlabel }},
region = '{{ region }}'
WHERE
account_id = '{{ account_id }}' --required
AND sitekey = '{{ sitekey }}' --required
AND name = '{{ name }}' --required
AND mode = '{{ mode }}' --required
AND domains = '{{ domains }}' --required
RETURNING
errors,
messages,
result,
success;

DELETE examples

Destroy a Turnstile Widget.

DELETE FROM cloudflare.turnstile.widgets
WHERE account_id = '{{ account_id }}' --required
AND sitekey = '{{ sitekey }}' --required
;

Lifecycle Methods

Generate a new secret key for this widget. If invalidate_immediately is set to false, the previous secret remains valid for 2 hours. Note that secrets cannot be rotated again during the grace period.

EXEC cloudflare.turnstile.widgets.rotate_secret
@account_id='{{ account_id }}' --required,
@sitekey='{{ sitekey }}' --required
@@json=
'{
"invalidate_immediately": {{ invalidate_immediately }}
}'
;