Form Challenge Widget: Siteverify Validation, Widget Modes, and Troubleshooting
How to embed a bot challenge widget, validate tokens with Siteverify, choose modes, and fix common failures.
This page summarizes Cloudflare Turnstile documentation: a CAPTCHA alternative you embed on forms and sensitive actions, then enforce on the server with the Siteverify API. Turnstile works on sites that do not use Cloudflare as a CDN; the client widget and server validation are self-contained.
Cloudflare’s smart CAPTCHA alternative. Turnstile can be embedded into any website without sending traffic through Cloudflare and works without showing visitors a CAPTCHA.
— Cloudflare, Cloudflare Turnstile
How Turnstile works: client signals and when visitors see a checkbox
Section titled “How Turnstile works: client signals and when visitors see a checkbox”Turnstile runs JavaScript challenges in the visitor’s browser to distinguish humans from automated traffic. It adapts difficulty to the visitor and often completes without a visible puzzle.
Turnstile adapts the challenge outcome to the individual visitor or browser. First, we run a series of small non-interactive JavaScript challenges to gather signals about the visitor or browser environment.
— Cloudflare, Cloudflare Turnstile
Unlike a full-page challenge, the widget sits on a specific form or action: the page loads first, and Turnstile gates submission until verification succeeds. After a pass, the visitor receives a token you must validate server-side before login, signup, or other sensitive processing.
After the challenge passes, Turnstile issues a clearance token to the visitor that must be validated via the Siteverify API before completing a sensitive action like login, sign up, or other form submissions.
— Cloudflare, Turnstile
Widget modes: Managed, Non-Interactive, and Invisible
Section titled “Widget modes: Managed, Non-Interactive, and Invisible”| Mode | Visitor experience | Typical use |
|---|---|---|
| Managed (recommended) | Checkbox only if risk warrants it | Balance of security and UX |
| Non-Interactive | Visible widget, spinner, no click | Show verification without interaction |
| Invisible | No visible widget | Minimal visual footprint |
Managed (recommended): Automatically decides whether to show a checkbox based on visitor risk level.
— Cloudflare, Cloudflare Turnstile
Two-step integration: embed the widget and call Siteverify
Section titled “Two-step integration: embed the widget and call Siteverify”Turnstile protects an endpoint only when both halves are implemented.
Turnstile setup has two parts: embed the widget in your frontend, then call siteverify from your backend. Without the second part, the widget appears on the page but does not protect the request.
— Cloudflare, Turnstile Spin
| Component | Role |
|---|---|
sitekey |
Public key in HTML or turnstile.render() |
| Secret key | Server-only; used with Siteverify |
cf-turnstile-response |
Hidden field or body field with the token |
Create a widget (sitekey and secret)
Section titled “Create a widget (sitekey and secret)”Create widgets in the Cloudflare dashboard, the Cloudflare API, or Terraform. Set Hostname management to every domain that may load the widget. Turnstile Spin can create the widget and help wire Siteverify from the dashboard, Wrangler, or an editor workflow.
Embed the widget: implicit vs explicit rendering
Section titled “Embed the widget: implicit vs explicit rendering”Implicit rendering scans for class="cf-turnstile" after api.js loads—best for static forms. Explicit rendering uses api.js?render=explicit and turnstile.render()—best for SPAs and dynamic UI. See Embed the widget.
Load the script from the canonical URL only:
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script><div class="cf-turnstile" data-sitekey="YOUR_SITEKEY"></div>— from Embed the widget
Inside a <form>, Turnstile adds a hidden cf-turnstile-response field automatically. Verify the token when the user submits, not before they finish the form, so an attacker cannot reuse a token after changing fields (Protect your forms).
Siteverify API: mandatory server-side validation
Section titled “Siteverify API: mandatory server-side validation”Endpoint: POST https://challenges.cloudflare.com/turnstile/v0/siteverify with secret and response (the token). Optional: remoteip, idempotency_key. Details: Validate the token.
Server-side validation is required because: Tokens can be forged. Tokens expire. Tokens are single-use.
— Cloudflare, Validate the token
| Rule | Detail |
|---|---|
| Lifetime | 300 seconds (5 minutes) from generation |
| Reuse | Second validation returns success: false (timeout-or-duplicate) |
| Length | Up to 2048 characters |
| HTTP method | POST with JSON or form body (not GET query params) |
It is important to call the Siteverify API. Without calling Siteverify API to validate the tokens, your website or application is not protected.
— Cloudflare, Challenge outcome
A solved widget in analytics does not by itself prove a human; you still need Siteverify on each protected action.
A “solved” Turnstile challenge does not automatically confirm the visitor is human. You must call the Siteverify API to validate the token and proceed only if the response returns success:true.
— Cloudflare, Challenge outcome
For production hardening, check hostname and action from the Siteverify response against expected values—especially with Any Hostname (Enterprise). Never call Siteverify from browser code; the secret must stay on the server (Validate the token).
Hostname management, CSP, and pre-clearance on Cloudflare zones
Section titled “Hostname management, CSP, and pre-clearance on Cloudflare zones”Hostname management limits which domains may use your sitekey (Hostname management). Error 110200 / 400021 usually means the page domain is not authorized (Error codes).
If you use a Content Security Policy, allow Turnstile’s origins:
script-src: https://challenges.cloudflare.com
frame-src: https://challenges.cloudflare.com— Cloudflare, Content Security Policy
Pre-clearance (optional) lets a successful Turnstile solve also set a cf_clearance cookie so the same visitor can skip matching WAF challenge levels on a registered Cloudflare zone whose hostname matches the widget (Pre-clearance support in Turnstile). The Turnstile token still requires Siteverify.
Analytics: solve rate, outcomes, and token validation metrics
Section titled “Analytics: solve rate, outcomes, and token validation metrics”Use Turnstile Analytics to see where challenges fail (country, browser, hostname). Challenge outcome tracks issued, solved, and unsolved challenges; Token validation compares Siteverify successes vs failures. If token validation counts stay at zero, Siteverify is likely not wired—dashboard widgets without matching Siteverify traffic can be flagged for Fix with Spin.
Solve rate splits interactive, non-interactive, and pre-clearance solves (Challenge outcome). A low solve rate may mean bots, misconfiguration, or regional issues.
Enterprise options: Ephemeral IDs and Offlabel
Section titled “Enterprise options: Ephemeral IDs and Offlabel”Ephemeral IDs are short-lived device identifiers returned in Siteverify as metadata.ephemeral_id for fraud pattern detection—not for WAF rules directly (Bot Management variables, Ephemeral IDs). They require Enterprise entitlement and account-team enablement. Treat them as abuse signals, not unique user IDs (Fraud detection with Ephemeral IDs).
Offlabel removes Cloudflare branding on widgets (Enterprise); you must still link the privacy addendum (Remove Cloudflare branding with Offlabel).
Testing keys, E2E tests, and common mistakes
Section titled “Testing keys, E2E tests, and common mistakes”Official dummy keys avoid real challenges in CI (Test your Turnstile implementation):
| Sitekey | Behavior |
|---|---|
1x00000000000000000000AA |
Always passes (visible) |
2x00000000000000000000AB |
Always fails |
3x00000000000000000000FF |
Forces interactive challenge |
Pair with test secret 1x0000000000000000000000000000000AA. Production secrets reject dummy tokens; test secrets reject real tokens.
Automated browsers (Selenium, Playwright, etc.) are not supported for production challenges—use test keys instead (Supported browsers).
Common mistakes
- Widget on the page but no Siteverify on the backend (Get started).
- Validating the token before final form submit (Protect your forms).
- Omitting hostname checks when using permissive domain settings (Any Hostname).
- Treating analytics “solved” as proof without Siteverify (Challenge outcome).
- No
error-callbackin production—errors may throw and break the page (Client-side errors).
Troubleshooting: loops, DNS noise, and error codes
Section titled “Troubleshooting: loops, DNS noise, and error codes”Challenge loops can follow strong bot signals, bad networks, extensions, disabled JavaScript, or VPNs (Challenge solve issues). Turnstile supports major browsers except Internet Explorer.
Failed lookups to *.challenges.cloudflare.com or dnstest.dev in DevTools are often expected and non-blocking (Challenge solve issues). For WebView apps, do not treat those as fatal; allow challenges.cloudflare.com (Mobile implementation). Recent changelog entries mention hagen.challenges.cloudflare.com and brunhild.challenges.cloudflare.com for allowlists (Turnstile changelog).
| Error code | Meaning | Retry? |
|---|---|---|
110200 |
Domain not authorized | No—fix hostnames |
110600 / 110620 |
Challenge or interaction timed out | Yes |
200500 |
Iframe load blocked | Yes—check CSP/firewall |
300* / 600* |
Challenge failure / bot signals | Yes—see troubleshooting |
Full table: Error codes. Console 401 during PAT fetch is often safe to ignore if tokens still work (Error codes).
For persistent user-side failures, Ray ID or widget QR feedback helps support (Feedback reports). Rotate secrets from the dashboard with a two-hour overlap for both keys (Rotate secret key).
Plans and when to add rate limiting
Section titled “Plans and when to add rate limiting”Free plan includes up to 20 widgets, 10 hostnames per widget, 7-day analytics; Enterprise adds more hostnames, Ephemeral IDs, Any Hostname, and Offlabel (Plans). Turnstile challenges form submissions; rate limiting still helps against direct POST abuse that skips the widget (Stop malicious bots).
Migration from reCAPTCHA or hCaptcha: replace script, response field name, and Siteverify URL (Migration). Turnstile Spin automates much of that substitution.
How to check this on your site
Section titled “How to check this on your site”-
Open Turnstile Analytics and confirm Token validation shows non-zero Siteverify requests with valid vs invalid tokens (Token validation).
-
Submit a protected form in a normal browser and confirm your server returns success only when Siteverify returns
success: true. -
Replay the same
cf-turnstile-responsetoken and confirm the server rejects the second attempt (timeout-or-duplicate) (Validate the token). -
Temporarily use test sitekey
1x00000000000000000000AAand secret1x0000000000000000000000000000000AAin a staging environment and run an automated form test (Test your Turnstile implementation). -
You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about.