# My SendGrid key leaked. What do I do?

**Short answer:** 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_` or `EXPO_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 `.env` or `.git` paths.

> **Scan box (use the site's ScanBox component):** Check whether your live app has this problem. Paste your URL for a free outside-in scan covering exposed keys, open database rules, CORS and security headers. [Scan my app free →](https://proofforge.live/#scan)

## 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.

## Sources

- [SendGrid: API Keys](https://www.twilio.com/docs/sendgrid/ui/account-and-settings/api-keys)

## Related

- [Fix: .env file exposed](/fix/env-file-exposed)
- [Fix: secrets in VITE_ / NEXT_PUBLIC_ vars](/fix/vite-env-secrets)
- [Exposed API key checker](/tools/exposed-api-key-checker)
- [Fix: source maps exposed](/fix/source-maps-exposed)
- [All leaked-key guides](/leaked-keys)
