What should I do if my API key leaked?

Published 2026-11-16 by Nordik. Written with AI from the sources listed at the end.

Short answerMake a new key and turn the old one off now, then check its usage, move the new one to a server, and find out how it leaked.

An API key is a long password your app uses to prove who it is to another service. If it leaked, revoke and replace it at the provider. GitHub says to rotate an affected credential immediately, and notes that scrubbing Git history (the saved record of every change to your code) is often unnecessary once the key is revoked.

Then check the provider's request logs for activity you do not recognise, put the new key in server-side secrets (a hidden store where visitors cannot look) without a VITE_ or NEXT_PUBLIC_ prefix, and search your project for other exposed keys. Those prefixes copy a setting into the code every visitor downloads.

Write down what you did and when, so you can answer questions from the provider or your users later.

Sources

Each source below was accessed on 2026-11-16. Documentation changes over time, so check the source for the current wording.

  • GitHub documentation, About secret scanning, accessed 2026-11-16
  • Stripe documentation, API keys, accessed 2026-11-16

See what your live app shows strangers

Paste the link to your app: in under a minute the free scan shows what your live app hands to any visitor, and where to look first. No sign-up, and it never signs in or changes anything.

Run a free scan

Want the code itself read? Order the $49 audit or see a sample report. Your card is held and charged only when your report is delivered. It is not a pentest: the audit is done by AI, and a second AI checks each serious finding.