npx wrangler secret put API_KEY --name my-worker

Category: Cloudflare

npx wrangler secret put API_KEY --name my-worker

Set a secret on a specific Worker by name

Targets the Worker named my-worker instead of reading the name from wrangler.toml, which is what you need when running outside the project directory. Useful in scripts that manage several workers. The --name flag appears on most secret commands.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.