This guide will show you how to manage resources in your target Twilio Region with Twilio's REST API. By the end of the guide, you'll learn:
Note that this guide uses examples that utilize the cURL command-line utility for making API requests, rather than one of Twilio's language-specific helper libraries. This choice is intended to highlight the principles of Twilio's REST API by avoiding the use of higher level abstractions that tend to obscure some of these details.
The Twilio REST API operates on a per-Region basis. When making requests to the API, it's up to you to select which Region will handle the request. Whichever Region you choose will be the Region that processes and stores data related to the request.
If you don't specify a target Region for a request, the request will be handled in the default US1 Region.
To specify a target Region for a request, include the name of the target Region in the request's hostname, also known as the fully qualified domain name (FQDN).
The FQDN format follows a convention that encodes three pieces of information in the hostname:
The format of an FQDN is:
{product}.{edge-location}.{region}.twilio.com
Some example FQDNs targeting API products in different Regions (through various Edge Locations) include:
FQDN | Target Region |
---|---|
api.sydney.au1.twilio.com | Australia (AU1) Region |
voice.ashburn.us1.twilio.com | United States (US1) Region |
insights.dublin.ie1.twilio.com | Ireland (IE1) Region (not yet available) |
Note: Legacy FQDNs which do not include the Edge Location and Region (e.g. video.twilio.com) are implicitly routed to the US1 Region through the ashburn Edge Location.
When making requests using any of Twilio's server-side helper libraries, you don't need to worry about constructing an FQDN. Instead, provide the client constructor with an edge
and region
parameter, and the client will construct the FQDN accordingly.
When specifying a region
parameter for a helper library client, be sure to also specify the edge
parameter. For backward compatibility purposes, specifying a region
without specifying an edge
will result in requests being routed to US1.
In order to provide Region-specific access control, Twilio manages your accounts' API credentials on a per-Region basis. This means that you'll need to use different Auth Tokens and API Keys based on which Region you are sending API requests to. Refer to the Twilio Regions overview for more information about the Region isolation model.
You can manage API Keys for a Region using the Twilio Console or the REST API. See our guide to managing Regional API credentials for complete instructions.
Most Twilio resources can be managed via REST API in a target Region using standard API Keys which exist in the Region.
For example, to list your account's TwiML Applications in the AU1 region using cURL (again with the appropriate environment variables present in your shell):
1curl -u $API_KEY_SID:$API_KEY_SECRET \2https://api.sydney.au1.twilio.com/2010-04-01/Accounts/$ACCOUNT_SID/Applications.json
Note that some API Endpoints are not yet available in Regions outside of US1.
For example, using the REST API to manage Push Credentials used by our Notification service is currently only supported in US1.
To learn more about building with Twilio's Global infrastructure, check out these other resources: