# What to do when an API key is exposed

> Short answer: If a private key reached browser code or a public file, treat it as compromised. Revoke it with the provider, review available usage, and replace the client-side operation with a protected server path.

## Respond in the right order

First identify the provider and key type without republishing the value. Revoke or rotate a confirmed private credential, update the server-side secret, and deploy a clean build. Then review provider activity for unexpected use.

Do not assume that deleting a line from the current source invalidates a key already copied from a public bundle or old commit. Credential rotation is what prevents further use.

## Do not mistake public keys for private keys

Some identifiers and publishable keys are designed to be visible. Confirm the key's role with its provider and check the policy that limits it; do not rotate a public key solely because a scanner recognized its format.

## Related pages

- [My Supabase service_role key is exposed. What now?](https://proofforge.live/fix/service-role-key-exposed) — Understand an exposed Supabase service_role k in an AI-built app. Learn what a public check proves, how to apply a safe fix, and what to verify before you ship.
- [An OpenAI API key is exposed in my app. How do I fix it?](https://proofforge.live/fix/openai-key-exposed) — Understand an exposed OpenAI API key in an AI-built app. Learn what a public check proves, how to apply a safe fix, and what to verify before you ship.
- [An Anthropic API key is exposed in my app. What should I do?](https://proofforge.live/fix/anthropic-key-exposed) — Understand an exposed Anthropic API key in an AI-built app. Learn what a public check proves, how to apply a safe fix, and what to verify before you ship.
- [A Stripe secret key is exposed in my app. How do I fix it?](https://proofforge.live/fix/stripe-secret-key-exposed) — Understand an exposed Stripe secret key in an AI-built app. Learn what a public check proves, how to apply a safe fix, and what to verify before you ship.
- [Free exposed API key checker](https://proofforge.live/tools/exposed-api-key-checker) — Understand an exposed API key checker in an AI-built app. Learn what a public check proves, how to apply a safe fix, and what to verify before you ship.

## Frequently asked questions

**Should I delete the key from Git first?**

Revoke or rotate it first. History cleanup helps reduce future exposure but does not invalidate copies.

**Can a public key be safe?**

Yes. Verify its provider role and the backend rules that limit it.

**Can a scanner tell if the key was abused?**

No. Review provider usage and audit information.

---
Last updated 2026-11-25 · Reviewed by ProofForge. Methodology: https://proofforge.live/methodology
