REST API: Subaccount

Twilio のサブアカウントは、アカウントが「所有」しているアカウントです。アカウントの利用者が Twilio を利用するたびにサブアカウントを使ってそれを独立させて、他のすべてのサブアカウントから分離された状態に維持することができます。これにより、各利用者の活動やリソースを簡単に管理できるようになります。

注記:1 つのマスターアカウントには、デフォルトで 1000 個のサブアカウントを作成できます。もしそれ以上必要であればサポートにご連絡ください。

課金

Twilio はすべてのサブアカウントの利用分を、直接マスター アカウントへ課金します。 すべてのアカウントの Twilio の残高は一括して管理されます。 Twilio のマスター アカウントが一時停止された場合、サブアカウントも一時停止されます。

サブアカウントの請求の計算にスキップ >>

認証

マスター アカウント のクレデンシャル (AccountSid と AuthToken) を使って Twilio の REST API にアクセスし、マスター アカウントと同じようにサブアカウントも操作することができます。 サブアカウントの AccountSid と AuthToken を使って、そのサブアカウントのリソースにアクセスすることもできます。サブアカウントのクレデンシャルを使って、マスター アカウントや他のサブアカウントのリソースにアクセスすることはできません。

国際通話

Twilio は現在、お客様が国際電話の不正利用のリスクを最小化するのに役立つ方法に取り組んでおり、Twilio サブアカウントで特定の国の宛先にダイヤルする方法を提供しています。ご質問がある場合はサポートにご連絡ください。

パーミッション

サブアカウントは、マスターアカウントの音声とSMSメッセージングのアクセス許可(地理による許可など)を引き継ぎます。電話番号を引き継ぐことはできません。

サブアカウントを作成する

新しいサブアカウントを作成するには、ユーザーの Accounts リスト リソース URI に HTTP POST リクエストを発行してください。

/2010-04-01/Accounts

リクエストが成功すると、Twilio は新しいAccount リソースの表現を返します。

POSTパラメータ

オプションパラメーター

サブアカウント作成のリクエストには、以下のパラメーターを含めることができます。

パラメーター 説明
FriendlyName 新しいサブアカウントの、人間が読みやすい形式の説明です。64 文字まで設定できます。 デフォルトでは、「SubAccount Created at {YYYY-MM-DD HH:MM am または pm}」となります。

FriendlyName プロパティは、アカウントを整理して自分のシステムの情報へ関連付ける際に役立ちます。 たとえば、ある顧客について、自分のアプリケーションのデータベースのプライマリ キーを FriendlyName とするサブアカウントを作成したい場合があります。

サブアカウントの作成
  • C#
  • curl
  • Java
  • Node.js
  • PHP
  • Python
  • Ruby
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
// 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->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.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.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.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.accounts.create({friendlyName: 'Submarine'})
  .then((account) => process.stdout.write(account.sid));
// 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
// 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());
  }
}
// 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);
});
出力を表示
  • JSON
  • XML
{
    "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>
サブアカウントの作成

サブアカウントを使い始めよう

サブアカウントは、Twilio を利用するたびにそれを独立させる非常に便利な方法であり、利用者、エージェント、または従業員の代わりに処理を実行します。

Twilio を活用したホスティングサービスを運営している場合、登録した利用者ごとに Twilio のサブアカウントを作成できます。利用者がそのサービスのアカウントを解約する場合、単純に、関連付けられている Twilio のサブアカウントを無効化できます。

サブアカウントではパレントアカウントと同様に Twilio REST API, 電話番号の所有、Caller ID、アプリケーション、および SIP ドメインを利用できます。サブアカウントの通話、メッセージ、録音、およびトランスクリプションは、他のサブアカウントに影響を与えずに、管理できます。

サブアカウントを検索する

AccountSid を使って、REST API で特定のサブアカウントとそれに関連するリソースをクエリできます。

SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
// 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->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
$ 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.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.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.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .fetch()
  .then((account) => console.log(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
// 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());
  }
}
// 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);
});
出力を表示
  • JSON
  • XML
{
    "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>
アカウント Sid を使ってサブアカウントリソースを返す

サブアカウントの AccoundSid が不明な場合も、FriendlyName がわかれば、FriendlyName クエリ文字列フィルターで Accounts リストリソースをクエリできます。

SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
// 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->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.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.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.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.accounts.each({friendlyName: 'MySubaccount'},
                     (account) => console.log(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 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
// 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());
    }
  }
}
// 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);
    });
});
出力を表示
  • JSON
  • XML
[{
    "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バージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 4.x
  • 5.x
<?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'
)
<?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'
)
// 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.account.calls.create(
    from_='+14158141829',
    to='+16518675309',
    url='http://twimlets.com/message?Message%5B0%5D=Hello%20from%20your%20subaccount'
)
サブアカウントからの通話の発信

サブアカウント利用の請求の計算

多くの場合、サブアカウントに発生した請求を計算できます。利用者のサブアカウントを作成し、毎月の使用料金を請求する必要があるとします。

次に、直近 30 日間の利用者の通話分数を計算する方法を示します。

SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 4.x
  • 5.x
<?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."
<?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.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."
# 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.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)
サブアカウント利用の請求の計算

サブアカウントを一時停止する

一時停止中のサブアカウントは、電話をかける、受ける、SMS メッセージを送る、受け取ることができません。これは、利用者が支払わないときに、支払が正しく行われるまでそのアカウントを一時停止したい場合に便利です。ただし、サブアカウントが所有する電話番号は毎月請求されます。

アカウントを一時停止するには、Status パラメーターの値を 'suspended' として POST します。

サブアカウントの一時停止を解除するには、Status パラメーターの値を「active」として POST します。アカウントが復元され、すべてのサービスが利用可能になります。

詳細とサンプルは、 Account インスタンス リソースの POST セクションを参照してください。

サブアカウントを一時停止するには、マスター アカウントの認証クレデンシャルを使用する必要がありますので、注意してください。 また、自分のマスター アカウントを一時停止することはできません。

サブアカウントを削除する

ユーザーが提供するサービスの顧客がアカウントを解約した時に、Status パラメーターの値を「closed」としてサブアカウントのリソース URI に POST すると、関連付けられた Twilio サブアカウントを削除できます。

サブアカウントを削除すると、Twilio はこのサブアカウントに割り当てられたすべての電話番号を開放し、このサブアカウントを完全に停止します。 削除されたアカウントを使って、通話の発信や受信、SMS メッセージの送受信はできません。 削除されたアカウントは、完全に利用不可となります。アカウント リストには引き続き表示され、履歴データへはアクセスできますが、一度削除されたアカウントを再開することはできません。

詳細とサンプルは、 Account インスタンス リソースの POST セクションを参照してください。

サブアカウントを削除するには、マスターアカウントの認証クレデンシャルを使用する必要がありますので、注意してください。 また、自分のマスターアカウントを削除することはできません。

アカウント間で電話番号を交換する

サブアカウント間、またはマスター アカウントとサブアカウントの間で、電話番号を移動できます。 電話番号を移動する API リクエストは、必ずマスター アカウントのクレデンシャルを使用して発行してください。

自分が管理する 2 つのアカウントの間で電話番号を移動するには、 IncomingPhoneNumber インスタンス リソース に HTTP POST リクエストを発行します。 POST のボディーの AccountSid パラメーターに、移動したい番号の所有者となるアカウントの AccountSid をセットします。 これにより、電話番号は元のアカウントから移動され、新しいアカウントの IncomingPhoneNumbers リスト リソースで使用可能になります。他のすべてのプロパティは引き継がれます。

住所の必要な電話番号を移動したい場合、新しいサブアカウントに適切な住所(Address)を記載する必要があります。

なお、前述の方法でサブアカウントを削除すると、このアカウントの電話番号はすべて開放されますので、電話番号を保持しておきたい場合は、事前にすべての番号をマスター アカウントへ移動しておくという方法もあります。

ある電話番号を AC00000000000000000000000000000001 から AC00000000000000000000000000000002 へ移動します。

サブアカウント間で電話番号を移動する
  • C#
  • curl
  • Java
  • Node.js
  • PHP
  • Python
  • Ruby
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
// 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->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)
$ 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.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.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.accounts(currentNumberOwnerAccountSid)
  .incomingPhoneNumbers(phoneNumberSid)
  .update({ 
    accountSid: newNumberOwnerAccountSid // specify new account owner
  })
  .then((number) => console.log(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
// 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());
  }
}
// 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);
});
出力を表示
  • JSON
  • XML
{
	"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>
サブアカウント間で電話番号を移動する
1 / 1
Loading Code Samples...
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • 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->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.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.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.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.accounts.create({friendlyName: 'Submarine'})
  .then((account) => process.stdout.write(account.sid));
// 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
// 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());
  }
}
// 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バージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • 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->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
$ 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.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.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.accounts('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .fetch()
  .then((account) => console.log(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
// 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());
  }
}
// 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バージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • 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->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.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.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.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.accounts.each({friendlyName: 'MySubaccount'},
                     (account) => console.log(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 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
// 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());
    }
  }
}
// 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バージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 4.x
  • 5.x
<?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'
)
<?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'
)
// 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.account.calls.create(
    from_='+14158141829',
    to='+16518675309',
    url='http://twimlets.com/message?Message%5B0%5D=Hello%20from%20your%20subaccount'
)
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 4.x
  • 5.x
<?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."
<?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.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."
# 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.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バージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
形式:
  • 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->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)
$ 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.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.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.accounts(currentNumberOwnerAccountSid)
  .incomingPhoneNumbers(phoneNumberSid)
  .update({ 
    accountSid: newNumberOwnerAccountSid // specify new account owner
  })
  .then((number) => console.log(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
// 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());
  }
}
// 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>