Skip to contentSkip to navigationSkip to topbar
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

emergency-addresses page anchor

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

create-a-new-emergency-address page anchor

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 AddressLink to code sample: Create a new emergency Address
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function createAddress() {
11
const address = await client.addresses.create({
12
city: "San Francisco",
13
customerName: "Twilio",
14
emergencyEnabled: true,
15
friendlyName: "Twilio",
16
isoCountry: "US",
17
postalCode: "94105",
18
region: "CA",
19
street: "645 Harrison St.",
20
});
21
22
console.log(address.accountSid);
23
}
24
25
createAddress();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"city": "San Francisco",
4
"customer_name": "Twilio",
5
"date_created": "Tue, 18 Aug 2015 17:07:30 +0000",
6
"date_updated": "Tue, 18 Aug 2015 17:07:30 +0000",
7
"emergency_enabled": true,
8
"friendly_name": "Twilio",
9
"iso_country": "US",
10
"postal_code": "94105",
11
"region": "CA",
12
"sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
13
"street": "645 Harrison St.",
14
"street_secondary": null,
15
"validated": false,
16
"verified": false,
17
"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

use-an-existing-address-resource-as-an-emergency-address page anchor

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 AddressLink to code sample: Use an existing Address resource as an emergency Address
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function updateAddress() {
11
const address = await client
12
.addresses("ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.update({ emergencyEnabled: true });
14
15
console.log(address.accountSid);
16
}
17
18
updateAddress();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"city": "SF",
4
"customer_name": "name",
5
"date_created": "Tue, 18 Aug 2015 17:07:30 +0000",
6
"date_updated": "Tue, 18 Aug 2015 17:07:30 +0000",
7
"emergency_enabled": true,
8
"friendly_name": null,
9
"iso_country": "US",
10
"postal_code": "94019",
11
"region": "CA",
12
"sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
13
"street": "4th",
14
"street_secondary": null,
15
"validated": false,
16
"verified": false,
17
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
18
}

Associate an emergency Address with a Phone Number

associate-an-emergency-address-with-a-phone-number page anchor

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 NumberLink to code sample: Associate an emergency Address with a Phone Number
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function updateIncomingPhoneNumber() {
11
const incomingPhoneNumber = await client
12
.incomingPhoneNumbers("PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.update({ emergencyAddressSid: "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" });
14
15
console.log(incomingPhoneNumber.accountSid);
16
}
17
18
updateIncomingPhoneNumber();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"address_requirements": "none",
4
"address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
5
"api_version": "2010-04-01",
6
"beta": false,
7
"capabilities": {
8
"voice": true,
9
"sms": false,
10
"mms": true,
11
"fax": false
12
},
13
"date_created": "Thu, 30 Jul 2015 23:19:04 +0000",
14
"date_updated": "Thu, 30 Jul 2015 23:19:04 +0000",
15
"emergency_status": "Inactive",
16
"emergency_address_sid": "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
17
"emergency_address_status": "registered",
18
"friendly_name": "(808) 925-5327",
19
"identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
20
"origin": "origin",
21
"phone_number": "+18089255327",
22
"sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
23
"sms_application_sid": "",
24
"sms_fallback_method": "POST",
25
"sms_fallback_url": "",
26
"sms_method": "POST",
27
"sms_url": "",
28
"status_callback": "",
29
"status_callback_method": "POST",
30
"trunk_sid": null,
31
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json",
32
"voice_application_sid": "",
33
"voice_caller_id_lookup": true,
34
"voice_fallback_method": "POST",
35
"voice_fallback_url": null,
36
"voice_method": "POST",
37
"voice_url": null,
38
"voice_receive_mode": "voice",
39
"status": "in-use",
40
"bundle_sid": "BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
41
"subresource_uris": {
42
"assigned_add_ons": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns.json"
43
}
44
}

Check a Phone Number's emergency Address status

check-a-phone-numbers-emergency-address-status page anchor

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 NumberLink to code sample: Check the emergency Address registration status of a Phone Number
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function fetchIncomingPhoneNumber() {
11
const incomingPhoneNumber = await client
12
.incomingPhoneNumbers("PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
13
.fetch();
14
15
console.log(incomingPhoneNumber.accountSid);
16
}
17
18
fetchIncomingPhoneNumber();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"address_requirements": "none",
4
"address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
5
"api_version": "2010-04-01",
6
"beta": false,
7
"capabilities": {
8
"voice": true,
9
"sms": false,
10
"mms": true,
11
"fax": false
12
},
13
"date_created": "Thu, 30 Jul 2015 23:19:04 +0000",
14
"date_updated": "Thu, 30 Jul 2015 23:19:04 +0000",
15
"emergency_status": "Active",
16
"emergency_address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
17
"emergency_address_status": "registered",
18
"friendly_name": "(808) 925-5327",
19
"identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
20
"origin": "origin",
21
"phone_number": "+18089255327",
22
"sid": "PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
23
"sms_application_sid": "",
24
"sms_fallback_method": "POST",
25
"sms_fallback_url": "",
26
"sms_method": "POST",
27
"sms_url": "",
28
"status_callback": "",
29
"status_callback_method": "POST",
30
"trunk_sid": null,
31
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json",
32
"voice_application_sid": "",
33
"voice_caller_id_lookup": false,
34
"voice_fallback_method": "POST",
35
"voice_fallback_url": null,
36
"voice_method": "POST",
37
"voice_url": null,
38
"voice_receive_mode": "voice",
39
"status": "in-use",
40
"bundle_sid": "BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
41
"subresource_uris": {
42
"assigned_add_ons": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns.json"
43
}
44
}

Remove an emergency Address from a Phone Number

remove-an-emergency-address-from-a-phone-number page anchor

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 NumberLink to code sample: Remove an emergency_address_sid from a Phone Number
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function updateIncomingPhoneNumber() {
11
const incomingPhoneNumber = await client
12
.incomingPhoneNumbers("PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.update({ emergencyAddressSid: "" });
14
15
console.log(incomingPhoneNumber.accountSid);
16
}
17
18
updateIncomingPhoneNumber();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"address_requirements": "none",
4
"address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
5
"api_version": "2010-04-01",
6
"beta": false,
7
"capabilities": {
8
"voice": true,
9
"sms": false,
10
"mms": true,
11
"fax": false
12
},
13
"date_created": "Thu, 30 Jul 2015 23:19:04 +0000",
14
"date_updated": "Thu, 30 Jul 2015 23:19:04 +0000",
15
"emergency_status": "Inactive",
16
"emergency_address_sid": "",
17
"emergency_address_status": "registered",
18
"friendly_name": "(808) 925-5327",
19
"identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
20
"origin": "origin",
21
"phone_number": "+18089255327",
22
"sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
23
"sms_application_sid": "",
24
"sms_fallback_method": "POST",
25
"sms_fallback_url": "",
26
"sms_method": "POST",
27
"sms_url": "",
28
"status_callback": "",
29
"status_callback_method": "POST",
30
"trunk_sid": null,
31
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json",
32
"voice_application_sid": "",
33
"voice_caller_id_lookup": true,
34
"voice_fallback_method": "POST",
35
"voice_fallback_url": null,
36
"voice_method": "POST",
37
"voice_url": null,
38
"voice_receive_mode": "voice",
39
"status": "in-use",
40
"bundle_sid": "BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
41
"subresource_uris": {
42
"assigned_add_ons": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns.json"
43
}
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

change-an-emergency-address-for-a-phone-number page anchor

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

delete-an-emergency-address page anchor

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.

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

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.