The rules
- Server-side only — API keys never go in frontend code, mobile apps, or anything the user’s browser can access.
- Environment variables — not hardcoded strings.
- Separate keys per environment — dev key leak shouldn’t compromise production.
- Rotate regularly — create a new key, update your app, revoke the old one.
- Revoke idle keys — if it’s not in use, it shouldn’t exist.
If a key is compromised
- Revoke the key from API Keys — takes effect immediately
- Create a new key and deploy it
- Check Logs for unauthorized requests
- Check Usage Analytics for unexpected token consumption
Checklist
| Practice | Done? |
|---|---|
| Keys in environment variables | |
| No keys in client-side code | |
| No keys in version control | |
| Separate keys for dev and production | |
| Unused keys revoked | |
| Rotation schedule in place |

