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 accounts

Overview

The following operations allow you to work with accounts. Click an operation name to see details on how to use it.

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

OperationDescription
createSubAccountCreates a new account resource as a sub-account of the master account.
getAccountsListRetrieves a list of the account resources belonging to the master account. This list will include the master account as well.
getAccountReturns a representation of a specified account.
updateAccountAllows you to modify the properties of an account.

Operation details

This section provides further details on the operations related to Accounts.

 Create a sub account 

createSubAccount
<twilioRest.createSubAccount>
    <friendlyName>{$ctx:friendlyName}</friendlyName>
</twilioRset.createSubAccount>

To create a sub-account as a resource of the master account, use twilioRest.createSubAccount and specify the following properties. If successful, Twilio responds with information about the sub-account, including its SID, a 34-character string that uniquely identifies this sub-account.

Properties
  • friendlyName: A human-readable description of the new sub-account, up to 64 characters. Defaults to "SubAccount Created at {YYYY-MM-DD HH:MM meridian}".
Sample request

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

Sample Request for createSubAccount
{
	"accountSid":"AC3c4055d0dd73aab7b5b1b26c0794e9c6",
	"authToken":"cdd1fdb143d482a05e4f1f6fdb195395",
	"apiUrl":"https://api.twilio.com",
	"apiVersion":"2010-04-01",
	"friendlyName":"wso2 sub Account"
}
Related Twilio documentation

http://www.twilio.com/docs/api/rest/subaccounts

Getting a list of accounts 

getAccountsList
<twilioRest.getAccountsList>
    <friendlyName>{$ctx:friendlyName}</friendlyName>
    <status>{$ctx:status}</status>
</twilioRest.getAccountsList>

To get a list of existing accounts that belong to the master account, use twilioRest.getAccountsList and optionally specify the following properties. If you do not specify these properties, all accounts belong to the master account are returned. The master account is included in the list.

Properties
  • friendlyName: Optional. The human-readable account name. Only accounts whose name exactly match this string are returned.
  • status: Optional. The status of accounts to return: active, suspended, or closed. Only accounts with this status are returned.
Sample request

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

Sample Request for getAccountsList
{
	"accountSid":"AC3c4055d0dd73aab7b5b1b26c0794e9c6",
	"authToken":"cdd1fdb143d482a05e4f1f6fdb195395",
	"apiUrl":"https://api.twilio.com",
	"apiVersion":"2010-04-01",
	"friendlyName":"wso2 sub Account",
	"status":"active"
}
Related Twilio documentation

http://www.twilio.com/docs/api/rest/account#list

Getting a specific account 

getAccount
<twilioRest.getAccount>
    <subAccountSid>{$ctx:subAccountSid}</subAccountSid>
</twilioRest.getAccount>

To get information about a specific account, use twilioRest.getAccount and specify the following properties.  

Properties
  • subAccountSid: The ID of the account you want to retrieve.
Sample request

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

Sample Request for getAccount
{
	"accountSid":"AC3c4055d0dd73aab7b5b1b26c0794e9c6",
	"authToken":"cdd1fdb143d482a05e4f1f6fdb195395",
	"apiUrl":"https://api.twilio.com",
	"apiVersion":"2010-04-01",
	"subAccountSid":"ACf2efe2f821a6086ea1460b57ea23f1d3"
}
Related Twilio documentation

http://www.twilio.com/docs/api/rest/account

Updating an account 

updateAccount
<twilioRest.updateAccount>
    <subAccountSid>{$ctx:subAccountSid}</subAccountSid>
    <friendlyName>{$ctx:friendlyName}</friendlyName>
    <status>suspended</status>
</twilioRest.updateAccount>

To update an account's friendly name and/or status, use twilioRest.updateAccount and specify the following properties.  

Properties
  • subAccountSid: The ID of the account you want to update.
  • friendlyName: Optional. The new human-readable name to give the account.
  • status: Optional. The new status of the account: active, suspended, or closed.
Sample request

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

Sample Request for updateAccount
{
	"accountSid":"AC3c4055d0dd73aab7b5b1b26c0794e9c6",
	"authToken":"cdd1fdb143d482a05e4f1f6fdb195395",
	"apiUrl":"https://api.twilio.com",
	"apiVersion":"2010-04-01",
	"subAccountSid":"ACf2efe2f821a6086ea1460b57ea23f1d3",
	"friendlyName":"wso2 sub Account Update",
	"status":"suspended"
}
Related Twilio documentation

http://www.twilio.com/docs/api/rest/account

Sample configuration

Following is a sample proxy service that illustrates how to connect to TwilioRest with the init operation and use the createSubAccount operation. The sample request for this proxy can be found in createSubAccount sample request. You can use this sample as a template for using other operations in this category.

Sample Proxy
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="twilioRest"
       transports="https,http" statistics="disable" trace="disable"
       startOnLoad="true">
    <target>
        <inSequence onError="faultHandlerSeq">
            <property name="accountSid" expression="//accountSid/text()"/>
            <property name="authToken" expression="//authToken/text()"/>
            <property name="apiUrl" expression="//apiUrl/text()"/>
            <property name="apiVersion" expression="//apiVersion/text()"/>
            <property name="subAccountSid" expression="//subAccountSid/text()"/>
            <property name="friendlyName" expression="//friendlyName/text()"/>      
            <twilioRest.init>
                <accountSid>{$ctx:accountSid}</accountSid>
                <authToken>{$ctx:authToken}</authToken>
                <apiUrl>{$ctx:apiUrl}</apiUrl>
                <apiVersion>{$ctx:apiVersion}</apiVersion>
            </twilioRest.init>
            <twilioRest.createSubAccount>
                <friendlyName>{$ctx:friendlyName}</friendlyName>
            </twilioRest.createSubAccount>          
            <respond/>
        </inSequence>
        <outSequence>
            <log/>
            <send/>
        </outSequence>
    </target>
    <description/>
</proxy>