Trunk Resource
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.
Property nameTypePIIDescription
The SID of the Account that created the Trunk resource.
Pattern: ^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.
disaster_recovery_methodenum<http-method> The HTTP method we use to call the disaster_recovery_url
. Can be: GET
or POST
.
disaster_recovery_urlstring<uri> 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.
The string that you assigned to describe the resource.
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.
transfer_modeenum<string> The call transfer settings for the trunk. Can be: enable-all
, sip-only
and disable-all
. See Transfer for more information.
Possible values: disable-all
enable-all
sip-only
transfer_caller_idenum<string> Caller Id for transfer target. Can be: from-transferee
(default) or from-transferor
.
Possible values: from-transferee
from-transferor
cnam_lookup_enabledboolean 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.
auth_type_setarray[string]
date_createdstring<date-time>
date_updatedstring<date-time>
The unique string that we created to identify the Trunk resource.
Pattern: ^TK[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The absolute URL of the resource.
The URLs of related resources.
POST https://trunking.twilio.com/v1/Trunks
Property nameTypeRequiredPIIDescription
FriendlyNamestringOptional 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.
DisasterRecoveryUrlstring<uri>Optional 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.
DisasterRecoveryMethodenum<http-method>Optional The HTTP method we should use to call the disaster_recovery_url
. Can be: GET
or POST
.
TransferModeenum<string>Optional The call transfer settings for the trunk. Can be: enable-all
, sip-only
and disable-all
. See Transfer for more information.
Possible values: 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.
CnamLookupEnabledbooleanOptional 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.
TransferCallerIdenum<string>Optional Caller Id for transfer target. Can be: from-transferee
(default) or from-transferor
.
Possible values: from-transferee
from-transferor
_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.trunking.v1.trunks.create().then(trunk => console.log(trunk.sid));
_27 "sid": "TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27 "domain_name": "test.pstn.twilio.com",
_27 "disaster_recovery_method": "POST",
_27 "disaster_recovery_url": "http://disaster-recovery.com",
_27 "friendly_name": "friendly_name",
_27 "cnam_lookup_enabled": false,
_27 "mode": "do-not-record",
_27 "trim": "do-not-trim"
_27 "transfer_mode": "disable-all",
_27 "transfer_caller_id": "from-transferee",
_27 "date_created": "2015-01-02T11:23:45Z",
_27 "date_updated": "2015-01-02T11:23:45Z",
_27 "url": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27 "origination_urls": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/OriginationUrls",
_27 "credential_lists": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/CredentialLists",
_27 "ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IpAccessControlLists",
_27 "phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/PhoneNumbers"
GET https://trunking.twilio.com/v1/Trunks/{Sid}
Property nameTypeRequiredPIIDescription
The unique string that we created to identify the Trunk resource to fetch.
Pattern: ^TK[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
_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.trunking.v1.trunks('TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10 .then(trunk => console.log(trunk.domainName));
_27 "sid": "TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27 "domain_name": "test.pstn.twilio.com",
_27 "disaster_recovery_method": "POST",
_27 "disaster_recovery_url": "http://disaster-recovery.com",
_27 "friendly_name": "friendly_name",
_27 "cnam_lookup_enabled": false,
_27 "mode": "do-not-record",
_27 "trim": "do-not-trim"
_27 "transfer_mode": "disable-all",
_27 "transfer_caller_id": "from-transferor",
_27 "date_created": "2015-01-02T11:23:45Z",
_27 "date_updated": "2015-01-02T11:23:45Z",
_27 "url": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27 "origination_urls": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/OriginationUrls",
_27 "credential_lists": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/CredentialLists",
_27 "ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IpAccessControlLists",
_27 "phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/PhoneNumbers"
GET https://trunking.twilio.com/v1/Trunks
Property nameTypeRequiredPIIDescription
How many resources to return in each list page. The default is 50, and the maximum is 1000.
Minimum: 1
Maximum: 1000
The page index. This value is simply for client state.
Minimum: 0
The page token. This is provided by the API.
_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.trunking.v1.trunks
_10 .then(trunks => trunks.forEach(t => console.log(t.sid)));
_40 "first_page_url": "https://trunking.twilio.com/v1/Trunks?PageSize=50&Page=0",
_40 "url": "https://trunking.twilio.com/v1/Trunks?PageSize=50&Page=0",
_40 "next_page_url": "https://trunking.twilio.com/v1/Trunks?PageSize=50&Page=1",
_40 "previous_page_url": "https://trunking.twilio.com/v1/Trunks?PageSize=50&Page=0"
_40 "sid": "TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_40 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_40 "domain_name": "test.pstn.twilio.com",
_40 "disaster_recovery_method": "POST",
_40 "disaster_recovery_url": "http://disaster-recovery.com",
_40 "friendly_name": "friendly_name",
_40 "cnam_lookup_enabled": false,
_40 "mode": "do-not-record",
_40 "trim": "do-not-trim"
_40 "transfer_mode": "disable-all",
_40 "transfer_caller_id": "from-transferee",
_40 "date_created": "2015-01-02T11:23:45Z",
_40 "date_updated": "2015-01-02T11:23:45Z",
_40 "url": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_40 "origination_urls": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/OriginationUrls",
_40 "credential_lists": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/CredentialLists",
_40 "ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IpAccessControlLists",
_40 "phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/PhoneNumbers"
POST https://trunking.twilio.com/v1/Trunks/{Sid}
Property nameTypeRequiredPIIDescription
The unique string that we created to identify the OriginationUrl resource to update.
Pattern: ^TK[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Property nameTypeRequiredPIIDescription
FriendlyNamestringOptional 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.
DisasterRecoveryUrlstring<uri>Optional 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.
DisasterRecoveryMethodenum<http-method>Optional The HTTP method we should use to call the disaster_recovery_url
. Can be: GET
or POST
.
TransferModeenum<string>Optional The call transfer settings for the trunk. Can be: enable-all
, sip-only
and disable-all
. See Transfer for more information.
Possible values: 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.
CnamLookupEnabledbooleanOptional 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.
TransferCallerIdenum<string>Optional Caller Id for transfer target. Can be: from-transferee
(default) or from-transferor
.
Possible values: from-transferee
from-transferor
_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.trunking.v1.trunks('TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10 .update({friendlyName: 'friendly_name'})
_10 .then(trunk => console.log(trunk.domainName));
_27 "sid": "TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27 "domain_name": "test.pstn.twilio.com",
_27 "disaster_recovery_method": "GET",
_27 "disaster_recovery_url": "http://updated-recovery.com",
_27 "friendly_name": "updated_name",
_27 "cnam_lookup_enabled": true,
_27 "mode": "do-not-record",
_27 "trim": "do-not-trim"
_27 "transfer_mode": "disable-all",
_27 "transfer_caller_id": "from-transferor",
_27 "date_created": "2015-01-02T11:23:45Z",
_27 "date_updated": "2015-01-02T11:23:45Z",
_27 "url": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27 "origination_urls": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/OriginationUrls",
_27 "credential_lists": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/CredentialLists",
_27 "ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IpAccessControlLists",
_27 "phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/PhoneNumbers"
DELETE https://trunking.twilio.com/v1/Trunks/{Sid}
Property nameTypeRequiredPIIDescription
The unique string that we created to identify the Trunk resource to delete.
Pattern: ^TK[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
_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.trunking.v1.trunks('TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove();