REST API: Subaccounts

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

Note: A master account can only have up to 1000 subaccounts by default. If you need more subaccounts please contact support.

Billing

Twilio bills all subaccount usage directly to your master account. You'll have one Twilio balance for all subaccounts. If your master Twilio account is ever suspended, your subaccounts will also be suspended.

Skip to calculate billing for subaccounts >>

Authentication

You can use your master Twilio Account credentials (AccountSid and AuthToken) to access Twilio's REST API for your master account as well as any of your subaccounts. You may also use a subaccount's AccountSid and AuthToken to access the resources of that subaccount. You can not use a subaccount's credentials to access the resources of your master Twilio account or any other subaccounts.

International

We are currently working on ways to help our customers minimize the risk of fraudulent international calls and provide ways for Twilio subaccounts to dial certain international destinations. If you have any questions, please contact support.

Permissions

Subaccounts use the master account's voice and SMS messaging permissions.

Creating Subaccounts

To create a new subaccount, make an HTTP POST request to your Accounts list resource URI:

/2010-04-01/Accounts

If successful, Twilio responds with a representation of the new Account resource.

POST Parameters

Optional Parameters

Your request to create a subaccount may include the following parameters:

Parameter Description
FriendlyName A human readable description of the new subaccount, up to 64 characters. Defaults to "SubAccount Created at {YYYY-MM-DD HH:MM meridian}".

The FriendlyName property is useful for organizing accounts and linking them back to information in your own system. For example, you may want to create subaccounts where the FriendlyName is the primary key of the customer in your application's database.

Example
Loading Code Samples...
Language
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
  • XML
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var account = AccountResource.Create("Submarine");

        Console.WriteLine(account.Sid);
    }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);

$account = $client->api->accounts->create(array(
    'FriendlyName' => 'Submarine'
));

echo $account->sid;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token  = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

account = client.accounts.create(friendly_name="Submarine")
print(account.sid)
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'rubygems'          # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

account = @client.api.accounts.create(:friendly_name => 'Submarine')
puts account.friendly_name
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    
    var account = twilio.CreateSubAccount("Submarine");
    
    Console.WriteLine(account.Sid);
  }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; 
$token = "your_auth_token"; 
$client = new Services_Twilio($sid, $token);

$account = $client->accounts->create(array(
        "FriendlyName" => "Submarine"
    ));
echo $account->sid;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'rubygems'          # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new account_sid, auth_token

account = @client.accounts.create(:friendly_name => "Submarine")
puts account.friendly_name
curl -XPOST https://api.twilio.com/2010-04-01/Accounts.json \
    -d "FriendlyName=Submarine" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.Account;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    Account subAccount = Account.creator().setFriendlyName("Submarine").create();

    System.out.println(subAccount.getSid());
  }
}
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.factory.AccountFactory;
import com.twilio.sdk.resource.instance.Account;
import com.twilio.sdk.resource.list.AccountList;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

public class Example { 

  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Build a filter for the AccountList
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("FriendlyName", "Submarine"));
    
    
    AccountFactory accountFactory = client.getAccountFactory();
    Account account = accountFactory.create(params);
    System.out.println(account.getSid());
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"

client = Client(account_sid, auth_token)

account = client.api.accounts.create(friendly_name="Submarine")

print(account.sid)
// Download the Node helper library from twilio.com/docs/node/install
// These consts are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.api.accounts.create({friendlyName: 'Submarine'})
  .then((account) => process.stdout.write(account.sid));
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

client.accounts.create({
    friendlyName: "Submarine"
}, function(err, account) {
    process.stdout.write(account.sid);
});
{
    "sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "friendly_name": "Submarine",
    "auth_token": "redacted",
    "date_created": "Tue, 25 Jan 2011 19:24:40 +0000",
    "date_updated": "Tue, 25 Jan 2011 19:25:02 +0000",
    "status": "active",
    "subresource_uris": {
        "available_phone_numbers": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers.json",
        "calls": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls.json",
        "conferences": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Conferences.json",
        "incoming_phone_numbers": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers.json",
        "notifications": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Notifications.json",
        "outgoing_caller_ids": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/OutgoingCallerIds.json",
        "recordings": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Recordings.json",
        "sandbox": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Sandbox.json",
        "sms_messages": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages.json",
        "transcriptions": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Transcriptions.json"
    },
    "type": "Full",
    "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"
}
<TwilioResponse>
  <Account>
	<Sid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</Sid>
	<FriendlyName>Submarine</FriendlyName>
	<Status>active</Status>
	<AuthToken>redacted</AuthToken>
	<DateCreated>Tue, 12 Jan 2010 04:41:09 +0000</DateCreated>
	<DateUpdated>Tue, 25 Jan 2011 07:24:36 +0000</DateUpdated>
	<Type>Full</Type>
	<Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</Uri>
	<SubresourceUris>
	  <AvailablePhoneNumbers>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers</AvailablePhoneNumbers>
	  <Calls>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls</Calls>
	  <Conferences>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Conferences</Conferences>
	  <IncomingPhoneNumbers>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers</IncomingPhoneNumbers>
	  <Notifications>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Notifications</Notifications>
	  <OutgoingCallerIds>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/OutgoingCallerIds</OutgoingCallerIds>
	  <Recordings>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Recordings</Recordings>
	  <Sandbox>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Sandbox</Sandbox>
	  <SMSMessages>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages</SMSMessages>
	  <Transcriptions>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Transcriptions</Transcriptions>
	</SubresourceUris>
  </Account>
</TwilioResponse>
Create a subaccount

Getting Started with Subaccounts

Subaccounts are a great way to segment your Twilio usage and act on behalf of your customers, agents or employees.

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.

Subaccounts allow you to use the Twilio REST API just as you would for a single account; a subaccount can have its own phone numbers and caller IDs, applications and SIP Domains. You can manage a subaccount's calls, messagess, recordings, and transcriptions without affecting other subaccounts.

Finding Subaccounts

You can query any particular subaccount and its related resources via the REST API by AccountSid.

Loading Code Samples...
Language
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
  • XML
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var account = AccountResource.Fetch("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

        Console.WriteLine(account.Status);
    }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);

$subAccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

// Get an object from its sid. If you do not have a sid,
// check out the list resource examples on this page
$account = $client->api->accounts($subAccountSid)->fetch();

echo $account->status;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token  = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

account = client.accounts.get("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
print(account.status)
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'rubygems'          # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

# Get an object from its sid. If you do not have a sid,
# check out the list resource examples on this page
@account = @client.api.v2010.accounts("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").fetch
puts @account.status
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    var account = twilio.GetAccount("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
    
    Console.WriteLine(account.Status);
  }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; 
$token = "your_auth_token"; 
$client = new Services_Twilio($sid, $token);

// Get an object from its sid. If you do not have a sid,
// check out the list resource examples on this page
$account = $client->accounts->get("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
echo $account->status;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'rubygems'          # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new account_sid, auth_token

# Get an object from its sid. If you do not have a sid,
# check out the list resource examples on this page
@account = @client.accounts.get("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
puts @account.status
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.Account;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    // Get an object from its sid. If you do not have a sid,
    // check out the list resource examples on this page
    Account account = Account.fetcher("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").fetch();

    System.out.println(account.getStatus());
  }
}
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.Account;

public class Example { 

  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Get an object from its sid. If you do not have a sid,
    // check out the list resource examples on this page
    Account account = client.getAccount("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
    System.out.println(account.getStatus());
    
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"

client = Client(account_sid, auth_token)

account = client.api.accounts("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").fetch()

print(account.status)
// Download the Node helper library from twilio.com/docs/node/install
// These consts are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.api.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .fetch()
  .then((account) => console.log(account.status));
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

client.accounts("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").get(function(err, account) {
    console.log(account.status);
});
{
    "sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "friendly_name": "MySubaccount",
    "auth_token": "redacted",
    "date_created": "Tue, 25 Jan 2011 19:24:40 +0000",
    "date_updated": "Tue, 25 Jan 2011 19:25:02 +0000",
    "status": "active",
    "subresource_uris": {
        "available_phone_numbers": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers.json",
        "calls": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls.json",
        "conferences": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Conferences.json",
        "incoming_phone_numbers": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers.json",
        "notifications": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Notifications.json",
        "outgoing_caller_ids": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/OutgoingCallerIds.json",
        "recordings": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Recordings.json",
        "sandbox": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Sandbox.json",
        "sms_messages": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages.json",
        "transcriptions": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Transcriptions.json"
    },
    "type": "Full",
    "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"
}
<TwilioResponse>
  <Account>
	<Sid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</Sid>
	<FriendlyName>MySubaccount</FriendlyName>
	<Status>active</Status>
	<AuthToken>redacted</AuthToken>
	<DateCreated>Tue, 12 Jan 2010 04:41:09 +0000</DateCreated>
	<DateUpdated>Tue, 25 Jan 2011 07:24:36 +0000</DateUpdated>
	<Type>Full</Type>
	<Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</Uri>
	<SubresourceUris>
	  <AvailablePhoneNumbers>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers</AvailablePhoneNumbers>
	  <Calls>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls</Calls>
	  <Conferences>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Conferences</Conferences>
	  <IncomingPhoneNumbers>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers</IncomingPhoneNumbers>
	  <Notifications>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Notifications</Notifications>
	  <OutgoingCallerIds>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/OutgoingCallerIds</OutgoingCallerIds>
	  <Recordings>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Recordings</Recordings>
	  <Sandbox>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Sandbox</Sandbox>
	  <SMSMessages>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages</SMSMessages>
	  <Transcriptions>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Transcriptions</Transcriptions>
	</SubresourceUris>
  </Account>
</TwilioResponse>
Return a subaccount resource by its account SID

If you don't know the AccountSid of a subaccount but you know the FriendlyName, you can query your Accounts list resource with a FriendlyName query string filter:

Loading Code Samples...
Language
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
  • XML
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var accounts = AccountResource.Read("MySubaccount");

        foreach (var account in accounts)
        {
            Console.WriteLine(account.Status);
        }
    }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);

$accounts = $client->api->accounts->read(
    array("friendlyName" => "MySubaccount")
);
// Loop over the list of accounts and echo a property for each one
foreach ($accounts as $account) {
    echo $account->status;
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token  = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

# A list of account objects with the properties described above
accounts = client.accounts.list(friendly_name="MySubaccount")
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)


# Loop over accounts and print out a property for each one
@client.api.accounts.list(:friendly_name => "MySubaccount").each do |account|
  puts account.status
end
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;

class Example
{
  static void Main(string[] args)
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    var accounts = twilio.ListSubAccounts("MySubaccount");

    foreach (var account in accounts.Accounts)
    {
      Console.WriteLine(account.Status);
    }
  }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; 
$token = "your_auth_token"; 
$client = new Services_Twilio($sid, $token);

// Loop over the list of accounts and echo a property for each one
foreach ($client->accounts->getIterator(0, 50, array(
        "FriendlyName" => "MySubaccount"
    )) as $account
) {
    echo $account->status;
}
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new account_sid, auth_token


# Loop over accounts and print out a property for each one
@client.accounts.list(:friendly_name => "MySubaccount").each do |account|
  puts account.status
end
$ curl -G https://api.twilio.com/2010-04-01/Accounts.json \
    -d "FriendlyName=MySubaccount" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.api.v2010.Account;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    ResourceSet<Account> accounts = Account.reader().setFriendlyName("MySubaccount").read();

    // Loop over accounts and print out a property for each one.
    for (Account account : accounts) {
      System.out.println(account.getStatus());
    }
  }
}
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.Account;
import com.twilio.sdk.resource.list.AccountList;
import java.util.HashMap;
import java.util.Map;

public class Example { 

  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Build a filter for the AccountList
    Map<String, String> params = new HashMap<String, String>();
    
    params.put("FriendlyName", "MySubaccount");
    
    AccountList accounts = client.getAccounts(params);
    
    // Loop over accounts and print out a property for each one.
    for (Account account : accounts) {
      System.out.println(account.getStatus());
    }
    
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"

client = Client(account_sid, auth_token)

# A list of account objects with the properties described above
accounts = client.api.accounts.list(friendly_name="MySubaccount")

for account in accounts:
    print(account.sid)
// Download the Node helper library from twilio.com/docs/node/install
// These consts are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.api.accounts.each({friendlyName: 'MySubaccount'},
                     (account) => console.log(account.status));
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

client.accounts.list({ friendlyName: "MySubaccount" }, function(err, data) {
    data.accounts.forEach(function(account) {
        console.log(account.Status);
    });
});
[{
    "sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "friendly_name": "MySubaccount",
    "auth_token": "redacted",
    "date_created": "Tue, 25 Jan 2011 19:24:40 +0000",
    "date_updated": "Tue, 25 Jan 2011 19:25:02 +0000",
    "status": "active",
    "subresource_uris": {
        "available_phone_numbers": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers.json",
        "calls": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls.json",
        "conferences": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Conferences.json",
        "incoming_phone_numbers": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers.json",
        "notifications": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Notifications.json",
        "outgoing_caller_ids": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/OutgoingCallerIds.json",
        "recordings": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Recordings.json",
        "sandbox": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Sandbox.json",
        "sms_messages": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages.json",
        "transcriptions": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Transcriptions.json"
    },
    "type": "Full",
    "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"
}]
<TwilioResponse>
  <Accounts>
	<Account>
		<Sid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</Sid>
		<FriendlyName>MySubaccount</FriendlyName>
		<Status>active</Status>
		<AuthToken>redacted</AuthToken>
		<DateCreated>Tue, 12 Jan 2010 04:41:09 +0000</DateCreated>
		<DateUpdated>Tue, 25 Jan 2011 07:24:36 +0000</DateUpdated>
		<Type>Full</Type>
		<Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</Uri>
		<SubresourceUris>
		  <AvailablePhoneNumbers>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers</AvailablePhoneNumbers>
		  <Calls>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls</Calls>
		  <Conferences>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Conferences</Conferences>
		  <IncomingPhoneNumbers>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers</IncomingPhoneNumbers>
		  <Notifications>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Notifications</Notifications>
		  <OutgoingCallerIds>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/OutgoingCallerIds</OutgoingCallerIds>
		  <Recordings>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Recordings</Recordings>
		  <Sandbox>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Sandbox</Sandbox>
		  <SMSMessages>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages</SMSMessages>
		  <Transcriptions>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Transcriptions</Transcriptions>
		</SubresourceUris>
	</Account>
  </Accounts>
</TwilioResponse>
Query subaccounts by friendly name

Making a phone call with a Subaccount

In order to make calls and send messages using a subaccount you simply need to replace the account credentials with the subaccount credentials.

Loading Code Samples...
Language
SDK Version:
  • 7.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 4.x
  • 5.x
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sAsid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$sAtoken = "your_auth_token";
$sAClient = new Client($sAsid, $sAtoken);

$sAClient->calls->create(
    '+16518675309', // The visitor's phone number
    '+14158141829', // A Twilio number in your subaccount
    array(
        "url" => 'http://twimlets.com/message?Message%5B0%5D=Hello%20from%20your%20subaccount'
    )
);
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Account Sid and Auth token for your new subaccount
sub_account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
sub_auth_token = 'your_auth_token'
@sub_account_client = Twilio::REST::Client.new(sub_account_sid, sub_auth_token)

# Make a call from your subaccount
@sub_account_client.calls.create(
  :from => '+14158141829',
  :to   => '+16518675309',
  :url  => 'http://twimlets.com/message?Message%5B0%5D=Hello%20from%20your%20subaccount'
)
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Account Sid and Auth token for your new subaccount
$sa_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$sa_token = "your_auth_token";
$sa_client = new Services_Twilio($sa_sid, $sa_token);

$sa_client->account->calls->create(
    '+14158141829', // A Twilio number in your subaccount
    '+16518675309', // The visitor's phone number
    'http://twimlets.com/message?Message%5B0%5D=Hello%20from%20your%20subaccount'
);
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Account Sid and Auth token for your new subaccount
sub_account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
sub_auth_token = 'your_auth_token'
@sub_account_client = Twilio::REST::Client.new(sub_account_sid, sub_auth_token)

# Make a call from your subaccount
@sub_account_client.account.calls.create(
  from: '+14158141829',
  to:   '+16518675309',
  url:  'http://twimlets.com/message?Message%5B0%5D=Hello%20from%20your%20subaccount'
)
// Install the Java helper library from twilio.com/docs/java/install
import java.net.URI;
import java.net.URISyntaxException;

import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Call;
import com.twilio.type.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String SUBACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String SUBACCOUNT_AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws URISyntaxException {
    Twilio.init(SUBACCOUNT_SID, SUBACCOUNT_AUTH_TOKEN);

    Call.creator(new PhoneNumber("+16518675309"), new PhoneNumber("+14158141829"),
        new URI("http://twimlets.com/message?Message%5B0%5D=Hello%20from%20your%20subaccount"))
            .create();
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
sub_account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
sub_auth_token = "your_auth_token"

sub_account_client = Client(sub_account_sid, sub_auth_token)

# Make a call from your subaccount
sub_account_client.api.account.calls.create(
    from_='+14158141829',
    to='+16518675309',
    url='http://twimlets.com/message?Message%5B0%5D=Hello%20from%20your%20subaccount'
)
Making a call from a subaccount

Calculate billing for Subaccount usage

In many cases you may want to calculate the billing incurred by a subaccount. Let's say you created a subaccount for a customer and you needed to charge them for their monthly usage.

This is how you would calculate how many minutes of calling your customer made over the last 30 days:

Loading Code Samples...
Language
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 4.x
  • 5.x
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);

// Place to store the billable usage
$timeToBill = 0;

// 30 days ago
$date = strtotime('-1 month');

$calls = $client
    ->calls
    ->read(
        array("startTime" => date('Y-m-d', $date))
    );

foreach ($calls as $call) {
    // Get time of call in minutes
    $timeToBill += ceil((float) $call->duration);
}

echo "Account $sid used $timeToBill minutes.";
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Account Sid and Auth token for your new subaccount
sub_account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
sub_auth_token = 'your_auth_token'
@sub_account_client = Twilio::REST::Client.new(sub_account_sid, sub_auth_token)
@subaccount = @sub_account_client.api.account

# Place to store the billable usage
time_to_bill = 0

# 30 days ago
start_time = Time.now - ( 30 * 24 * 60 * 60 )

# Get all calls for the last 30 days
@subaccount.calls.list(:start_time => start_time).each do |call|
  # Get time of call in minutes
  time_to_bill += (call.duration.to_f/60).ceil
end

puts "Account #{sub_account_sid} used #{time_to_bill} minutes."
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Account Sid and Auth token for your new subaccount
$sa_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$sa_token = "your_auth_token";
$sa_client = new Services_Twilio($sa_sid, $sa_token);
$subaccount = $sa_client->account;

// Place to store the billable usage
$time_to_bill = 0;

// 30 days ago
$date = strtotime('-1 month');

// Get all calls for the last 30 days
$callIterator = $sa_client->account->calls->getIterator(
    0,
    1000,
    array(
        "StartTime" => date('Y-m-d', $date)
    )
);

foreach ($callIterator as $call) {
    // Get time of call in minutes
    $time_to_bill += ceil((float) $call->duration);
}

echo "Account $sa_sid used {$time_to_bill} minutes.";
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Account Sid and Auth token for your new subaccount
sub_account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
sub_auth_token = 'your_auth_token'
@sub_account_client = Twilio::REST::Client.new sub_account_sid, sub_auth_token
@subaccount = @sub_account_client.account

# Place to store the billable usage
time_to_bill = 0

# 30 days ago
start_time = Time.now - ( 30 * 24 * 60 * 60 )

# Get all calls for the last 30 days
@subaccount.calls.list({:page => 0, :page_size => 1000, :start_time => ">#{start_time.strftime('%Y-%m-%d')}"}).each do |call|
  # Get time of call in minutes
  time_to_bill += (call.duration.to_f/60).ceil
end

puts "Account #{sub_account_sid} used #{time_to_bill} minutes."
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client
from math import ceil
import datetime

# Your Account Sid and Auth Token from twilio.com/user/account
sub_account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
sub_auth_token = "your_auth_token"
sub_account_client = Client(sub_account_sid, sub_auth_token)
sub_account = sub_account_client.api.account

# Place to store the billable usage
time_to_bill = 0

# 30 days ago
date = datetime.datetime.now() + datetime.timedelta(-30)

calls = sub_account.calls.list(start_time=date.strftime('%Y-%m-%d'))

for call in calls:
    time_to_bill += ceil(int(call.duration) / 60)

print("Account {0} used {1} minutes.").format(sub_account_sid, time_to_bill)
Calculate billing for subaccount usage

Suspending a Subaccount

While an account is suspended it cannot make or receive phone calls or send and receive SMS messages. This is useful when your customer does not pay their bill and you want to suspend their account until a successful payment is received. However, you will be charged monthly for any phone numbers the subaccount owns.

Simply POST the parameter 'Status' with the value 'suspended' to suspend an account.

To reactivate a suspended subaccount, just POST the value 'active' for the 'Status' parameter and we will restore the account to full service.

For details and an example, see the Account instance resource POST section.

Note that you must use your master account's authentication credentials to suspend a subaccount. Also you cannot suspend your master account.

Closing a Subaccount

If your customer closes his or her account with you, you can permanently close the associated Twilio subaccount by POSTing the parameter 'Status' with the value 'closed' to the subaccount resource URI.

When you close a subaccount, Twilio will release all phone numbers assigned to it and shut it down completely. You can't ever use a closed account to make and receive phone calls or send and receive SMS messages. It's closed, gone, kaput. It will still appear in your accounts list, and you will still have access to historical data for that subaccount, but you cannot reopen a closed account.

For details and an example, see the Account instance resource POST section.

Note that you must use your master account's authentication credentials to close a subaccount. You also cannot close your master account.

Exchanging Phone Numbers Between Accounts

You can transfer numbers between subaccounts, and between your master account and any one of your subaccounts. You must use your master account's credentials when making the API request to transfer a phone number.

To transfer a phone number between two accounts that you control, make an HTTP POST request to an IncomingPhoneNumber instance resource URI. In the body of the POST set the parameter 'AccountSid' to the AccountSid of the account you wish to own that number. This will remove the phone number from its original account and make it available under the IncomingPhoneNumbers list resource of the new account while retaining all other properties.

If any of the phone numbers you would like to transfer have Address Requirements, you will need to create a compliant Address in the new subaccount before transferring the phone number.

Remember, closing a subaccount as described above will release all of that account's phone numbers, so you might consider transferring all numbers to your master account beforehand if you want to keep them.

Example

Transfer a phone number from account AC00000000000000000000000000000001 to AC00000000000000000000000000000002:

Loading Code Samples...
Language
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
Format:
  • JSON
  • XML
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        // In the case you want to transfer numbers between subaccounts, you need to
        // know three things - the account SID of the phone number's current owner,
        // the account SID of the account you'd like to transfer the number to, and
        // the SID of the phone number you'd like to transfer
        const string currentOwnerSid = "ACYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY";
        const string newOwnerSid = "ACZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ";
        const string phoneNumberSid = "PNYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY";

        // Create an authenticated REST client
        TwilioClient.Init(accountSid, authToken);

        IncomingPhoneNumberResource.Update(phoneNumberSid,
                                           accountSid: newOwnerSid);
    }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);

// In the case you want to transfer numbers between subaccounts, you need to
// know three things - the account SID of the phone number's current owner,
// the account SID of the account you'd like to transfer the number to, and
// the SID of the phone number you'd like to transfer
$currentNumberOwnerAccountSid = "ACyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";
$newNumberOwnerAccountSid = "ACzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
$phoneNumberSid = "PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";

// Get an object from its sid. If you do not have a sid,
// check out the list resource examples on this page
$number = $client->api->accounts($currentNumberOwnerAccountSid)
    ->incomingPhoneNumbers($phoneNumberSid)
    ->update(array("accountSid" => $newNumberOwnerAccountSid));

echo $number->phoneNumber;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Use the Account Sid and Auth Token of the subaccount which currently
# owns the number you want to transfer (twilio.com/console/account/subaccounts)
account_sid = "ACyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
auth_token  = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

# In the case you want to transfer numbers between subaccounts, you need to 
# know two things: the account SID of the account you'd like to transfer the
# number to, and the SID of the phone number you'd like to transfer
new_owner_sid = "ACzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
number_sid = "PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"

number = client.phone_numbers.update(number_sid, account_sid=new_owner_sid)
print(number.phone_number)
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    var accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    var authToken = "your_auth_token";

    // In the case you want to transfer numbers between subaccounts, you need to 
    // know three things - the account SID of the phone number's current owner, 
    // the account SID of the account you'd like to transfer the number to, and 
    // the SID of the phone number you'd like to transfer
    var currentOwnerSid = "ACyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";
    var newOwnerSid = "ACzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
    var phoneNumberSid = "PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";

    // Create an authenticated REST client
    var twilio = new TwilioRestClient(accountSid, authToken, currentOwnerSid);

    var options = new PhoneNumberOptions();
    options.AccountSid = newOwnerSid;
    
    twilio.UpdateIncomingPhoneNumber(phoneNumberSid, options);
  }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; 
$token = "your_auth_token"; 
$client = new Services_Twilio($sid, $token);

// In the case you want to transfer numbers between subaccounts, you need to 
// know three things - the account SID of the phone number's current owner, 
// the account SID of the account you'd like to transfer the number to, and 
// the SID of the phone number you'd like to transfer
$currentNumberOwnerAccountSid = "ACyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";
$newNumberOwnerAccountSid = "ACzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
$phoneNumberSid = "PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";

// Get an object from its sid. If you do not have a sid,
// check out the list resource examples on this page
$number = $client->accounts->get($currentNumberOwnerAccountSid)
    ->incoming_phone_numbers->get($phoneNumberSid);

$number->update(array(
    "AccountSid" => $newNumberOwnerAccountSid,
));
echo $number->phone_number;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'rubygems'          # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new account_sid, auth_token

# In the case you want to transfer numbers between subaccounts, you need to 
# know three things - the account SID of the phone number's current owner, 
# the account SID of the account you'd like to transfer the number to, and 
# the SID of the phone number you'd like to transfer
current_owner_sid = 'ACyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
new_owner_sid = 'ACzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'
phone_number_sid = 'PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
 
# Update the number
@subaccount = @client.accounts.get(current_owner_sid)
@number = @subaccount.incoming_phone_numbers.get(phone_number_sid)
@number.update(:account_sid => new_owner_sid)
puts @number.phone_number
$ curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy/IncomingPhoneNumbers/PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy.json \
    -d "AccountSid=ACzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.IncomingPhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  // In the case you want to transfer numbers between subaccounts, you need to 
  // know three things - the account SID of the phone number's current owner, 
  // the account SID of the account you'd like to transfer the number to, and 
  // the SID of the phone number you'd like to transfer
  public static final String CURRENT_OWNER_SID = "ACyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";
  public static final String NEW_OWNER_SID = "ACzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
  public static final String NUMBER_SID = "PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    IncomingPhoneNumber number = IncomingPhoneNumber
        .updater(CURRENT_OWNER_SID, NUMBER_SID)
        .setAccountSid(NEW_OWNER_SID)
        .update();

    System.out.println(number.getDateUpdated());
  }
}
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.IncomingPhoneNumber;
import com.twilio.sdk.resource.list.IncomingPhoneNumberList;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

public class Example { 

  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String ORIGINAL_ACCT = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Get an object from its sid. If you do not have a sid,
    // check out the list resource examples on this page
    IncomingPhoneNumber number = client.getAccount(ORIGINAL_ACCT)
      .getIncomingPhoneNumber("PN2a0747eba6abf96b7e3c3ff0b4530f6e");
    // Build a filter for the IncomingPhoneNumberList
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("AccountSid", "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"));
    number.update(params);
    
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

# In the case you want to transfer numbers between subaccounts, you need to
# know three things - the account SID of the phone number's current owner,
# the account SID of the account you'd like to transfer the number to, and
# the SID of the phone number you'd like to transfer
current_owner_sid = "ACyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
new_owner_sid = "ACzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
number_sid = "PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"

number = client.api.accounts(current_owner_sid) \
               .incoming_phone_numbers(number_sid) \
               .update(account_sid=new_owner_sid)

print(number.phone_number)
// Download the Node helper library from twilio.com/docs/node/install
// These consts are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

// In the case you want to transfer numbers between accounts, you need to know
// three things - the account SID of the phone number's current owner, the
// account SID of the account you'd like to transfer the number to, and the SID
// of the phone number you'd like to transfer
const currentNumberOwnerAccountSid = 'ACyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy';
const newNumberOwnerAccountSid = 'ACzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
const phoneNumberSid = 'PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy';

client.api.accounts(currentNumberOwnerAccountSid)
  .incomingPhoneNumbers(phoneNumberSid)
  .update({
    accountSid: newNumberOwnerAccountSid // specify new account owner
  })
  .then((number) => console.log(number));
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var client = require('twilio')(accountSid, authToken);

// In the case you want to transfer numbers between accounts, you need to know
// three things - the account SID of the phone number's current owner, the
// account SID of the account you'd like to transfer the number to, and the SID
// of the phone number you'd like to transfer
var currentNumberOwnerAccountSid = 'ACyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy';
var newNumberOwnerAccountSid = 'ACzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
var phoneNumberSid = 'PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy';

var phoneNumber = client
  .accounts(currentNumberOwnerAccountSid)
  .incomingPhoneNumbers(phoneNumberSid);

phoneNumber.update({
  accountSid: newNumberOwnerAccountSid // Specify a new account as owner
}, function(err, number) {
  console.log(number);
});
{
	"sid": "PN2a0747eba6abf96b7e3c3ff0b4530f6e",
	"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
	"friendly_name": "My Company Line",
	"phone_number": "+15105647903",
	"voice_url": "http://demo.twilio.com/docs/voice.xml",
	"voice_method": "POST",
	"voice_fallback_url": null,
	"voice_fallback_method": "POST",
	"voice_caller_idlookup": null,
	"date_created": "Mon, 16 Aug 2010 23:00:23 +0000",
	"date_updated": "Mon, 16 Aug 2010 23:00:23 +0000",
	"sms_url": null,
	"sms_method": "POST",
	"sms_fallback_url": null,
	"sms_fallback_method": "GET",
	"capabilities": {
		"voice": null,
		"sms": null
	},
	"status_callback": null,
	"status_callback_method": null,
	"api_version": "2010-04-01",
	"uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/IncomingPhoneNumbers\/PN2a0747eba6abf96b7e3c3ff0b4530f6e.json"
}
<TwilioResponse>
	<IncomingPhoneNumber>
		<Sid>PN2a0747eba6abf96b7e3c3ff0b4530f6e</Sid>
		<AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
		<FriendlyName>My Company Line</FriendlyName>
		<PhoneNumber>+15105647903</PhoneNumber>
		<VoiceUrl>http://demo.twilio.com/docs/voice.xml</VoiceUrl>
		<VoiceMethod>POST</VoiceMethod>
		<VoiceFallbackUrl/>
		<VoiceFallbackMethod>POST</VoiceFallbackMethod>
		<VoiceCallerIdLookup>false</VoiceCallerIdLookup>
		<DateCreated>Mon, 16 Aug 2010 23:00:23 +0000</DateCreated>
		<DateUpdated>Mon, 16 Aug 2010 23:00:23 +0000</DateUpdated>
		<SmsUrl/>
		<SmsMethod>POST</SmsMethod>
		<SmsFallbackUrl/>
		<SmsFallbackMethod>GET</SmsFallbackMethod>
		<Capabilities>
			<Voice>true</Voice>
			<SMS>true</SMS>
		</Capabilities>
		<StatusCallback/>
		<StatusCallbackMethod/>
		<ApiVersion>2010-04-01</ApiVersion>
		<Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers/PN2a0747eba6abf96b7e3c3ff0b4530f6e</Uri>
	</IncomingPhoneNumber>
</TwilioResponse>
Transfer phone numbers between subaccounts

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 browsing the Twilio tag on Stack Overflow.

1 / 1
Loading Code Samples...
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
  • XML
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var account = AccountResource.Create("Submarine");

        Console.WriteLine(account.Sid);
    }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);

$account = $client->api->accounts->create(array(
    'FriendlyName' => 'Submarine'
));

echo $account->sid;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token  = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

account = client.accounts.create(friendly_name="Submarine")
print(account.sid)
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'rubygems'          # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

account = @client.api.accounts.create(:friendly_name => 'Submarine')
puts account.friendly_name
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    
    var account = twilio.CreateSubAccount("Submarine");
    
    Console.WriteLine(account.Sid);
  }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; 
$token = "your_auth_token"; 
$client = new Services_Twilio($sid, $token);

$account = $client->accounts->create(array(
        "FriendlyName" => "Submarine"
    ));
echo $account->sid;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'rubygems'          # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new account_sid, auth_token

account = @client.accounts.create(:friendly_name => "Submarine")
puts account.friendly_name
curl -XPOST https://api.twilio.com/2010-04-01/Accounts.json \
    -d "FriendlyName=Submarine" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.Account;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    Account subAccount = Account.creator().setFriendlyName("Submarine").create();

    System.out.println(subAccount.getSid());
  }
}
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.factory.AccountFactory;
import com.twilio.sdk.resource.instance.Account;
import com.twilio.sdk.resource.list.AccountList;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

public class Example { 

  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Build a filter for the AccountList
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("FriendlyName", "Submarine"));
    
    
    AccountFactory accountFactory = client.getAccountFactory();
    Account account = accountFactory.create(params);
    System.out.println(account.getSid());
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"

client = Client(account_sid, auth_token)

account = client.api.accounts.create(friendly_name="Submarine")

print(account.sid)
// Download the Node helper library from twilio.com/docs/node/install
// These consts are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.api.accounts.create({friendlyName: 'Submarine'})
  .then((account) => process.stdout.write(account.sid));
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

client.accounts.create({
    friendlyName: "Submarine"
}, function(err, account) {
    process.stdout.write(account.sid);
});
{
    "sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "friendly_name": "Submarine",
    "auth_token": "redacted",
    "date_created": "Tue, 25 Jan 2011 19:24:40 +0000",
    "date_updated": "Tue, 25 Jan 2011 19:25:02 +0000",
    "status": "active",
    "subresource_uris": {
        "available_phone_numbers": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers.json",
        "calls": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls.json",
        "conferences": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Conferences.json",
        "incoming_phone_numbers": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers.json",
        "notifications": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Notifications.json",
        "outgoing_caller_ids": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/OutgoingCallerIds.json",
        "recordings": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Recordings.json",
        "sandbox": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Sandbox.json",
        "sms_messages": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages.json",
        "transcriptions": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Transcriptions.json"
    },
    "type": "Full",
    "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"
}
<TwilioResponse>
  <Account>
	<Sid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</Sid>
	<FriendlyName>Submarine</FriendlyName>
	<Status>active</Status>
	<AuthToken>redacted</AuthToken>
	<DateCreated>Tue, 12 Jan 2010 04:41:09 +0000</DateCreated>
	<DateUpdated>Tue, 25 Jan 2011 07:24:36 +0000</DateUpdated>
	<Type>Full</Type>
	<Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</Uri>
	<SubresourceUris>
	  <AvailablePhoneNumbers>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers</AvailablePhoneNumbers>
	  <Calls>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls</Calls>
	  <Conferences>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Conferences</Conferences>
	  <IncomingPhoneNumbers>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers</IncomingPhoneNumbers>
	  <Notifications>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Notifications</Notifications>
	  <OutgoingCallerIds>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/OutgoingCallerIds</OutgoingCallerIds>
	  <Recordings>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Recordings</Recordings>
	  <Sandbox>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Sandbox</Sandbox>
	  <SMSMessages>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages</SMSMessages>
	  <Transcriptions>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Transcriptions</Transcriptions>
	</SubresourceUris>
  </Account>
</TwilioResponse>
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
  • XML
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var account = AccountResource.Fetch("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

        Console.WriteLine(account.Status);
    }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);

$subAccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

// Get an object from its sid. If you do not have a sid,
// check out the list resource examples on this page
$account = $client->api->accounts($subAccountSid)->fetch();

echo $account->status;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token  = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

account = client.accounts.get("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
print(account.status)
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'rubygems'          # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

# Get an object from its sid. If you do not have a sid,
# check out the list resource examples on this page
@account = @client.api.v2010.accounts("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").fetch
puts @account.status
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    var account = twilio.GetAccount("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
    
    Console.WriteLine(account.Status);
  }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; 
$token = "your_auth_token"; 
$client = new Services_Twilio($sid, $token);

// Get an object from its sid. If you do not have a sid,
// check out the list resource examples on this page
$account = $client->accounts->get("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
echo $account->status;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'rubygems'          # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new account_sid, auth_token

# Get an object from its sid. If you do not have a sid,
# check out the list resource examples on this page
@account = @client.accounts.get("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
puts @account.status
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.Account;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    // Get an object from its sid. If you do not have a sid,
    // check out the list resource examples on this page
    Account account = Account.fetcher("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").fetch();

    System.out.println(account.getStatus());
  }
}
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.Account;

public class Example { 

  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Get an object from its sid. If you do not have a sid,
    // check out the list resource examples on this page
    Account account = client.getAccount("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
    System.out.println(account.getStatus());
    
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"

client = Client(account_sid, auth_token)

account = client.api.accounts("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").fetch()

print(account.status)
// Download the Node helper library from twilio.com/docs/node/install
// These consts are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.api.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .fetch()
  .then((account) => console.log(account.status));
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

client.accounts("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").get(function(err, account) {
    console.log(account.status);
});
{
    "sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "friendly_name": "MySubaccount",
    "auth_token": "redacted",
    "date_created": "Tue, 25 Jan 2011 19:24:40 +0000",
    "date_updated": "Tue, 25 Jan 2011 19:25:02 +0000",
    "status": "active",
    "subresource_uris": {
        "available_phone_numbers": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers.json",
        "calls": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls.json",
        "conferences": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Conferences.json",
        "incoming_phone_numbers": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers.json",
        "notifications": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Notifications.json",
        "outgoing_caller_ids": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/OutgoingCallerIds.json",
        "recordings": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Recordings.json",
        "sandbox": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Sandbox.json",
        "sms_messages": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages.json",
        "transcriptions": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Transcriptions.json"
    },
    "type": "Full",
    "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"
}
<TwilioResponse>
  <Account>
	<Sid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</Sid>
	<FriendlyName>MySubaccount</FriendlyName>
	<Status>active</Status>
	<AuthToken>redacted</AuthToken>
	<DateCreated>Tue, 12 Jan 2010 04:41:09 +0000</DateCreated>
	<DateUpdated>Tue, 25 Jan 2011 07:24:36 +0000</DateUpdated>
	<Type>Full</Type>
	<Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</Uri>
	<SubresourceUris>
	  <AvailablePhoneNumbers>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers</AvailablePhoneNumbers>
	  <Calls>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls</Calls>
	  <Conferences>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Conferences</Conferences>
	  <IncomingPhoneNumbers>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers</IncomingPhoneNumbers>
	  <Notifications>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Notifications</Notifications>
	  <OutgoingCallerIds>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/OutgoingCallerIds</OutgoingCallerIds>
	  <Recordings>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Recordings</Recordings>
	  <Sandbox>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Sandbox</Sandbox>
	  <SMSMessages>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages</SMSMessages>
	  <Transcriptions>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Transcriptions</Transcriptions>
	</SubresourceUris>
  </Account>
</TwilioResponse>
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
  • XML
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var accounts = AccountResource.Read("MySubaccount");

        foreach (var account in accounts)
        {
            Console.WriteLine(account.Status);
        }
    }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);

$accounts = $client->api->accounts->read(
    array("friendlyName" => "MySubaccount")
);
// Loop over the list of accounts and echo a property for each one
foreach ($accounts as $account) {
    echo $account->status;
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token  = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

# A list of account objects with the properties described above
accounts = client.accounts.list(friendly_name="MySubaccount")
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)


# Loop over accounts and print out a property for each one
@client.api.accounts.list(:friendly_name => "MySubaccount").each do |account|
  puts account.status
end
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;

class Example
{
  static void Main(string[] args)
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    var twilio = new TwilioRestClient(AccountSid, AuthToken);

    var accounts = twilio.ListSubAccounts("MySubaccount");

    foreach (var account in accounts.Accounts)
    {
      Console.WriteLine(account.Status);
    }
  }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; 
$token = "your_auth_token"; 
$client = new Services_Twilio($sid, $token);

// Loop over the list of accounts and echo a property for each one
foreach ($client->accounts->getIterator(0, 50, array(
        "FriendlyName" => "MySubaccount"
    )) as $account
) {
    echo $account->status;
}
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new account_sid, auth_token


# Loop over accounts and print out a property for each one
@client.accounts.list(:friendly_name => "MySubaccount").each do |account|
  puts account.status
end
$ curl -G https://api.twilio.com/2010-04-01/Accounts.json \
    -d "FriendlyName=MySubaccount" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.api.v2010.Account;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    ResourceSet<Account> accounts = Account.reader().setFriendlyName("MySubaccount").read();

    // Loop over accounts and print out a property for each one.
    for (Account account : accounts) {
      System.out.println(account.getStatus());
    }
  }
}
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.Account;
import com.twilio.sdk.resource.list.AccountList;
import java.util.HashMap;
import java.util.Map;

public class Example { 

  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Build a filter for the AccountList
    Map<String, String> params = new HashMap<String, String>();
    
    params.put("FriendlyName", "MySubaccount");
    
    AccountList accounts = client.getAccounts(params);
    
    // Loop over accounts and print out a property for each one.
    for (Account account : accounts) {
      System.out.println(account.getStatus());
    }
    
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"

client = Client(account_sid, auth_token)

# A list of account objects with the properties described above
accounts = client.api.accounts.list(friendly_name="MySubaccount")

for account in accounts:
    print(account.sid)
// Download the Node helper library from twilio.com/docs/node/install
// These consts are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.api.accounts.each({friendlyName: 'MySubaccount'},
                     (account) => console.log(account.status));
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = "your_auth_token";
var client = require('twilio')(accountSid, authToken);

client.accounts.list({ friendlyName: "MySubaccount" }, function(err, data) {
    data.accounts.forEach(function(account) {
        console.log(account.Status);
    });
});
[{
    "sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "friendly_name": "MySubaccount",
    "auth_token": "redacted",
    "date_created": "Tue, 25 Jan 2011 19:24:40 +0000",
    "date_updated": "Tue, 25 Jan 2011 19:25:02 +0000",
    "status": "active",
    "subresource_uris": {
        "available_phone_numbers": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers.json",
        "calls": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls.json",
        "conferences": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Conferences.json",
        "incoming_phone_numbers": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers.json",
        "notifications": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Notifications.json",
        "outgoing_caller_ids": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/OutgoingCallerIds.json",
        "recordings": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Recordings.json",
        "sandbox": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Sandbox.json",
        "sms_messages": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages.json",
        "transcriptions": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Transcriptions.json"
    },
    "type": "Full",
    "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"
}]
<TwilioResponse>
  <Accounts>
	<Account>
		<Sid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</Sid>
		<FriendlyName>MySubaccount</FriendlyName>
		<Status>active</Status>
		<AuthToken>redacted</AuthToken>
		<DateCreated>Tue, 12 Jan 2010 04:41:09 +0000</DateCreated>
		<DateUpdated>Tue, 25 Jan 2011 07:24:36 +0000</DateUpdated>
		<Type>Full</Type>
		<Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</Uri>
		<SubresourceUris>
		  <AvailablePhoneNumbers>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers</AvailablePhoneNumbers>
		  <Calls>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls</Calls>
		  <Conferences>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Conferences</Conferences>
		  <IncomingPhoneNumbers>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers</IncomingPhoneNumbers>
		  <Notifications>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Notifications</Notifications>
		  <OutgoingCallerIds>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/OutgoingCallerIds</OutgoingCallerIds>
		  <Recordings>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Recordings</Recordings>
		  <Sandbox>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Sandbox</Sandbox>
		  <SMSMessages>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SMS/Messages</SMSMessages>
		  <Transcriptions>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Transcriptions</Transcriptions>
		</SubresourceUris>
	</Account>
  </Accounts>
</TwilioResponse>
SDK Version:
  • 7.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 4.x
  • 5.x
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sAsid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$sAtoken = "your_auth_token";
$sAClient = new Client($sAsid, $sAtoken);

$sAClient->calls->create(
    '+16518675309', // The visitor's phone number
    '+14158141829', // A Twilio number in your subaccount
    array(
        "url" => 'http://twimlets.com/message?Message%5B0%5D=Hello%20from%20your%20subaccount'
    )
);
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Account Sid and Auth token for your new subaccount
sub_account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
sub_auth_token = 'your_auth_token'
@sub_account_client = Twilio::REST::Client.new(sub_account_sid, sub_auth_token)

# Make a call from your subaccount
@sub_account_client.calls.create(
  :from => '+14158141829',
  :to   => '+16518675309',
  :url  => 'http://twimlets.com/message?Message%5B0%5D=Hello%20from%20your%20subaccount'
)
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Account Sid and Auth token for your new subaccount
$sa_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$sa_token = "your_auth_token";
$sa_client = new Services_Twilio($sa_sid, $sa_token);

$sa_client->account->calls->create(
    '+14158141829', // A Twilio number in your subaccount
    '+16518675309', // The visitor's phone number
    'http://twimlets.com/message?Message%5B0%5D=Hello%20from%20your%20subaccount'
);
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Account Sid and Auth token for your new subaccount
sub_account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
sub_auth_token = 'your_auth_token'
@sub_account_client = Twilio::REST::Client.new(sub_account_sid, sub_auth_token)

# Make a call from your subaccount
@sub_account_client.account.calls.create(
  from: '+14158141829',
  to:   '+16518675309',
  url:  'http://twimlets.com/message?Message%5B0%5D=Hello%20from%20your%20subaccount'
)
// Install the Java helper library from twilio.com/docs/java/install
import java.net.URI;
import java.net.URISyntaxException;

import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Call;
import com.twilio.type.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String SUBACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String SUBACCOUNT_AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws URISyntaxException {
    Twilio.init(SUBACCOUNT_SID, SUBACCOUNT_AUTH_TOKEN);

    Call.creator(new PhoneNumber("+16518675309"), new PhoneNumber("+14158141829"),
        new URI("http://twimlets.com/message?Message%5B0%5D=Hello%20from%20your%20subaccount"))
            .create();
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
sub_account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
sub_auth_token = "your_auth_token"

sub_account_client = Client(sub_account_sid, sub_auth_token)

# Make a call from your subaccount
sub_account_client.api.account.calls.create(
    from_='+14158141829',
    to='+16518675309',
    url='http://twimlets.com/message?Message%5B0%5D=Hello%20from%20your%20subaccount'
)
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 4.x
  • 5.x
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);

// Place to store the billable usage
$timeToBill = 0;

// 30 days ago
$date = strtotime('-1 month');

$calls = $client
    ->calls
    ->read(
        array("startTime" => date('Y-m-d', $date))
    );

foreach ($calls as $call) {
    // Get time of call in minutes
    $timeToBill += ceil((float) $call->duration);
}

echo "Account $sid used $timeToBill minutes.";
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Account Sid and Auth token for your new subaccount
sub_account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
sub_auth_token = 'your_auth_token'
@sub_account_client = Twilio::REST::Client.new(sub_account_sid, sub_auth_token)
@subaccount = @sub_account_client.api.account

# Place to store the billable usage
time_to_bill = 0

# 30 days ago
start_time = Time.now - ( 30 * 24 * 60 * 60 )

# Get all calls for the last 30 days
@subaccount.calls.list(:start_time => start_time).each do |call|
  # Get time of call in minutes
  time_to_bill += (call.duration.to_f/60).ceil
end

puts "Account #{sub_account_sid} used #{time_to_bill} minutes."
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Account Sid and Auth token for your new subaccount
$sa_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$sa_token = "your_auth_token";
$sa_client = new Services_Twilio($sa_sid, $sa_token);
$subaccount = $sa_client->account;

// Place to store the billable usage
$time_to_bill = 0;

// 30 days ago
$date = strtotime('-1 month');

// Get all calls for the last 30 days
$callIterator = $sa_client->account->calls->getIterator(
    0,
    1000,
    array(
        "StartTime" => date('Y-m-d', $date)
    )
);

foreach ($callIterator as $call) {
    // Get time of call in minutes
    $time_to_bill += ceil((float) $call->duration);
}

echo "Account $sa_sid used {$time_to_bill} minutes.";
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Account Sid and Auth token for your new subaccount
sub_account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
sub_auth_token = 'your_auth_token'
@sub_account_client = Twilio::REST::Client.new sub_account_sid, sub_auth_token
@subaccount = @sub_account_client.account

# Place to store the billable usage
time_to_bill = 0

# 30 days ago
start_time = Time.now - ( 30 * 24 * 60 * 60 )

# Get all calls for the last 30 days
@subaccount.calls.list({:page => 0, :page_size => 1000, :start_time => ">#{start_time.strftime('%Y-%m-%d')}"}).each do |call|
  # Get time of call in minutes
  time_to_bill += (call.duration.to_f/60).ceil
end

puts "Account #{sub_account_sid} used #{time_to_bill} minutes."
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client
from math import ceil
import datetime

# Your Account Sid and Auth Token from twilio.com/user/account
sub_account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
sub_auth_token = "your_auth_token"
sub_account_client = Client(sub_account_sid, sub_auth_token)
sub_account = sub_account_client.api.account

# Place to store the billable usage
time_to_bill = 0

# 30 days ago
date = datetime.datetime.now() + datetime.timedelta(-30)

calls = sub_account.calls.list(start_time=date.strftime('%Y-%m-%d'))

for call in calls:
    time_to_bill += ceil(int(call.duration) / 60)

print("Account {0} used {1} minutes.").format(sub_account_sid, time_to_bill)
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
Format:
  • JSON
  • XML
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        // In the case you want to transfer numbers between subaccounts, you need to
        // know three things - the account SID of the phone number's current owner,
        // the account SID of the account you'd like to transfer the number to, and
        // the SID of the phone number you'd like to transfer
        const string currentOwnerSid = "ACYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY";
        const string newOwnerSid = "ACZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ";
        const string phoneNumberSid = "PNYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY";

        // Create an authenticated REST client
        TwilioClient.Init(accountSid, authToken);

        IncomingPhoneNumberResource.Update(phoneNumberSid,
                                           accountSid: newOwnerSid);
    }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);

// In the case you want to transfer numbers between subaccounts, you need to
// know three things - the account SID of the phone number's current owner,
// the account SID of the account you'd like to transfer the number to, and
// the SID of the phone number you'd like to transfer
$currentNumberOwnerAccountSid = "ACyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";
$newNumberOwnerAccountSid = "ACzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
$phoneNumberSid = "PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";

// Get an object from its sid. If you do not have a sid,
// check out the list resource examples on this page
$number = $client->api->accounts($currentNumberOwnerAccountSid)
    ->incomingPhoneNumbers($phoneNumberSid)
    ->update(array("accountSid" => $newNumberOwnerAccountSid));

echo $number->phoneNumber;
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient

# Use the Account Sid and Auth Token of the subaccount which currently
# owns the number you want to transfer (twilio.com/console/account/subaccounts)
account_sid = "ACyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
auth_token  = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)

# In the case you want to transfer numbers between subaccounts, you need to 
# know two things: the account SID of the account you'd like to transfer the
# number to, and the SID of the phone number you'd like to transfer
new_owner_sid = "ACzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
number_sid = "PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"

number = client.phone_numbers.update(number_sid, account_sid=new_owner_sid)
print(number.phone_number)
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    var accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    var authToken = "your_auth_token";

    // In the case you want to transfer numbers between subaccounts, you need to 
    // know three things - the account SID of the phone number's current owner, 
    // the account SID of the account you'd like to transfer the number to, and 
    // the SID of the phone number you'd like to transfer
    var currentOwnerSid = "ACyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";
    var newOwnerSid = "ACzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
    var phoneNumberSid = "PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";

    // Create an authenticated REST client
    var twilio = new TwilioRestClient(accountSid, authToken, currentOwnerSid);

    var options = new PhoneNumberOptions();
    options.AccountSid = newOwnerSid;
    
    twilio.UpdateIncomingPhoneNumber(phoneNumberSid, options);
  }
}
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; 
$token = "your_auth_token"; 
$client = new Services_Twilio($sid, $token);

// In the case you want to transfer numbers between subaccounts, you need to 
// know three things - the account SID of the phone number's current owner, 
// the account SID of the account you'd like to transfer the number to, and 
// the SID of the phone number you'd like to transfer
$currentNumberOwnerAccountSid = "ACyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";
$newNumberOwnerAccountSid = "ACzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
$phoneNumberSid = "PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";

// Get an object from its sid. If you do not have a sid,
// check out the list resource examples on this page
$number = $client->accounts->get($currentNumberOwnerAccountSid)
    ->incoming_phone_numbers->get($phoneNumberSid);

$number->update(array(
    "AccountSid" => $newNumberOwnerAccountSid,
));
echo $number->phone_number;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'rubygems'          # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new account_sid, auth_token

# In the case you want to transfer numbers between subaccounts, you need to 
# know three things - the account SID of the phone number's current owner, 
# the account SID of the account you'd like to transfer the number to, and 
# the SID of the phone number you'd like to transfer
current_owner_sid = 'ACyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
new_owner_sid = 'ACzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'
phone_number_sid = 'PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
 
# Update the number
@subaccount = @client.accounts.get(current_owner_sid)
@number = @subaccount.incoming_phone_numbers.get(phone_number_sid)
@number.update(:account_sid => new_owner_sid)
puts @number.phone_number
$ curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy/IncomingPhoneNumbers/PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy.json \
    -d "AccountSid=ACzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.IncomingPhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  // In the case you want to transfer numbers between subaccounts, you need to 
  // know three things - the account SID of the phone number's current owner, 
  // the account SID of the account you'd like to transfer the number to, and 
  // the SID of the phone number you'd like to transfer
  public static final String CURRENT_OWNER_SID = "ACyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";
  public static final String NEW_OWNER_SID = "ACzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
  public static final String NUMBER_SID = "PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    IncomingPhoneNumber number = IncomingPhoneNumber
        .updater(CURRENT_OWNER_SID, NUMBER_SID)
        .setAccountSid(NEW_OWNER_SID)
        .update();

    System.out.println(number.getDateUpdated());
  }
}
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.IncomingPhoneNumber;
import com.twilio.sdk.resource.list.IncomingPhoneNumberList;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

public class Example { 

  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String ORIGINAL_ACCT = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

    // Get an object from its sid. If you do not have a sid,
    // check out the list resource examples on this page
    IncomingPhoneNumber number = client.getAccount(ORIGINAL_ACCT)
      .getIncomingPhoneNumber("PN2a0747eba6abf96b7e3c3ff0b4530f6e");
    // Build a filter for the IncomingPhoneNumberList
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("AccountSid", "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"));
    number.update(params);
    
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

# In the case you want to transfer numbers between subaccounts, you need to
# know three things - the account SID of the phone number's current owner,
# the account SID of the account you'd like to transfer the number to, and
# the SID of the phone number you'd like to transfer
current_owner_sid = "ACyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
new_owner_sid = "ACzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
number_sid = "PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"

number = client.api.accounts(current_owner_sid) \
               .incoming_phone_numbers(number_sid) \
               .update(account_sid=new_owner_sid)

print(number.phone_number)
// Download the Node helper library from twilio.com/docs/node/install
// These consts are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

// In the case you want to transfer numbers between accounts, you need to know
// three things - the account SID of the phone number's current owner, the
// account SID of the account you'd like to transfer the number to, and the SID
// of the phone number you'd like to transfer
const currentNumberOwnerAccountSid = 'ACyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy';
const newNumberOwnerAccountSid = 'ACzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
const phoneNumberSid = 'PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy';

client.api.accounts(currentNumberOwnerAccountSid)
  .incomingPhoneNumbers(phoneNumberSid)
  .update({
    accountSid: newNumberOwnerAccountSid // specify new account owner
  })
  .then((number) => console.log(number));
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var client = require('twilio')(accountSid, authToken);

// In the case you want to transfer numbers between accounts, you need to know
// three things - the account SID of the phone number's current owner, the
// account SID of the account you'd like to transfer the number to, and the SID
// of the phone number you'd like to transfer
var currentNumberOwnerAccountSid = 'ACyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy';
var newNumberOwnerAccountSid = 'ACzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
var phoneNumberSid = 'PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy';

var phoneNumber = client
  .accounts(currentNumberOwnerAccountSid)
  .incomingPhoneNumbers(phoneNumberSid);

phoneNumber.update({
  accountSid: newNumberOwnerAccountSid // Specify a new account as owner
}, function(err, number) {
  console.log(number);
});
{
	"sid": "PN2a0747eba6abf96b7e3c3ff0b4530f6e",
	"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
	"friendly_name": "My Company Line",
	"phone_number": "+15105647903",
	"voice_url": "http://demo.twilio.com/docs/voice.xml",
	"voice_method": "POST",
	"voice_fallback_url": null,
	"voice_fallback_method": "POST",
	"voice_caller_idlookup": null,
	"date_created": "Mon, 16 Aug 2010 23:00:23 +0000",
	"date_updated": "Mon, 16 Aug 2010 23:00:23 +0000",
	"sms_url": null,
	"sms_method": "POST",
	"sms_fallback_url": null,
	"sms_fallback_method": "GET",
	"capabilities": {
		"voice": null,
		"sms": null
	},
	"status_callback": null,
	"status_callback_method": null,
	"api_version": "2010-04-01",
	"uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/IncomingPhoneNumbers\/PN2a0747eba6abf96b7e3c3ff0b4530f6e.json"
}
<TwilioResponse>
	<IncomingPhoneNumber>
		<Sid>PN2a0747eba6abf96b7e3c3ff0b4530f6e</Sid>
		<AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
		<FriendlyName>My Company Line</FriendlyName>
		<PhoneNumber>+15105647903</PhoneNumber>
		<VoiceUrl>http://demo.twilio.com/docs/voice.xml</VoiceUrl>
		<VoiceMethod>POST</VoiceMethod>
		<VoiceFallbackUrl/>
		<VoiceFallbackMethod>POST</VoiceFallbackMethod>
		<VoiceCallerIdLookup>false</VoiceCallerIdLookup>
		<DateCreated>Mon, 16 Aug 2010 23:00:23 +0000</DateCreated>
		<DateUpdated>Mon, 16 Aug 2010 23:00:23 +0000</DateUpdated>
		<SmsUrl/>
		<SmsMethod>POST</SmsMethod>
		<SmsFallbackUrl/>
		<SmsFallbackMethod>GET</SmsFallbackMethod>
		<Capabilities>
			<Voice>true</Voice>
			<SMS>true</SMS>
		</Capabilities>
		<StatusCallback/>
		<StatusCallbackMethod/>
		<ApiVersion>2010-04-01</ApiVersion>
		<Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers/PN2a0747eba6abf96b7e3c3ff0b4530f6e</Uri>
	</IncomingPhoneNumber>
</TwilioResponse>