Menu

Expand
Rate this page:

Messaging Service PhoneNumber Resource

Public Beta

The Service Resource is currently available as a Public Beta product. This means that some features for configuring your Messaging Service via the REST API are not yet implemented, and others may be changed before the product is declared Generally Available. Messaging Service Configuration through the Twilio Console is Generally Available.

Public Beta products are not covered by a Twilio SLA.

The resources for sending Messages with a Messaging Service are Generally Available.

The PhoneNumber subresource of a Service instance represents a phone number you have associated to the Service.

When sending a message with your Messaging Service, Twilio will select a phone number from the service for delivery.

Inbound messages received on any phone number associated to a Messaging Service are passed to the inbound request URL of the Service with the TWiML parameters that describe the message.

PhoneNumber properties

Resource Properties in REST API format
sid
sid<PN> Not PII

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

account_sid
sid<AC> Not PII

The SID of the Account that created the PhoneNumber resource.

service_sid
sid<MG> Not PII

The SID of the Service the resource is associated with.

date_created
date_time<iso8601> Not PII

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

date_updated
date_time<iso8601> Not PII

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

phone_number
phone_number Not PII

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

country_code
string Not PII

The 2-character ISO Country Code of the number.

capabilities
string[] Not PII

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

url
url Not PII

The absolute URL of the PhoneNumber resource.

Create a PhoneNumber Resource (Add a Phone Number to a Messaging Service)

post
https://messaging.twilio.com/v1/Services/{ServiceSid}/PhoneNumbers

Add a Phone Number to your Messaging Service by creating a PhoneNumber resource.

Each Service can have no more than 400 phone numbers by default. If you think you might need a higher limit, contact Twilio Support about a Messaging Service number limit increase, and include an explanation of your use case.

Parameters
Parameters in REST API format
service_sid
Path
post sid<MG> Not PII

The SID of the Service to create the resource under.

phone_number_sid
Required
post sid<PN> Not PII

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

Example 1
Loading Code Sample...
        
        
        Create a PhoneNumber Resource to add it to a Messaging Service

        Add a Phone Number to a Messaging Service

        Create a PhoneNumber Resource to add it to a Messaging Service

        Fetch a PhoneNumber resource

        get
        https://messaging.twilio.com/v1/Services/{ServiceSid}/PhoneNumbers/{Sid}
        Parameters
        Parameters in REST API format
        service_sid
        Path
        get sid<MG> Not PII

        The SID of the Service to fetch the resource from.

        sid
        Path
        get sid_like<PN> Not PII

        The SID of the PhoneNumber resource to fetch.

        Example 1
        Loading Code Sample...
              
              

              Fetch Phone Number

              Read multiple PhoneNumber resources

              get
              https://messaging.twilio.com/v1/Services/{ServiceSid}/PhoneNumbers
              Parameters
              Parameters in REST API format
              service_sid
              Path
              get sid<MG> Not PII

              The SID of the Service to read the resources from.

              Example 1
              Loading Code Sample...
                    
                    

                    Read Phone Number

                    Delete a PhoneNumber resource

                    delete
                    https://messaging.twilio.com/v1/Services/{ServiceSid}/PhoneNumbers/{Sid}

                    Removing a phone number from the Service does not release the number from your account. You must release a phone number from your Account to disassociate and delete the phone number from the Service.

                    Returns a "204 NO CONTENT" if the phone number was successfully removed from the service.

                    Parameters
                    Parameters in REST API format
                    service_sid
                    Path
                    delete sid<MG> Not PII

                    The SID of the Service to delete the resource from.

                    sid
                    Path
                    delete sid_like<PN> Not PII

                    The SID of the PhoneNumber resource to delete.

                    Example 1
                    Loading Code Sample...
                          
                          

                          Delete Phone Number

                          Rate this page:

                          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 by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.

                          Loading Code Sample...
                                
                                
                                

                                Thank you for your feedback!

                                Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

                                Sending your feedback...
                                🎉 Thank you for your feedback!
                                Something went wrong. Please try again.

                                Thanks for your feedback!

                                thanks-feedback-gif