Twilio error 20003: permission denied
Updated
20003 (Permission Denied) means Twilio didn't accept the credentials on your request. Usually the Auth Token or API key secret is wrong, deleted or rotated, belongs to another account or subaccount, or was made in another Twilio Region. Check the exact SID and secret pair, the account you're calling, and the key type.
What Twilio says it means
Twilio's error reference names 20003 Permission Denied, an application error from the REST API. It usually means the credentials on your request are incorrect, expired, deleted, scoped to the wrong account, or not valid for the resource.
Twilio's REST API uses HTTP Basic authentication: either an API key SID as the username and its secret as the password, or the Account SID and Auth Token. Twilio recommends API keys for production and the Auth Token for local testing.
Likely causes, and the fix for each
| Cause | Fix |
|---|---|
| Wrong Account SID and Auth Token pair, a deleted token, or extra spaces in the value | Copy both again from the Console. Trim whitespace in env vars. |
| The token or key was deleted, rotated or compromised | Create a replacement and update every environment variable, secret store and deployed app. |
| Subaccount credentials used on the main account (or another subaccount), or main-account keys on subaccount resources that need subaccount authentication | Use credentials from the account that owns the resource. |
Standard API key on /Accounts or /v1/Keys | Use a Main API key for those endpoints. |
| Key created in a different Twilio Region | Create or use credentials in the same Region as the request. |
| Test Credentials against live resources | Call only the test resources that support them. |
A proxy or middleware removed the Authorization header | Make it forward the header unchanged. |
| Auth Token used to sign an Access Token or other JWT | Sign with an API Key SID and secret. |
| Expired or wrong OAuth access token | Request a new one and send it as a Bearer token. |
| Account suspended or closed | Contact Twilio Support before retrying (see 30002). |
Twilio also lists some product-specific cases: the AI/ML Features Addendum not accepted in the Console, a Flex Webchat request from an origin not on the deployment key's allowed list (up to 10 per key), and a Primary Compliance Profile in Trust Hub that hasn't been submitted and approved.
How to check, step by step
- Test with curl. Twilio suggests repeating a failing SDK request with curl: if curl works, the problem is in your code or config.
- Read the SID prefix. Account SIDs start with
AC, API key SIDs withSK. Pairing anSKwith the Auth Token, or anACwith a key secret, fails. - Check the key still exists in the Console's list of API keys, and what type it is. Twilio shows a key's secret only once, when you create it; if you've lost it, make a new key.
- Check the account in the URL.
/2010-04-01/Accounts/{AccountSid}/…must be an account those credentials can reach. - Check the Region if you use Twilio Regions: credentials are region-specific.
How to prevent it
- Give each app its own API key, so rotating one doesn't break the rest.
- Keep secrets in one store and deploy from it, so a rotation updates every copy.
- Rotate the Auth Token with the secondary-token flow described in Twilio API keys, Auth Token and subaccounts.
Related codes
- 20429 Too many requests: the credentials were fine, but the account sent too many requests at once.
- 20404 Not Found: the resource doesn't exist for that account.
- 30002 Account suspended: messages that failed because the account was suspended.
Connecting Switchmast
Switchmast connects to your Twilio account with an API key SID and secret (recommended) or with the Account SID and Auth Token. The secret stays in your iPhone's Keychain and is only ever sent to Twilio's own API hosts over HTTPS. If Switchmast shows 20003 when connecting, the usual fixes are the ones above: pick the Region the key was made in, paste the secret again without spaces, or create a fresh key. A Standard key is enough; Switchmast falls back to reading a phone number when a key can't read /Accounts.
Questions
What does Twilio error 20003 mean?
Permission Denied: the credentials on your request are incorrect, expired, deleted, belong to the wrong account, or aren't valid for the resource you're calling.
Why do I get 20003 with the right Auth Token?
Common reasons: a space or line break copied with the token, using it with a different Account SID, calling a main-account resource with subaccount credentials, a proxy stripping the Authorization header, or an account that is suspended or closed.
Can a Standard API key cause 20003?
Yes, on the Accounts and Keys resources (/Accounts, /v1/Keys). Those need a Main API key or the Account SID and Auth Token. Standard keys reach everything else.
Does 20003 mean my account is suspended?
Sometimes. Twilio lists a suspended or closed account as one cause. If your credentials are definitely right, check your email for a suspension notice and contact Twilio Support.
Does Twilio Regions affect API keys?
Yes. API credentials are per Region. A key created in one Region gets 20003 when you send the request to another Region's API.
Sources
All read 27 November 2026.
- Twilio docs: Error 20003, Permission Denied (read 27 Nov 2026)
- Twilio docs: API keys overview (Main, Standard, Restricted) (read 27 Nov 2026)
- Twilio docs: Key resource v1 (SID patterns SK… and AC…, secret shown once) (read 27 Nov 2026)
- Twilio docs: Requests to Twilio (HTTP Basic authentication, regional credentials) (read 27 Nov 2026)
- Twilio docs: REST API best practices (test with curl) (read 27 Nov 2026)