Create phone number

POST /v1/Services/{ServiceSid}/PhoneNumbers

A Messaging Service resource to add, fetch or remove phone numbers from a Messaging Service.

Path parameters

  • ServiceSid string Required

    The SID of the Service to create the resource under.

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

application/x-www-form-urlencoded

Body

  • PhoneNumberSid string Required

    The SID of the Phone Number being added to the Service.

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

Responses

  • 200 application/json

    OK

    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
    • 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}$.

    • 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}$.

    • service_sid string | null

      The SID of the Service the resource is associated with.

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

    • date_created string(date-time) | null

      The date and time in GMT when the resource was created specified in ISO 8601 format.

    • date_updated string(date-time) | null

      The date and time in GMT when the resource was last updated specified in ISO 8601 format.

    • 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.

    • country_code string | null

      The 2-character ISO Country Code of the number.

    • capabilities array[string] | null

      An array of values that describe whether the number can receive calls or messages. Can be: Voice, SMS, and MMS.

    • url string(uri) | null

      The absolute URL of the PhoneNumber resource.

  • 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
    • 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}$.

    • 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}$.

    • service_sid string | null

      The SID of the Service the resource is associated with.

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

    • date_created string(date-time) | null

      The date and time in GMT when the resource was created specified in ISO 8601 format.

    • date_updated string(date-time) | null

      The date and time in GMT when the resource was last updated specified in ISO 8601 format.

    • 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.

    • country_code string | null

      The 2-character ISO Country Code of the number.

    • capabilities array[string] | null

      An array of values that describe whether the number can receive calls or messages. Can be: Voice, SMS, and MMS.

    • url string(uri) | null

      The absolute URL of the PhoneNumber resource.

POST /v1/Services/{ServiceSid}/PhoneNumbers
curl \
 --request POST 'https://messaging.twilio.com/v1/Services/{ServiceSid}/PhoneNumbers' \
 --user "username:password" \
 --header "Content-Type: application/x-www-form-urlencoded" \
 --data 'PhoneNumberSid=PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
{"PhoneNumberSid"=>"PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}
{"PhoneNumberSid"=>"PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}
{"PhoneNumberSid"=>"PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}
Response examples (200)
{
  "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "capabilities": [
    "MMS",
    "SMS",
    "Voice"
  ],
  "country_code": "US",
  "date_created": "2015-07-30T20:12:31Z",
  "date_updated": "2015-07-30T20:12:33Z",
  "phone_number": "+987654321"
}
Response examples (201)
{
  "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "capabilities": [],
  "country_code": "US",
  "date_created": "2015-07-30T20:12:31Z",
  "date_updated": "2015-07-30T20:12:33Z",
  "phone_number": "+987654321"
}
{
  "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "capabilities": [
    "MMS",
    "SMS",
    "Voice"
  ],
  "country_code": "US",
  "date_created": "2015-07-30T20:12:31Z",
  "date_updated": "2015-07-30T20:12:33Z",
  "phone_number": "+987654321"
}