Create phone number

POST /v1/Trunks/{TrunkSid}/PhoneNumbers

Phone numbers associated with trunks

Path parameters

  • TrunkSid string Required

    The SID of the Trunk to associate the phone number with.

    Minimum length is 34, maximum length is 34. Format should match the following pattern: ^TK[0-9a-fA-F]{32}$.

application/x-www-form-urlencoded

Body

  • PhoneNumberSid string Required

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

    Minimum length is 34, maximum length is 34. Format should match the following pattern: ^PN[0-9a-fA-F]{32}$.

Responses

  • 201 application/json

    Created

    Hide headers attributes Show headers attributes
    • Access-Control-Allow-Origin string

      Specify the origin(s) allowed to access the resource

    • Access-Control-Allow-Methods string

      Specify the HTTP methods allowed when accessing the resource

    • Access-Control-Allow-Headers string

      Specify the headers allowed when accessing the resource

    • Access-Control-Allow-Credentials boolean

      Indicates whether the browser should include credentials

    • Access-Control-Expose-Headers string

      Headers exposed to the client

    Hide response attributes Show response attributes object
    • account_sid string | null

      The SID of the Account that created the PhoneNumber resource.

      Minimum length is 34, maximum length is 34. Format should match the following pattern: ^AC[0-9a-fA-F]{32}$.

    • address_requirements string

      Whether the phone number requires an Address registered with Twilio and, if so, what type. Can be: none, any, local, or foreign.

      Values are none, any, local, or foreign.

    • api_version string | null

      The API version used to start a new TwiML session.

    • beta boolean | null

      Whether the phone number is new to the Twilio platform. Can be: true or false.

    • capabilities object(string-map) | null

      The set of Boolean properties that indicate whether a phone number can receive calls or messages. Capabilities are Voice, SMS, and MMS and each capability can be: true or false.

    • date_created string(date-time) | null

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

    • date_updated string(date-time) | null

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

    • friendly_name string | null

      The string that you assigned to describe the resource.

    • phone_number string(phone-number) | null

      The phone number in E.164 format, which consists of a + followed by the country code and subscriber number.

    • sid string | null

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

      Minimum length is 34, maximum length is 34. Format should match the following pattern: ^PN[0-9a-fA-F]{32}$.

    • sms_application_sid string | null

      The SID of the application that handles SMS messages sent to the phone number. If an sms_application_sid is present, we ignore all sms_*_url values and use those of the application.

      Minimum length is 34, maximum length is 34. Format should match the following pattern: ^AP[0-9a-fA-F]{32}$.

    • sms_fallback_method string(http-method) | null

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

      Values are GET or POST.

    • sms_fallback_url string(uri) | null

      The URL that we call using the sms_fallback_method when an error occurs while retrieving or executing the TwiML from sms_url.

    • sms_method string(http-method) | null

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

      Values are GET or POST.

    • sms_url string(uri) | null

      The URL we call using the sms_method when the phone number receives an incoming SMS message.

    • status_callback string(uri) | null

      The URL we call using the status_callback_method to send status information to your application.

    • status_callback_method string(http-method) | null

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

      Values are GET or POST.

    • trunk_sid string | null

      The SID of the Trunk that handles calls to the phone number. If a trunk_sid is present, we ignore all of the voice URLs and voice applications and use those set on the Trunk. Setting a trunk_sid will automatically delete your voice_application_sid and vice versa.

      Minimum length is 34, maximum length is 34. Format should match the following pattern: ^TK[0-9a-fA-F]{32}$.

    • url string(uri) | null

      The absolute URL of the resource.

    • voice_application_sid string | null

      The SID of the application that handles calls to the phone number. If a voice_application_sid is present, we ignore all of the voice URLs and use those set on the application. Setting a voice_application_sid will automatically delete your trunk_sid and vice versa.

      Minimum length is 34, maximum length is 34. Format should match the following pattern: ^AP[0-9a-fA-F]{32}$.

    • voice_caller_id_lookup boolean | null

      Whether we look up the caller's caller-ID name from the CNAM database ($0.01 per look up). Can be: true or false.

    • voice_fallback_method string(http-method) | null

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

      Values are GET or POST.

    • voice_fallback_url string(uri) | null

      The URL that we call using the voice_fallback_method when an error occurs retrieving or executing the TwiML requested by url.

    • voice_method string(http-method) | null

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

      Values are GET or POST.

    • voice_url string(uri) | null

      The URL we call using the voice_method when the phone number receives a call. The voice_url is not be used if a voice_application_sid or a trunk_sid is set.

POST /v1/Trunks/{TrunkSid}/PhoneNumbers
curl \
 --request POST 'https://trunking.twilio.com/v1/Trunks/{TrunkSid}/PhoneNumbers' \
 --user "username:password" \
 --header "Content-Type: application/x-www-form-urlencoded" \
 --data 'PhoneNumberSid=PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
Request example
{"PhoneNumberSid"=>"PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}
Response examples (201)
{
  "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "beta": false,
  "links": {
    "phone_number": "https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
  },
  "sms_url": "https://webhooks.twilio.com/v1/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Proxy/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/Message",
  "trunk_sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "voice_url": "https://webhooks.twilio.com/v1/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Proxy/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/Call",
  "sms_method": "POST",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "api_version": "2010-04-01",
  "capabilities": {
    "mms": true,
    "sms": true,
    "voice": true
  },
  "date_created": "2010-12-10T17:27:34Z",
  "date_updated": "2015-10-09T11:36:32Z",
  "phone_number": "+14158675309",
  "voice_method": "POST",
  "friendly_name": "(415) 867-5309",
  "status_callback": "",
  "sms_fallback_url": "",
  "voice_fallback_url": null,
  "sms_application_sid": "APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "sms_fallback_method": "POST",
  "address_requirements": "none",
  "voice_application_sid": "",
  "voice_fallback_method": null,
  "status_callback_method": "POST",
  "voice_caller_id_lookup": null
}