REST API: API キー

APIキーはTwilioAPIにアクセスするためのクレデンシャルを表します。2つの理由があります。

APIキーはREST APIもしくはアカウントコンソールを通じて提供・破棄されます。TwilioAPIへのアクセス管理に非常にパワフルでフレキシブルな原理を提供します。例えば、APIキーを異なった開発者に、アプリケーション毎の異なったサブシステムそれぞれに発行することができます。APIキーは個別に破棄できます、APIクレデンシャルのライフサイクルを完全に管理できます。

APIキーを使用してREST APIの認証を行うサンプルを、以下に示します。

SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

/// Instantiate a client using your API key and secret - but then, you'll need to
// manually specify your main account (or subaccount) SID when making a request
$accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$apiKey = 'SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$apiSecret = 'your_api_secret';
$client = new Client($apiKey, $apiSecret, $accountSid);

// Send a message for the main account
$message = $client->messages->create(
    '+15558675309', // destination phone number
    array(
        'from' => '+15017250604', // twilio number in your account
        'body' => 'Never gonna give you up.'
    )
);

echo $message->sid;
# 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'
api_key = 'SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
api_secret = 'your_api_secret'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(api_key, api_secret, account_sid)

@message = @client.messages.create(
  to: '+15558675309',
  from: '+15017250604',
  body: 'Hello World!'
)

puts @message.sid
$ curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages.json \
    --data-urlencode "Body=Never gonna give you up." \
    --data-urlencode "To=+15558675309" \
    --data-urlencode "From=+15017250604" \
    -u 'SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_api_secret'
# 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"
api_key = "SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
api_secret = "your_api_secret"

client = Client(api_key, api_secret, account_sid)

message = client.messages.create("+15558675309",
                                 from_='+15017250604',  # twilio number
                                 body='Never gonna give you up.')

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

// Create a message for your account (send an outbound SMS)
client.messages.create({
    to: '+15558675309', // the destination phone number
    from: '+15017250604', // a Twilio number in your account
    body: 'Never gonna give you up.', // body of a text message
  })
  .then((messageData) => console.log(messageData.sid));
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('./twilio-php/Services/Twilio.php');

// Instantiate a client using your API key and secret - but then, you'll need to
// manually specify your main account (or subaccount) SID when making a request
$accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$apiKey = 'SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$apiSecret = 'your_api_secret';
$client = new Services_Twilio($apiKey, $apiSecret);

// Get a reference to the main account
$account = $client->accounts->get($accountSid);

// Send a message for the main account
$message = $account->messages->create(
    array(
      'To' => '+15558675309', // destination phone number
      'From' => '+15017250604', // twilio number in your account
      'Body' => 'Never gonna give you up.'
    )
);

echo $message->sid;
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Message;
import com.twilio.type.PhoneNumber;

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 API_KEY = "SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String API_SECRET = "your_api_secret";

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

    Message message = Message.creator(new PhoneNumber("+15558675309"),
        new PhoneNumber("+15017250604"), "Never gonna give you up.").create();

    System.out.println(message.getSid());
  }
}
// Download the Node helper library from twilio.com/docs/node/install
// Instantiate a client using your API key and secret - but then, you'll need to
// manually specify your main account (or subaccount) SID when making a request
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var apiKey = 'SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var apiSecret = 'your_api_secret';
var client = require('twilio')(apiKey, apiSecret);

// Create a reference to your Twilio account
var account = client.accounts(accountSid);

// Create a message for your account (send an outbound SMS)
account.messages.create({
  to: '+15558675309', // the destination phone number
  from: '+15017250604', // a Twilio number in your account
  body: 'Never gonna give you up.' // body of a text message
}, (err, messageData) => {
  // print SID of the message you just sent
  console.log(messageData.sid);
});
APIキーペアを使用してメッセージを送信する

APIキーインスタンスリソース

リソース URI

https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Keys/{API KeySid}

リソースのプロパティ

APIキーは下記のプロパティーで表されます。

プロパティ 説明
Sid このAPIキーを識別する 34 文字の文字列です。APIをを認証する際、ベーシック認証としてuserを利用します。
FriendlyName このリソースを説明する文字列です。アプリケーションで選択されています。64 文字まで設定できます。
Secret アプリケーションのシークレットはアクセストークンをサインする際、REST APIを認証する際に使われます。(ベーシック認証の際passwordを利用します。
注 : セキュリティ上の理由からこのフィールドはAPIキーが最初に生成された時「のみ」表示されます。
DateCreated APIキーが生成された日時、UTC ISO 8601 フォーマットで提供
DateUpdated APIキーが生成されたもっとも直近の日時、UTC ISO 8601 フォーマットで提供

HTTP GET

上述のプロパティを含む、APIキーの表現を返します。

注 : セキュリティ上の理由からこのSecretフィールドはAPIキーが最初に生成された時「のみ」表示されます。

APIキーの例注 : API キーのSecretフィールドが編集済みの場合、SecretフィールドはAPIキーが最初に作成された時「のみ」表示されます。

API キーの詳細の取得
  • C#
  • curl
  • Java
  • Node.js
  • PHP
  • Python
  • Ruby
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
  • xml
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.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";
        TwilioClient.Init(accountSid, authToken);

        var key = KeyResource.Fetch("SK2a0747eba6abf96b7e3c3ff0b4530f6e");

        Console.WriteLine(key.FriendlyName);
    }
}
<?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);

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

echo $key->friendlyName;
# 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)

key = client.keys.get("SK2a0747eba6abf96b7e3c3ff0b4530f6e")
print(key.friendly_name)
# 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'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)

@key = @client.account.keys('SK2a0747eba6abf96b7e3c3ff0b4530f6e').fetch

puts @key.friendly_name
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Keys/SK2a0747eba6abf96b7e3c3ff0b4530f6e.json \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Keys/SK2a0747eba6abf96b7e3c3ff0b4530f6e \
    -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.Key;

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
    Key key = client.getAccount().getKey("SK2a0747eba6abf96b7e3c3ff0b4530f6e");
    System.out.println(key.getFriendlyName());

  }
}
# 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)

key = client.keys("SK2a0747eba6abf96b7e3c3ff0b4530f6e") \
            .fetch()

print(key.friendly_name)
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers 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.keys('SK2a0747eba6abf96b7e3c3ff0b4530f6e')
  .fetch()
  .then((key) => console.log(key.friendlyName));
// 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 key = twilio.GetKey("SK2a0747eba6abf96b7e3c3ff0b4530f6e");

    Console.WriteLine(key.FriendlyName);
  }
}
<?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
$key = $client->account->keys->get("SK2a0747eba6abf96b7e3c3ff0b4530f6e");
echo $key->friendly_name;
# 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
@key = @client.account.keys.get("SK2a0747eba6abf96b7e3c3ff0b4530f6e")
puts @key.friendly_name
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Key;

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
    Key key = Key.fetcher("SK2a0747eba6abf96b7e3c3ff0b4530f6e").fetch();

    System.out.println(key.getFriendlyName());
  }
}
// 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.keys("SK2a0747eba6abf96b7e3c3ff0b4530f6e").get(function(err, key) {
    console.log(key.friendlyName);
});
出力を表示
  • JSON
  • XML
{
  "date_updated": "2015-05-14T23:44:32Z",
  "date_created": "2015-05-14T23:44:32Z",
  "friendly_name": "Foobar",
  "sid": "SKdac2dad1695721987de823226f0a62a4"
}
<?xml version='1.0' encoding='UTF-8'?>
<TwilioResponse>
    <Key>
        <Sid>SKdac2dad1695721987de823226f0a62a4</Sid>
        <FriendlyName>Foobar</FriendlyName>
        <DateCreated>2015-05-14T23:44:32Z</DateCreated>
        <DateUpdated>2015-05-14T23:44:32Z</DateUpdated>
    </Key>
</TwilioResponse>
API キーの詳細の取得

HTTP POST

APIキーのフィールドのアップデートが試行され、成功するとアップデートされたリソース表現を返します。成功すると、レスポンスはHTTP GETと同じものになります。

オプションパラメーター

下記の1つ以上のパラメータをAPIキーアップデートの際含める必要があります。

パラメーター 説明
FriendlyName このリソースを説明する文字列です。アプリケーションで選択されています。64 文字まで設定できます。

HTTP PUT

サポートしません。

HTTP DELETE

APIキーを削除するこれはREST APIへの認証を破棄し、同一のシークレットを使って作られた全てのアクセストークンが無効化されます。

削除に成功すると、本文(Body)のない HTTP 204 レスポンスを返します。

注 : マスターキーである該当のAccountSID・AuthToken を使った場合のみキーを削除できます。

APIキーリストリソース

リソース URI

https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Keys

HTTP GET

このアカウントのAPIキーのリストを返します。DateUpdated で並び替えられます。このリストはページ情報を含みます。

全てのAPIキーが含まれます。

アカウントに含まれる全てのAPIキーを検索します。

すべての API キーの取得
  • curl
  • Java
  • Node.js
  • PHP
  • Python
  • Ruby
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
<?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);

// Loop over the list of apps and echo a property for each one
foreach ($client->keys->read() as $key) {
    echo $key->friendlyName;
}
# 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 app objects with the properties described above
keys = client.keys.list()
for key in keys:
    print(key.friendly_name)
# 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'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)

@client.account.keys.list.each do |key|
  puts key.friendly_name
end
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Keys.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.Key;
import com.twilio.sdk.resource.list.KeyList;

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);

    KeyList keys = client.getAccount().getKeys();

    // Loop over keys and print out a property for each one.
    for (Key key : keys) {
      System.out.println(key.getFriendlyName());
    }

  }
}
# 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 app objects with the properties described above
keys = client.keys.list()
for key in keys:
    print(key.friendly_name)
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers 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.keys
  .each((key) => console.log(friendlyName));
<?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 apps and echo a property for each one
foreach ($client->account->keys as $key) {
    echo $key->friendly_name;
}
# 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


# Loop over apps and print out a property for each one
@client.account.keys.list.each do |key|
  puts key.friendly_name
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.Key;

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<Key> keys = Key.reader().read();

    // Loop over keys and print out a property for each one.
    for (Key key : keys) {
      System.out.println(key.getFriendlyName());
    }
  }
}
// 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.keys.list(function(err, data) {
    data.keys.forEach(function(key) {
        console.log(key.friendlyName);
    });
});
出力を表示
  • JSON
  • XML
{
	"page": 0,
	"page_size": 50,
	"uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/Keys.json",
	"first_page_uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/Keys.json?Page=0&PageSize=50",
	"previous_page_uri": null,
	"next_page_uri": null,
	"keys": [
            {
                "date_updated": "2015-05-14T23:44:32Z",
                "date_created": "2015-05-14T23:44:32Z",
                "friendly_name": null,
                "sid": "SKdac2dad1695721987de823226f0a62a4"
            },
            ...
	]
}
<TwilioResponse>
	<Keys page="0" pagesize="50" uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Keys" firstpageuri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Keys?Page=0&PageSize=50" previouspageuri="" nextpageuri="">
            <Key>
                <Sid>SKdac2dad1695721987de823226f0a62a4</Sid>
                <FriendlyName>Foobar</FriendlyName>
                <DateCreated>2015-05-14T23:44:32Z</DateCreated>
                <DateUpdated>2015-05-14T23:44:32Z</DateUpdated>
            </Key>
	</Keys>
</TwilioResponse>
すべての API キーの取得

HTTP POST

新しいAPIキーを作成します。

注 : マスターキーである該当のAccountSID・AuthToken を使った場合のみ新しいキーを生成できます。

オプションパラメーター

リクエストには、次のパラメーターを含めることができます。

パラメーター 説明
FriendlyName このリソースを説明する文字列です。アプリケーションで選択されています。64 文字まで設定できます。

リクエストが成功すると、Twilio は新しいAPIキーを返します。この表現はAPIキーインスタンスリソースを使ってGETした場合と同様です。ただしSecretが含まれる場合は異なります。

注 : セキュリティ上の理由から APIキーのシークレットはAPIキーが最初に生成された時「のみ」表示されます。アプリケーションは APIキーのSIDとシークレットをアクセストークンを将来作成するときのため、安全な場所に保管するべきです。

フレンドリー名 "User Jenny" という APIキーを 生成する

APIキーを作成する
  • C#
  • curl
  • Java
  • Node.js
  • PHP
  • Python
  • Ruby
SDKバージョン:
  • 4.x
  • 5.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.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";
        TwilioClient.Init(accountSid, authToken);

        var key = NewKeyResource.Create(friendlyName: "User Jenny");

        Console.WriteLine(key.Sid);
        Console.WriteLine(key.Secret);
    }
}
<?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);

$key = $client->newKeys->create(
    array('friendlyName' => 'User Jenny')
);

echo $key->sid;
echo $key->secret;
# 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)

key = client.keys.create(friendly_name="User Jenny")
print(key.sid)
# 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'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)

@key = @client.account.new_keys.create(friendly_name: 'User Jenny')

puts @key.sid
puts @key.secret
$ curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Keys.json \
    -d "FriendlyName=User+Jenny" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
# 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)

key = client.new_keys \
            .create(friendly_name="User Jenny")

print(key.sid)
print(key.secret)
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers 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.account.newKeys.create({
    friendlyName: 'User Jenny',
  })
  .then((key) => {
    process.stdout.write(key.sid);
    process.stdout.write(key.secret);
  });
// 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 key = twilio.AddKey("User Jenny");

    Console.WriteLine(key.Sid);
    Console.WriteLine(key.Secret);
  }
}
<?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);

$key = $client->account->keys->create(array("FriendlyName" => "User Jenny"));
echo $key->sid;
echo $key->secret;
# 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

key = @client.account.keys.create(friendly_name: "User Jenny")
puts key.sid
puts key.secret
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.NewKey;

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);

    NewKey key = NewKey.creator().setFriendlyName("User Jenny").create();

    System.out.println(key.getSid());
    System.out.println(key.getSecret());
  }
}
// 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.keys.create({
    friendlyName: "User Jenny",
}, function(err, key) {
    process.stdout.write(key.sid);
    process.stdout.write(key.secret);
});
出力を表示
  • JSON
  • XML
{
    "secret": "RdXY0fRhkrP1scKYpv2SOHV2GrqHGjPw",
    "date_updated": "2015-05-14T23:44:32Z",
    "date_created": "2015-05-14T23:44:32Z",
    "friendly_name": "User Jenny",
    "sid": "SKdac2dad1695721987de823226f0a62a4"
}
<?xml version='1.0' encoding='UTF-8'?>
<TwilioResponse>
    <Key>
        <Secret>rD7Y0frhkrPOzcKypv2SOHV8GrXHGJPw</Secret>
        <Sid>SKdac2dad1695721987de823226f0a62a4</Sid>
        <FriendlyName>User Jenny</FriendlyName>
        <DateCreated>2015-05-14T23:44:32Z</DateCreated>
        <DateUpdated>2015-05-14T23:44:32Z</DateUpdated>
    </Key>
</TwilioResponse>
APIキーを作成する

HTTP PUT

サポートしません。

HTTP DELETE

サポートしません。

1 / 1
Loading Code Samples...
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

/// Instantiate a client using your API key and secret - but then, you'll need to
// manually specify your main account (or subaccount) SID when making a request
$accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$apiKey = 'SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$apiSecret = 'your_api_secret';
$client = new Client($apiKey, $apiSecret, $accountSid);

// Send a message for the main account
$message = $client->messages->create(
    '+15558675309', // destination phone number
    array(
        'from' => '+15017250604', // twilio number in your account
        'body' => 'Never gonna give you up.'
    )
);

echo $message->sid;
# 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'
api_key = 'SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
api_secret = 'your_api_secret'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(api_key, api_secret, account_sid)

@message = @client.messages.create(
  to: '+15558675309',
  from: '+15017250604',
  body: 'Hello World!'
)

puts @message.sid
$ curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages.json \
    --data-urlencode "Body=Never gonna give you up." \
    --data-urlencode "To=+15558675309" \
    --data-urlencode "From=+15017250604" \
    -u 'SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_api_secret'
# 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"
api_key = "SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
api_secret = "your_api_secret"

client = Client(api_key, api_secret, account_sid)

message = client.messages.create("+15558675309",
                                 from_='+15017250604',  # twilio number
                                 body='Never gonna give you up.')

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

// Create a message for your account (send an outbound SMS)
client.messages.create({
    to: '+15558675309', // the destination phone number
    from: '+15017250604', // a Twilio number in your account
    body: 'Never gonna give you up.', // body of a text message
  })
  .then((messageData) => console.log(messageData.sid));
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('./twilio-php/Services/Twilio.php');

// Instantiate a client using your API key and secret - but then, you'll need to
// manually specify your main account (or subaccount) SID when making a request
$accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$apiKey = 'SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$apiSecret = 'your_api_secret';
$client = new Services_Twilio($apiKey, $apiSecret);

// Get a reference to the main account
$account = $client->accounts->get($accountSid);

// Send a message for the main account
$message = $account->messages->create(
    array(
      'To' => '+15558675309', // destination phone number
      'From' => '+15017250604', // twilio number in your account
      'Body' => 'Never gonna give you up.'
    )
);

echo $message->sid;
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Message;
import com.twilio.type.PhoneNumber;

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 API_KEY = "SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String API_SECRET = "your_api_secret";

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

    Message message = Message.creator(new PhoneNumber("+15558675309"),
        new PhoneNumber("+15017250604"), "Never gonna give you up.").create();

    System.out.println(message.getSid());
  }
}
// Download the Node helper library from twilio.com/docs/node/install
// Instantiate a client using your API key and secret - but then, you'll need to
// manually specify your main account (or subaccount) SID when making a request
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var apiKey = 'SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var apiSecret = 'your_api_secret';
var client = require('twilio')(apiKey, apiSecret);

// Create a reference to your Twilio account
var account = client.accounts(accountSid);

// Create a message for your account (send an outbound SMS)
account.messages.create({
  to: '+15558675309', // the destination phone number
  from: '+15017250604', // a Twilio number in your account
  body: 'Never gonna give you up.' // body of a text message
}, (err, messageData) => {
  // print SID of the message you just sent
  console.log(messageData.sid);
});
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
  • xml
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.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";
        TwilioClient.Init(accountSid, authToken);

        var key = KeyResource.Fetch("SK2a0747eba6abf96b7e3c3ff0b4530f6e");

        Console.WriteLine(key.FriendlyName);
    }
}
<?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);

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

echo $key->friendlyName;
# 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)

key = client.keys.get("SK2a0747eba6abf96b7e3c3ff0b4530f6e")
print(key.friendly_name)
# 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'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)

@key = @client.account.keys('SK2a0747eba6abf96b7e3c3ff0b4530f6e').fetch

puts @key.friendly_name
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Keys/SK2a0747eba6abf96b7e3c3ff0b4530f6e.json \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Keys/SK2a0747eba6abf96b7e3c3ff0b4530f6e \
    -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.Key;

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
    Key key = client.getAccount().getKey("SK2a0747eba6abf96b7e3c3ff0b4530f6e");
    System.out.println(key.getFriendlyName());

  }
}
# 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)

key = client.keys("SK2a0747eba6abf96b7e3c3ff0b4530f6e") \
            .fetch()

print(key.friendly_name)
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers 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.keys('SK2a0747eba6abf96b7e3c3ff0b4530f6e')
  .fetch()
  .then((key) => console.log(key.friendlyName));
// 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 key = twilio.GetKey("SK2a0747eba6abf96b7e3c3ff0b4530f6e");

    Console.WriteLine(key.FriendlyName);
  }
}
<?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
$key = $client->account->keys->get("SK2a0747eba6abf96b7e3c3ff0b4530f6e");
echo $key->friendly_name;
# 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
@key = @client.account.keys.get("SK2a0747eba6abf96b7e3c3ff0b4530f6e")
puts @key.friendly_name
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Key;

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
    Key key = Key.fetcher("SK2a0747eba6abf96b7e3c3ff0b4530f6e").fetch();

    System.out.println(key.getFriendlyName());
  }
}
// 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.keys("SK2a0747eba6abf96b7e3c3ff0b4530f6e").get(function(err, key) {
    console.log(key.friendlyName);
});
{
  "date_updated": "2015-05-14T23:44:32Z",
  "date_created": "2015-05-14T23:44:32Z",
  "friendly_name": "Foobar",
  "sid": "SKdac2dad1695721987de823226f0a62a4"
}
<?xml version='1.0' encoding='UTF-8'?>
<TwilioResponse>
    <Key>
        <Sid>SKdac2dad1695721987de823226f0a62a4</Sid>
        <FriendlyName>Foobar</FriendlyName>
        <DateCreated>2015-05-14T23:44:32Z</DateCreated>
        <DateUpdated>2015-05-14T23:44:32Z</DateUpdated>
    </Key>
</TwilioResponse>
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
<?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);

// Loop over the list of apps and echo a property for each one
foreach ($client->keys->read() as $key) {
    echo $key->friendlyName;
}
# 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 app objects with the properties described above
keys = client.keys.list()
for key in keys:
    print(key.friendly_name)
# 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'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)

@client.account.keys.list.each do |key|
  puts key.friendly_name
end
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Keys.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.Key;
import com.twilio.sdk.resource.list.KeyList;

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);

    KeyList keys = client.getAccount().getKeys();

    // Loop over keys and print out a property for each one.
    for (Key key : keys) {
      System.out.println(key.getFriendlyName());
    }

  }
}
# 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 app objects with the properties described above
keys = client.keys.list()
for key in keys:
    print(key.friendly_name)
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers 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.keys
  .each((key) => console.log(friendlyName));
<?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 apps and echo a property for each one
foreach ($client->account->keys as $key) {
    echo $key->friendly_name;
}
# 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


# Loop over apps and print out a property for each one
@client.account.keys.list.each do |key|
  puts key.friendly_name
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.Key;

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<Key> keys = Key.reader().read();

    // Loop over keys and print out a property for each one.
    for (Key key : keys) {
      System.out.println(key.getFriendlyName());
    }
  }
}
// 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.keys.list(function(err, data) {
    data.keys.forEach(function(key) {
        console.log(key.friendlyName);
    });
});
{
	"page": 0,
	"page_size": 50,
	"uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/Keys.json",
	"first_page_uri": "\/2010-04-01\/Accounts\/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\/Keys.json?Page=0&PageSize=50",
	"previous_page_uri": null,
	"next_page_uri": null,
	"keys": [
            {
                "date_updated": "2015-05-14T23:44:32Z",
                "date_created": "2015-05-14T23:44:32Z",
                "friendly_name": null,
                "sid": "SKdac2dad1695721987de823226f0a62a4"
            },
            ...
	]
}
<TwilioResponse>
	<Keys page="0" pagesize="50" uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Keys" firstpageuri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Keys?Page=0&PageSize=50" previouspageuri="" nextpageuri="">
            <Key>
                <Sid>SKdac2dad1695721987de823226f0a62a4</Sid>
                <FriendlyName>Foobar</FriendlyName>
                <DateCreated>2015-05-14T23:44:32Z</DateCreated>
                <DateUpdated>2015-05-14T23:44:32Z</DateUpdated>
            </Key>
	</Keys>
</TwilioResponse>
SDKバージョン:
  • 4.x
  • 5.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.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";
        TwilioClient.Init(accountSid, authToken);

        var key = NewKeyResource.Create(friendlyName: "User Jenny");

        Console.WriteLine(key.Sid);
        Console.WriteLine(key.Secret);
    }
}
<?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);

$key = $client->newKeys->create(
    array('friendlyName' => 'User Jenny')
);

echo $key->sid;
echo $key->secret;
# 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)

key = client.keys.create(friendly_name="User Jenny")
print(key.sid)
# 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'

# Initialize Twilio Client
@client = Twilio::REST::Client.new(account_sid, auth_token)

@key = @client.account.new_keys.create(friendly_name: 'User Jenny')

puts @key.sid
puts @key.secret
$ curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Keys.json \
    -d "FriendlyName=User+Jenny" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
# 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)

key = client.new_keys \
            .create(friendly_name="User Jenny")

print(key.sid)
print(key.secret)
// Download the Node helper library from twilio.com/docs/node/install
// These identifiers 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.account.newKeys.create({
    friendlyName: 'User Jenny',
  })
  .then((key) => {
    process.stdout.write(key.sid);
    process.stdout.write(key.secret);
  });
// 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 key = twilio.AddKey("User Jenny");

    Console.WriteLine(key.Sid);
    Console.WriteLine(key.Secret);
  }
}
<?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);

$key = $client->account->keys->create(array("FriendlyName" => "User Jenny"));
echo $key->sid;
echo $key->secret;
# 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

key = @client.account.keys.create(friendly_name: "User Jenny")
puts key.sid
puts key.secret
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.NewKey;

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);

    NewKey key = NewKey.creator().setFriendlyName("User Jenny").create();

    System.out.println(key.getSid());
    System.out.println(key.getSecret());
  }
}
// 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.keys.create({
    friendlyName: "User Jenny",
}, function(err, key) {
    process.stdout.write(key.sid);
    process.stdout.write(key.secret);
});
{
    "secret": "RdXY0fRhkrP1scKYpv2SOHV2GrqHGjPw",
    "date_updated": "2015-05-14T23:44:32Z",
    "date_created": "2015-05-14T23:44:32Z",
    "friendly_name": "User Jenny",
    "sid": "SKdac2dad1695721987de823226f0a62a4"
}
<?xml version='1.0' encoding='UTF-8'?>
<TwilioResponse>
    <Key>
        <Secret>rD7Y0frhkrPOzcKypv2SOHV8GrXHGJPw</Secret>
        <Sid>SKdac2dad1695721987de823226f0a62a4</Sid>
        <FriendlyName>User Jenny</FriendlyName>
        <DateCreated>2015-05-14T23:44:32Z</DateCreated>
        <DateUpdated>2015-05-14T23:44:32Z</DateUpdated>
    </Key>
</TwilioResponse>