Create and manage widgets using Cloudflare API
import { APIRequest } from "~/components"
Use the Cloudflare API for programmatic widget management and automation.
Prerequisites
Before you begin, you must have:
- A Cloudflare API token with
Account:Turnstile:Editpermissions - An account ID found in your Cloudflare dashboard
Create a widget via the API
<APIRequest path="/accounts/{account_id}/challenges/widgets" method="POST" json={{ domains: ["example.com"], mode: "managed", name: "My Example Turnstile Widget", }} />
Manage widgets via the API
<APIRequest path="/accounts/{account_id}/challenges/widgets/{sitekey}" method="PUT" json={{ domains: ["203.0.113.1", "cloudflare.com", "blog.example.com"], mode: "invisible", name: "blog.cloudflare.com login form", clearance_level: "interactive", }} />
<APIRequest path="/accounts/{account_id}/challenges/widgets/{sitekey}/rotate_secret" method="POST" json={{ invalidate_immediately: false, }} />
这篇文档对你有帮助吗?
谢谢你的反馈!