Purchase a phone-number for the account

POST /2010-04-01/Accounts/{AccountSid}/IncomingPhoneNumbers.json

Incoming phone numbers on a Twilio account/project

Purchase a phone-number for the account.

Path parameters

Body

  • The SID of the Address resource we should associate with the new phone number. Some regions require addresses to meet local regulations.

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

  • The API version to use for incoming calls made to the new phone number. The default is 2010-04-01.

  • AreaCode string

    The desired area code for your new incoming phone number. Can be any three-digit, US or Canada area code. We will provision an available phone number within this area code for you. You must provide an area_code or a phone_number. (US and Canada only).

  • The SID of the Bundle resource that you associate with the phone number. Some regions require a Bundle to meet local Regulations.

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

  • The SID of the emergency address configuration to use for emergency calling from the new phone number.

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

  • The parameter displays if emergency calling is enabled for this number. Active numbers may place emergency calls by dialing valid emergency numbers for the country.

    Values are Active or Inactive.

  • A descriptive string that you created to describe the new phone number. It can be up to 64 characters long. By default, this is a formatted version of the new phone number.

  • The SID of the Identity resource that we should associate with the new phone number. Some regions require an identity to meet local regulations.

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

  • PhoneNumber string(phone-number)

    The phone number to purchase specified in E.164 format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234.

  • The SID of the application that should handle SMS messages sent to the new phone number. If an sms_application_sid is present, we ignore all of the sms_*_url urls and use those set on the application.

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

  • SmsFallbackMethod string(http-method)

    The HTTP method that we should use to call sms_fallback_url. Can be: GET or POST and defaults to POST.

    Values are HEAD, GET, POST, PATCH, PUT, or DELETE.

  • SmsFallbackUrl string(uri)

    The URL that we should call when an error occurs while requesting or executing the TwiML defined by sms_url.

  • SmsMethod string(http-method)

    The HTTP method that we should use to call sms_url. Can be: GET or POST and defaults to POST.

    Values are HEAD, GET, POST, PATCH, PUT, or DELETE.

  • SmsUrl string(uri)

    The URL we should call when the new phone number receives an incoming SMS message.

  • StatusCallback string(uri)

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

  • StatusCallbackMethod string(http-method)

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

    Values are HEAD, GET, POST, PATCH, PUT, or DELETE.

  • TrunkSid string

    The SID of the Trunk we should use to handle calls to the new phone number. If a trunk_sid is present, we ignore all of the voice urls and voice applications and use only 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}$.

  • The SID of the application we should use to handle calls to the new phone number. If a voice_application_sid is present, we ignore all of the voice urls and use only 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}$.

  • Whether to lookup the caller's name from the CNAM database and post it to your app. Can be: true or false and defaults to false.

  • VoiceFallbackMethod string(http-method)

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

    Values are HEAD, GET, POST, PATCH, PUT, or DELETE.

  • VoiceFallbackUrl string(uri)

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

  • VoiceMethod string(http-method)

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

    Values are HEAD, GET, POST, PATCH, PUT, or DELETE.

  • The configuration parameter for the new phone number to receive incoming voice calls or faxes. Can be: fax or voice and defaults to voice.

    Values are voice or fax.

  • VoiceUrl string(uri)

    The URL that we should call to answer a call to the new phone number. The voice_url will not be called if a voice_application_sid or a trunk_sid is set.

Responses

  • Created

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

      The SID of the Account that created the resource

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

    • Whether the phone number requires an Address registered with Twilio.

      Values are none, any, local, or foreign.

    • address_sid string | null

      The SID of the Address resource associated with the phone number

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

    • 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

    • bundle_sid string | null

      The SID of the Bundle resource associated with number

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

    • capabilities object(phone-number-capabilities) | null

      Indicate if a phone can receive calls or messages

      Hide capabilities attributes Show capabilities attributes object(phone-number-capabilities) | null
    • date_created string(date-time-rfc-2822) | null

      The RFC 2822 date and time in GMT that the resource was created

    • date_updated string(date-time-rfc-2822) | null

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

    • The emergency address configuration to use for emergency calling

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

    • State of the emergency address configuration for the phone number

      Values are registered, unregistered, pending-registration, registration-failure, pending-unregistration, or unregistration-failure.

    • emergency_status string | null

      Displays if emergency calling is enabled for this number.

      Values are Active or Inactive.

    • friendly_name string | null

      The string that you assigned to describe the resource

    • identity_sid string | null

      The SID of the Identity resource associated with number

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

    • origin string | null

      The phone number's origin. Can be twilio or hosted.

    • phone_number string(phone-number) | null

      The phone number in E.164 format

    • sid string | null

      The unique string that identifies the 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

      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 used with sms_fallback_url

      Values are HEAD, GET, POST, PATCH, PUT, or DELETE.

    • sms_fallback_url string(uri) | null

      The URL that we call when an error occurs while retrieving or executing the TwiML

    • sms_method string(http-method) | null

      The HTTP method to use with sms_url

      Values are HEAD, GET, POST, PATCH, PUT, or DELETE.

    • sms_url string(uri) | null

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

    • status string | null
    • status_callback string(uri) | null

      The URL to send status information to your application

    • status_callback_method string(http-method) | null

      The HTTP method we use to call status_callback

      Values are HEAD, GET, POST, PATCH, PUT, or DELETE.

    • trunk_sid string | null

      The SID of the Trunk that handles calls to the phone number

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

    • uri string(uri) | null

      The URI of the resource, relative to https://api.twilio.com

    • The SID of the application that handles calls to the phone number

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

    • Whether to lookup the caller's name

    • voice_fallback_method string(http-method) | null

      The HTTP method used with voice_fallback_url

      Values are HEAD, GET, POST, PATCH, PUT, or DELETE.

    • voice_fallback_url string(uri) | null

      The URL we call when an error occurs in TwiML

    • voice_method string(http-method) | null

      The HTTP method used with the voice_url

      Values are HEAD, GET, POST, PATCH, PUT, or DELETE.

    • voice_receive_mode string | null

      Values are voice or fax.

    • voice_url string(uri) | null

      The URL we call when the phone number receives a call

POST /2010-04-01/Accounts/{AccountSid}/IncomingPhoneNumbers.json
curl \
 -X POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/IncomingPhoneNumbers.json \
 --user "username:password" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -d 'AddressSid=string&ApiVersion=string&AreaCode=string&BundleSid=string&EmergencyAddressSid=string&EmergencyStatus=Active&FriendlyName=string&IdentitySid=string&PhoneNumber=string&SmsApplicationSid=string&SmsFallbackMethod=HEAD&SmsFallbackUrl=https%3A%2F%2Fexample.com&SmsMethod=HEAD&SmsUrl=https%3A%2F%2Fexample.com&StatusCallback=https%3A%2F%2Fexample.com&StatusCallbackMethod=HEAD&TrunkSid=string&VoiceApplicationSid=string&VoiceCallerIdLookup=true&VoiceFallbackMethod=HEAD&VoiceFallbackUrl=https%3A%2F%2Fexample.com&VoiceMethod=HEAD&VoiceReceiveMode=voice&VoiceUrl=https%3A%2F%2Fexample.com'
Request example
{
  "AddressSid": "string",
  "ApiVersion": "string",
  "AreaCode": "string",
  "BundleSid": "string",
  "EmergencyAddressSid": "string",
  "EmergencyStatus": "Active",
  "FriendlyName": "string",
  "IdentitySid": "string",
  "PhoneNumber": "string",
  "SmsApplicationSid": "string",
  "SmsFallbackMethod": "HEAD",
  "SmsFallbackUrl": "https://example.com",
  "SmsMethod": "HEAD",
  "SmsUrl": "https://example.com",
  "StatusCallback": "https://example.com",
  "StatusCallbackMethod": "HEAD",
  "TrunkSid": "string",
  "VoiceApplicationSid": "string",
  "VoiceCallerIdLookup": true,
  "VoiceFallbackMethod": "HEAD",
  "VoiceFallbackUrl": "https://example.com",
  "VoiceMethod": "HEAD",
  "VoiceReceiveMode": "voice",
  "VoiceUrl": "https://example.com"
}
Request examples
{
  "AddressSid": "string",
  "ApiVersion": "string",
  "AreaCode": "string",
  "BundleSid": "string",
  "EmergencyAddressSid": "string",
  "EmergencyStatus": "Active",
  "FriendlyName": "string",
  "IdentitySid": "string",
  "PhoneNumber": "string",
  "SmsApplicationSid": "string",
  "SmsFallbackMethod": "HEAD",
  "SmsFallbackUrl": "https://example.com",
  "SmsMethod": "HEAD",
  "SmsUrl": "https://example.com",
  "StatusCallback": "https://example.com",
  "StatusCallbackMethod": "HEAD",
  "TrunkSid": "string",
  "VoiceApplicationSid": "string",
  "VoiceCallerIdLookup": true,
  "VoiceFallbackMethod": "HEAD",
  "VoiceFallbackUrl": "https://example.com",
  "VoiceMethod": "HEAD",
  "VoiceReceiveMode": "voice",
  "VoiceUrl": "https://example.com"
}
Response examples (201)
{
  "account_sid": "string",
  "address_requirements": "none",
  "address_sid": "string",
  "api_version": "string",
  "beta": true,
  "bundle_sid": "string",
  "capabilities": {
    "fax": true,
    "mms": true,
    "sms": true,
    "voice": true
  },
  "date_created": "string",
  "date_updated": "string",
  "emergency_address_sid": "string",
  "emergency_address_status": "registered",
  "emergency_status": "Active",
  "friendly_name": "string",
  "identity_sid": "string",
  "origin": "string",
  "phone_number": "string",
  "sid": "string",
  "sms_application_sid": "string",
  "sms_fallback_method": "HEAD",
  "sms_fallback_url": "https://example.com",
  "sms_method": "HEAD",
  "sms_url": "https://example.com",
  "status": "string",
  "status_callback": "https://example.com",
  "status_callback_method": "HEAD",
  "trunk_sid": "string",
  "uri": "https://example.com",
  "voice_application_sid": "string",
  "voice_caller_id_lookup": true,
  "voice_fallback_method": "HEAD",
  "voice_fallback_url": "https://example.com",
  "voice_method": "HEAD",
  "voice_receive_mode": "voice",
  "voice_url": "https://example.com"
}
Response examples (201)
{
  "account_sid": "string",
  "address_requirements": "none",
  "address_sid": "string",
  "api_version": "string",
  "beta": true,
  "bundle_sid": "string",
  "capabilities": {
    "fax": true,
    "mms": true,
    "sms": true,
    "voice": true
  },
  "date_created": "string",
  "date_updated": "string",
  "emergency_address_sid": "string",
  "emergency_address_status": "registered",
  "emergency_status": "Active",
  "friendly_name": "string",
  "identity_sid": "string",
  "origin": "string",
  "phone_number": "string",
  "sid": "string",
  "sms_application_sid": "string",
  "sms_fallback_method": "HEAD",
  "sms_fallback_url": "https://example.com",
  "sms_method": "HEAD",
  "sms_url": "https://example.com",
  "status": "string",
  "status_callback": "https://example.com",
  "status_callback_method": "HEAD",
  "trunk_sid": "string",
  "uri": "https://example.com",
  "voice_application_sid": "string",
  "voice_caller_id_lookup": true,
  "voice_fallback_method": "HEAD",
  "voice_fallback_url": "https://example.com",
  "voice_method": "HEAD",
  "voice_receive_mode": "voice",
  "voice_url": "https://example.com"
}