You access the Twilio API using API keys that represent the required credentials. These keys:
See this document for more information about your request to Twilio's REST API, or read our article on Access Tokens to learn more.
API Keys can be provisioned and revoked through the REST API or the Twilio Console. This provides a powerful and flexible primitive for managing access to the Twilio API. There are two types of API Keys: Standard and Main.
Standard API Keys give you access to all the functionality in Twilio's API, except for managing API Keys, Account Configuration, and Subaccounts.
Main API Keys have the same access as Standard Keys, and can also manage API Keys, Account Configuration, and Subaccounts. Main API Keys give you the same level of access as if you were using account API Credentials.
Since API Keys can be independently revoked, you have complete control of the lifecycle of your API credentials.
For example, you might issue separate API Keys to different developers or different subsystems within your application. If a key is compromised or no longer used, you can easily delete it to prevent unauthorized access!
If your use case requires API Keys to access the /Accounts
or /Keys
endpoint, a Main Key needs to be used. This can be created in the Console.
sid
type: SID<SK>The unique string that that we created to identify the Key resource.
^SK[0-9a-fA-F]{32}$
34
34
date_created
type: string<date-time-rfc-2822>The date and time in GMT that the resource was created specified in RFC 2822 format.
GET https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Keys/{Sid}.json
Returns a representation of the API Key, including the properties below.
For security reasons, the Secret
field is ONLY returned when the API Key is first created - never when fetching the resource. Your application should store the API Key's Sid and Secret in a secure location to authenticate to the API and generate Access Tokens in the future.
AccountSid
type: SID<AC>The SID of the Account that created the Key resource to fetch.
^AC[0-9a-fA-F]{32}$
34
34
Sid
type: SID<SK>The Twilio-provided string that uniquely identifies the Key resource to fetch.
^SK[0-9a-fA-F]{32}$
34
34
GET https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Keys.json
Returns a list of API Keys in this account, sorted by DateUpdated
.
The list includes all API Keys. It also includes paging information.
AccountSid
type: SID<AC>The SID of the Account that created the Key resources to read.
^AC[0-9a-fA-F]{32}$
34
34
PageSize
type: integerHow many resources to return in each list page. The default is 50, and the maximum is 1000.
1
Page
type: integerThe page index. This value is simply for client state.
0
Retrieve all the API Keys in an account
POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Keys/{Sid}.json
Attempts to update the fields of an API Key instance.
If successful, it returns the updated resource representation. The response will be identical to that of the HTTP GET (fetch).
AccountSid
type: SID<AC>The SID of the Account that created the Key resources to update.
^AC[0-9a-fA-F]{32}$
34
34
Sid
type: SID<SK>The Twilio-provided string that uniquely identifies the Key resource to update.
^SK[0-9a-fA-F]{32}$
34
34
FriendlyName
type: stringA descriptive string that you create to describe the resource. It can be up to 64 characters long.
DELETE https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Keys/{Sid}.json
Deletes an API Key. This revokes its authorization to authenticate to the REST API and invalidates all Access Tokens generated using its secret.
If the delete is successful, Twilio will return an HTTP 204 response with no body.
You may only delete Keys by authenticating with the account's AccountSid and AuthToken or API Keys that have the main key flag set in the console.
AccountSid
type: SID<AC>The SID of the Account that created the Key resources to delete.
^AC[0-9a-fA-F]{32}$
34
34
Sid
type: SID<SK>The Twilio-provided string that uniquely identifies the Key resource to delete.
^SK[0-9a-fA-F]{32}$
34
34