Keys / Cloudflare Turnstile
TURNSTILE_SECRET_KEY
The widget's secret key your server sends to Turnstile's siteverify endpoint with each token to check that a visitor passed. The sitekey is the public half.
- Expires
- the docs don't say
- API
- rotate, with a Cloudflare API token that has Turnstile Sites Write
Get it
Create one on dash.cloudflare.com. The steps aren't recorded yet.
Set it
TURNSTILE_SECRET_KEY=...
No official Cloudflare library reads it; your app passes it in. Cloudflare's docs use both TURNSTILE_SECRET_KEY and TURNSTILE_SECRET. Or keep it out of .env with keypin: keypin run -- npm run dev
Replace it
- On the Turnstile page, open the widget and select Settings, then Rotate Secret Key. The old secret keeps working for 2 hours.
- Deploy the new secret everywhere that reads
TURNSTILE_SECRET_KEYwithin those 2 hours. - You can't rotate again until the 2 hours pass. The API can also end the old secret at once with
invalidate_immediately.
Set rotate_every on the key in keypin.toml and a rotated date on its vault item, and keypin status shows when it's due.
Sources, checked 2026-11-16
- Cloudflare Turnstile: Rotate secret key
- Cloudflare Turnstile: Create and manage widgets using the dashboard
- Cloudflare Turnstile: Create and manage widgets using the API
- Cloudflare API: Rotate Secret for a Turnstile Widget
- Cloudflare Turnstile: Validate the token
- Cloudflare Turnstile: Turnstile Spin