My Mapbox key leaked. What do I do?
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_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
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.