Skip to contentSkip to navigationSkip to topbar
Page tools
Useful for sharing or LLM
Accelerate development with AI

On this pageProducts used
Looking for more inspiration?Visit the

Use Functions and Assets with Twilio Regions


(information)

Legal information

Functions and Assets in IE1 are not PCI compliant or HIPAA Eligible Services and should not be used in workflows that are subject to HIPAA or PCI.

You can use Functions and Assets in Twilio's Ireland (IE1) Region for EU data residency. Functions and Assets in IE1 work the same way they do in US1, with the differences called out on this page. For the complete list of Twilio Regions and product availability, see Regional product and feature availability.


Configure your account for IE1

configure-your-account-for-ie1 page anchor

To use Functions and Assets in IE1, complete the following steps:

  1. In the Twilio Console, use the region selector to switch to Ireland (IE1). When you set the Console to the IE1 region, created Services only run in IE1.

  2. Use Region-specific credentials. Twilio isolates its Regions, so a US1 Auth Token or API key doesn't work when you target IE1. For details, see Manage Regional API Credentials.

    1. In the Console, go to API keys & tokens.
    2. Change the region selector to Ireland (IE1).
    3. Find your IE1 Auth Token.
    4. Create API keys with the Console region selector set to Ireland (IE1). Any keys you create only work in IE1.
  3. Send Serverless API requests to the dublin edge with this base URL:

    ResourceBase URL
    Serverless APIserverless.dublin.ie1.twilio.com

    Using the Twilio CLI, sign in with the IE1 region and the dublin edge.

    twilio login --region ie1 --edge dublin

    Using a Twilio helper library, pass both the region and the edge when you create the client. In Node.js:

    const client = require('twilio')(accountSid, authToken, { region: 'ie1', edge: 'dublin' });

To deploy a Service to IE1 with the Twilio CLI, complete the following steps:

  1. Make sure that you have the Twilio CLI and version 3.1.2 or later of the Serverless Toolkit plugin installed.
  2. Create an IE1 profile by signing in with the IE1 region and the dublin edge, as described in Configure your account for IE1.
  3. If you don't already have a Service, create and develop one. Otherwise, skip to the next step.
  4. Deploy your Service with the Serverless Toolkit, and specify the profile for IE1: twilio serverless:deploy -p <YOUR_REGIONAL_PROFILE_NAME>.
(information)

Info

If you use twilio-run, or if you want to pass credentials directly into your deployment command, you can use the --region flag. For example:

1
twilio serverless:deploy \
2
--region=ie1 \
3
--username=<YOUR_TWILIO_REGIONAL_API_KEY> \
4
--password=<YOUR_TWILIO_REGIONAL_API_SECRET>

To host a Service in multiple Regions, you must deploy to each Region individually. The Console can't deploy a Service to multiple Regions at once. To use different environment variables for each Region, add your Account SID and the Region to the projects section of your .twilioserverlessrc configuration file. For example:

1
{
2
"projects": {
3
"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:us1": {
4
"env": ".env"
5
},
6
"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:ie1": {
7
"env": ".env.ie1"
8
}
9
}
10
}
(warning)

Warning

Deployments that use dependencies still contact the npm registry to fetch them. Twilio doesn't control whether npm fetches those dependencies from the US.


The domain of a Service includes its Edge and Region. Functions URLs with regional support use the following pattern:

<unique-name>-<random-four-digits>[-<optional-environment-suffix>].<edge>.<region>.twil.io

For example, a Service in IE1 might use ahoy-1234.dublin.ie1.twil.io.


Identify the Region of a running Function

identify-the-region-of-a-running-function page anchor

The Runtime Handler provides Environment Variables that identify where a Function is running. You can use these in logs or any other logic:

  • context.TWILIO_REGION
  • context.TWILIO_EDGE

If context.TWILIO_REGION is undefined in a deployed Function, the Function is running in US1.


Validate signatures across Regions

validate-signatures-across-regions page anchor

Protected Functions and Assets use signature validation to protect them from requests that don't originate from Twilio products and services, or from your own code that generates secure signatures.

Your Auth Token, which Twilio uses to generate these signatures, differs by Region. This means that Functions and Assets in one Region can only be triggered by Twilio products in that same Region. To send a request to a Protected Function or Asset in a different Region, generate a valid X-Twilio-Signature header based on credentials from the Region where the Function or Asset is deployed.


Keep Functions and their resources in the same Region

keep-functions-and-their-resources-in-the-same-region page anchor

By default, Functions provide the Auth Token for the Region where the Function is deployed through context.AUTH_TOKEN, and use it to initialize the built-in Twilio REST Client that context.getTwilioClient() returns. The default client can only make requests to Twilio products and APIs in the same Region. A Function that runs in IE1 can't reach a product that exists only in US1 without additional credentials.

Use a product in another Region

use-a-product-in-another-region page anchor
(error)

Danger

If your Function interacts with Twilio services in a Region other than where your Function is deployed, the data for those requests is transmitted to and processed or stored in that Region.

To create a Twilio client that can communicate with Twilio products in a different Region, complete the following steps:

  1. In the Console, create a new API Key SID and Secret pair(link takes you to an external page).

  2. Add the API Key SID and Secret as environment variables to your Service. For example, TWILIO_US1_API_KEY_SID and TWILIO_US1_API_KEY_SECRET.

  3. In your Function, create a new Twilio client:

    1
    const clientUs1 = new Twilio(
    2
    context.TWILIO_US1_API_KEY_SID,
    3
    context.TWILIO_US1_API_KEY_SECRET,
    4
    {
    5
    region: 'us1',
    6
    edge: 'ashburn',
    7
    accountSid: context.TWILIO_ACCOUNT_SID
    8
    });
  4. Use this US-specific client to make requests to Twilio services in the US, even though your Function runs in another Region such as Ireland:

    1
    clientUs1.messages.create({
    2
    from: context.US_PHONE_NUMBER,
    3
    to: 'some other US number',
    4
    body: 'Ahoy from another region!',
    5
    })
    6
    .then((message) => {
    7
    console.log({ callSid: message.sid });
    8
    return callback();
    9
    })
    10
    .catch((error) => {
    11
    console.error(error);
    12
    return callback(error);
    13
    });