My SendGrid key leaked. What do I do?
Delete the key under Settings → API Keys in SendGrid, create a Restricted Access key with only Mail Send on your server, and check Activity for mail you didn't send. Leaked SendGrid keys are widely abused for spam and phishing, which can get your account suspended.
Last updated 2026-11-25 · Reviewed by ProofForge
Is it this key?
Format: SG.
Blast radius: Full-access keys can send mail, read contacts, and change settings and other keys. Restricted keys only reach what they allow.
The first 10 minutes
| When | Do | How |
|---|---|---|
| 0–2 min | Delete | Settings → API Keys → delete the leaked key. |
| 2–4 min | Replace | Create a Restricted Access key (Mail Send only) and set it server-side. Redeploy. |
| 4–8 min | Check activity | Review Activity and stats for unexpected volume. Check for new API keys, users or sender identities. |
| 8–10 min | Close the hole | Remove the key from code and git history, and turn on 2FA if it isn't on. |
Stop the next leak
- Keep the key in a server-side env var. Never use a
VITE_,NEXT_PUBLIC_orEXPO_PUBLIC_variable or hard-code it in frontend code. - Call the provider from your backend or an edge function, and add
.env*to.gitignore. - Re-scan the live site after every deploy. Keys also leak through JS bundles, source maps and exposed
.envor.gitpaths.
Check your live app
A free, read-only public-surface scan. It cannot diagnose private sessions or every cause described above.
FAQ
Is SendGrid part of Twilio?
Yes. Its docs live on twilio.com/docs/sendgrid.
Can I edit a key to remove permissions instead of deleting it?
Delete a leaked key. Editing permissions doesn't stop the holder from sending with what's left.
Was my contact list exposed?
If the key had Marketing or full access, assume so.