Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Emergency Calling for SIP Trunking API


This page covers how to use Twilio's REST API to configure a SIP Trunk Phone Number's emergency Address. Before proceeding, you must read the SIP Trunking Emergency Calling doc.

Don't want to use the REST API? You can also use the Console to configure emergency calling Addresses. See the SIP Trunking Emergency Calling doc for more information.


Emergency Addresses

Before you can configure a Twilio Phone Number for emergency calling, you need to create an emergency Address. An emergency Address is an Address resource with the emergency_enabled property set to true.

You can use the same emergency Address for multiple Phone Numbers if appropriate.

Create a new emergency Address

To create a new emergency Address resource via REST API, create a new Address resource with the emergency_enabled parameter set to true. An example request is shown below.

Create a new emergency Address

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_25
// Download the helper library from https://www.twilio.com/docs/node/install
_25
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_25
_25
// Find your Account SID and Auth Token at twilio.com/console
_25
// and set the environment variables. See http://twil.io/secure
_25
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_25
const authToken = process.env.TWILIO_AUTH_TOKEN;
_25
const client = twilio(accountSid, authToken);
_25
_25
async function createAddress() {
_25
const address = await client.addresses.create({
_25
city: "San Francisco",
_25
customerName: "Twilio",
_25
emergencyEnabled: true,
_25
friendlyName: "Twilio",
_25
isoCountry: "US",
_25
postalCode: "94105",
_25
region: "CA",
_25
street: "645 Harrison St.",
_25
});
_25
_25
console.log(address.accountSid);
_25
}
_25
_25
createAddress();

Output

_18
{
_18
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_18
"city": "San Francisco",
_18
"customer_name": "Twilio",
_18
"date_created": "Tue, 18 Aug 2015 17:07:30 +0000",
_18
"date_updated": "Tue, 18 Aug 2015 17:07:30 +0000",
_18
"emergency_enabled": true,
_18
"friendly_name": "Twilio",
_18
"iso_country": "US",
_18
"postal_code": "94105",
_18
"region": "CA",
_18
"sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_18
"street": "645 Harrison St.",
_18
"street_secondary": null,
_18
"validated": false,
_18
"verified": false,
_18
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
_18
}

The response to this request contains a sid property. This is the Address's SID, which you need when configuring your Phone Numbers.

Use an existing Address resource as an emergency Address

If you already have an Address resource you wish to use as an emergency Address, update the Address resource so that the emergency_enabled property is true as shown in the example below.

Use an existing Address resource as an emergency Address

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_18
// Download the helper library from https://www.twilio.com/docs/node/install
_18
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18
_18
// Find your Account SID and Auth Token at twilio.com/console
_18
// and set the environment variables. See http://twil.io/secure
_18
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18
const authToken = process.env.TWILIO_AUTH_TOKEN;
_18
const client = twilio(accountSid, authToken);
_18
_18
async function updateAddress() {
_18
const address = await client
_18
.addresses("ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.update({ emergencyEnabled: true });
_18
_18
console.log(address.accountSid);
_18
}
_18
_18
updateAddress();

Output

_18
{
_18
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_18
"city": "SF",
_18
"customer_name": "name",
_18
"date_created": "Tue, 18 Aug 2015 17:07:30 +0000",
_18
"date_updated": "Tue, 18 Aug 2015 17:07:30 +0000",
_18
"emergency_enabled": true,
_18
"friendly_name": null,
_18
"iso_country": "US",
_18
"postal_code": "94019",
_18
"region": "CA",
_18
"sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_18
"street": "4th",
_18
"street_secondary": null,
_18
"validated": false,
_18
"verified": false,
_18
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
_18
}


Associate an emergency Address with a Phone Number

Once you've created an emergency Address, you need to update the IncomingPhoneNumber resource's emergency_address_sid property with the emergency Address SID, as shown in the code sample below.

This request requires the SID of the Phone Number. You can find the SIDs of your SIP Trunk's Phone Numbers using the PhoneNumber Subresource.

Associate an emergency Address with a Phone Number

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_18
// Download the helper library from https://www.twilio.com/docs/node/install
_18
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18
_18
// Find your Account SID and Auth Token at twilio.com/console
_18
// and set the environment variables. See http://twil.io/secure
_18
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18
const authToken = process.env.TWILIO_AUTH_TOKEN;
_18
const client = twilio(accountSid, authToken);
_18
_18
async function updateIncomingPhoneNumber() {
_18
const incomingPhoneNumber = await client
_18
.incomingPhoneNumbers("PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.update({ emergencyAddressSid: "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" });
_18
_18
console.log(incomingPhoneNumber.accountSid);
_18
}
_18
_18
updateIncomingPhoneNumber();

Output

_44
{
_44
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_44
"address_requirements": "none",
_44
"address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_44
"api_version": "2010-04-01",
_44
"beta": false,
_44
"capabilities": {
_44
"voice": true,
_44
"sms": false,
_44
"mms": true,
_44
"fax": false
_44
},
_44
"date_created": "Thu, 30 Jul 2015 23:19:04 +0000",
_44
"date_updated": "Thu, 30 Jul 2015 23:19:04 +0000",
_44
"emergency_status": "Inactive",
_44
"emergency_address_sid": "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_44
"emergency_address_status": "registered",
_44
"friendly_name": "(808) 925-5327",
_44
"identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_44
"origin": "origin",
_44
"phone_number": "+18089255327",
_44
"sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_44
"sms_application_sid": "",
_44
"sms_fallback_method": "POST",
_44
"sms_fallback_url": "",
_44
"sms_method": "POST",
_44
"sms_url": "",
_44
"status_callback": "",
_44
"status_callback_method": "POST",
_44
"trunk_sid": null,
_44
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json",
_44
"voice_application_sid": "",
_44
"voice_caller_id_lookup": true,
_44
"voice_fallback_method": "POST",
_44
"voice_fallback_url": null,
_44
"voice_method": "POST",
_44
"voice_url": null,
_44
"voice_receive_mode": "voice",
_44
"status": "in-use",
_44
"bundle_sid": "BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_44
"subresource_uris": {
_44
"assigned_add_ons": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns.json"
_44
}
_44
}


Check a Phone Number's emergency Address status

You can check on the status of a Phone Number's emergency Address registration by fetching the IncomingPhoneNumber resource and checking the value of the emergency_address_status property. An example of this request is shown below.

Check the emergency Address registration status of a Phone Number

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_18
// Download the helper library from https://www.twilio.com/docs/node/install
_18
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18
_18
// Find your Account SID and Auth Token at twilio.com/console
_18
// and set the environment variables. See http://twil.io/secure
_18
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18
const authToken = process.env.TWILIO_AUTH_TOKEN;
_18
const client = twilio(accountSid, authToken);
_18
_18
async function fetchIncomingPhoneNumber() {
_18
const incomingPhoneNumber = await client
_18
.incomingPhoneNumbers("PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
_18
.fetch();
_18
_18
console.log(incomingPhoneNumber.accountSid);
_18
}
_18
_18
fetchIncomingPhoneNumber();

Output

_44
{
_44
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_44
"address_requirements": "none",
_44
"address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_44
"api_version": "2010-04-01",
_44
"beta": false,
_44
"capabilities": {
_44
"voice": true,
_44
"sms": false,
_44
"mms": true,
_44
"fax": false
_44
},
_44
"date_created": "Thu, 30 Jul 2015 23:19:04 +0000",
_44
"date_updated": "Thu, 30 Jul 2015 23:19:04 +0000",
_44
"emergency_status": "Active",
_44
"emergency_address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_44
"emergency_address_status": "registered",
_44
"friendly_name": "(808) 925-5327",
_44
"identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_44
"origin": "origin",
_44
"phone_number": "+18089255327",
_44
"sid": "PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_44
"sms_application_sid": "",
_44
"sms_fallback_method": "POST",
_44
"sms_fallback_url": "",
_44
"sms_method": "POST",
_44
"sms_url": "",
_44
"status_callback": "",
_44
"status_callback_method": "POST",
_44
"trunk_sid": null,
_44
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json",
_44
"voice_application_sid": "",
_44
"voice_caller_id_lookup": false,
_44
"voice_fallback_method": "POST",
_44
"voice_fallback_url": null,
_44
"voice_method": "POST",
_44
"voice_url": null,
_44
"voice_receive_mode": "voice",
_44
"status": "in-use",
_44
"bundle_sid": "BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_44
"subresource_uris": {
_44
"assigned_add_ons": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns.json"
_44
}
_44
}


Remove an emergency Address from a Phone Number

To remove an emergency Address from a Phone Number, you need to remove the emergency_address_sid from the IncomingPhoneNumber resource as shown in the example below.

Remove an emergency_address_sid from a Phone Number

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_18
// Download the helper library from https://www.twilio.com/docs/node/install
_18
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18
_18
// Find your Account SID and Auth Token at twilio.com/console
_18
// and set the environment variables. See http://twil.io/secure
_18
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18
const authToken = process.env.TWILIO_AUTH_TOKEN;
_18
const client = twilio(accountSid, authToken);
_18
_18
async function updateIncomingPhoneNumber() {
_18
const incomingPhoneNumber = await client
_18
.incomingPhoneNumbers("PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.update({ emergencyAddressSid: "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" });
_18
_18
console.log(incomingPhoneNumber.accountSid);
_18
}
_18
_18
updateIncomingPhoneNumber();

Output

_44
{
_44
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_44
"address_requirements": "none",
_44
"address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_44
"api_version": "2010-04-01",
_44
"beta": false,
_44
"capabilities": {
_44
"voice": true,
_44
"sms": false,
_44
"mms": true,
_44
"fax": false
_44
},
_44
"date_created": "Thu, 30 Jul 2015 23:19:04 +0000",
_44
"date_updated": "Thu, 30 Jul 2015 23:19:04 +0000",
_44
"emergency_status": "Inactive",
_44
"emergency_address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_44
"emergency_address_status": "registered",
_44
"friendly_name": "(808) 925-5327",
_44
"identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_44
"origin": "origin",
_44
"phone_number": "+18089255327",
_44
"sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_44
"sms_application_sid": "",
_44
"sms_fallback_method": "POST",
_44
"sms_fallback_url": "",
_44
"sms_method": "POST",
_44
"sms_url": "",
_44
"status_callback": "",
_44
"status_callback_method": "POST",
_44
"trunk_sid": null,
_44
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json",
_44
"voice_application_sid": "",
_44
"voice_caller_id_lookup": true,
_44
"voice_fallback_method": "POST",
_44
"voice_fallback_url": null,
_44
"voice_method": "POST",
_44
"voice_url": null,
_44
"voice_receive_mode": "voice",
_44
"status": "in-use",
_44
"bundle_sid": "BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_44
"subresource_uris": {
_44
"assigned_add_ons": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns.json"
_44
}
_44
}

After this request, you should check the emergency Address registration status of the Phone Number to ensure the de-registration of that emergency Address.


Change an emergency Address for a Phone Number

To change a Phone Number's emergency Address, you need to follow the steps listed below.

  1. Remove the emergency_address_sid from the IncomingPhoneNumber resource .
  2. Check the emergency Address registration status of the Phone Number . Wait until the emergency_address_status is unregistered before proceeding.
  3. Update the IncomingPhoneNumber resource's emergency_address_sid with the new emergency Address SID.
  4. Check the emergency Address registration status of the Phone Number . Once the emergency_address_status is registered , the Phone Number has been successfully updated.

Delete an emergency Address

If you wish to delete an emergency Address, you must first make sure that it is no longer associated with any IncomingPhoneNumber resources (or any other Twilio resource).

You can then delete the Address resource, as shown in the sample request below.

Delete an emergency Address

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_14
// Download the helper library from https://www.twilio.com/docs/node/install
_14
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_14
_14
// Find your Account SID and Auth Token at twilio.com/console
_14
// and set the environment variables. See http://twil.io/secure
_14
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_14
const authToken = process.env.TWILIO_AUTH_TOKEN;
_14
const client = twilio(accountSid, authToken);
_14
_14
async function deleteAddress() {
_14
await client.addresses("ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").remove();
_14
}
_14
_14
deleteAddress();


Rate this page: