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

ByocTrunk Resource


The ByocTrunks resource describes a trunk that can be configured to send/receive traffic to/from a PSTN Carrier.


ByocTrunk Properties

Property nameTypePIIDescription
account_sidSID<AC>
Not PII

The SID of the Account that created the BYOC Trunk resource.

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

sidSID<BY>

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

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

friendly_namestring

The string that you assigned to describe the resource.


voice_urlstring<uri>
PII MTL: 30 days

The URL we call using the voice_method when the BYOC Trunk receives a call.


voice_methodenum<http-method>

The HTTP method we use to call voice_url. Can be: GET or POST.

Possible values:
GETPOST

voice_fallback_urlstring<uri>

The URL that we call when an error occurs while retrieving or executing the TwiML requested from voice_url.


voice_fallback_methodenum<http-method>

The HTTP method we use to call voice_fallback_url. Can be: GET or POST.

Possible values:
GETPOST

status_callback_urlstring<uri>

The URL that we call to pass status parameters (such as call ended) to your application.


status_callback_methodenum<http-method>

The HTTP method we use to call status_callback_url. Either GET or POST.

Possible values:
GETPOST

cnam_lookup_enabledboolean

Whether Caller ID Name (CNAM) lookup is enabled for the trunk. If enabled, all inbound calls to the BYOC 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.


connection_policy_sidSID<NY>

The SID of the Connection Policy that Twilio will use when routing traffic to your communications infrastructure.

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

from_domain_sidSID<SD>

The SID of the SIP Domain that should be used in the From header of originating calls sent to your SIP infrastructure. If your SIP infrastructure allows users to "call back" an incoming call, configure this with a SIP Domain to ensure proper routing. If not configured, the from domain will default to "sip.twilio.com".

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

date_createdstring<date-time>

date_updatedstring<date-time>

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


urlstring<uri>

The absolute URL of the resource.


Create a ByocTrunk resource

POST https://voice.twilio.com/v1/ByocTrunks

Request body parameters

Property nameTypeRequiredPIIDescription
FriendlyNamestringOptional

A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.


VoiceUrlstring<uri>Optional

The URL we should call when the BYOC Trunk receives a call.


VoiceMethodenum<http-method>Optional

The HTTP method we should use to call voice_url. Can be: GET or POST.

Possible values:
GETPOST

VoiceFallbackUrlstring<uri>Optional

The URL that we should call when an error occurs while retrieving or executing the TwiML from voice_url.


VoiceFallbackMethodenum<http-method>Optional

The HTTP method we should use to call voice_fallback_url. Can be: GET or POST.

Possible values:
GETPOST

StatusCallbackUrlstring<uri>Optional

The URL that we should call to pass status parameters (such as call ended) to your application.


StatusCallbackMethodenum<http-method>Optional

The HTTP method we should use to call status_callback_url. Can be: GET or POST.

Possible values:
GETPOST

CnamLookupEnabledbooleanOptional

Whether Caller ID Name (CNAM) lookup is enabled for the trunk. If enabled, all inbound calls to the BYOC 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.


ConnectionPolicySidSID<NY>Optional

The SID of the Connection Policy that Twilio will use when routing traffic to your communications infrastructure.

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

FromDomainSidSID<SD>Optional

The SID of the SIP Domain that should be used in the From header of originating calls sent to your SIP infrastructure. If your SIP infrastructure allows users to "call back" an incoming call, configure this with a SIP Domain to ensure proper routing. If not configured, the from domain will default to "sip.twilio.com".

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

Create a ByocTrunk

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 createByocTrunk() {
_16
const byocTrunk = await client.voice.v1.byocTrunks.create();
_16
_16
console.log(byocTrunk.accountSid);
_16
}
_16
_16
createByocTrunk();

Output

_17
{
_17
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"sid": "BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"friendly_name": "friendly_name",
_17
"voice_url": "https://byoc.example.com/twilio/app",
_17
"voice_method": "POST",
_17
"voice_fallback_method": "POST",
_17
"voice_fallback_url": "https://byoc.example.com/twilio/fallback",
_17
"status_callback_method": "POST",
_17
"status_callback_url": "https://byoc.example.com/twilio/status_callback",
_17
"cnam_lookup_enabled": false,
_17
"connection_policy_sid": "NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"from_domain_sid": "SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"date_created": "2020-03-18T23:31:36Z",
_17
"date_updated": "2020-03-18T23:31:36Z",
_17
"url": "https://voice.twilio.com/v1/ByocTrunks/BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_17
}


Fetch a ByocTrunk resource

GET https://voice.twilio.com/v1/ByocTrunks/{Sid}

Path parameters

Property nameTypeRequiredPIIDescription
SidSID<BY>required

The Twilio-provided string that uniquely identifies the BYOC Trunk resource to fetch.

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

Fetch a ByocTrunk

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 fetchByocTrunk() {
_18
const byocTrunk = await client.voice.v1
_18
.byocTrunks("BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.fetch();
_18
_18
console.log(byocTrunk.accountSid);
_18
}
_18
_18
fetchByocTrunk();

Output

_17
{
_17
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"sid": "BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"friendly_name": "friendly_name",
_17
"voice_url": "https://byoc.example.com/twilio/app",
_17
"voice_method": "POST",
_17
"voice_fallback_method": "POST",
_17
"voice_fallback_url": "https://byoc.example.com/twilio/fallback",
_17
"status_callback_method": "POST",
_17
"status_callback_url": "https://byoc.example.com/twilio/status_callback",
_17
"cnam_lookup_enabled": false,
_17
"connection_policy_sid": "NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"from_domain_sid": "SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"date_created": "2020-03-18T23:31:36Z",
_17
"date_updated": "2020-03-18T23:31:37Z",
_17
"url": "https://voice.twilio.com/v1/ByocTrunks/BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_17
}


Read multiple ByocTrunk resources

GET https://voice.twilio.com/v1/ByocTrunks

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.

List multiple ByocTrunks

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 listByocTrunk() {
_16
const byocTrunks = await client.voice.v1.byocTrunks.list({ limit: 20 });
_16
_16
byocTrunks.forEach((b) => console.log(b.accountSid));
_16
}
_16
_16
listByocTrunk();

Output

_30
{
_30
"meta": {
_30
"page": 0,
_30
"page_size": 50,
_30
"first_page_url": "https://voice.twilio.com/v1/ByocTrunks?PageSize=50&Page=0",
_30
"previous_page_url": null,
_30
"url": "https://voice.twilio.com/v1/ByocTrunks?PageSize=50&Page=0",
_30
"next_page_url": null,
_30
"key": "byoc_trunks"
_30
},
_30
"byoc_trunks": [
_30
{
_30
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_30
"sid": "BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_30
"friendly_name": "friendly_name",
_30
"voice_url": "https://byoc.example.com/twilio/app",
_30
"voice_method": "POST",
_30
"voice_fallback_method": "POST",
_30
"voice_fallback_url": "https://byoc.example.com/twilio/fallback",
_30
"status_callback_method": "POST",
_30
"status_callback_url": "https://byoc.example.com/twilio/status_callback",
_30
"cnam_lookup_enabled": false,
_30
"connection_policy_sid": "NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_30
"from_domain_sid": "SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_30
"date_created": "2020-03-18T23:31:36Z",
_30
"date_updated": "2020-03-18T23:31:37Z",
_30
"url": "https://voice.twilio.com/v1/ByocTrunks/BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_30
}
_30
]
_30
}


Update a ByocTrunk resource

POST https://voice.twilio.com/v1/ByocTrunks/{Sid}

Path parameters

Property nameTypeRequiredPIIDescription
SidSID<BY>required

The Twilio-provided string that uniquely identifies the BYOC Trunk resource to update.

Pattern: ^BY[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 is not unique and can be up to 255 characters long.


VoiceUrlstring<uri>Optional

The URL we should call when the BYOC Trunk receives a call.


VoiceMethodenum<http-method>Optional

The HTTP method we should use to call voice_url

Possible values:
GETPOST

VoiceFallbackUrlstring<uri>Optional

The URL that we should call when an error occurs while retrieving or executing the TwiML requested by voice_url.


VoiceFallbackMethodenum<http-method>Optional

The HTTP method we should use to call voice_fallback_url. Can be: GET or POST.

Possible values:
GETPOST

StatusCallbackUrlstring<uri>Optional

The URL that we should call to pass status parameters (such as call ended) to your application.


StatusCallbackMethodenum<http-method>Optional

The HTTP method we should use to call status_callback_url. Can be: GET or POST.

Possible values:
GETPOST

CnamLookupEnabledbooleanOptional

Whether Caller ID Name (CNAM) lookup is enabled for the trunk. If enabled, all inbound calls to the BYOC 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.


ConnectionPolicySidSID<NY>Optional

The SID of the Connection Policy that Twilio will use when routing traffic to your communications infrastructure.

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

FromDomainSidSID<SD>Optional

The SID of the SIP Domain that should be used in the From header of originating calls sent to your SIP infrastructure. If your SIP infrastructure allows users to "call back" an incoming call, configure this with a SIP Domain to ensure proper routing. If not configured, the from domain will default to "sip.twilio.com".

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

Update a ByocTrunk

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 updateByocTrunk() {
_18
const byocTrunk = await client.voice.v1
_18
.byocTrunks("BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.update({ friendlyName: "FriendlyName" });
_18
_18
console.log(byocTrunk.accountSid);
_18
}
_18
_18
updateByocTrunk();

Output

_17
{
_17
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"sid": "BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"friendly_name": "FriendlyName",
_17
"voice_url": "https://byoc.example.com/twilio_updated/app",
_17
"voice_method": "GET",
_17
"voice_fallback_method": "GET",
_17
"voice_fallback_url": "https://byoc.example.com/twilio_updated/fallback",
_17
"status_callback_method": "GET",
_17
"status_callback_url": "https://byoc.example.com/twilio_updated/status_callback",
_17
"cnam_lookup_enabled": true,
_17
"connection_policy_sid": "NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
_17
"from_domain_sid": "SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
_17
"date_created": "2020-03-18T23:31:36Z",
_17
"date_updated": "2020-03-18T23:31:37Z",
_17
"url": "https://voice.twilio.com/v1/ByocTrunks/BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_17
}


Delete a ByocTrunk resource

DELETE https://voice.twilio.com/v1/ByocTrunks/{Sid}

Path parameters

Property nameTypeRequiredPIIDescription
SidSID<BY>required

The Twilio-provided string that uniquely identifies the BYOC Trunk resource to delete.

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

Delete a ByocTrunk

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 deleteByocTrunk() {
_16
await client.voice.v1
_16
.byocTrunks("BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_16
.remove();
_16
}
_16
_16
deleteByocTrunk();


Rate this page: