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.
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.
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.
_19// Download the helper library from https://www.twilio.com/docs/node/install
_19// Find your Account SID and Auth Token at twilio.com/console
_19// and set the environment variables. See http://twil.io/secure
_19const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19const authToken = process.env.TWILIO_AUTH_TOKEN;
_19const client = require('twilio')(accountSid, authToken);
_19 friendlyName: 'Twilio',
_19 emergencyEnabled: true,
_19 customerName: 'Twilio',
_19 street: '645 Harrison St.',
_19 city: 'San Francisco',
_19 .then(address => console.log(address.sid));
_18 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_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 "postal_code": "94105",
_18 "sid": "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18 "street": "645 Harrison St.",
_18 "street_secondary": null,
_18 "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Addresses/ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"
The response to this request contains a sid
property. This is the Address's SID, which you need when configuring your Phone Numbers.
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.
_10// Download the helper library from https://www.twilio.com/docs/node/install
_10// Find your Account SID and Auth Token at twilio.com/console
_10// and set the environment variables. See http://twil.io/secure
_10const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10const authToken = process.env.TWILIO_AUTH_TOKEN;
_10const client = require('twilio')(accountSid, authToken);
_10client.addresses('ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10 .update({emergencyEnabled: true})
_10 .then(address => console.log(address.customerName));
_18 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_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 "postal_code": "94019",
_18 "sid": "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18 "street_secondary": null,
_18 "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Addresses/ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"
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.
_10// Download the helper library from https://www.twilio.com/docs/node/install
_10// Find your Account SID and Auth Token at twilio.com/console
_10// and set the environment variables. See http://twil.io/secure
_10const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10const authToken = process.env.TWILIO_AUTH_TOKEN;
_10const client = require('twilio')(accountSid, authToken);
_10client.incomingPhoneNumbers('PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10 .update({emergencyAddressSid: 'ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'})
_10 .then(incoming_phone_number => console.log(incoming_phone_number.friendlyName));
_41 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_41 "address_requirements": "none",
_41 "address_sid": "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_41 "api_version": "2010-04-01",
_41 "date_created": "Thu, 30 Jul 2015 23:19:04 +0000",
_41 "date_updated": "Thu, 30 Jul 2015 23:19:04 +0000",
_41 "emergency_status": "Inactive",
_41 "emergency_address_sid": "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_41 "emergency_address_status": "registered",
_41 "friendly_name": "(808) 925-5327",
_41 "identity_sid": "RIXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_41 "phone_number": "+18089255327",
_41 "sid": "PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_41 "sms_application_sid": "",
_41 "sms_fallback_method": "POST",
_41 "sms_fallback_url": "",
_41 "sms_method": "POST",
_41 "status_callback": "",
_41 "status_callback_method": "POST",
_41 "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers/PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json",
_41 "voice_application_sid": "",
_41 "voice_caller_id_lookup": true,
_41 "voice_fallback_method": "POST",
_41 "voice_fallback_url": null,
_41 "voice_method": "POST",
_41 "voice_receive_mode": "voice",
_41 "bundle_sid": "BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
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.
_10// Download the helper library from https://www.twilio.com/docs/node/install
_10// Find your Account SID and Auth Token at twilio.com/console
_10// and set the environment variables. See http://twil.io/secure
_10const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10const authToken = process.env.TWILIO_AUTH_TOKEN;
_10const client = require('twilio')(accountSid, authToken);
_10client.incomingPhoneNumbers('PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10 .then(incoming_phone_number => console.log(incoming_phone_number.friendlyName));
_41 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_41 "address_requirements": "none",
_41 "address_sid": "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_41 "api_version": "2010-04-01",
_41 "date_created": "Thu, 30 Jul 2015 23:19:04 +0000",
_41 "date_updated": "Thu, 30 Jul 2015 23:19:04 +0000",
_41 "emergency_status": "Active",
_41 "emergency_address_sid": "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_41 "emergency_address_status": "registered",
_41 "friendly_name": "(808) 925-5327",
_41 "identity_sid": "RIXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_41 "phone_number": "+18089255327",
_41 "sid": "PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_41 "sms_application_sid": "",
_41 "sms_fallback_method": "POST",
_41 "sms_fallback_url": "",
_41 "sms_method": "POST",
_41 "status_callback": "",
_41 "status_callback_method": "POST",
_41 "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers/PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json",
_41 "voice_application_sid": "",
_41 "voice_caller_id_lookup": false,
_41 "voice_fallback_method": "POST",
_41 "voice_fallback_url": null,
_41 "voice_method": "POST",
_41 "voice_receive_mode": "voice",
_41 "bundle_sid": "BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
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.
_10// Download the helper library from https://www.twilio.com/docs/node/install
_10// Find your Account SID and Auth Token at twilio.com/console
_10// and set the environment variables. See http://twil.io/secure
_10const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10const authToken = process.env.TWILIO_AUTH_TOKEN;
_10const client = require('twilio')(accountSid, authToken);
_10client.incomingPhoneNumbers('PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10 .update({emergencyAddressSid: ''})
_10 .then(incoming_phone_number => console.log(incoming_phone_number.friendlyName));
_41 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_41 "address_requirements": "none",
_41 "address_sid": "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_41 "api_version": "2010-04-01",
_41 "date_created": "Thu, 30 Jul 2015 23:19:04 +0000",
_41 "date_updated": "Thu, 30 Jul 2015 23:19:04 +0000",
_41 "emergency_status": "Inactive",
_41 "emergency_address_sid": "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_41 "emergency_address_status": "registered",
_41 "friendly_name": "(808) 925-5327",
_41 "identity_sid": "RIXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_41 "phone_number": "+18089255327",
_41 "sid": "PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_41 "sms_application_sid": "",
_41 "sms_fallback_method": "POST",
_41 "sms_fallback_url": "",
_41 "sms_method": "POST",
_41 "status_callback": "",
_41 "status_callback_method": "POST",
_41 "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers/PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json",
_41 "voice_application_sid": "",
_41 "voice_caller_id_lookup": true,
_41 "voice_fallback_method": "POST",
_41 "voice_fallback_url": null,
_41 "voice_method": "POST",
_41 "voice_receive_mode": "voice",
_41 "bundle_sid": "BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
After this request, you should check the emergency Address registration status of the Phone Number to ensure the de-registration of that 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.
_10// Download the helper library from https://www.twilio.com/docs/node/install
_10// Find your Account SID and Auth Token at twilio.com/console
_10// and set the environment variables. See http://twil.io/secure
_10const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10const authToken = process.env.TWILIO_AUTH_TOKEN;
_10const client = require('twilio')(accountSid, authToken);
_10client.addresses('ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove();