public class

TwilioConnector

extends Object
java.lang.Object
   ↳ org.mule.module.twilio.TwilioConnector
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Twilio is a provider of cloud API for voice and SMS communications for customers who want to use phone services as marketing leverage.

Summary

Fields
private String accountSid The account sid to be used to connect to Twilio.
private String authToken The authentication token to be used to connect to Twilio
private TwilioClient twilioClient
Public Constructors
TwilioConnector()
Public Methods
String addIncomingPhoneNumberByAreaCode(String accountSid, String areaCode, String friendlyName, String voiceUrl, HttpMethod voiceMethod, HttpCallback voiceFallback, HttpCallback statusCallback, Boolean voiceCallerIdLookup, String voiceApplicationSid, String smsUrl, HttpMethod smsMethod, HttpCallback smsFallback, String smsApplicationSid)
Adds a new phone number to your account.
String addIncomingPhoneNumberByPhoneNumber(String accountSid, String phoneNumber, String friendlyName, String voiceUrl, HttpMethod voiceMethod, HttpCallback voiceFallback, HttpCallback statusCallback, Boolean voiceCallerIdLookup, String voiceApplicationSid, String smsUrl, HttpMethod smsMethod, HttpCallback smsFallback, String smsApplicationSid)
Adds a new phone number to your account.
String addNewCallerId(String accountSid, String phoneNumber, String friendlyName, Integer callDelay, String extension)
Adds a new CallerID to your account.
String changeCallState(String accountSid, String callSid, String url, HttpMethod method, String status)
Modify the state of a live call.
String createApplication(String accountSid, String friendlyName, String apiVersion, String voiceUrl, HttpMethod voiceMethod, HttpCallback voiceFallback, HttpCallback statusCallback, Boolean voiceCallerIdLookup, String smsUrl, HttpMethod smsMethod, HttpCallback smsFallback, HttpCallback smsStatusCallback)
Creates a new application within your account.
String createSubAccount(String friendlyName)
Creates a new subaccount.
void createTwilioClient()
String deleteApplication(String accountSid, String applicationSid)
Delete this application.
String deleteIncomingPhoneNumber(String accountSid, String incomingPhoneNumberSid)
Release this phone number from your account.
String deleteNotification(String accountSid, String notificationSid)
Deletes the notification identified by {NotificationSid} from an account's log.
String deleteOutgoingCallerId(String accountSid, String outgoingCallerIdSid)
Deletes the caller ID from the account.
String deleteParticipant(String accountSid, String conferenceSid, String callSid)
Kick this participant from the conference.
String deleteRecording(String accountSid, String recordingSid)
Deletes a recording from your account.
String exchangePhoneNumbersBetweenSubaccounts(String accountSidFrom, String incomingPhoneNumberSid, String accountSidTo)
Trasfers a number between two subaccounts.
String getAccountDetails(String accountSid)
Returns a representation of an account.
String getAccountSid()
String getAllAccountsDetails(AccountStatus accountStatus, String friendlyName)
Retrieve a list of the Account resources belonging to the account used to make the API request.
String getAllApplications(String accountSid, String friendlyName)
Returns a list of Application resource representations, each representing an application within your account.
String getAllNotifications(String accountSid, Integer log, String messageDate)
Returns a list of notifications generated for an account.
String getAllOutgoingCallerIds(String accountSid, String phoneNumber, String friendlyName)
Returns a list of OutgoingCallerId resource representations, each representing a Caller ID number valid for an account.
String getAllSmsMessages(String accountSid, String to, String from, String dateSent)
Returns a list of SMS messages associated with your account.
String getApplication(String accountSid, String applicationSid)
Returns an application resource matching the given application sid.
String getAuthToken()
String getAvailablePhoneNumbers(String accountSid, String isoCountryCode, String areaCode, String contains, String inRegion, String inPostalCode)
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.
String getAvailablePhoneNumbersAdvancedSeach(String accountSid, String isoCountryCode, String areaCode, String contains, String inRegion, String inPostalCode, String nearLatLong, String nearPhoneNumber, String inLata, String inRateCenter, String distance)
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.
String getAvailableTollFreeNumbers(String accountSid, String isoCountryCode, String contains)
Returns a list of toll-free AvailablePhoneNumber elements that match the specified filters, each representing a phone number that is currently available for provisioning within your account.
String getCall(String accountSid, String callSid)
Returns the single Call resource identified by the given call sid.
String getCalls(String accountSid, String to, String from, String status, String startTime)
Returns a list of phone calls made to and from the account identified by the given account sid.
String getConference(String accountSid, String conferenceSid)
Returns a representation of the conference identified by the given conference id.
String getConferences(String accountSid, String status, String friendlyName, String dateCreated, String dateUpdated)
Returns a list of conferences within an account.
String getIncomingPhoneNumbers(String accountSid, String phoneNumber, String friendlyName)
Returns a list of IncomingPhoneNumber resource representations, each representing a phone number given to your account.
String getIncomingPhoneNumbersByIncomingPhoneNumberSid(String accountSid, String incomingPhoneNumberSid)
Returns an incoming phone numbers matching the given query filters.
String getNotification(String accountSid, String notificationSid)
Return a notificaction resource for the given notification sid.
String getNotificationsByCallSid(String accountSid, String callSid, Integer log, String messageDate)
Returns a list of notifications generated for an account.
String getOutgoingCallerIdByOutgoingCallerIdSid(String accountSid, String outgoingCallerIdSid)
Returns an outgoing caller id instance matching the given filters.
String getParticipant(String accountSid, String conferenceSid, String callSid)
Returns a representation of this participant.
String getParticipants(String accountSid, String conferenceSid, Boolean muted)
Returns the list of participants in the conference identified by the given conference sid.
String getRecording(String accountSid, String recordingSid, RecordingType recordingType)
Returns one of several representations depending on the given recording type.
String getRecordings(String accountSid, String callSid, String dateCreated)
Returns a list of Recording resource representations, each representing a recording generated during the course of a phone call.
String getSandbox(String accountSid)
Returns the Sandbox resource associated with the account identified by {YourAccountSid}.
String getSmsMessage(String accountSid, String smsMessageSid)
Returns a single SMS message specified by the provided SMS message sid.
String getSubAccountByAccountSid(String accountSid)
Subaccounts in Twilio are just accounts that are "owned" by another account.
String getSubAccountByFriendlyName(String friendlyName)
Subaccounts in Twilio are just accounts that are "owned" by another account.
String getTranscriptionByTranscriptionSid(String accountSid, String transcriptionSid, TranscriptionFormat transcriptionFormat)
Returns a single Transcription resource representation identified by the given transcription sid.
String getTranscriptions(String accountSid, String recordingSid, TranscriptionFormat transcriptionFormat)
Returns a set of Transcription resource representations that includes paging information, sorted by 'DateUpdated', with most recent transcripts first.
String makeCall(String accountSid, String from, String to, String url, String applicationSid, HttpMethod method, HttpCallback fallback, HttpCallback statusCallback, String sendDigits, String ifMachine, String timeout)
Initiates a call using the given paramaters.
String sendSmsMessage(String accountSid, String from, String to, String body, HttpCallback statusCallback, String applicationSid)
Send an outgoing SMS message.
void setAccountSid(String accountSid)
void setAuthToken(String authToken)
String updateAccount(String accountSid, AccountStatus accountStatus, String friendlyName)
Allows you to modify the properties of an account.
String updateApplication(String accountSid, String applicationSid, String friendlyName, String apiVersion, String voiceUrl, HttpMethod voiceMethod, HttpCallback voiceFallback, HttpCallback statusCallback, Boolean voiceCallerIdLookup, String smsUrl, HttpMethod smsMethod, HttpCallback smsFallback, HttpCallback smsStatusCallback)
Tries to update the application's properties, and returns the updated resource representation if successful.
String updateIncomingPhoneNumbers(String accountSid, String incomingPhoneNumberSid, String friendlyName, String apiVersion, String voiceUrl, HttpMethod voiceMethod, HttpCallback voiceFallback, HttpCallback statusCallback, Boolean voiceCallerIdLookup, String voiceApplicationSid, String smsUrl, HttpMethod smsMethod, HttpCallback smsFallback, String smsApplicationSid, String accountSidDestination)
Tries to update the incoming phone number's properties, and returns the updated resource representation if successful.
String updateOutgoingCallerIdByOutgoingCallerIdSid(String accountSid, String outgoingCallerIdSid, String friendlyName)
Updates the caller id, and returns the updated resource if successful.
String updateParticipantStatus(String accountSid, String conferenceSid, String callSid, Boolean muted)
Updates the participant status.
String updateSandbox(String accountSid, String voiceUrl, HttpMethod voiceMethod, String smsUrl, HttpMethod smsMethod)
You can POST to the Sandbox resource to update the TwiML voice and SMS URLs associated with the sandbox number.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

private String accountSid

The account sid to be used to connect to Twilio.

private String authToken

The authentication token to be used to connect to Twilio

private TwilioClient twilioClient

Public Constructors

public TwilioConnector ()

Public Methods

public String addIncomingPhoneNumberByAreaCode (String accountSid, String areaCode, String friendlyName, String voiceUrl, HttpMethod voiceMethod, HttpCallback voiceFallback, HttpCallback statusCallback, Boolean voiceCallerIdLookup, String voiceApplicationSid, String smsUrl, HttpMethod smsMethod, HttpCallback smsFallback, String smsApplicationSid)

Adds a new phone number to 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. If Twilio can't find a phone number to match your request, you will receive an HTTP 400 with Twilio error code 21452. If successful, Twilio responds with a representation of the new phone number that was assigned to your account.

Parameters
accountSid Optionally override globally configured Account SID
areaCode The area code in which you'd like a new incoming phone number. Any three digit, US area code is valid. Twilio will provision a random phone number within this area code for you.
friendlyName A human readable description of the new incoming phone number. Maximum 64 characters. Defaults to a formatted version of the number.
voiceUrl The URL that Twilio should request when somebody dials the new phone number.
voiceMethod The HTTP method that should be used to request the VoiceUrl. Must be either GET or POST. Defaults to POST.
voiceFallback A flow that Twilio will request if an error occurs requesting or executing the TwiML at Url.
statusCallback A flow that Twilio will request to pass status parameters (such as call ended) to your application.
voiceCallerIdLookup Do a lookup of a caller's name from the CNAM database and post it to your app. Either true or false. Defaults to false.
voiceApplicationSid The 34 character sid of the application Twilio should use to handle phone calls to the new number. If a VoiceApplicationSid is present, Twilio will ignore all of the voice urls above and use those set on the application.
smsUrl The URL that Twilio should request when somebody sends an SMS to the phone number.
smsMethod The HTTP method that should be used to request the SmsUrl. Must be either GET or POST. Defaults to POST.
smsFallback A flow that Twilio will request if an error occurs requesting or executing the TwiML defined by SmsUrl.
smsApplicationSid The 34 character sid of the application Twilio should use to handle SMSs sent to the new number. If a SmsApplicationSid is present, Twilio will ignore all of the SMS urls above and use those set on the application.
Returns
  • If successful, Twilio responds with a representation of the new phone number that was assigned to your account.

public String addIncomingPhoneNumberByPhoneNumber (String accountSid, String phoneNumber, String friendlyName, String voiceUrl, HttpMethod voiceMethod, HttpCallback voiceFallback, HttpCallback statusCallback, Boolean voiceCallerIdLookup, String voiceApplicationSid, String smsUrl, HttpMethod smsMethod, HttpCallback smsFallback, String smsApplicationSid)

Adds a new phone number to 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. If Twilio can't find a phone number to match your request, you will receive an HTTP 400 with Twilio error code 21452. If successful, Twilio responds with a representation of the new phone number that was assigned to your account.

Parameters
accountSid Optionally override globally configured Account SID
phoneNumber The phone number you want to purchase. The number should be formated starting with a '+' followed by the country code and the number in E.164 format e.g., '+15105555555'.
friendlyName A human readable description of the new incoming phone number. Maximum 64 characters. Defaults to a formatted version of the number.
voiceUrl The URL that Twilio should request when somebody dials the new phone number.
voiceMethod The HTTP method that should be used to request the VoiceUrl. Must be either GET or POST. Defaults to POST.
voiceFallback A flow that Twilio will request if an error occurs requesting or executing the TwiML at Url.
statusCallback A flow that Twilio will request to pass status parameters (such as call ended) to your application.
voiceCallerIdLookup Do a lookup of a caller's name from the CNAM database and post it to your app. Either true or false. Defaults to false.
voiceApplicationSid The 34 character sid of the application Twilio should use to handle phone calls to the new number. If a VoiceApplicationSid is present, Twilio will ignore all of the voice urls above and use those set on the application.
smsUrl The URL that Twilio should request when somebody sends an SMS to the phone number.
smsMethod The HTTP method that should be used to request the SmsUrl. Must be either GET or POST. Defaults to POST.
smsFallback A flow that Twilio will request if an error occurs requesting or executing the TwiML defined by SmsUrl.
smsApplicationSid The 34 character sid of the application Twilio should use to handle SMSs sent to the new number. If a SmsApplicationSid is present, Twilio will ignore all of the SMS urls above and use those set on the application.
Returns
  • If successful, Twilio responds with a representation of the new phone number that was assigned to your account.

public String addNewCallerId (String accountSid, String phoneNumber, String friendlyName, Integer callDelay, String extension)

Adds a new CallerID to your account. After making this request, Twilio will return to you a validation code and Twilio will dial the phone number given to perform validation. The code returned must be entered via the phone before the CallerID will be added to your account.

Parameters
accountSid Optionally override globally configured Account SID
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 A human readable description for the new caller ID with maximum length 64 characters. Defaults to a nicely formatted version of the number.
callDelay The number of seconds, between 0 and 60, to delay before initiating the validation call. Defaults to 0.
extension Digits to dial after connecting the validation call.
Returns
  • a validation request (see validation request propertie)

public String changeCallState (String accountSid, String callSid, String url, HttpMethod method, String status)

Modify the state of a live call. Returns the call representation.

Parameters
accountSid Optionally override globally configured Account SID
callSid The call sid to modify
url A valid URL that returns TwiML. Twilio will immediately redirect the call to the new TwiML.
method The HTTP method Twilio should use when requesting the above URL. Defaults to POST.
status Either canceled or completed. Specifying canceled will attempt to hangup calls that are queued or ringing but not affect calls already in progress. Specifying completed will attempt to hang up a call even if it's already in progress.
Returns
  • the call representation

public String createApplication (String accountSid, String friendlyName, String apiVersion, String voiceUrl, HttpMethod voiceMethod, HttpCallback voiceFallback, HttpCallback statusCallback, Boolean voiceCallerIdLookup, String smsUrl, HttpMethod smsMethod, HttpCallback smsFallback, HttpCallback smsStatusCallback)

Creates a new application within your account. If successful, Twilio responds with a representation of the new application.

Parameters
accountSid Optionally override globally configured Account SID
friendlyName A human readable description of the new application. Maximum 64 characters.
apiVersion Requests to this application's URLs will start a new TwiML session with this API version. Either 2010-04-01 or 2008-08-01. Defaults to your account's default API version.
voiceUrl The URL that Twilio should request when somebody dials a phone number assigned to this application
voiceMethod The HTTP method that should be used to request the VoiceUrl. Must be either GET or POST. Defaults to POST.
voiceFallback A flow that Twilio will request if an error occurs requesting or executing the TwiML at Url.
statusCallback A flow that Twilio will request to pass status parameters (such as call ended) to your application.
voiceCallerIdLookup Do a lookup of a caller's name from the CNAM database and post it to your app. Either true or false. Defaults to false.
smsUrl The URL that Twilio should request when somebody sends an SMS to a phone number assigned to this application.
smsMethod The HTTP method that should be used to request the SmsUrl. Must be either GET or POST. Defaults to POST.
smsFallback A flow that Twilio will request if an error occurs requesting or executing the TwiML defined by SmsUrl.
smsStatusCallback Twilio will make a POST request to this flow to pass status parameters (such as sent or failed) to your application if you specify this application's Sid as the ApplicationSid on an outgoing SMS request.
Returns
  • If successful, Twilio responds with a representation of the new application.

public String createSubAccount (String friendlyName)

Creates a new subaccount.

Subaccounts in Twilio are just accounts that are "owned" by another account. Using a subaccount you can segment each of your customers' use of Twilio and keep it separate from all the rest, allowing you to easily manage the activity and resources of each customer independently.

For instance, if you are running a hosted service that relies on Twilio you can create a Twilio subaccount for each customer that signs up. Then if a customer closes his or her account with your service, you can simply deactivate the associated Twilio subaccount.

Parameters
friendlyName A human readable description of the new subaccount, up to 64 characters. Defaults to "SubAccount Created at {YYYY-MM-DD HH:MM meridiam}".
Returns
  • a representation of the account

public void createTwilioClient ()

public String deleteApplication (String accountSid, String applicationSid)

Delete this application. If this application's sid is assigned to any IncomingPhoneNumber resources as a VoiceApplicationSid or SmsApplicationSid it will be removed.

Parameters
accountSid Optionally override globally configured Account SID
applicationSid The application sid to use
Returns
  • If succesful, Twilio will return an HTTP 204 response with no body.

public String deleteIncomingPhoneNumber (String accountSid, String incomingPhoneNumberSid)

Release 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 with care.

Parameters
accountSid Optionally override globally configured Account SID
incomingPhoneNumberSid The incoming phone number sid to delete
Returns
  • if succesful, returns an HTTP 204 response with no body.

public String deleteNotification (String accountSid, String notificationSid)

Deletes the notification identified by {NotificationSid} from an account's log.

Parameters
accountSid Optionally override globally configured Account SID
notificationSid The notification sid to use
Returns
  • If successful, returns HTTP status 204 (No Content) with no body.

public String deleteOutgoingCallerId (String accountSid, String outgoingCallerIdSid)

Deletes the caller ID from the account. Returns an HTTP 204 response if successful, with no body.

Parameters
accountSid Optionally override globally configured Account SID
outgoingCallerIdSid The outgoing caller id sid to delete
Returns
  • an HTTP 204 response if successful, with no body.

public String deleteParticipant (String accountSid, String conferenceSid, String callSid)

Kick this participant from the conference. Returns HTTP 204 (No Content), with no body, if the participant was successfuly booted from the conference.

Parameters
accountSid Optionally override globally configured Account SID
conferenceSid The conference sid to use
callSid The call sid to use
Returns
  • Returns HTTP 204 (No Content), with no body, if the participant was successfuly booted from the conference.

public String deleteRecording (String accountSid, String recordingSid)

Deletes a recording from your account. If successful, returns HTTP 204 (No Content) with no body.

Parameters
accountSid Optionally override globally configured Account SID
recordingSid The recording sid to use.
Returns
  • If successful, returns HTTP 204 (No Content) with no body.

public String exchangePhoneNumbersBetweenSubaccounts (String accountSidFrom, String incomingPhoneNumberSid, String accountSidTo)

Trasfers a number between two subaccounts.

Parameters
accountSidFrom The account sid from where to get the number, leave empty to use accountSid
incomingPhoneNumberSid The incoming phone number sid to transfer
accountSidTo The account sid where to transfer the phone number.
Returns
  • an incoming phone number instance.

public String getAccountDetails (String accountSid)

Returns a representation of an account.

Parameters
accountSid The account sid for which to get the details, leave empty to use to use accountSid
Returns
  • a representation of the account

public String getAccountSid ()

public String getAllAccountsDetails (AccountStatus accountStatus, String friendlyName)

Retrieve a list of the Account resources belonging to the account used to make the API request. This list will include that Account as well.

Parameters
accountStatus Only return Account resources with the given status. Can be closed, suspended or active.
friendlyName Only return the Account resources with friendly names that exactly match this name.
Returns
  • a list of the Account resources belonging to the account used to make the API request. This list will include that Account as well.

public String getAllApplications (String accountSid, String friendlyName)

Returns a list of Application resource representations, each representing an application within your account. The list includes paging information.

Parameters
accountSid Optionally override globally configured Account SID
friendlyName Only return the Application resources with friendly names that exactly match this name.
Returns
  • a list of Application resource representations

public String getAllNotifications (String accountSid, Integer log, String messageDate)

Returns a list of notifications generated for an account. The list includes paging information and is sorted by DateUpdated, with most recent notifications first.

Parameters
accountSid Optionally override globally configured Account SID
log An integer log level corresponding to the type of notification: 0 is ERROR, 1 is WARNING.
messageDate Only show notifications for this date. Should be formatted as YYYY-MM-DD. You can also specify inequality, such as MessageDate<=YYYY-MM-DD for messages logged at or before midnight on a date, and MessageDate>=YYYY-MM-DD for messages logged at or after midnight on a date.
Returns
  • a list of notifications generated for an account

public String getAllOutgoingCallerIds (String accountSid, String phoneNumber, String friendlyName)

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

Parameters
accountSid Optionally override globally configured Account SID
phoneNumber Only show the caller id resource that exactly matches this phone number.
friendlyName Only show the caller id resource that exactly matches this name.
Returns
  • a list of OutgoingCallerId resource representations

public String getAllSmsMessages (String accountSid, String to, String from, String dateSent)

Returns a list of SMS messages associated with your account. The list includes paging information and is sorted by DateSent, with most recent messages first.

Parameters
accountSid Optionally override globally configured Account SID
to Only show SMS messages to this phone number.
from Only show SMS messages from this phone number.
dateSent Only show SMS messages sent on this date, given as YYYY-MM-DD. Example: DateSent=2009-07-06. You can also specify inequality, such as DateSent<=YYYY-MM-DD for SMS messages that were sent on or before midnight on a date, and DateSent>=YYYY-MM-DD for SMS messages sent on or after midnight on a date.
Returns
  • a list of SMS messages associated with your account

public String getApplication (String accountSid, String applicationSid)

Returns an application resource matching the given application sid.

An Application instance resource represents an application that you have created with Twilio. An application inside of Twilio is just a set of URLs and other configuration data that tells Twilio how to behave when one of your Twilio numbers receives a call or SMS message.

Parameters
accountSid Optionally override globally configured Account SID
applicationSid The application sid to use in the query
Returns
  • an application resource matching the given application sid.

public String getAuthToken ()

public String getAvailablePhoneNumbers (String accountSid, String isoCountryCode, String areaCode, String contains, String inRegion, String inPostalCode)

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.

Parameters
accountSid Optionally override globally configured Account SID
isoCountryCode A country code in ISO 3166-1 alpha-2 format (e.g. 'US' for United States, 'CA' for Canada).
areaCode Find phone numbers in the specified Area Code. Only available for North American numbers.
contains A pattern to match phone numbers on. Valid characters are '*' and [0-9a-zA-Z]. The '*' character will match any single digit.
inRegion Limit results to a particular region (i.e. State/Province). Given a phone number, search within the same Region as that number.
inPostalCode Limit results to a particular postal code. Given a phone number, search within the same postal code as that number.
Returns
  • a list of local AvailablePhoneNumber resource representations that match the specified filters

public String getAvailablePhoneNumbersAdvancedSeach (String accountSid, String isoCountryCode, String areaCode, String contains, String inRegion, String inPostalCode, String nearLatLong, String nearPhoneNumber, String inLata, String inRateCenter, String distance)

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.

Parameters
accountSid Optionally override globally configured Account SID
isoCountryCode A country code in ISO 3166-1 alpha-2 format (e.g. 'US' for United States, 'CA' for Canada).
areaCode Find phone numbers in the specified Area Code. Only available for North American numbers.
contains A pattern to match phone numbers on. Valid characters are '*' and [0-9a-zA-Z]. The '*' character will match any single digit.
inRegion Limit results to a particular region (i.e. State/Province). Given a phone number, search within the same Region as that number.
inPostalCode Limit results to a particular postal code. Given a phone number, search within the same postal code as that number.
nearLatLong Given a latitude/longitude pair lat,long find geographically close numbers within Distance miles.
nearPhoneNumber Given a phone number, find a geographically close number within Distance miles. Distance defaults to 25 miles.
inLata Limit results to a specific Local access and transport area (LATA). Given a phone number, search within the same LATA as that number.
inRateCenter Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires InLata to be set as well.
distance Specifies the search radius for a Near- query in miles. If not specified this defaults to 25 miles.
Returns
  • a list of local AvailablePhoneNumber resource representations that match the specified filters

public String getAvailableTollFreeNumbers (String accountSid, String isoCountryCode, String contains)

Returns a list of toll-free AvailablePhoneNumber elements that match the specified filters, each representing a phone number that is currently available for provisioning within your account.

Parameters
accountSid Optionally override globally configured Account SID
isoCountryCode A country code in ISO 3166-1 alpha-2 format (e.g. 'US' for United States, 'CA' for Canada).
contains A pattern to match phone numbers on. Valid characters are '*' and [0-9a-zA-Z]. The '*' character will match any single digit.
Returns
  • a list of toll-free AvailablePhoneNumber elements that match the specified filters

public String getCall (String accountSid, String callSid)

Returns the single Call resource identified by the given call sid.

A Call instance resource represents a connection between a telephone and Twilio. This may be inbound, when a person calls your application, or outbound, when your application initiates the call, either via the REST API (see Making Calls) or during a call via the TwiML verb. The Calls list resource represents the set of phone calls made to and from an account.

Parameters
accountSid Optionally override globally configured Account SID
callSid The call sid to use in the query
Returns
  • the single Call resource identified by the given call sid.

public String getCalls (String accountSid, String to, String from, String status, String startTime)

Returns a list of phone calls made to and from the account identified by the given account sid. The list includes paging information and is sorted by DateUpdated with most-recent calls first.

Parameters
accountSid Optionally override globally configured Account SID
to Only show calls to this phone number.
from Only show calls from this phone number.
status Only show calls currently in this status. May be queued, ringing, in-progress, completed, failed, busy, or no-answer.
startTime Only show calls that started on this date, given as YYYY-MM-DD. Also supports inequalities, such as StartTime<=YYYY-MM-DD for calls that started at or before midnight on a date, and StartTime>=YYYY-MM-DD for calls that started at or after midnight on a date.
Returns
  • a list of phone calls made to and from the account identified by the given account sid

public String getConference (String accountSid, String conferenceSid)

Returns a representation of the conference identified by the given conference id.

Parameters
accountSid Optionally override globally configured Account SID
conferenceSid The conference sid to use in the query
Returns
  • a representation of the conference identified by the given conference id.

public String getConferences (String accountSid, String status, String friendlyName, String dateCreated, String dateUpdated)

Returns a list of conferences within an account. The list includes paging information and is sorted by DateUpdated, with most recent conferences first.

Parameters
accountSid Optionally override globally configured Account SID
status Only show conferences currently in with this status. May be init, in-progress, or completed.
friendlyName List conferences who's FriendlyName is the exact match of this string.
dateCreated Only show conferences that started on this date, given as YYYY-MM-DD. You can also specify inequality, such as DateCreated<=YYYY-MM-DD for conferences that started at or before midnight on a date, and DateCreated>=YYYY-MM-DD for conferences that started at or after midnight on a date.
dateUpdated Only show conferences that were last updated on this date, given as YYYY-MM-DD. You can also specify inequality, such as DateUpdated<=YYYY-MM-DD for conferences that were last updated at or before midnight on a date, and DateUpdated>=YYYY-MM-DD for conferences that were updated at or after midnight on a date.
Returns
  • a list of conferences within an account

public String getIncomingPhoneNumbers (String accountSid, String phoneNumber, String friendlyName)

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

An IncomingPhoneNumber instance resource represents a Twilio phone number purchased from Twilio or ported to Twilio.

Parameters
accountSid Optionally override globally configured Account SID
phoneNumber Only show the incoming phone number resources that match this pattern. You can specify partial numbers and use '*' as a wildcard for any digit.
friendlyName Only show the incoming phone number resources with friendly names that exactly match this name.
Returns
  • a list of IncomingPhoneNumber resource representations

public String getIncomingPhoneNumbersByIncomingPhoneNumberSid (String accountSid, String incomingPhoneNumberSid)

Returns an incoming phone numbers matching the given query filters.

An IncomingPhoneNumber instance resource represents a Twilio phone number purchased from Twilio or ported to Twilio.

Parameters
accountSid Optionally override globally configured Account SID
incomingPhoneNumberSid The incoming phone number sid to use in the query
Returns
  • an incoming phone number matching the given incoming phone number sid

public String getNotification (String accountSid, String notificationSid)

Return a notificaction resource for the given notification sid.

Parameters
accountSid The account sid to use in the query
notificationSid The notification sid to use in the query
Returns
  • a notificaction resource for the given notification sid.

public String getNotificationsByCallSid (String accountSid, String callSid, Integer log, String messageDate)

Returns a list of notifications generated for an account. The list includes paging information and is sorted by DateUpdated, with most recent notifications first.

Parameters
accountSid Optionally override globally configured Account SID
callSid The call sid to use in the query
log An integer log level corresponding to the type of notification: 0 is ERROR, 1 is WARNING.
messageDate Only show notifications for this date. Should be formatted as YYYY-MM-DD. You can also specify inequality, such as MessageDate<=YYYY-MM-DD for messages logged at or before midnight on a date, and MessageDate>=YYYY-MM-DD for messages logged at or after midnight on a date.
Returns
  • a list of notifications generated for an account for the given call sid.

public String getOutgoingCallerIdByOutgoingCallerIdSid (String accountSid, String outgoingCallerIdSid)

Returns an outgoing caller id instance matching the given filters.

Parameters
accountSid Optionally override globally configured Account SID
outgoingCallerIdSid The outgoing caller id sid to use in the query
Returns
  • an outgoing caller id instance matching the given filters.

public String getParticipant (String accountSid, String conferenceSid, String callSid)

Returns a representation of this participant.

Parameters
accountSid Optionally override globally configured Account SID
conferenceSid The conference sid to use in the query
callSid The call sid to use in the query
Returns
  • a representation of this participant.

public String getParticipants (String accountSid, String conferenceSid, Boolean muted)

Returns the list of participants in the conference identified by the given conference sid.

Parameters
accountSid Optionally override globally configured Account SID
conferenceSid The conference sid to use in the query
muted Only show participants that are muted or unmuted. Either true or false.
Returns
  • he list of participants in the conference identified by the given conference sid.

public String getRecording (String accountSid, String recordingSid, RecordingType recordingType)

Returns one of several representations depending on the given recording type.

Parameters
accountSid Optionally override globally configured Account SID
recordingSid The recording sid to use in the query
recordingType The recording type to use
Returns
  • a recording representation.

public String getRecordings (String accountSid, String callSid, String dateCreated)

Returns a list of Recording resource representations, each representing a recording generated during the course of a phone call. The list includes paging information.

Parameters
accountSid Optionally override globally configured Account SID
callSid Show only recordings made during the call given by this sid.
dateCreated Only show recordings created on the given date. Should be formatted as YYYY-MM-DD. You can also specify inequality, such as DateCreated<=YYYY-MM-DD for recordings generated at or before midnight on a date, and DateCreated>=YYYY-MM-DD for recordings generated at or after midnight on a date.
Returns
  • a list of Recording resource representations.

public String getSandbox (String accountSid)

Returns the Sandbox resource associated with the account identified by {YourAccountSid}. Twilio accounts upgraded prior to February 2010 may not have a Sandbox resource, and in this case you will receive a 404 (Not Found) response.

The Sandbox resource gives you programatic access to your Twilio Developer Sandbox phone number. Using this resource you can get the phone number and PIN for your sandbox, view the current voice and SMS URLs and update those URLs just like any other IncomingPhoneNumber resource on a Full Twilio Account.

Parameters
accountSid Optionally override globally configured Account SID
Returns
  • the Sandbox resource associated with the account identified by {YourAccountSid}. Twilio accounts upgraded prior to February 2010 may not have a Sandbox resource, and in this case you will receive a 404 (Not Found) response.

public String getSmsMessage (String accountSid, String smsMessageSid)

Returns a single SMS message specified by the provided SMS message sid.

Parameters
accountSid Optionally override globally configured Account SID
smsMessageSid The SMS message sid to use in the query.
Returns
  • a single SMS message specified by the provided SMS message sid.

public String getSubAccountByAccountSid (String accountSid)

Subaccounts in Twilio are just accounts that are "owned" by another account. Using a subaccount you can segment each of your customers' use of Twilio and keep it separate from all the rest, allowing you to easily manage the activity and resources of each customer independently.

Parameters
accountSid The account sid to use in the query
Returns
  • a representation of the subaccount

public String getSubAccountByFriendlyName (String friendlyName)

Subaccounts in Twilio are just accounts that are "owned" by another account. Using a subaccount you can segment each of your customers' use of Twilio and keep it separate from all the rest, allowing you to easily manage the activity and resources of each customer independently.

For instance, if you are running a hosted service that relies on Twilio you can create a Twilio subaccount for each customer that signs up. Then if a customer closes his or her account with your service, you can simply deactivate the associated Twilio subaccount.

Parameters
friendlyName The friendly name to use in the query
Returns
  • a representation of the subaccount

public String getTranscriptionByTranscriptionSid (String accountSid, String transcriptionSid, TranscriptionFormat transcriptionFormat)

Returns a single Transcription resource representation identified by the given transcription sid.

Parameters
accountSid Optionally override globally configured Account SID
transcriptionSid The transcription sid to use in the query.
transcriptionFormat The transcription format of the response
Returns
  • a single Transcription resource representation identified by the given transcription sid.

public String getTranscriptions (String accountSid, String recordingSid, TranscriptionFormat transcriptionFormat)

Returns a set of Transcription resource representations that includes paging information, sorted by 'DateUpdated', with most recent transcripts first.

Parameters
accountSid Optionally override globally configured Account SID
recordingSid The recording sid to use in the query
transcriptionFormat The transcription format for the response
Returns
  • a set of Transcription resource representations

public String makeCall (String accountSid, String from, String to, String url, String applicationSid, HttpMethod method, HttpCallback fallback, HttpCallback statusCallback, String sendDigits, String ifMachine, String timeout)

Initiates a call using the given paramaters. Only one of url or applicationSid parameters must be specified, not both. Returns the call representation.

Parameters
accountSid Optionally override globally configured Account SID
from The phone number to use as the caller id. Format with a '+' and country code e.g., +16175551212 (E.164 format). Must be a Twilio number or a valid outgoing caller id for your account.
to The number to call 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.
url The fully qualified URL that should be consulted when the call connects. Just like when you set a URL on a phone number for handling inbound calls.
applicationSid The 34 character sid of the application Twilio should use to handle this phone call. If this parameter is present, Twilio will ignore all of the voice URLs passed and use the URLs set on the application.
method The HTTP method Twilio should use when making its request to the above Url parameter's value. Defaults to POST. If an ApplicationSid parameter is present, this parameter is ignored.
fallback A flow that Twilio will request if an error occurs requesting or executing the TwiML at Url. If an ApplicationSid parameter is present, this parameter is ignored.
statusCallback A flow that Twilio will request when the call ends to notify your app. If an ApplicationSid parameter is present, this parameter is ignored.
sendDigits A string of keys to dial after connecting to the number. Valid digits in the string include: any digit (0-9), '#' and '*'. For example, if you connected to a company phone number, and wanted to dial extension 1234 and then the pound key, use SendDigits=1234#. Remember to URL-encode this string, since the '#' character has special meaning in a URL.
ifMachine Tell Twilio to try and determine if a machine (like voicemail) or a human has answered the call. Possible values are Continue and Hangup.
timeout The integer number of seconds that Twilio should allow the phone to ring before assuming there is no answer. Default is 60 seconds, the maximum is 999 seconds. Note, you could set this to a low value, such as 15, to hangup before reaching an answering machine or voicemail.
Returns
  • the call representation.

public String sendSmsMessage (String accountSid, String from, String to, String body, HttpCallback statusCallback, String applicationSid)

Send an outgoing SMS message. By specifying an SMS URL for your SMS enabled Twilio phone number, Twilio will make a request to your application to notify you when someone replies to a message you send.

Parameters
accountSid Optionally override globally configured Account SID
from A Twilio number enabled for SMS. Only phone numbers purchased from Twilio work here; you cannot (for example) spoof SMS messages from your own cell phone number.
to The destination phone number. Format 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.
body The text of the message you want to send, limited to 160 characters.
statusCallback A flow that Twilio will POST to when your message is processed. Twilio will POST the SmsSid as well as SmsStatus=sent or SmsStatus=failed.
applicationSid Twilio will POST SmsSid as well as SmsStatus=sent or SmsStatus=failed to the URL in the SmsStatusCallback property of this Application. If the StatusCallback parameter above is also passed, the Application's SmsStatusCallback parameter will take precedence.
Returns
  • the SMS message representation.

public void setAccountSid (String accountSid)

Parameters
accountSid

public void setAuthToken (String authToken)

Parameters
authToken

public String updateAccount (String accountSid, AccountStatus accountStatus, String friendlyName)

Allows you to modify the properties of an account.

Parameters
accountSid Optionally override globally configured Account SID
accountStatus Alter the status of this account: use closed to irreversibly close this account, suspended to temporarily suspend it, or active to reactivate it.
friendlyName Update the human-readable description of this account.
Returns
  • a representation of the account

public String updateApplication (String accountSid, String applicationSid, String friendlyName, String apiVersion, String voiceUrl, HttpMethod voiceMethod, HttpCallback voiceFallback, HttpCallback statusCallback, Boolean voiceCallerIdLookup, String smsUrl, HttpMethod smsMethod, HttpCallback smsFallback, HttpCallback smsStatusCallback)

Tries to update the application's properties, and returns the updated resource representation if successful.

Parameters
accountSid Optionally override globally configured Account SID
applicationSid The application sid to update
friendlyName A human readable description of the application, with maximum length 64 characters.
apiVersion Requests to this application's URLs will start a new TwiML session with this API version. Either 2010-04-01 or 2008-08-01.
voiceUrl The URL that Twilio should request when somebody dials a phone number assigned to this application.
voiceMethod The HTTP method that should be used to request the VoiceUrl. Either GET or POST.
voiceFallback A flow that Twilio will request if an error occurs requesting or executing the TwiML defined by VoiceUrl.
statusCallback A flow that Twilio will request to pass status parameters (such as call ended) to your application.
voiceCallerIdLookup Do a lookup of a caller's name from the CNAM database and post it to your app. Either true or false.
smsUrl The URL that Twilio should request when somebody sends an SMS to a phone number assigned to this application.
smsMethod The HTTP method that should be used to request the SmsUrl. Either GET or POST.
smsFallback A flow that Twilio will request if an error occurs requesting or executing the TwiML defined by SmsUrl.
smsStatusCallback Twilio will make a POST request to this flow to pass status parameters (such as sent or failed) to your application if you specify this application's Sid as the ApplicationSid on an outgoing SMS request.
Returns
  • returns the updated resource representation if successful.

public String updateIncomingPhoneNumbers (String accountSid, String incomingPhoneNumberSid, String friendlyName, String apiVersion, String voiceUrl, HttpMethod voiceMethod, HttpCallback voiceFallback, HttpCallback statusCallback, Boolean voiceCallerIdLookup, String voiceApplicationSid, String smsUrl, HttpMethod smsMethod, HttpCallback smsFallback, String smsApplicationSid, String accountSidDestination)

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

* An IncomingPhoneNumber instance resource represents a Twilio phone number purchased from Twilio or ported to Twilio.

Parameters
accountSid Optionally override globally configured Account SID
incomingPhoneNumberSid The incoming phone number sid to use
friendlyName A human readable description of the new incoming phone number resource, with maximum length 64 characters.
apiVersion Calls to this phone number will start a new TwiML session with this API version. Either 2010-04-01 or 2008-08-01.
voiceUrl The URL that Twilio should request when somebody dials the new phone number.
voiceMethod The HTTP method that should be used to request the VoiceUrl. Must be either GET or POST. Defaults to POST.
voiceFallback A flow that Twilio will request if an error occurs requesting or executing the TwiML at Url.
statusCallback A flow that Twilio will request to pass statusCallback parameters (such as call ended) to your application.
voiceCallerIdLookup Do a lookup of a caller's name from the CNAM database and post it to your app. Either true or false.
voiceApplicationSid The 34 character sid of the application Twilio should use to handle phone calls to this number. If a VoiceApplicationSid is present, Twilio will ignore all of the voice urls above and use those set on the application instead.
smsUrl The URL that Twilio should request when somebody sends an SMS to the phone number.
smsMethod The HTTP method that should be used to request the SmsUrl. Must be either GET or POST. Defaults to POST.
smsFallback A flow that Twilio will request if an error occurs requesting or executing the TwiML defined by sms.
smsApplicationSid The 34 character sid of the application Twilio should use to handle SMSs sent to this number. If a SmsApplicationSid is present, Twilio will ignore all of the SMS urls above and use those set on the application instead.
accountSidDestination The unique 34 character id of the account to which you wish to transfer this phone number.
Returns
  • if successful the updated incoming phone number instance.

public String updateOutgoingCallerIdByOutgoingCallerIdSid (String accountSid, String outgoingCallerIdSid, String friendlyName)

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

Parameters
accountSid Optionally override globally configured Account SID
outgoingCallerIdSid The outgoing caller id sid to update
friendlyName A human readable description of a Caller ID, with maximum length of 64 characters. Defaults to a nicely formatted version of the phone number.
Returns
  • returns the updated resource if successful.

public String updateParticipantStatus (String accountSid, String conferenceSid, String callSid, Boolean muted)

Updates the participant status. Returns the participant representation.

Parameters
accountSid Optionally override globally configured Account SID
conferenceSid The conference sid to use
callSid The call sid to use
muted Specifying true will mute the participant, while false will un-mute.
Returns
  • the participant representation

public String updateSandbox (String accountSid, String voiceUrl, HttpMethod voiceMethod, String smsUrl, HttpMethod smsMethod)

You can POST to the Sandbox resource to update the TwiML voice and SMS URLs associated with the sandbox number.

The Sandbox resource gives you programatic access to your Twilio Developer Sandbox phone number. Using this resource you can get the phone number and PIN for your sandbox, view the current voice and SMS URLs and update those URLs just like any other IncomingPhoneNumber resource on a Full Twilio Account.

Parameters
accountSid Optionally override globally configured Account SID
voiceUrl The URL that Twilio should request when somebody calls this sandbox.
voiceMethod The HTTP method that should be used to request the above URL. Must be either GET or POST. Defaults to POST.
smsUrl The URL that Twilio should request when somebody sends an SMS to the sandbox.
smsMethod The HTTP method that should be used to request the SmsUrl. Must be either GET or POST. Defaults to POST.
Returns
  • If successful, Twilio responds with an updated representation of the sandbox.