Where do I keep API keys safe? (vaults and secrets)
Keep the master copy of every key in a password manager or vault, give each app its keys as encrypted secrets, and never put a key in your code or a chat.
Each place a key is used has one right home:
- You: a password manager such as 1Password or Bitwarden holds the original, with a note on where it's used.
- Your Cloudflare Worker: Worker secrets, set with
npx wrangler secret put, which your code reads by name while it runs. - Automation such as GitHub Actions: the encrypted secrets settings of that service.
- AI agents: an agent platform's vault, so agents can use keys without the value appearing in the conversation.
Keys don't belong in code files, config files committed to Git, chats, emails, screenshots or AI prompts. Each of those gets copied, synced or shown to people you didn't plan for. A .gitignore file keeps local secret files out of Git, but only if it's in place before you commit them.
If a key leaks, act in this order: revoke or replace it in the provider's dashboard, put the new key where it belongs, then check the account's usage for anything you didn't do. Deleting the commit isn't enough, because copies may already exist.
Vumbli's Accounts, API Keys & Secrets track covers vaults, Worker secrets and what to do after a leak. Ship It includes "Secrets: get the API key out of the browser", where you fix AI code that exposed a key.
Start with these missions
- What an API key really is (Accounts, API Keys & Secrets)
- Build a secret scanner (Accounts, API Keys & Secrets)
- Git & GitHub in 15 minutes (Ship It)
- Deploy your first site to Cloudflare (Ship It)
Tracks that teach it
More questions, answered by building