# My Mapbox key leaked. What do I do?

**Short answer:** A public `pk.` token in your map is expected. Add URL restrictions so other sites can't use it on your bill. A secret `sk.` token must never be in client code: create a replacement on your Access Tokens page, swap it in, and delete the leaked token. Check Statistics for usage you don't recognize.

*Last updated 2026-11-25 · Reviewed by ProofForge*

## Is it this key?

**Format:** Public `pk.` (public by design, restrict by URL). Secret `sk.` (server only, shown once). Temporary `tk.`

**Blast radius:** Public tokens are billed when used. Secret tokens can carry write scopes (uploads, styles, datasets, token management).

## The first 10 minutes

| When | Do | How |
|---|---|---|
| 0–3 min | Identify | `pk.` means restrict. `sk.` means rotate now. |
| 3–6 min | Rotate | Access Tokens page → create a new token with the same minimal scopes. Swap it into your app or server, then delete the old token. |
| 6–8 min | Restrict | Add URL restrictions to public tokens used on the web. |
| 8–10 min | Check usage | Review Statistics for the token and look for usage spikes. |

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

### Do I need to rotate my pk. token?
Not unless it's being abused. Add URL restrictions.

### Can I see a secret token again?
No. Secret tokens are shown once, so create a new one.

### Does the default public token support URL restrictions?
Create your own scoped public tokens for production and restrict those.

## Sources

- [Mapbox: Token management](https://docs.mapbox.com/accounts/guides/tokens/)

## Related

- [Google Maps key leaked: first 10 minutes](/leaked-keys/google-maps)
- [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)
