ConnectionPolicy Resource
This reference page provides the properties and API parameters for the Twilio ConnectionPolicy Resource to route outbound traffic using connection policies. See Related how-to documentation to learn the steps to use the info on this page.
The ConnectionPolicies resource describes a list of URI Entries that are used to route Origination traffic to a PSTN Carrier over a BYOC Trunk.
The SID of the Account that created the Connection Policy resource.
^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34The unique string that we created to identify the Connection Policy resource.
^NY[0-9a-fA-F]{32}$Min length: 34Max length: 34The 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 URLs of related resources.
POST https://voice.twilio.com/v1/ConnectionPolicies
application/x-www-form-urlencodedA descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
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 at twilio.com/console5// Provision API Keys at twilio.com/console/runtime/api-keys6// and set the environment variables. See http://twil.io/secure7// For local testing, you can use your Account SID and Auth token8const accountSid = process.env.TWILIO_ACCOUNT_SID;9const apiKey = process.env.TWILIO_API_KEY;10const apiSecret = process.env.TWILIO_API_SECRET;11const client = twilio(apiKey, apiSecret, { accountSid: accountSid });1213async function createConnectionPolicy() {14const connectionPolicy = await client.voice.v1.connectionPolicies.create();1516console.log(connectionPolicy.accountSid);17}1819createConnectionPolicy();
Response
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"sid": "NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"friendly_name": "friendly_name",5"date_created": "2020-03-18T23:31:36Z",6"date_updated": "2020-03-18T23:31:36Z",7"url": "https://voice.twilio.com/v1/ConnectionPolicies/NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",8"links": {9"targets": "https://voice.twilio.com/v1/ConnectionPolicies/NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Targets"10}11}
GET https://voice.twilio.com/v1/ConnectionPolicies/{Sid}
The unique string that we created to identify the Connection Policy resource to fetch.
^NY[0-9a-fA-F]{32}$Min length: 34Max length: 341// 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 at twilio.com/console5// Provision API Keys at twilio.com/console/runtime/api-keys6// and set the environment variables. See http://twil.io/secure7// For local testing, you can use your Account SID and Auth token8const accountSid = process.env.TWILIO_ACCOUNT_SID;9const apiKey = process.env.TWILIO_API_KEY;10const apiSecret = process.env.TWILIO_API_SECRET;11const client = twilio(apiKey, apiSecret, { accountSid: accountSid });1213async function fetchConnectionPolicy() {14const connectionPolicy = await client.voice.v115.connectionPolicies("NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")16.fetch();1718console.log(connectionPolicy.accountSid);19}2021fetchConnectionPolicy();
Response
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"sid": "NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"friendly_name": "friendly_name",5"date_created": "2020-03-18T23:31:36Z",6"date_updated": "2020-03-18T23:31:37Z",7"url": "https://voice.twilio.com/v1/ConnectionPolicies/NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",8"links": {9"targets": "https://voice.twilio.com/v1/ConnectionPolicies/NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Targets"10}11}
GET https://voice.twilio.com/v1/ConnectionPolicies
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1Maximum: 1000The 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 at twilio.com/console5// Provision API Keys at twilio.com/console/runtime/api-keys6// and set the environment variables. See http://twil.io/secure7// For local testing, you can use your Account SID and Auth token8const accountSid = process.env.TWILIO_ACCOUNT_SID;9const apiKey = process.env.TWILIO_API_KEY;10const apiSecret = process.env.TWILIO_API_SECRET;11const client = twilio(apiKey, apiSecret, { accountSid: accountSid });1213async function listConnectionPolicy() {14const connectionPolicies = await client.voice.v1.connectionPolicies.list({15limit: 20,16});1718connectionPolicies.forEach((c) => console.log(c.accountSid));19}2021listConnectionPolicy();
Response
1{2"meta": {3"page": 0,4"page_size": 50,5"first_page_url": "https://voice.twilio.com/v1/ConnectionPolicies?PageSize=50&Page=0",6"previous_page_url": null,7"url": "https://voice.twilio.com/v1/ConnectionPolicies?PageSize=50&Page=0",8"next_page_url": null,9"key": "connection_policies"10},11"connection_policies": [12{13"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"sid": "NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",15"friendly_name": "friendly_name",16"date_created": "2020-03-18T23:31:36Z",17"date_updated": "2020-03-18T23:31:37Z",18"url": "https://voice.twilio.com/v1/ConnectionPolicies/NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",19"links": {20"targets": "https://voice.twilio.com/v1/ConnectionPolicies/NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Targets"21}22}23]24}
POST https://voice.twilio.com/v1/ConnectionPolicies/{Sid}
The unique string that we created to identify the Connection Policy resource to update.
^NY[0-9a-fA-F]{32}$Min length: 34Max length: 34application/x-www-form-urlencodedA descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.
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 at twilio.com/console5// Provision API Keys at twilio.com/console/runtime/api-keys6// and set the environment variables. See http://twil.io/secure7// For local testing, you can use your Account SID and Auth token8const accountSid = process.env.TWILIO_ACCOUNT_SID;9const apiKey = process.env.TWILIO_API_KEY;10const apiSecret = process.env.TWILIO_API_SECRET;11const client = twilio(apiKey, apiSecret, { accountSid: accountSid });1213async function updateConnectionPolicy() {14const connectionPolicy = await client.voice.v115.connectionPolicies("NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")16.update({ friendlyName: "FriendlyName" });1718console.log(connectionPolicy.accountSid);19}2021updateConnectionPolicy();
Response
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"sid": "NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"friendly_name": "FriendlyName",5"date_created": "2020-03-18T23:31:36Z",6"date_updated": "2020-03-18T23:31:37Z",7"url": "https://voice.twilio.com/v1/ConnectionPolicies/NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",8"links": {9"targets": "https://voice.twilio.com/v1/ConnectionPolicies/NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Targets"10}11}
DELETE https://voice.twilio.com/v1/ConnectionPolicies/{Sid}
The unique string that we created to identify the Connection Policy resource to delete.
^NY[0-9a-fA-F]{32}$Min length: 34Max length: 341// 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 at twilio.com/console5// Provision API Keys at twilio.com/console/runtime/api-keys6// and set the environment variables. See http://twil.io/secure7// For local testing, you can use your Account SID and Auth token8const accountSid = process.env.TWILIO_ACCOUNT_SID;9const apiKey = process.env.TWILIO_API_KEY;10const apiSecret = process.env.TWILIO_API_SECRET;11const client = twilio(apiKey, apiSecret, { accountSid: accountSid });1213async function deleteConnectionPolicy() {14await client.voice.v115.connectionPolicies("NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")16.remove();17}1819deleteConnectionPolicy();