key■panic

> an API key leaked. revoke it first. then fix the code.

Your key shipped in the browser bundle under a VITE_ or NEXT_PUBLIC_ name, got committed to git, or was pasted in a public repo. Moving the code doesn't make it safe. Anyone who copied the key still has it. So step 1 is always the same: kill the key and make a new one.

Date checked: 29 November 2026. Every provider step links to that provider's own documentation. Menus change, so if a step doesn't match what you see, follow the linked page.

═[1]═ is this key meant to be public?

Some keys are built to sit in the browser. If yours is one of these, you don't need to rotate it. What protects you is the setting behind it.

keywhy it's fine in the browserwhat actually protects you
Stripe publishable key pk_live_… / pk_test_…why it's fineStripe marks it safe to expose. It can't create charges or read account data. Stripe API keyswhat protects youKeeping sk_ and rk_ keys on the server.
Supabase publishable key, or the legacy anon keywhy it's fineSupabase says it's safe to expose in a web page or app. Supabase API keyswhat protects youRow Level Security. The key reaches only what your policies allow. Patterns 1 and 2
Firebase web config apiKeywhy it's fineFirebase says these keys are OK in code and checked-in config. Firebase API keyswhat protects youSecurity Rules and App Check. Unless the same key may also call Gemini: then it's a secret. See Firebase
Google Maps key in a web page (Maps JavaScript, Static Maps)why it's fineThe page needs it to load the map, so every visitor can see it. Google says to restrict a leaked one first. Maps security guidewhat protects youWebsite restrictions and API restrictions, plus App Check for Maps JavaScript and Places. Replace it only if abuse goes on. See Google Cloud
Clerk publishable keywhy it's fineClerk says it's safe on the frontend and needn't be rotated if made public. Clerk: which keys to rotatewhat protects youKeeping the Clerk secret key on the server.
Mapbox public token pk.…why it's finePublic tokens are the ones meant for maps in web and mobile apps. Mapbox tokenswhat protects youURL restrictions on a public token you make, so other sites can't use it. The default token can't have them. Secret sk. tokens never go in the browser. See Mapbox

Everything else is a secret: secret keys, restricted keys, service_role, access keys, auth tokens, personal access tokens. If one of those is public, start at step 1.

═[2]═ the five steps, in this order

  1. Revoke and replace the key. Now.

    Before you touch the code. Not after the fix, not after the redeploy. Removing a key from your code doesn't take it back: copies live on in old builds, caches, forks and other people's clones. GitHub's own guide says revoking is the step that matters. GitHub: remediating a leaked secret

    • Open your provider below, delete or disable the leaked key, and create a new one.
    • Provider guides often say: create the new key, switch over, then delete the old one, so nothing goes down. Our advice when the key is already public: disable or delete it right away wherever the provider lets you, and accept a short outage. Every minute it stays live, someone else can use it.
    • Don't put the new key back where the old one leaked. It goes into a server's secret settings in step 3.
  2. Check usage, logs and billing for abuse.

    Look at the window from when the key first went public until you revoked it. Each provider below says where.

    • Spikes in requests or spend. Models, regions or products you don't use.
    • Things you didn't create: new keys, users, servers, functions. Emails or texts you didn't send.
    • Some logs are kept only a short time. Supabase's free plan keeps API logs for one day. Look today.
    • Set a spend limit or budget alert while you're there. If you find abuse, write to the provider's support with the dates.
  3. Move the call to a server.

    A VITE_ variable is bundled into the code every visitor downloads. Vite docs. A NEXT_PUBLIC_ variable is inlined into the JavaScript sent to the browser. Next.js docs. Renaming it isn't enough. The call itself has to move.

    browser ─▶ your function ─▶ provider
               holds the key
    the browser never sees the key

    Paste this into Lovable, Bolt, Cursor or Claude Code:

    My app calls an API from the browser with a secret key. Move every call that uses it into a server-side function (a Supabase Edge Function, a Vercel or Netlify function, a Cloudflare Worker, or my backend). Keep the key in that function's secret environment settings, with no VITE_ or NEXT_PUBLIC_ prefix. The browser calls my function, never the provider. Only signed-in users may call it, and limit how often each user can. Then list every place the old key name still appears.

    A server function anyone can call is the next leak. Pattern 8 covers it.

  4. Rebuild and redeploy.

    Put the new key in your host's secret settings, not in a .env file in git. Build again and deploy. Old deployments and cached files can stay reachable for a while. That's one more reason step 1 comes first: the key in them is already dead.

  5. Confirm the key is gone.

    From the build. Search your build folder for the variable name and for a distinctive chunk of the old key: about 12 characters from the middle, not the prefix every key shares. Never paste the whole key into a command.

    $ grep -rn "A_UNIQUE_CHUNK" dist build out .next/static 2>/dev/null

    Soon, npx launch-blockers check will scan dist, build, out and .next/static for you. Until then, use grep.

    From git history. GitHub secret scanning reads your whole history on every branch, and it's free on public repositories. About secret scanning. To find the commits yourself:

    $ git log -p -S "A_UNIQUE_CHUNK" --all

    Rewriting history doesn't un-leak a key. GitHub says copies stay in other people's clones and in forks, and that the first step is to revoke. GitHub: removing sensitive data. That's why step 1 is first.

═[3]═ where to revoke it

OpenAI#

revoke
On the API keys page, platform.openai.com/api-keys, delete the leaked key and create a new one. OpenAI says to rotate a leaked key immediately. OpenAI docs
usage
The Usage page, platform.openai.com/usage. OpenAI docs
watch out
OpenAI says never to deploy a key in browsers or mobile apps. Spend alerts alone don't stop traffic; a hard spend limit does. OpenAI docs

Anthropic (Claude API)#

revoke
In the Claude Console, API keys (platform.claude.com/settings/keys), open the three-dot menu next to the key and choose Delete API key. Then Create key for a new one. compromised key help
usage
The Usage page, platform.claude.com/usage, filtered to that key. Spend is on platform.claude.com/cost. cost and usage reporting
watch out
Disable can be undone; Delete is permanent. For a leaked key, delete. If your code sets dangerouslyAllowBrowser or the anthropic-dangerous-direct-browser-access header, the key is in the browser. Claude API authentication

Google Gemini / Google AI Studio#

revoke
Disable the leaked key in the Google Cloud console. Make a new key in Google AI Studio (aistudio.google.com/api-keys) and deploy it. Delete the old key only once the new one works. Google's checklist makes and checks the new key before disabling the old one, so nothing goes down. For a key that's already public, we'd disable first and take the short outage. If you don't see Disable, delete it on the Credentials page; a deleted key can be restored within 30 days. Gemini leak response · Google Cloud API keys
usage
AI Studio's Usage page (aistudio.google.com/usage), plus billing and API usage in the Google Cloud console. Gemini leak response
watch out
Since 28 May 2026, new keys made in AI Studio are auth keys. They're tied to a service account and limited to the Gemini API by default, and Google says it stops leaked ones fast. An older standard key made in the Cloud console needs a restriction: the Gemini API rejects unrestricted standard keys. Either way, don't wait for Google to block it. Gemini API keys · restricting keys

Google Cloud API keys (Maps and others)#

A Maps key used in a web page is visible to every visitor. If it leaked from there, Google says to restrict it first: website restrictions, API restrictions, and App Check for Maps JavaScript and Places. Replace it only if it can't be restricted or abuse goes on after you do. Maps security guide

revoke
Any other leaked key: on the Credentials page (console.cloud.google.com/apis/credentials), select the key and click Delete. Google says it's rejected after a few minutes. Then create a new key with API and application restrictions. A deleted key can be restored within 30 days. Google Cloud API keys · deleting a key
usage
Metrics Explorer: add a filter on the label credential_id and pick the key. It shows which APIs that key called. Then check billing for the same days. checking API key usage
watch out
Rotate key makes a new key with the old one's restrictions, but the old key keeps working until you delete it. For a public leak, delete it now instead. Google calls unrestricted keys insecure: set both API and application restrictions on the new key. Google Cloud API keys · rotating with care

OpenRouter#

revoke
At openrouter.ai/settings/keys, delete the leaked key and create a new one. OpenRouter API keys
usage
The Activity page, openrouter.ai/activity, filtered by API key. OpenRouter activity
watch out
OpenRouter is a GitHub secret scanning partner and may email you about a leak. A key with no credit limit can spend your whole balance, auto top-ups included. Set a limit on the new key. OpenRouter API keys

Stripe#

Publishable keys (pk_) are meant to be public. Stripe says they're safe to expose. Secret (sk_) and restricted (rk_) keys are not.

revoke
On the API keys page (dashboard.stripe.com/apikeys), open the ⋯ menu on the key, choose Rotate key, and set Expiry to Now. rolling keys
usage
The key's ⋯ menu, View request logs, opens its requests in Workbench. request logs
watch out
Rotation can keep the old key working for up to 7 days. For a leak, pick Now. Webhook signing secrets are separate from API keys. rolling keys

Supabase#

The publishable key and the legacy anon key are meant to be public. They reach only what Row Level Security allows. Secret keys and service_role are not.

revoke
Create a new secret key in Settings › API Keys, then delete the leaked secret key. Deleting can't be undone. For a leaked legacy service_role key: switch clients to a new secret key and a publishable key, then deactivate the legacy keys. Then, on the JWT signing keys page, click Migrate JWT secret, then Rotate keys, and revoke the legacy secret under Previously used. rotating leaked keys · JWT signing keys
usage
Logs in the dashboard, filtered to API Gateway requests. Retention depends on your plan: 1 day on Free, 7 on Pro. Supabase logs
watch out
Supabase's order switches clients first. If someone is using the leaked key now, it says to retire it right away, even though parts of your app stop working. Deactivating the legacy keys turns off anon and service_role together. Don't re-enable them for a missed client; that brings the leaked key back. Revoking the legacy JWT secret right away signs out everyone who's signed in. To avoid that, wait at least 1 hour 15 minutes after Rotate keys (with 1-hour sessions), so current sessions expire. rotating leaked keys · JWT signing keys

Firebase#

The web config apiKey is meant to be public. Firebase says these keys are fine in code. Your data is protected by Security Rules and App Check, not by hiding the key.

revoke
What needs rotating is a service account private key (the Admin SDK JSON file). In the Google Cloud console, Service accounts › the account › Keys › Delete. Make a new one in the Firebase console, Settings › Service accounts. deleting service account keys · Admin SDK setup
usage
Cloud Logging audit logs, for activity by that service account. Admin Activity logs are always on. Data Access logs, which show what was read, are off by default except for BigQuery, so reads may not show up. compromised credentials · audit logs
watch out
If your Firebase key is also allowed to call Gemini, it's a secret now. Firebase says never allow the Gemini Developer API on a public key; use a separate restricted key. separate keys. Deleting a service account key doesn't cancel short-lived tokens already made from it; disabling the service account does. That cuts off every app using the account, the new key too. Wait at least 60 minutes before turning it back on, or up to 12 hours if you extended token lifetimes. deleting service account keys · compromised credentials

Resend#

revoke
On resend.com/api-keys, click More options, then Remove API key. It stops working at once. Create a replacement. Resend docs
usage
Logs (resend.com/logs) filtered by API key, and Emails (resend.com/emails) for what was sent. Resend docs
watch out
Resend keeps 30 days of activity, so look soon. Give the new key Sending access, not Full access. Resend docs

Twilio#

revoke
Auth Token: account settings › Keys & Credentials › API keys & tokens. Request a secondary token, update your apps, then Promote to primary. The old token stops working. API keys: open each one and click Delete this API Key. rotate auth token
usage
Billing & Usage › Account usage. Then Monitor › Logs › Calls and Messaging, and the Audit Events log. Twilio usage · fraud guide
watch out
Untick Geo permissions for countries you don't serve, and turn on SMS Pumping Protection, so a stolen credential can't run up calls and texts. geo permissions · SMS pumping

AWS access keys#

revoke
Sign in as the root user or another admin, not as the leaked user. IAM console › Users › the user › Security credentials › Access keys. Choose Actions › Deactivate on the leaked key, create a new one, then Actions › Delete on the leaked one. A user can have only two access keys, so if there are already two, you can't create first. updating access keys · IAM quotas
usage
CloudTrail Event history for access keys, policies, roles or users you didn't create. Cost Explorer for charges. Check every Region. AWS Knowledge Center
watch out
Temporary credentials already made from the key keep working after you delete it: up to 36 hours, 12 by default. To stop them, attach a deny policy such as AWSDenyAll to the user. That blocks the new key too, until you remove it. temporary credentials. AWS may attach a quarantine policy to the user. Don't remove it; follow the support case. It only partly limits charges and doesn't make the account safe. It also stops that user from changing its own keys or opening CloudTrail Event history, which is why you work as another admin. quarantine policy · exposed keys check

GitHub personal access tokens#

revoke
Settings › Developer settings › Personal access tokens › Fine-grained tokens or Tokens (classic). Click Delete next to the token. deleting a token
usage
Your security log, for what happened on your account. GitHub says only organization and enterprise audit logs can be searched for one token's events. remediating a leaked secret
watch out
GitHub revokes a token pushed to a public repository or gist on its own. Check yours is gone anyway, then look at what it did while it was live. token revocation

Mapbox#

Public tokens (pk.) are meant for the browser. Secret tokens (sk.) must never be there.

revoke
A leaked secret sk. token: on the Access tokens page (console.mapbox.com/account/access-tokens), delete it first, then make a new one. Deleting is permanent. Mapbox's usual order (new token, redeploy, then delete) is for a planned change. If you delete the default public token, Mapbox makes a new one for you. rotating tokens
usage
The Statistics page, console.mapbox.com/account/statistics. Mapbox tokens
watch out
A token with secret scopes is shown only once. Put it straight into your server's secret settings. URL restrictions can't go on the default public token, and they don't work for mobile apps built with the Mapbox SDKs. For a web app, make a new public token, restrict it to your sites, and use that. Mapbox calls URL restrictions best-effort, not a lock. URL restrictions

Clerk#

The publishable key is meant to be public. Clerk says it needn't be rotated if exposed. The secret key is not.

revoke
Dashboard › API keys: add a new secret key, set it as CLERK_SECRET_KEY everywhere, redeploy, then delete the old key. rotate your secret key
usage
Each secret key shows when it was last used on the API keys page. rotate your secret key
watch out
Clerk warns you if the old key was used recently. After a leak, that use may not be yours. Delete it as soon as your redeploy works. Clerk key rotation

Replicate#

revoke
On replicate.com/account/api-tokens, click disable next to the token. Create a new one. disabling tokens
usage
Current usage is on your account billing page, replicate.com/account/billing. Replicate billing
watch out
Replicate scans public GitHub repos and may disable a leaked token itself and email you. Apps on that token stop working until they get the new one. Replicate API tokens

Groq#

revoke
Revoke the key at console.groq.com/keys, make a new one, and redeploy. Groq docs
usage
Pick the project, then the Dashboard's Usage, Metrics and Logs pages. Groq projects
watch out
Keys belong to the project they were made in, so check the right one. Groq projects. Groq's own words: "Never reuse compromised keys, even temporarily." Groq incident response

Mistral#

revoke
Admins: Admin Panel › API › API Keys (admin.mistral.ai/organization/api-keys), then delete the key. You manage your own keys from your User Profile in Studio. Mistral's docs describe deleting only from the admin list, so if you can't delete yours in Studio, ask an admin. Mistral API keys
usage
Admin Panel › API › Usage (admin.mistral.ai/organization/usage). Mistral usage
watch out
A key keeps working until it's revoked or expires. A key with no expiry never stops on its own. The admin key list shows each key's last-used date. Mistral API keys

ElevenLabs#

revoke
In API key settings (elevenlabs.io/app/settings/api-keys), create a new key and delete the old one. Service account keys: Workspace settings › Service Accounts. rotating API keys
usage
Developers › Analytics › Usage, filtered by API key, and the Request Log tab. usage analytics
watch out
A key committed to a public GitHub repo is disabled automatically, but only if third-party disabling is on for it. That's on by default for non-Enterprise plans and off for Enterprise plans. Give the new key a credit quota. detecting leaked keys

Missing a provider, or a step changed? Tell us: [email protected] · github issues. Stop it happening again: npx launch-blockers check flags a secret named to ship to the browser before you deploy. launch blockers