Switchmast

Twilio API keys, Auth Token and subaccounts, explained

Updated

Short answer

Twilio has three kinds of credentials. The Account SID identifies your account. The Auth Token is its master password. API keys are separate credentials (a key SID and a secret) that you create and revoke one at a time, as Main, Standard or Restricted. Twilio recommends API keys for apps.

Account SID, Auth Token and API keys

CredentialWhat it isUse it for
Account SIDThe ID of your account (or subaccount), starting AC. Not secret on its own.Paired with the Auth Token, or in API URLs
Auth TokenThe account's master password, shown in the ConsoleValidating webhook signatures; rotating credentials; little else
API key (SID + secret)A credential you create, name and revoke on its own; the SID starts SKEvery app and integration, each with its own key

Giving each app or person its own key means you can revoke one leaked key without breaking everything else. Twilio's docs recommend separate keys for separate purposes and revoking keys that are unused or compromised. Twilio's client-side SDKs need an API key to create Access Tokens.

The three API key types

TypeAccessCreated in
MainEverything; same as the Account SID and Auth TokenConsole only
StandardNearly all APIs, except the Accounts and Keys resourcesConsole or REST API
RestrictedOnly the permissions you choose, up to 100 per key; US1 Region onlyConsole, or the v1 Keys API

Restricted keys cover Messaging, Voice, phone numbers and regulatory compliance, Studio, TaskRouter, Lookup, Verify, Video, Event Streams, Monitor events and alerts, usage records, Serverless and IAM. They can't be used to create Access Tokens for Twilio's client-side SDKs. API credentials are tied to a Twilio Region: accounts using IE1 or AU1 create keys per region, and Twilio's Console guide says Restricted keys exist only in the United States Region.

How to create an API key

  1. In the Twilio Console, go to Settings › Account settings › API keys & auth tokens (legacy Console: Admin › Account management › Keys & credentials › API keys & tokens).
  2. Pick the Region, click Create API key, give it a name that says where it's used, and choose Standard or Restricted. For Restricted, tick the permissions it needs. Main keys appear only in the legacy Console's type list.
  3. Copy the secret when it's displayed and store it in a secret manager or your phone's keychain, then tick Got it! to finish. Treat the secret as shown once.
  4. To revoke it, delete the key. Anything using it stops working.

Which key for which job

JobUse
A server that sends texts and makes callsStandard key, or Restricted (US1) with Messaging and Voice only
A script that creates or deletes subaccounts or keysMain key or the Auth Token
A test suite that only places callsRestricted key allowed only to create Calls
Checking that a webhook request really came from TwilioThe Auth Token (signatures are made with it)
A browser or mobile softphoneStandard key, to mint Access Tokens on your server

Rotating the Auth Token

  1. Create a secondary Auth Token in the Console or with the Secondary Auth Token API (POST https://accounts.twilio.com/v1/AuthTokens/Secondary).
  2. Update everything that uses the token: apps, servers, and the code that validates Twilio's webhook signatures.
  3. Promote the secondary token (POST https://accounts.twilio.com/v1/AuthTokens/Promote). Twilio deletes the current primary token and makes the secondary the primary. Anything still using the old token now fails with error 20003 (Permission Denied), which Twilio's reference lists for deleted Auth Tokens.
  4. If Services or Functions (Classic) have the token written into their code rather than read from a variable, wait one minute for the change to reach them, or they fail with 403 Forbidden.

Each Auth Token change emails every owner and administrator of the account, unless you set SuppressEmailNotification to true (Twilio suggests it when rotating many subaccounts, as the emails can delay others such as Console verification codes).

Common mistakes

Subaccounts

Connecting Switchmast

Switchmast works with an API key SID and secret (recommended) or with your Account SID and Auth Token. A Standard key named "Switchmast" is the safer choice: you can see and revoke it on its own. The Auth Token gives full access to the account and its subaccounts, and rotating it disconnects the app. Either is stored in your phone's Keychain or Keystore and sent only to Twilio's API over HTTPS. To use several accounts or subaccounts (Pro), add a credential for each, or use a Main key or the Auth Token to reach every subaccount.

Questions

What is the difference between an API key and the Auth Token?

The Auth Token is the account's master password: it works for everything and there is one primary token per account. API keys are extra credentials you create and revoke one by one. Twilio calls API keys the preferred way to authenticate with its REST APIs.

Where do I find my Twilio Auth Token?

In the Console under Settings › Account settings › API keys & auth tokens, and on the Console home page next to the Account SID. Treat it like a password: anyone with the SID and token can use your account.

How do I rotate my Twilio Auth Token?

Create a secondary Auth Token, update every app and webhook check to use it, then promote it. Promoting deletes the old primary token and makes the secondary the primary. Anything still using the old token gets error 20003.

Can an API key create other API keys?

Only a Main key, which has the same access as the Account SID and Auth Token. Standard keys can reach nearly everything except the Accounts and Keys resources. Restricted keys only get the permissions you pick.

Do Restricted API keys work in every region?

No. Twilio's Console guide says Restricted API keys are only available in the United States Region (US1). In IE1 or AU1, use a Standard key.

Do subaccounts have their own credentials?

Yes. Each subaccount has its own Account SID and Auth Token, and you can create API keys in it. They reach only that subaccount. The main account's credentials can reach subaccounts' 2010 API resources, but not products on other subdomains like Studio or TaskRouter.

Sources

All read 27 November 2026.