Working with Twilio phone numbers

This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Working with Twilio phone numbers

Overview

The following operations are available for working with phone numbers. Click an operation name to see details on how to use it.

For a sample proxy service that illustrates how to work with phone numbers, see Sample configuration.

Operation

Description

Operation

Description

addOutgoingPhoneNumber

Adds a new caller ID to your account.

getOutgoingPhoneNumberList

Returns a list of OutgoingCallerId resource representations, each representing a caller ID number valid for an account. The list includes paging information.

getOutgoingPhoneNumber

Returns a representation of a specific caller ID number.

updateOutgoingPhoneNumber

Updates the caller ID, and returns the updated resource if successful.

removeOutgoingPhoneNumber

Deletes the caller ID from the account.

getAvailableLocalNumbers

Returns a list of local AvailablePhoneNumber resource representations that match the specified filters, each representing a phone number that is currently available for provisioning within your account.

getAvailableTollFreeNumbers

Returns a list of AvailableTollFreeNumber resources that match the specified filters, each representing a phone number.

purchasePhoneNumber

Purchases a new phone number for your account. If a phone number is found for your request, Twilio will add it to your account and bill you for the first month's cost of the phone number.

getIncomingPhoneNumberList

Returns a list of IncomingPhoneNumber resource representations, each representing a phone number given to your account. The list includes paging information.

getIncomingPhoneNumber

Returns a IncomingPhoneNumber resource representations, representing a phone number given to your account.

updateIncomingPhoneNumber

Tries to update the incoming phone number's properties and returns the updated resource representation if successful.

removeIncomingPhoneNumber

Releases this phone number from your account. Twilio will no longer answer calls to this number, and you will stop being billed the monthly phone number fee. The phone number will eventually be recycled and potentially given to another customer, so use this operation with care.

Operation details

This section provides further details on the operations related to Phone numbers.

Adding an outgoing phone number 

addOutgoingPhoneNumber
<twilioRest.addOutgoingPhoneNumber> <phoneNumber>{$ctx:phoneNumber}</phoneNumber> <friendlyName>{$ctx:friendlyName}</friendlyName> <callDelay>{$ctx:callDelay}</callDelay> <extension>{$ctx:extension}</extension> <statusCallback>{$ctx:statusCallback}</statusCallback> <statusCallbackMethod>{$ctx:statusCallbackMethod}</statusCallbackMethod> </twilioRest.addOutgoingPhoneNumber>

To add a new caller ID to your account, use twilioRest.addOutgoingPhoneNumber and specify the following properties. After making this request, Twilio returns a validation code and dials the phone number to perform validation. The code returned must be entered via the phone before the caller ID will be added to your account.

Properties
  • phoneNumber: The phone number to verify. Should be formatted with a '+' and country code, e.g., +16175551212 (E.164 format). Twilio will also accept unformatted US numbers, e.g., (415) 555-1212, 415-555-1212.

  • friendlyName: Optional. A human readable description for the new caller ID with maximum length 64 characters. Defaults to a nicely formatted version of the number.

  • callDelay: Optional. The number of seconds, between 0 and 60, to delay before initiating the verification call. Defaults to 0.

  • extension: Optional. Digits to dial after connecting the verification call.

  • statusCallback: Optional. The URL that Twilio will request when the verification call ends to notify your application whether the verification was successful.

  • statusCallbackMethod: Optional. The HTTP method, either GET or POST, that should be used to request the status callback URL. Defaults to POST.

Sample request

Following is a sample REST/JSON request that can be handled by the addOutgoingPhoneNumber operation.

Sample Request for addOutgoingPhoneNumber
{ "accountSid":"AC3c4055d0dd73aab7b5b1b26c0794e9c6", "authToken":"cdd1fdb143d482a05e4f1f6fdb195395", "apiUrl":"https://api.twilio.com", "apiVersion":"2010-04-01", "phoneNumber":"+442033229574", "friendlyName":"My Home Number", "callDelay":"30", "extension":"1234", "statusCallback":"http://demo.twilio.com/docs/statuscallback.xml", "statusCallbackMethod":"post" }
Related Twilio documentation

https://www.twilio.com/docs/api/rest/outgoing-caller-ids#list-post

Getting a list of outgoing phone numbers 

getOutgoingPhoneNumberList
<twilioRest.getOutgoingPhoneNumberList> <phoneNumber>{$ctx:phoneNumber}</phoneNumber> <friendlyName>{$ctx:friendlyName}</friendlyName> </twilioRest.getOutgoingPhoneNumberList>

To get a list of caller IDs for this account, use twilioRest.getOutgoingPhoneNumberList and specify the following properties. The list returns information about each caller ID including the SID, friendly name, and more. The list includes paging information.

Properties
  • phoneNumber: Optional. Only shows the caller ID resource with this phone number. Should be formatted with a '+' and country code, e.g., +16175551212 (E.164 format). Twilio will also accept unformatted US numbers, e.g., (415) 555-1212, 415-555-1212.

  • friendlyName: Optional. Only shows the caller ID resource with this friendly name.

Sample request

Following is a sample REST/JSON request that can be handled by the getOutgoingPhoneNumberList operation.

Sample Request for getOutgoingPhoneNumberList
{ "accountSid":"AC3c4055d0dd73aab7b5b1b26c0794e9c6", "authToken":"cdd1fdb143d482a05e4f1f6fdb195395", "apiUrl":"https://api.twilio.com", "apiVersion":"2010-04-01", "phoneNumber":"+447891063180" }
Related Twilio documentation

https://www.twilio.com/docs/api/rest/outgoing-caller-ids#list-get

Getting a specific outgoing phone number 

getOutgoingPhoneNumber
<twilioRest.getOutgoingPhoneNumber> <outgoingCallerId>{$ctx:outgoingCallerId}</outgoingCallerId> </twilioRest.getOutgoingPhoneNumber>

To get information about a specific caller ID for this account, use twilioRest.getOutgoingPhoneNumber and specify the following properties.

Properties
  • outgoingCallerId: The 34-character string that identifies this caller ID record.

Sample request

Following is a sample REST/JSON request that can be handled by the getOutgoingPhoneNumber operation.

Sample Request for getOutgoingPhoneNumber
{ "accountSid":"AC3c4055d0dd73aab7b5b1b26c0794e9c6", "authToken":"cdd1fdb143d482a05e4f1f6fdb195395", "apiUrl":"https://api.twilio.com", "apiVersion":"2010-04-01", "outgoingCallerId":"PN3021125b69f65961553060dad19131fd" }