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

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.


Trunk Properties

Property nameTypePIIDescription
account_sidSID<AC>
Not PII

The SID of the Account that created the Trunk resource.

Pattern: ^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34

domain_namestring

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.

Possible values:
GETPOST

disaster_recovery_urlstring<uri>
PII MTL: 30 days

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.


friendly_namestring

The string that you assigned to describe the resource.


secureboolean

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.


recordingobject

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-allenable-allsip-only

transfer_caller_idenum<string>

Caller Id for transfer target. Can be: from-transferee (default) or from-transferor.

Possible values:
from-transfereefrom-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.


auth_typestring

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]

Reserved.


date_createdstring<date-time>

date_updatedstring<date-time>

The date and time in GMT when the resource was last updated specified in RFC 2822 format.


sidSID<TK>

The unique string that we created to identify the Trunk resource.

Pattern: ^TK[0-9a-fA-F]{32}$Min length: 34Max length: 34

urlstring<uri>

The absolute URL of the resource.


linksobject<uri-map>

The URLs of related resources.


Create a Trunk resource

POST https://trunking.twilio.com/v1/Trunks

Request body parameters

Property nameTypeRequiredPIIDescription
FriendlyNamestringOptional

A descriptive string that you create to describe the resource. It can be up to 64 characters long.


DomainNamestringOptional

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.

Possible values:
GETPOST

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-allenable-allsip-only

SecurebooleanOptional

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-transfereefrom-transferor

Create Trunk

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

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

Output

_27
{
_27
"sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_27
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_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
"secure": false,
_27
"cnam_lookup_enabled": false,
_27
"recording": {
_27
"mode": "do-not-record",
_27
"trim": "do-not-trim"
_27
},
_27
"transfer_mode": "disable-all",
_27
"transfer_caller_id": "from-transferee",
_27
"auth_type": "",
_27
"auth_type_set": [],
_27
"date_created": "2015-01-02T11:23:45Z",
_27
"date_updated": "2015-01-02T11:23:45Z",
_27
"url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_27
"links": {
_27
"origination_urls": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls",
_27
"credential_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists",
_27
"ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists",
_27
"phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers"
_27
}
_27
}


Fetch a Trunk resource

GET https://trunking.twilio.com/v1/Trunks/{Sid}

Path parameters

Property nameTypeRequiredPIIDescription
SidSID<TK>required

The unique string that we created to identify the Trunk resource to fetch.

Pattern: ^TK[0-9a-fA-F]{32}$Min length: 34Max length: 34

Fetch Trunk

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 fetchTrunk() {
_18
const trunk = await client.trunking.v1
_18
.trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.fetch();
_18
_18
console.log(trunk.accountSid);
_18
}
_18
_18
fetchTrunk();

Output

_27
{
_27
"sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_27
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_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
"secure": false,
_27
"cnam_lookup_enabled": false,
_27
"recording": {
_27
"mode": "do-not-record",
_27
"trim": "do-not-trim"
_27
},
_27
"transfer_mode": "disable-all",
_27
"transfer_caller_id": "from-transferor",
_27
"auth_type": "",
_27
"auth_type_set": [],
_27
"date_created": "2015-01-02T11:23:45Z",
_27
"date_updated": "2015-01-02T11:23:45Z",
_27
"url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_27
"links": {
_27
"origination_urls": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls",
_27
"credential_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists",
_27
"ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists",
_27
"phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers"
_27
}
_27
}


Read multiple Trunk resources

GET https://trunking.twilio.com/v1/Trunks

Query parameters

Property nameTypeRequiredPIIDescription
PageSizeintegerOptional

How many resources to return in each list page. The default is 50, and the maximum is 1000.

Minimum: 1Maximum: 1000

PageintegerOptional

The page index. This value is simply for client state.

Minimum: 0

PageTokenstringOptional

The page token. This is provided by the API.

Read Trunk

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

_16
// Download the helper library from https://www.twilio.com/docs/node/install
_16
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_16
_16
// Find your Account SID and Auth Token at twilio.com/console
_16
// and set the environment variables. See http://twil.io/secure
_16
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_16
const authToken = process.env.TWILIO_AUTH_TOKEN;
_16
const client = twilio(accountSid, authToken);
_16
_16
async function listTrunk() {
_16
const trunks = await client.trunking.v1.trunks.list({ limit: 20 });
_16
_16
trunks.forEach((t) => console.log(t.accountSid));
_16
}
_16
_16
listTrunk();

Output

_40
{
_40
"meta": {
_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
"page_size": 50,
_40
"key": "trunks",
_40
"next_page_url": null,
_40
"page": 0,
_40
"previous_page_url": null
_40
},
_40
"trunks": [
_40
{
_40
"sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_40
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_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
"secure": false,
_40
"cnam_lookup_enabled": false,
_40
"recording": {
_40
"mode": "do-not-record",
_40
"trim": "do-not-trim"
_40
},
_40
"transfer_mode": "disable-all",
_40
"transfer_caller_id": "from-transferee",
_40
"auth_type": "",
_40
"auth_type_set": [],
_40
"date_created": "2015-01-02T11:23:45Z",
_40
"date_updated": "2015-01-02T11:23:45Z",
_40
"url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_40
"links": {
_40
"origination_urls": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls",
_40
"credential_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists",
_40
"ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists",
_40
"phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers"
_40
}
_40
}
_40
]
_40
}


Update a Trunk resource

POST https://trunking.twilio.com/v1/Trunks/{Sid}

Path parameters

Property nameTypeRequiredPIIDescription
SidSID<TK>required

The unique string that we created to identify the OriginationUrl resource to update.

Pattern: ^TK[0-9a-fA-F]{32}$Min length: 34Max length: 34

Request body parameters

Property nameTypeRequiredPIIDescription
FriendlyNamestringOptional

A descriptive string that you create to describe the resource. It can be up to 64 characters long.


DomainNamestringOptional

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.

Possible values:
GETPOST

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-allenable-allsip-only

SecurebooleanOptional

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-transfereefrom-transferor

Update Trunk

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 updateTrunk() {
_18
const trunk = await client.trunking.v1
_18
.trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.update({ friendlyName: "FriendlyName" });
_18
_18
console.log(trunk.accountSid);
_18
}
_18
_18
updateTrunk();

Output

_27
{
_27
"sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_27
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_27
"domain_name": "test.pstn.twilio.com",
_27
"disaster_recovery_method": "GET",
_27
"disaster_recovery_url": "http://updated-recovery.com",
_27
"friendly_name": "FriendlyName",
_27
"secure": true,
_27
"cnam_lookup_enabled": true,
_27
"recording": {
_27
"mode": "do-not-record",
_27
"trim": "do-not-trim"
_27
},
_27
"transfer_mode": "disable-all",
_27
"transfer_caller_id": "from-transferor",
_27
"auth_type": "",
_27
"auth_type_set": [],
_27
"date_created": "2015-01-02T11:23:45Z",
_27
"date_updated": "2015-01-02T11:23:45Z",
_27
"url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_27
"links": {
_27
"origination_urls": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls",
_27
"credential_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists",
_27
"ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists",
_27
"phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers"
_27
}
_27
}


Delete a Trunk resource

DELETE https://trunking.twilio.com/v1/Trunks/{Sid}

Path parameters

Property nameTypeRequiredPIIDescription
SidSID<TK>required

The unique string that we created to identify the Trunk resource to delete.

Pattern: ^TK[0-9a-fA-F]{32}$Min length: 34Max length: 34

Delete Trunk

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

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


Rate this page: