Accounts, API Keys & Secrets
Beginner · 13 missions · about 3 hours
Real apps run on accounts with AI providers, Stripe and Cloudflare, and on the API keys that unlock them. Learn to create keys the right way, use them from code without leaking them, keep them in a vault, and clean up fast when one escapes. You finish by shipping a live Worker whose secret stays secret.
Missions
- What an API key really is: A password for programs: who can see it, what a leak costs, and test versus live.
- Build a secret scanner: Spot keys hiding in text by their prefixes, the way real secret scanners do.
- Get an AI model key the safe way: Create Anthropic and OpenAI keys per project, copy them once, and cap the spend.
- Mask keys for logs and screens: Show just enough of a key to recognize it, and never enough to use it.
- Stripe keys: sandbox, live, and who sees what: Publishable, secret, restricted and webhook keys, and the only one a browser may see.
- Decide where each key may live: Turn the rules into code: browser, server, or never in code at all.
- Cloudflare: tokens, wrangler login and Worker secrets: Scoped API tokens, the legacy Global API Key, and where each credential lives.
- Check a Worker's secrets without revealing them: Report which secrets are missing, by name only, so a Worker fails clearly.
- Fix the AI: four ways a Worker leaks its key: Typed into the code, logged, put in the URL and sent to the browser. Plug every leak.
- Will this commit leak a secret?: Read .gitignore rules like Git does and list the secret files a commit would leak.
- Vaults, password managers and agents that keep secrets: Where keys should live, how agent platforms use them unseen, and what to do after a leak.
- Write your agent's secrets rules: Standing instructions that keep an AI coding agent from ever leaking a key.
- Boss: Ship a Worker that keeps its secret: Deploy a live Worker with a real Worker secret and a health check that never reveals it.
Part of: AI Web Developer career path, AI Product Engineer career path, Indie SaaS Founder career path, Backend & Cloud Engineer career path, AI Automation Specialist career path, AI Creator & Freelancer career path