An API Key Is Access, Not Just Configuration
After reading about a security incident on a cloud platform, I ran a very basic but worthwhile check. Is there a key anywhere in the website? In the Git history? Has a local configuration file been tracked by accident?
An API key is not just a line of text for connecting services. It is closer to a key that grants access. If it ends up in a public repository, a screenshot, a document, frontend code, or an environment variable on a third-party platform, someone may be able to use it to call services, burn through your quota, or even reach your data.
The point of this note is not to cause anxiety. It is to lay out a first-pass check that anyone can follow.
Do These Three Things First
- Find every place a key has ever appeared. Check separately: public website source, Git repositories and their commit history, local
.envfiles, cloud platform environment variables, notes, and screenshots. Do not look only at current files, because a deleted key can still live in Git history. - Rotate when in doubt; do not wait for confirmed exposure. If a key was ever in a public repo or on the third-party platform involved in the incident, or you cannot be sure whether anyone has seen it, the cleanest approach is to revoke the old key, create a new one, and then disable the old one.
- Add usage limits and alerts. Set a budget or usage cap for paid APIs, turn on unusual-activity alerts, disable automatic top-ups you do not need, and review usage logs regularly. None of this prevents a leak, but it keeps the damage from growing unchecked.
Never Put a Key in These Places
- Frontend JavaScript, HTML, public JSON, or public configuration files.
- Git commits, issues, PRs, READMEs, tutorials, or chat screenshots.
- Real values in
.env.example, or a.envfile that is not excluded by.gitignore. - Publicly accessible notes, spreadsheets, cloud drives, or draft posts.
If a service genuinely needs to be called from the browser, route it through a backend or serverless function proxy so the server keeps the secret. Never send a long-lived key to the user's browser.
A Reusable 30-Minute Checklist
- List the API keys, tokens, databases, and bot credentials currently in use.
- Search the current code and the full Git history for real keys.
- Confirm
.envis not tracked, and check.gitignore. - Review environment variables on every cloud deployment platform.
- Revoke and recreate any key that was exposed or whose status you cannot confirm.
- Set budgets, rate limits, and unusual-activity alerts.
- Record each key's purpose, owner, and rotation date, but never the key itself.
Make Rotation Routine Maintenance
Security does not mean shutting every tool down. It means managing convenience and access separately. Treat a key as access, not configuration, and treat rotation as routine maintenance rather than a fix that only starts after an incident.