Cloudflare Turnstile is a bot-mitigation solution that verifies that visitors are real without requiring them to solve a CAPTCHA. The eCDN Turnstile endpoints let you manage Turnstile widgets for your Commerce Cloud storefronts—creating, listing, updating, and deleting widgets programmatically.
Each widget is identified by a sitekey (the public key embedded in your storefront HTML) and has a corresponding secret (used server-side to validate challenge responses). The API returns the secret so that you can store it in your application’s server-side configuration.
For general eCDN concepts and the zones API, see CDN Zones.
Widget Modes
A widget operates in one of three modes:
Mode
Behavior
managed
Cloudflare determines the optimal challenge type (recommended for most use cases).
non-interactive
A non-interactive challenge runs automatically without user action.
invisible
The challenge runs entirely in the background with no visible widget rendered.
Scope
Widgets are scoped to the realm and environment derived from the organization ID. For example, a GET request from f_ecom_bcxj_prd returns only production widgets for realm bcxj.
Domains
Each widget is associated with one or more domains (hostnames) where it can be presented. Only requests that originate from a listed domain pass validation. Update the domain list as hostnames are added to or removed from your storefront.
Authorization
All Turnstile endpoints require an OAuth 2.0 bearer token with the sfcc.cdn-zones.rw scope.
The Turnstile endpoints are relative to the following base URL:
A 200 OK response returns the updated widget. The endpoint returns 404 Not Found if the widget doesn’t exist, and 400 Bad Request if the request exceeds the Cloudflare hostname limit for the widget.
Delete a Turnstile Widget
Deletes an existing widget. This operation is irreversible and immediately invalidates the sitekey and secret.
Must be true to delete a production widget. Without this flag, deleting a production widget returns 403 Forbidden.
dryRun
No
false
When true, validates the request without performing the deletion.
A successful deletion returns 204 No Content. The endpoint returns 404 Not Found if the widget doesn’t exist, and 403 Forbidden if you attempt to delete a production widget without forceProduction=true.
Production widgets (environment = prd) require an explicit forceProduction=true. Use dryRun=true to validate parameters before committing to deletion. Post-deletion verification runs automatically to confirm removal.
Note
Error Responses
All Turnstile endpoints return errors in application/problem+json format:
1{2 "title": "Short description of the error",3 "type": "ErrorType",4 "detail": "Additional context about what went wrong"5}
Status Code
Meaning
400
Bad request—invalid input, name too long, hostname limit exceeded, and so on.
401
Unauthorized—missing or invalid bearer token.
403
Forbidden—insufficient scope, or production deletion without the force flag.
404
Not found—a widget with the given sitekey doesn’t exist.
500
Internal server error.
Integration Workflow
A typical workflow:
Create a widget. Call POST /turnstile/widgets with your desired name, domains, and mode.
Configure your storefront. Add the sitekey and secret from the response to your Managed Runtime application’s .env file. For the exact environment variables and configuration, see steps 2(a) and 2(b) in the Storefront Next One-Click Checkout guide.
Update domains. As you add or remove storefront hostnames, call PUT /turnstile/widgets/{sitekey} to keep the domain list in sync.
Limitations and Considerations
Each instance allows up to 5,000 widgets.
Each widget’s domain list is subject to Cloudflare’s per-widget hostname limit.
List results are cached for 5 minutes, so newly created widgets can take up to 5 minutes to appear in list responses. To retrieve a new widget right away, use GET /turnstile/widgets/{sitekey}, which isn’t cached.
You can’t change the name after creation. To rename a widget, delete and recreate it.
Each environment (development, staging, production) has its own widgets. Widgets can’t be shared across environments.
If you delete a widget that is still in use, its sitekey and secret are immediately invalidated, and any Turnstile challenges that use that sitekey fail. Remove the widget HTML from your storefront before, or immediately after, deletion.
To choose a mode, use this guidance:
Use managed (recommended) for most storefronts—Cloudflare picks the optimal challenge.
Use invisible for a seamless experience where no widget is shown.
Use non-interactive when you want the challenge to run automatically without a visible puzzle but still show the widget.