Menu

Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Phone Numbers

The Phone Numbers subresource contains the list of Phone Number instances associated with this Trunk.

Phone Number instances are managed through the core Twilio REST API. Check out the Phone Number reference docs for more information.

Actions


List all Phone Numbers for a Trunk

Back To Top

GET /Trunks/{Trunk SID}/PhoneNumbers

Get a paged listing of all Phone Number instances for this SIP Trunk.

curl -G https://trunking.twilio.com/v1/Trunks/{trunk sid}/PhoneNumbers \
    -u '{twilio account sid}:{twilio auth token}'

Example Response

{
  "phone_numbers": [
    {
      "sid": "PN57668c402291251d54cbcf7f1be5004c",
      "date_created": "2015-02-19T16:54:13Z",
      "date_updated": "2015-05-14T14:22:19Z",
      "friendly_name": "867-5310 (Joey)",
      "account_sid": "ACxxx",
      "phone_number": "+14158675310",
      "api_version": "2010-04-01",
      "voice_caller_id_lookup": false,
      "voice_url": null,
      "voice_method": null,
      "voice_fallback_url": null,
      "voice_fallback_method": "POST",
      "status_callback": "",
      "status_callback_method": "POST",
      "voice_application_sid": null,
      "trunk_sid": "TK298268bb645f1854e9ad171bd1427003",
      "sms_url": "https://demo.twilio.com/welcome/sms/reply/",
      "sms_method": "POST",
      "sms_fallback_url": "",
      "sms_fallback_method": "POST",
      "sms_application_sid": "",
      "address_requirements": "none",
      "beta": false,
      "url": "https://trunking.twilio.com/v1/Trunks/TK298268bb645f1854e9ad171bd1427003/PhoneNumbers/PN57668c402291251d54cbcf7f1be5004c",
      "capabilities": {
        "voice": true,
        "sms": true,
        "mms": true
      },
      "links": {
        "phone_number": "https://api.twilio.com/2010-04-01/Accounts/ACxxx/IncomingPhoneNumbers/PN57668c402291251d54cbcf7f1be5004c"
      }
    }
  ],
  "meta": {
    "page": 0,
    "page_size": 50,
    "first_page_url": "https://trunking.twilio.com/v1/Trunks/TK298268bb645f1854e9ad171bd1427003/PhoneNumbers?PageSize=50&Page=0",
    "previous_page_url": null,
    "url": "https://trunking.twilio.com/v1/Trunks/TK298268bb645f1854e9ad171bd1427003/PhoneNumbers?PageSize=50&Page=0",
    "next_page_url": null,
    "key": "phone_numbers"
  }
}


Associate a Phone Number with a Trunk

Back To Top

POST /Trunks/{Trunk SID}/PhoneNumbers

Associate a Phone Number (by SID) with this SIP Trunk.

curl -XPOST https://trunking.twilio.com/v1/Trunks/{trunk sid}/PhoneNumbers \
    -d "PhoneNumberSid=xxx" \
    -u '{twilio account sid}:{twilio auth token}'

Required Parameters

Names in PHP format
phoneNumberSid
Required
post sid<PN> Not PII

The SID of the Incoming Phone Number that you want to associate with this trunk.

Example Response

{
  "sid": "PNc0a685788c03871e1e0576ba1878e2e8",
  "date_created": "2014-10-07T13:37:19Z",
  "date_updated": "2015-09-02T16:27:22Z",
  "friendly_name": "867-5310 (Joey)",
  "account_sid": "ACxxx",
  "phone_number": "+14158675310",
  "api_version": "2010-04-01",
  "voice_caller_id_lookup": false,
  "voice_url": null,
  "voice_method": null,
  "voice_fallback_url": "",
  "voice_fallback_method": "POST",
  "status_callback": "",
  "status_callback_method": "POST",
  "voice_application_sid": null,
  "trunk_sid": "TK298268bb645f1854e9ad171bd1427003",
  "sms_url": "https://demo.twilio.com/welcome/sms/reply/",
  "sms_method": "POST",
  "sms_fallback_url": "",
  "sms_fallback_method": "POST",
  "sms_application_sid": "",
  "address_requirements": "none",
  "beta": false,
  "url": "https://trunking.twilio.com/v1/Trunks/TK298268bb645f1854e9ad171bd1427003/PhoneNumbers/PNc0a685788c03871e1e0576ba1878e2e8",
  "capabilities": {
    "voice": true,
    "sms": true,
    "mms": true
  },
  "links": {
    "phone_number": "https://api.twilio.com/2010-04-01/Accounts/ACxxx/IncomingPhoneNumbers/PNc0a685788c03871e1e0576ba1878e2e8"
  }
}


Remove an associated Phone Number from a Trunk

Back To Top

DELETE /Trunks/{Trunk SID}/PhoneNumbers/{Phone Number SID}

Remove a Phone Number (identified by a SID) from this SIP Trunk.

curl -XDELETE https://trunking.twilio.com/v1/Trunks/{trunk sid}/PhoneNumbers/{phone number sid} \
    -u '{twilio account sid}:{twilio auth token}'

Example Response

A successful request returns an HTTP status code 204 and an empty body.

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.