Leaked an API key? › Perplexity
Leaked Perplexity API key: what to do in the next 10 minutes
Last updated: November 11, 2026. Steps checked against Perplexity's own docs on November 11, 2026.
Short answer: In the API Console at console.perplexity.ai, open API keys and generate a new key. Copy it once; Perplexity shows the full token only at creation. Put it only in a server-only environment variable such as PERPLEXITY_API_KEY, never in client JavaScript or a VITE_ or NEXT_PUBLIC_ variable, then redeploy. Revoke the leaked key with POST https://api.perplexity.ai/revoke_auth_token. A revoked key cannot be recovered. Check Billing for usage you don't recognize. A free SniffPup scan of a site you own can help find a remaining exposed pplx- key in public pages, but it cannot confirm the key is absent everywhere or that the site is secure. Removing the key from code alone does not un-leak it.
Which Perplexity keys are secret?
- Secret: Perplexity API keys. Official examples use tokens that start with pplx- (for example pplx-1234567890abcdef). Treat every API key as a password. You can view the full token only once at creation, through the console or the generate_auth_token endpoint; it cannot be retrieved again.
- Meant to be public: None. Perplexity says never to expose API keys in client-side JavaScript, mobile applications, or public repositories.
The next 10 minutes
Times are a rough guide. Do the first step before anything else.
1. Generate a replacement key (Minutes 0-2)
- Open the API Portal at console.perplexity.ai, click API keys in the left sidebar (console.perplexity.ai/project/keys), and click + Generate API Key. You need a project first. Copy the token now. Perplexity shows the full key only once, whether you create it in the console or with POST https://api.perplexity.ai/generate_auth_token. Set a descriptive token_name if you create the key through the API, so you can identify it later.
- If Auto reload is on and you already see usage you don't recognize, consider turning it off on the Billing page (Change preferences next to Auto reload) until the leaked key is revoked, so unexpected calls cannot keep buying credits. That is our advice, based on how auto-reload works; Perplexity's compromised-key steps do not say to change billing first.
2. Move the new key to the server (Minutes 2-5)
- Store the new key only in a server-only environment variable or secrets manager, using PERPLEXITY_API_KEY as Perplexity's docs do. Never hardcode it, and never put it in client JavaScript, a mobile app, a public repository, log files, a URL, or a VITE_ or NEXT_PUBLIC_ variable. Then redeploy so the public bundle no longer ships the leaked key.
- Send the key as Authorization: Bearer $PERPLEXITY_API_KEY from your backend only. Do not print the key or any part of it in shell history, logs, or chat.
3. Revoke the leaked key (Minutes 5-8)
- Perplexity's compromised-key order is: generate a new key, update your applications, then revoke the old one with POST https://api.perplexity.ai/revoke_auth_token. Authorize with your new key and pass the leaked token in the JSON body as auth_token. A 200 means it was revoked. Once revoked, it cannot be recovered.
- If you already see usage you don't recognize, revoking sooner stops that key from spending credits, even if calls still using it fail briefly. That is our advice, not Perplexity's. Their docs say to update applications first so you are not stuck with a revoked key and no replacement.
4. Check usage and clean up (Minutes 8-10)
- On the Billing page in the API Portal (console.perplexity.ai/project/billing), review the credit balance, usage chart, and billing breakdown for activity you don't recognize. Only Admins can see Billing; Members should ask an Admin. Note times and amounts. Perplexity also says to review access logs for unauthorized usage.
- Remove the key from frontend code, public files, screenshots, CI logs, and git history. History can keep a secret after the file is deleted. Rotate any other secrets that sat in the same file or commit. Give each environment its own named key.
- Re-scan the live site you own. A passive scan can help find a remaining exposed pplx- key in public pages. It cannot confirm the key is absent everywhere, and a clean report is not a guarantee of security. Don't paste the full secret into chat.
Good to know
- The free scan flags a Perplexity API key when it finds a pplx- token followed by 48 letters or digits, including at least one digit, in HTML, inline scripts, or same-origin JavaScript bundles. It skips obvious placeholders such as a run of x or X characters. That is what the checker looks for, not a complete list of every possible Perplexity credential, and not a claim that official keys are always that length.
- For a planned rotation, Perplexity's zero-downtime order is: generate a new key while the current one still works, update and verify your applications, then revoke the old key. They recommend rotating regularly (for example every 90 days).
- Replacing a key without removing it from client bundles or public .env files exposes the new key the same way.
- The scan is passive and read-only on a live URL you own or are authorized to test. It is not a security guarantee.
After the first 10 minutes
Move the code that needs the key to the server (an API route, serverless function or Supabase Edge Function), keep the key in a server-only environment variable, redeploy, and re-check your live site. The general plan, with a prompt you can paste into Lovable, Bolt, Cursor or Claude Code, is in I leaked an API key in my vibe-coded app. What do I do now?
What SniffPup checks, and what it doesn't
A free SniffPup scan reads only what your live site serves to the public: secret key patterns in HTML and same-origin JavaScript (masked in the report) and public files such as /.env and /.git/config. It never uses a key it finds. It can't see your repo, your server or Perplexity's logs, so the steps above are always on you. A clean report is not a guarantee of security.
Sources
- Perplexity Docs: API Key Management
- Perplexity Docs: Projects and Billing
- Perplexity Docs: Quickstart
- Perplexity API: Generate Auth Token
- Perplexity API: Revoke Auth Token
Perplexity can change its dashboard and steps at any time. If something here doesn't match what you see, follow Perplexity's docs and tell us.
Other providers
- Leaked OpenAI API key: what to do in the next 10 minutes
- Leaked Anthropic API key: what to do in the next 10 minutes
- Leaked Gemini API key: what to do in the next 10 minutes
- Leaked Resend API key: what to do in the next 10 minutes
- Leaked OpenRouter API key: what to do in the next 10 minutes
- Leaked ElevenLabs API key (unauthorized charges): what to do
- Leaked Stripe secret key: what to do in the next 10 minutes
- Leaked Supabase service_role or secret key: next 10 minutes
- Leaked AWS access key: what to do in the next 10 minutes
- Leaked GitHub token: what to do in the next 10 minutes