Leaked an API key? › Twilio
Leaked Twilio auth token: what to do in the next 10 minutes
Last updated: November 25, 2026. Steps checked against Twilio's own docs on November 25, 2026.
Short answer: If your primary Auth Token leaked, request a fresh secondary Auth Token in the Twilio Console (Account management, API keys & tokens), put it only in a server-only environment variable such as TWILIO_AUTH_TOKEN, update and test your server, then click Promote to Primary. Twilio says promoting instantly removes the old primary token, so the leaked token stops working right away. If the token that leaked is a secondary token, delete it instead of promoting it. Twilio warns that anyone with your Account SID and Auth Token has full access to your account. Then move your app to an API key you can revoke on its own. A free SniffPup scan of a site you own can flag an exposed environment file or Git metadata, but it has no pattern for a Twilio Auth Token and cannot confirm the token is absent everywhere. Removing the token from code alone does not un-leak it.
Which Twilio keys are secret?
- Secret: The Auth Token. Twilio says the Account SID acts as a username and the Auth Token as a password, and that anyone who has both gets full access to your account and can use the Twilio API as if they were you. By default Twilio also uses the Auth Token as the secret that signs your webhook requests.
- Secret: API key secrets. A Main API key has full access to all Twilio API resources, the same as your Account SID and Auth Token. Standard and Restricted keys have less access but are still secrets.
- Secret: The Account SID (AC...) is an account identifier, like a username. It can't authenticate on its own, but keep it out of public code along with the token.
The next 10 minutes
Times are a rough guide. Do the first step before anything else.
1. Request a fresh secondary Auth Token (Minutes 0-2)
- In the Twilio Console, open the Admin menu, choose Account management, then the API keys & tokens page. If your account uses Twilio Regions, pick the Region at the top right. In the Auth Tokens section, click Request a secondary token, then Request Token.
- Twilio says the secondary token works the same as the primary one, so you can switch your app over before the old token stops working.
- If the token that leaked is your secondary token, click Delete this Token to remove it, and don't promote it. Promoting only removes the old primary token, so a leaked secondary token would stay valid as your new primary.
2. Update your server, then promote the new token (Minutes 2-5)
- Put the new token only in a server-only environment variable or secrets manager, for example TWILIO_AUTH_TOKEN, never in client JavaScript, a mobile app, a public repository, or a VITE_ or NEXT_PUBLIC_ variable. Remove the old token from client code and build inputs, rebuild and redeploy, and check that the files your site serves no longer contain it.
- Back on API keys & tokens, click Promote to Primary and confirm. Twilio says this instantly and automatically removes the old primary token, and every request that still uses the old token fails from then on.
- If you validate Twilio webhook signatures with the Auth Token (Twilio's default), update that code to the new token too, or webhook validation fails after the switch.
- If you use Twilio Services or Functions (Classic) with the token pasted in directly instead of a variable, Twilio says to wait 1 minute for the change to reach them, or they fail with 403 Forbidden.
- By default, Twilio emails every owner and administrator on the account when an Auth Token changes, so tell your team before they see it.
3. Move your app to an API key (Minutes 5-8)
- Twilio calls API keys the preferred way to authenticate with its REST APIs. You can create one per app or developer, and if a key is compromised you revoke just that key instead of rotating the Auth Token for everything.
- Pick the least access that works. A Standard key can't reach the Accounts or Keys resources, and a Restricted key gives fine-grained access to specific resources. A Main key is as powerful as the Auth Token, so avoid it for app code.
- Twilio says client-side SDKs need API keys to create Access Tokens, and that Access Tokens can be created with Main and Standard keys but not yet with Restricted keys. Use a Standard key for that, and create the Access Tokens on your server so the Auth Token and the API key secret never reach the browser or app.
- Keep the Auth Token on the server for the jobs that still need it. Twilio says rotating the Auth Token through the API needs the Account SID and Auth Token, and requests made with an API key fail with error 20003. Twilio also lets you sign webhooks with a separate shared key, so rotating the Auth Token later doesn't break webhook validation.
4. Check for use you didn't make, and clean up (Minutes 8-10)
- In the Console, look over recent messages, calls and usage for anything your app didn't send, and note times and amounts. That is our advice. If you think someone has used your account, follow Twilio's help article on steps for account takeover.
- Remove the token 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.
- Deleting the token from a repo does not revoke it. Only replacing it in Twilio does that: promoting a new token for a leaked primary, or deleting a leaked secondary.
- Re-scan the live site you own. A clean report is not a guarantee of security. Don't paste the full token into chat.
Good to know
- The free scan has no pattern for a Twilio Auth Token, so it will not flag one sitting in your HTML or JavaScript. It does check whether environment files such as /.env and Git metadata such as /.git/config are publicly downloadable. It reports that the file is exposed, not which tokens are inside it. Check your bundles and repo yourself.
- For a planned rotation, Twilio's zero-downtime order is: create a secondary token, update your applications to use it, then promote it to primary. If you decide not to switch, Delete this Token removes the secondary token.
- Replacing the token without removing it from client bundles or public .env files exposes the new token 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? Not sure what kind of key you found? Check it with What kind of key is this?
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 Twilio's logs, so the steps above are always on you. A clean report is not a guarantee of security.
Sources
- Twilio Help Center: Auth Tokens and How to Change Them
- Twilio Docs: REST API: Auth Token
- Twilio Docs: API keys overview
- Twilio Docs: Access Tokens
- Twilio Docs: Secure webhooks
Twilio can change its dashboard and steps at any time. If something here doesn't match what you see, follow Twilio'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 Perplexity API key: what to do in the next 10 minutes
- Leaked OpenRouter API key: what to do in the next 10 minutes
- Leaked Groq 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
- Leaked Clerk secret key: what to do in the next 10 minutes
- Leaked DATABASE_URL: what to do in the next 10 minutes
- Leaked SendGrid API key: what to do in the next 10 minutes