The Trunk resource represents a SIP Trunk in your Twilio account. A Trunk can have associated Credential Lists, IP Access Control Lists, Origination URLs, and Phone Numbers.
To learn how to create and use SIP Trunks, check out our getting started guide.
The SID of the Account that created the Trunk resource.
^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The unique address you reserve on Twilio to which you route your SIP traffic. Domain names can contain letters, digits, and -
and must end with pstn.twilio.com
. See Termination Settings for more information.
The HTTP method we use to call the disaster_recovery_url
. Can be: GET
or POST
.
GET
POST
The URL we call using the disaster_recovery_method
if an error occurs while sending SIP traffic towards the configured Origination URL. We retrieve TwiML from this URL and execute the instructions like any other normal TwiML call. See Disaster Recovery for more information.
Whether Secure Trunking is enabled for the trunk. If enabled, all calls going through the trunk will be secure using SRTP for media and TLS for signaling. If disabled, then RTP will be used for media. See Secure Trunking for more information.
The recording settings for the trunk. Can be: do-not-record
, record-from-ringing
, record-from-answer
. If set to record-from-ringing
or record-from-answer
, all calls going through the trunk will be recorded. The only way to change recording parameters is on a sub-resource of a Trunk after it has been created. e.g./Trunks/[Trunk_SID]/Recording -XPOST -d'Mode=record-from-answer'
. See Recording for more information.
The call transfer settings for the trunk. Can be: enable-all
, sip-only
and disable-all
. See Transfer for more information.
disable-all
enable-all
sip-only
Caller Id for transfer target. Can be: from-transferee
(default) or from-transferor
.
from-transferee
from-transferor
Whether Caller ID Name (CNAM) lookup is enabled for the trunk. If enabled, all inbound calls to the SIP Trunk from the United States and Canada automatically perform a CNAM Lookup and display Caller ID data on your phone. See CNAM Lookups for more information.
The types of authentication mapped to the domain. Can be: IP_ACL
and CREDENTIAL_LIST
. If both are mapped, the values are returned in a comma delimited list. If empty, the domain will not receive any traffic.
The date and time in GMT when the resource was created specified in RFC 2822 format.
The date and time in GMT when the resource was last updated specified in RFC 2822 format.
The unique string that we created to identify the Trunk resource.
^TK[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The URLs of related resources.
POST https://trunking.twilio.com/v1/Trunks
application/x-www-form-urlencoded
A descriptive string that you create to describe the resource. It can be up to 64 characters long.
The unique address you reserve on Twilio to which you route your SIP traffic. Domain names can contain letters, digits, and -
and must end with pstn.twilio.com
. See Termination Settings for more information.
The URL we should call using the disaster_recovery_method
if an error occurs while sending SIP traffic towards the configured Origination URL. We retrieve TwiML from the URL and execute the instructions like any other normal TwiML call. See Disaster Recovery for more information.
The HTTP method we should use to call the disaster_recovery_url
. Can be: GET
or POST
.
GET
POST
The call transfer settings for the trunk. Can be: enable-all
, sip-only
and disable-all
. See Transfer for more information.
disable-all
enable-all
sip-only
Whether Secure Trunking is enabled for the trunk. If enabled, all calls going through the trunk will be secure using SRTP for media and TLS for signaling. If disabled, then RTP will be used for media. See Secure Trunking for more information.
Whether Caller ID Name (CNAM) lookup should be enabled for the trunk. If enabled, all inbound calls to the SIP Trunk from the United States and Canada automatically perform a CNAM Lookup and display Caller ID data on your phone. See CNAM Lookups for more information.
Caller Id for transfer target. Can be: from-transferee
(default) or from-transferor
.
from-transferee
from-transferor
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createTrunk() {11const trunk = await client.trunking.v1.trunks.create();1213console.log(trunk.accountSid);14}1516createTrunk();
1{2"sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"domain_name": "test.pstn.twilio.com",5"disaster_recovery_method": "POST",6"disaster_recovery_url": "http://disaster-recovery.com",7"friendly_name": "friendly_name",8"secure": false,9"cnam_lookup_enabled": false,10"recording": {11"mode": "do-not-record",12"trim": "do-not-trim"13},14"transfer_mode": "disable-all",15"transfer_caller_id": "from-transferee",16"auth_type": "",17"auth_type_set": [],18"date_created": "2015-01-02T11:23:45Z",19"date_updated": "2015-01-02T11:23:45Z",20"url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",21"links": {22"origination_urls": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls",23"credential_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists",24"ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists",25"phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers"26}27}
GET https://trunking.twilio.com/v1/Trunks/{Sid}
The unique string that we created to identify the Trunk resource to fetch.
^TK[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function fetchTrunk() {11const trunk = await client.trunking.v112.trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.fetch();1415console.log(trunk.accountSid);16}1718fetchTrunk();
1{2"sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"domain_name": "test.pstn.twilio.com",5"disaster_recovery_method": "POST",6"disaster_recovery_url": "http://disaster-recovery.com",7"friendly_name": "friendly_name",8"secure": false,9"cnam_lookup_enabled": false,10"recording": {11"mode": "do-not-record",12"trim": "do-not-trim"13},14"transfer_mode": "disable-all",15"transfer_caller_id": "from-transferor",16"auth_type": "",17"auth_type_set": [],18"date_created": "2015-01-02T11:23:45Z",19"date_updated": "2015-01-02T11:23:45Z",20"url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",21"links": {22"origination_urls": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls",23"credential_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists",24"ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists",25"phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers"26}27}
GET https://trunking.twilio.com/v1/Trunks
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1
Maximum: 1000
The page token. This is provided by the API.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function listTrunk() {11const trunks = await client.trunking.v1.trunks.list({ limit: 20 });1213trunks.forEach((t) => console.log(t.accountSid));14}1516listTrunk();
1{2"meta": {3"first_page_url": "https://trunking.twilio.com/v1/Trunks?PageSize=50&Page=0",4"url": "https://trunking.twilio.com/v1/Trunks?PageSize=50&Page=0",5"page_size": 50,6"key": "trunks",7"next_page_url": null,8"page": 0,9"previous_page_url": null10},11"trunks": [12{13"sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",15"domain_name": "test.pstn.twilio.com",16"disaster_recovery_method": "POST",17"disaster_recovery_url": "http://disaster-recovery.com",18"friendly_name": "friendly_name",19"secure": false,20"cnam_lookup_enabled": false,21"recording": {22"mode": "do-not-record",23"trim": "do-not-trim"24},25"transfer_mode": "disable-all",26"transfer_caller_id": "from-transferee",27"auth_type": "",28"auth_type_set": [],29"date_created": "2015-01-02T11:23:45Z",30"date_updated": "2015-01-02T11:23:45Z",31"url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",32"links": {33"origination_urls": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls",34"credential_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists",35"ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists",36"phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers"37}38}39]40}
POST https://trunking.twilio.com/v1/Trunks/{Sid}
The unique string that we created to identify the OriginationUrl resource to update.
^TK[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
application/x-www-form-urlencoded
A descriptive string that you create to describe the resource. It can be up to 64 characters long.
The unique address you reserve on Twilio to which you route your SIP traffic. Domain names can contain letters, digits, and -
and must end with pstn.twilio.com
. See Termination Settings for more information.
The URL we should call using the disaster_recovery_method
if an error occurs while sending SIP traffic towards the configured Origination URL. We retrieve TwiML from the URL and execute the instructions like any other normal TwiML call. See Disaster Recovery for more information.
The HTTP method we should use to call the disaster_recovery_url
. Can be: GET
or POST
.
GET
POST
The call transfer settings for the trunk. Can be: enable-all
, sip-only
and disable-all
. See Transfer for more information.
disable-all
enable-all
sip-only
Whether Secure Trunking is enabled for the trunk. If enabled, all calls going through the trunk will be secure using SRTP for media and TLS for signaling. If disabled, then RTP will be used for media. See Secure Trunking for more information.
Whether Caller ID Name (CNAM) lookup should be enabled for the trunk. If enabled, all inbound calls to the SIP Trunk from the United States and Canada automatically perform a CNAM Lookup and display Caller ID data on your phone. See CNAM Lookups for more information.
Caller Id for transfer target. Can be: from-transferee
(default) or from-transferor
.
from-transferee
from-transferor
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function updateTrunk() {11const trunk = await client.trunking.v112.trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.update({ friendlyName: "FriendlyName" });1415console.log(trunk.accountSid);16}1718updateTrunk();
1{2"sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"domain_name": "test.pstn.twilio.com",5"disaster_recovery_method": "GET",6"disaster_recovery_url": "http://updated-recovery.com",7"friendly_name": "FriendlyName",8"secure": true,9"cnam_lookup_enabled": true,10"recording": {11"mode": "do-not-record",12"trim": "do-not-trim"13},14"transfer_mode": "disable-all",15"transfer_caller_id": "from-transferor",16"auth_type": "",17"auth_type_set": [],18"date_created": "2015-01-02T11:23:45Z",19"date_updated": "2015-01-02T11:23:45Z",20"url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",21"links": {22"origination_urls": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls",23"credential_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists",24"ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists",25"phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers"26}27}
DELETE https://trunking.twilio.com/v1/Trunks/{Sid}
The unique string that we created to identify the Trunk resource to delete.
^TK[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function deleteTrunk() {11await client.trunking.v112.trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.remove();14}1516deleteTrunk();