REST API: 利用限度トリガー

利用限度トリガーは、ユーザーのアプリケーションに利用限度を通知するためのウェブ フックです。 すべての 利用カテゴリーに利用限度トリガーを設定できます。 アプリケーションにタイムリーな情報を提供するため、利用限度トリガーは高頻度 (およそ 1 分に 1 回)に検証されます。 さらに、利用限度トリガーは、日、月、年単位で設定できますので、日々の利用を管理する場合も、1 つの利用限度トリガーを作成すれば済みます。

たとえば、料金が 1 日の予想額を超え始めると、利用限度トリガーでアプリケーションに通知することができます。 または、エンド ユーザーの サブアカウント と組み合わせて、特定の利用者がその月に割り当てられた利用額を超えた時に、利用限度トリガーでアプリケーションに通知することができます。

このリソースでは、POST リクエストで 新しい利用限度トリガーの作成 、または 既存の利用限度トリガーの更新、GET リクエストで 既存の利用限度トリガーの取得、DELETE リクエストで 既存のトリガーの削除を行えます。

Trigger インスタンス リソース

リソース URI

利用限度トリガーは /Usage の配下に位置し、Sid で参照されます。

/2010-04-01/Accounts/{AccountSid}/Usage/Triggers/{UsageTriggerSid}

リソースのプロパティ

Recording リソースには、次のプロパティがあります。

プロパティ 説明
Sid このトリガーのユニークな Sid です。
DateCreated このトリガーが生成された日付の GMT 表記です。 RFC 2822 フォーマットを使用します。
DateUpdated このトリガーが最後に更新された日付の GMT 表記です。 RFC 2822 フォーマットを使用します。
AccountSid このトリガーが監視しているアカウントです。
FriendlyName ユーザー定義の、人間が読みやすい形式のトリガーの名前です。
繰り返し単位 トリガーの繰り返しの状態です。 繰り返しのないトリガーは、空になります。 繰り返しのあるトリガーは、dailymonthlyyearly のいずれかになります。 トリガーは繰り返し期間の間、1 回だけ発行されます。 繰り返し期間は GMT で表記されます。
利用カテゴリー このトリガーが監視する利用カテゴリーです。 サポートされる 利用カテゴリーのいずれか 1 つです。
単位 このトリガーを発行する 利用記録 の中のフィールドです。 countusageprice のいずれかです。 利用記録のドキュメントを参照してください。
トリガー値 トリガーを発行する値です。 必ず正の数値とします。
CurrentValue このトリガーが監視しているフィールドの、現在の値です。
UsageRecordUri このトリガーが監視している 利用記録 の URI です。https://api.twilio.com からの相対パスです。
コールバックURL トリガーが発行された時に、Twilio がリクエストを発行する URL です。
コールバックメソッド CallbackUrl へリクエストを送信する際に、Twilio が使用する HTTP のメソッドです。 GET または POST です。
DateFired このトリガーが最後に発行された日付の GMT 表記です。 RFC 2822 フォーマットを使用します。
Uri このリソースの URI です。https://api.twilio.com からの相対パスです。

指定した期間の間に、アカウントの 利用カテゴリー が利用限度トリガーの TriggerValue に近づくと、Twilio は CallbackMethod に指定された HTTP メソッドを使って、 後述のパラメーターとともに CallbackUrl へリクエストを発行します。利用限度トリガーは、繰り返し期間の間に最大 1 回発行されます。500 番台のエラーの場合は、ただちにコールバック URL へ 3 回リトライを行います。

HTTP GET

上述のプロパティを含む、利用限度トリガーの表現を返します。

利用限度トリガーの取得
  • 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.Usage;

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 trigger = TriggerResource.Fetch("UT33c6aeeba34e48f38d6899ea5b765ad4");

        Console.WriteLine(trigger.CurrentValue);
    }
}
<?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
$trigger = $client
    ->usage
    ->triggers("UT33c6aeeba34e48f38d6899ea5b765ad4")
    ->fetch();

echo $trigger->currentValue;
# 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)

trigger = client.usage.triggers.get("UT33c6aeeba34e48f38d6899ea5b765ad4")
print(trigger.current_value)
# 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
trigger = @client.usage.triggers('UT33c6aeeba34e48f38d6899ea5b765ad4').fetch

puts trigger.current_value
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UT33c6aeeba34e48f38d6899ea5b765ad4.json \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UT33c6aeeba34e48f38d6899ea5b765ad4 \
    -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.UsageTrigger;

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
    UsageTrigger trigger = client.getAccount().getUsageTrigger("UT33c6aeeba34e48f38d6899ea5b765ad4");
    System.out.println(trigger.getCurrentValue());
    
  }
}
# 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)

trigger = client.usage.triggers("UT33c6aeeba34e48f38d6899ea5b765ad4").fetch()
print(trigger.current_value)
// 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.usage.triggers('UT33c6aeeba34e48f38d6899ea5b765ad4')
  .fetch()
  .then((trigger) => trigger.currentValue);
// 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 trigger = twilio.GetUsageTrigger("UT33c6aeeba34e48f38d6899ea5b765ad4");
    
    Console.WriteLine(trigger.CurrentValue);
  }
}
<?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
$trigger = $client->account->usage_triggers->get("UT33c6aeeba34e48f38d6899ea5b765ad4");
echo $trigger->current_value;
# 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
@trigger = @client.account.usage.triggers.get("UT33c6aeeba34e48f38d6899ea5b765ad4")
puts @trigger.current_value
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.usage.Trigger;

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
    Trigger trigger = Trigger.fetcher("UT33c6aeeba34e48f38d6899ea5b765ad4").fetch();

    System.out.println(trigger.getCurrentValue());
  }
}
// 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.usage.triggers("UT33c6aeeba34e48f38d6899ea5b765ad4").get(function(err, trigger) {
    console.log(trigger.currentValue);
});
出力を表示
  • JSON
  • XML
{
   "usage_record_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Records.json?Category=calls", 
   "date_updated": "Sat, 29 Sep 2012 19:47:54 +0000", 
   "date_fired": null, 
   "friendly_name": "Trigger for calls at usage of 500", 
   "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UT33c6aeeba34e48f38d6899ea5b765ad4.json", 
   "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 
   "callback_method": "POST", 
   "trigger_by": "usage", 
   "sid": "UT33c6aeeba34e48f38d6899ea5b765ad4", 
   "current_value": "21", 
   "date_created": "Sat, 29 Sep 2012 19:45:43 +0000", 
   "callback_url": "http://www.example.com/", 
   "recurring": null, 
   "usage_category": "calls", 
   "trigger_value": "500.000000"
}
<TwilioResponse>
   <UsageTrigger>
      <Sid>UT33c6aeeba34e48f38d6899ea5b765ad4</Sid>
      <AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
      <DateCreated>Sat, 29 Sep 2012 19:45:43 +0000</DateCreated>
      <DateUpdated>Sat, 29 Sep 2012 19:47:54 +0000</DateUpdated>
      <DateFired />
      <FriendlyName>Trigger for calls at usage of 500</FriendlyName>
      <UsageCategory>calls</UsageCategory>
      <TriggerBy>usage</TriggerBy>
      <Recurring />
      <TriggerValue>500.000000</TriggerValue>
      <CurrentValue>21</CurrentValue>
      <CallbackUrl>http://www.example.com/</CallbackUrl>
      <CallbackMethod>POST</CallbackMethod>
      <UsageRecordUri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Records?Category=calls</UsageRecordUri>
      <Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UT33c6aeeba34e48f38d6899ea5b765ad4</Uri>
   </UsageTrigger>
</TwilioResponse>
利用限度トリガーの取得

HTTP POST

利用限度トリガーのプロパティを更新します。更新に成功すると、更新されたリソース表現を返します。 返却されるレスポンスは、GET リクエストを送信した場合と同じです。

オプションパラメーター

次のパラメーターの 1 つまたは複数を指定して、この利用限度トリガーのプロパティを更新できます。 POST パラメーターの大文字と小文字は区別されます。

パラメーター 説明
FriendlyName 人間が読みやすい形式のトリガーの名前です。
コールバックURL トリガーが発行された時に、Twilio がリクエストを発行する URL です。
コールバックメソッド CallbackUrl へリクエストを送信する際に、Twilio が使用する HTTP のメソッドです。GET または POST です。

Twilio では現在、既存の利用限度トリガーのカテゴリーやトリガー値の更新ができませんので、注意してください。 POST で新しい利用限度トリガーを作成し、 DELETE で古いトリガーを削除してください。

FriendlyName と CallbackUrl を変更します。

利用限度トリガーのプロパティの変更
  • 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.Usage;

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

        TriggerResource.Update(
            "UT33c6aeeba34e48f38d6899ea5b765ad4",
            friendlyName: "Monthly Maximum Call Usage",
            callbackUrl: new Uri("https://www.example.com/monthly-usage-trigger"));
    }
}
<?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
$trigger = $client
    ->usage
    ->triggers("UT33c6aeeba34e48f38d6899ea5b765ad4")
    ->update(
        array(
            "friendlyName" => "Monthly Maximum Call Usage",
            "callbackUrl" => "https://www.example.com/monthly-usage-trigger"
        )
    );

echo $trigger->dateFired->format('Y-m-d H:i:s');;
# 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)

trigger = client.usage.triggers.update("UT33c6aeeba34e48f38d6899ea5b765ad4", friendly_name="Monthly Maximum Call Usage",
    callback_url="https://www.example.com/monthly-usage-trigger")
print(trigger.date_fired)
# 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
trigger = @client.usage.triggers("UT33c6aeeba34e48f38d6899ea5b765ad4").fetch
trigger.update(:friendly_name => "Monthly Maximum Call Usage",
               :callback_url  => "https://www.example.com/monthly-usage-trigger")

puts trigger.date_fired
$ curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UT33c6aeeba34e48f38d6899ea5b765ad4.json \
    -d "FriendlyName=Monthly%20Maximum%20Call%20Usage" \
    -d "CallbackUrl=https://www.example.com/monthly-usage-trigger" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
$ curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UT33c6aeeba34e48f38d6899ea5b765ad4 \
    -d "FriendlyName=Monthly%20Maximum%20Call%20Usage" \
    -d "CallbackUrl=https://www.example.com/monthly-usage-trigger" \
    -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.UsageTrigger;
import com.twilio.sdk.resource.list.UsageTriggerList;
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);

    // Get an object from its sid. If you do not have a sid,
    // check out the list resource examples on this page
    UsageTrigger trigger = client.getAccount().getUsageTrigger("UT33c6aeeba34e48f38d6899ea5b765ad4");
    // Build a filter for the UsageTriggerList
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("FriendlyName", "Monthly Maximum Call Usage"));
    params.add(new BasicNameValuePair("CallbackUrl", "https://www.example.com/monthly-usage-trigger"));
    trigger.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)

trigger = client.usage.triggers("UT33c6aeeba34e48f38d6899ea5b765ad4").update(
    friendly_name="Monthly Maximum Call Usage",
    callback_url="https://www.example.com/monthly-usage-trigger"
)

print(trigger.date_fired)
// 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.usage.triggers('UT33c6aeeba34e48f38d6899ea5b765ad4')
  .update({
    friendlyName: 'Monthly Maximum Call Usage',
    callbackUrl: 'https://www.example.com/monthly-usage-trigger',
  })
  .then((trigger) => console.log(trigger.dateFired));
// 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);

    
    
    twilio.UpdateUsageTrigger("UT33c6aeeba34e48f38d6899ea5b765ad4", "Monthly Maximum Call Usage", "https://www.example.com/monthly-usage-trigger", null);
  }
}
<?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
$trigger = $client->account->usage_triggers->get("UT33c6aeeba34e48f38d6899ea5b765ad4");
$trigger->update(array(
        "FriendlyName" => "Monthly Maximum Call Usage",
    "CallbackUrl" => "https://www.example.com/monthly-usage-trigger"
    ));
echo $trigger->date_fired;
# 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
@trigger = @client.account.usage.triggers.get("UT33c6aeeba34e48f38d6899ea5b765ad4")
@trigger.update(:friendly_name => "Monthly Maximum Call Usage",
                :callback_url => "https://www.example.com/monthly-usage-trigger")
puts @trigger.date_fired
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.usage.Trigger;

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
    Trigger trigger = Trigger
        .updater("UT33c6aeeba34e48f38d6899ea5b765ad4")
        .setFriendlyName("Monthly Maximum Call Usage")
        .setCallbackUrl("https://www.example.com/monthly-usage-trigger")
        .update();

    System.out.println(trigger.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);

client.usage.triggers("UT33c6aeeba34e48f38d6899ea5b765ad4").update({
    friendlyName: "Monthly Maximum Call Usage",
    callbackUrl: "https://www.example.com/monthly-usage-trigger"
}, function(err, trigger) {
    console.log(trigger.dateFired);
});
出力を表示
  • JSON
  • XML
{
   "usage_record_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Records.json?Category=calls", 
   "date_updated": "Sat, 13 Oct 2012 21:24:35 +0000", 
   "date_fired": null, 
   "friendly_name": "Monthly Maximum Call Usage", 
   "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UT33c6aeeba34e48f38d6899ea5b765ad4.json", 
   "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 
   "callback_method": "POST", 
   "trigger_by": "usage", 
   "sid": "UT33c6aeeba34e48f38d6899ea5b765ad4", 
   "current_value": "21", 
   "date_created": "Sat, 29 Sep 2012 19:45:43 +0000", 
   "callback_url": "https://www.example.com/monthly-usage-trigger", 
   "recurring": null, 
   "usage_category": "calls", 
   "trigger_value": "500.000000"
}
<TwilioResponse>
   <UsageTrigger>
      <Sid>UT33c6aeeba34e48f38d6899ea5b765ad4</Sid>
      <AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
      <DateCreated>Sat, 29 Sep 2012 19:45:43 +0000</DateCreated>
      <DateUpdated>Sat, 13 Oct 2012 21:24:35 +0000</DateUpdated>
      <DateFired />
      <FriendlyName>Monthly Maximum Call Usage</FriendlyName>
      <UsageCategory>calls</UsageCategory>
      <TriggerBy>usage</TriggerBy>
      <Recurring />
      <TriggerValue>500.000000</TriggerValue>
      <CurrentValue>21</CurrentValue>
      <CallbackUrl>https://www.example.com/monthly-usage-trigger</CallbackUrl>
      <CallbackMethod>POST</CallbackMethod>
      <UsageRecordUri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Records?Category=calls</UsageRecordUri>
      <Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UT33c6aeeba34e48f38d6899ea5b765ad4</Uri>
   </UsageTrigger>
</TwilioResponse>
利用限度トリガーのプロパティの変更

HTTP PUT

サポートしません。

HTTP DELETE

この利用限度トリガーを削除します。

削除に成功すると、ボディーのない HTTP 204 レスポンスを返します。

UsageTriggers リスト リソース

リソース URI

すべての利用限度トリガーのリスト リソースです。

/2010-04-01/Accounts/{AccountSid}/Usage/Triggers

HTTP GET

UsageTrigger リソース表現のリストを返します。 このリストは ページ情報を含みます。

リスト フィルター

デフォルトでは、すべての利用限度トリガーを返します。 1 つまたは複数のクエリ パラメーターを指定して、リストをフィルターすることができます。 クエリ パラメーターの大文字と小文字は区別されますので、注意してください。

パラメーター 説明
繰り返し単位 この期間の利用を監視する利用限度トリガーのみを表示します。 dailymonthlyyearly のいずれかになります。 繰り返しのないトリガーを取得する場合は、空にするか、または alltime を使用します。
利用カテゴリー この利用カテゴリーを監視する利用限度トリガーのみを表示します。 必ず、サポートされる 利用カテゴリーのいずれか 1 つとします。
単位 TriggerBy | 利用記録のこのフィールドでトリガーを発行する利用限度トリガーのみを表示します。 必ず、countusageprice のいずれかです。 利用記録のドキュメントを参照してください。
例: 1 日の通話の利用限度トリガーをすべて取得する
1 日の利用限度トリガーの取得
  • 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.Usage;

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 triggers = TriggerResource.Read(
            recurring: TriggerResource.RecurringEnum.Daily,
            usageCategory: TriggerResource.UsageCategoryEnum.Calls);

        foreach (var trigger in triggers)
        {
            Console.WriteLine(trigger.CurrentValue);
        }
    }
}
<?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);

$triggers = $client->usage->triggers->read(
    array(
        "Recurring" => "daily",
        "UsageCategory" => "calls"
    )
);

// Loop over the list of triggers and echo a property for each one
foreach ($triggers as $trigger) {
    echo $trigger->currentValue;
}
# 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 trigger objects with the properties described above
triggers = client.usage.triggers.list(recurring="daily",
    usage_category="calls")
# 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)


# Loop over triggers and print out a property for each one
triggers = @client.usage.triggers.list(:recurring => "daily",
                                       :usage_category => "calls")

triggers.each do |trigger|
  puts trigger.current_value
end
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers.json \
    -d "Recurring=daily" \
    -d "UsageCategory=calls" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers \
    -d "Recurring=daily" \
    -d "UsageCategory=calls" \
    -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.UsageTrigger;
import com.twilio.sdk.resource.list.UsageTriggerList;
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 UsageTriggerList
    Map<String, String> params = new HashMap<String, String>();
    
    params.put("Recurring", "daily");
    params.put("UsageCategory", "calls");
    
    UsageTriggerList triggers = client.getAccount().getUsageTriggers(params);
    
    // Loop over triggers and print out a property for each one.
    for (UsageTrigger trigger : triggers) {
      System.out.println(trigger.getCurrentValue());
    }
    
  }
}
# 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 trigger objects with the properties described above

triggers = client.usage.triggers.list(
    recurring="daily",
    usage_category="calls"
)
// 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);

const filterOpts = {
  recurring: 'daily',
  usageCategory: 'calls',
};

client.usage.triggers
  .each(filterOpts, (trigger) => console.log(trigger.currentValue));
// 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 triggers = twilio.ListUsageTriggers("daily", "calls", null);
    
    foreach (var trigger in triggers.UsageTriggers)
    {
      Console.WriteLine(trigger.CurrentValue);
    }
  }
}
<?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 triggers and echo a property for each one
foreach ($client->account->usage_triggers->getIterator(0, 50, array(
        "Recurring" => "daily",
    "UsageCategory" => "calls"
    )) as $trigger
) {
    echo $trigger->current_value;
}
# 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 triggers and print out a property for each one
@client.account.usage.triggers.list({
  :recurring => "daily",
  :usage_category => "calls"}).each do |trigger|
  puts trigger.current_value
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.usage.Trigger;

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<Trigger> triggers = Trigger.reader()
        .setUsageCategory(Trigger.UsageCategory.CALLS)
        .setRecurring(Trigger.Recurring.DAILY)
        .read();

    // Loop over triggers and print out a property for each one.
    for (Trigger trigger : triggers) {
      System.out.println(trigger.getCurrentValue());
    }
  }
}
// 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.usage.triggers.list({ recurring: "daily",
    usageCategory: "calls" }, function(err, data) {
    data.usageTriggers.forEach(function(trigger) {
        console.log(trigger.currentValue);
    });
});
出力を表示
  • JSON
  • XML
{
   "first_page_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/.json?UsageCategory=calls&Recurring=daily&Page=0&PageSize=50",
   "previous_page_uri": null, 
   "usage_triggers": [
      {
         "usage_record_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Records/Today.json?Category=calls", 
         "date_updated": "Sat, 29 Sep 2012 19:42:57 +0000", 
         "date_fired": null, 
         "friendly_name": "a trigger", 
         "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers//UTc2db285b0cbf4c60a2f1a8db237a5fba.json", 
         "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 
         "callback_method": "POST", 
         "trigger_by": "count", 
         "sid": "UTc2db285b0cbf4c60a2f1a8db237a5fba", 
         "current_value": "0", 
         "date_created": "Sun, 23 Sep 2012 23:07:29 +0000", 
         "callback_url": "http://www.google.com", 
         "recurring": "daily", 
         "usage_category": "calls", 
         "trigger_value": "0.000000"
      }
   ], 
   "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers.json?UsageCategory=calls&Recurring=daily", 
   "page_size": 50,
   "next_page_uri": null,
   "page": 0
}
<TwilioResponse>
   <UsageTriggers pagesize="50" nextpageuri="" uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/?UsageCategory=calls&Recurring=daily" firstpageuri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/?UsageCategory=calls&Recurring=daily&Page=0&PageSize=50" previouspageuri="" page="0">
      <UsageTrigger>
         <Sid>UTc2db285b0cbf4c60a2f1a8db237a5fba</Sid>
         <AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
         <DateCreated>Sun, 23 Sep 2012 23:07:29 +0000</DateCreated>
         <DateUpdated>Sat, 29 Sep 2012 19:42:57 +0000</DateUpdated>
         <DateFired />
         <FriendlyName>a trigger</FriendlyName>
         <UsageCategory>calls</UsageCategory>
         <TriggerBy>count</TriggerBy>
         <Recurring>daily</Recurring>
         <TriggerValue>0.000000</TriggerValue>
         <CurrentValue>0</CurrentValue>
         <CallbackUrl>http://www.google.com</CallbackUrl>
         <CallbackMethod>POST</CallbackMethod>
         <UsageRecordUri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Records/Today?Category=calls</UsageRecordUri>
         <Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers//UTc2db285b0cbf4c60a2f1a8db237a5fba</Uri>
      </UsageTrigger>
   </UsageTriggers>
</TwilioResponse>
1 日の利用限度トリガーの取得

HTTP POST

新しい利用限度トリガーを作成します。 アカウントごとに 最大 1000 件の利用限度トリガーを作成できます。 現在、アクティブでなくなった利用限度トリガーは、自動的に削除されません。 不要になったトリガーは、 DELETE で削除してください。

必要なパラメーター

リクエストには、次のパラメーターを含める 必要があります

パラメーター 説明
利用カテゴリー このトリガーが監視する利用カテゴリーです。 サポートされる 利用カテゴリーのいずれか 1 つです。
トリガー値 利用料金がこの値に達すると、トリガーが発行されます。 +30 のようにオフセットを使用して、 現在の利用料金に 30 単位加算した TriggerValue の利用限度トリガーを作成することもできます。(+%2B に URL エンコードしてください)。
コールバックURL トリガーが発行された時に、Twilio がリクエストを発行する URL です。
オプションパラメーター

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

パラメーター 説明
FriendlyName 新しいトリガーの、人間が読みやすい形式の説明です。 64 文字まで設定できます。
単位 このトリガーを発行する 利用記録 の中のフィールドです。 countusageprice のいずれかです。 利用記録のドキュメントを参照してください。 初期値は usage です。
繰り返し単位 繰り返しのあるトリガーを作成して、繰り返し期間の間の利用を監視する場合は、この値を dailymonthlyyearly のいずれかにセットしてください。 繰り返しのないトリガーの場合は、このパラメーターを省略します。
コールバックメソッド CallbackUrl へリクエストを送信する際に、Twilio が使用する HTTP のメソッドです。GET または POST です。 初期値は POST です。

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

SMS メッセージを 1000 件送信すると発行される、新しい利用限度トリガーを作成します。

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.Usage;

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 callbackUrl = new Uri("http://www.example.com/");
        const string triggerValue = "1000";
        var trigger = TriggerResource.Create(callbackUrl,
                                             triggerValue,
                                             TriggerResource.UsageCategoryEnum.Sms);

        Console.WriteLine(trigger.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);

$trigger = $client->usage->triggers->create(
    "http://www.example.com/", "1000", "sms"
);

echo $trigger->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)

trigger = client.usage.triggers.create(trigger_value="1000",
    usage_category="sms",
    callback_url="http://www.example.com/")
print(trigger.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)

trigger = @client.usage.triggers.create(
  :trigger_value  => "1000",
  :usage_category => "sms",
  :callback_url   => "http://www.example.com/")

puts trigger.usage_category
$ curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers.json \
    -d "TriggerValue=1000" \
    -d "UsageCategory=sms" \
    -d "CallbackUrl=http://www.example.com/" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
$ curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers \
    -d "TriggerValue=1000" \
    -d "UsageCategory=sms" \
    -d "CallbackUrl=http://www.example.com/" \
    -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.UsageTriggerFactory;
import com.twilio.sdk.resource.instance.UsageTrigger;
import com.twilio.sdk.resource.list.UsageTriggerList;
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 UsageTriggerList
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("TriggerValue", "1000"));
    params.add(new BasicNameValuePair("UsageCategory", "sms"));
    params.add(new BasicNameValuePair("CallbackUrl", "http://www.example.com/"));
    
    
    UsageTriggerFactory triggerFactory = client.getAccount().getUsageTriggerFactory();
    UsageTrigger trigger = triggerFactory.create(params);
    System.out.println(trigger.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)

trigger = client.usage.triggers.create(
    trigger_value="1000",
    usage_category="sms",
    callback_url="http://www.example.com/")

print(trigger.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.usage.triggers
  .create({
    triggerValue: '1000',
    usageCategory: 'sms',
    callbackUrl: 'http://www.example.com/',
  })
  .then((trigger) => process.stdout.write(trigger.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 trigger = twilio.CreateUsageTrigger("sms", "1000", "http://www.example.com/");
    
    Console.WriteLine(trigger.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);

$trigger = $client->account->usage_triggers->create("sms", "1000", "http://www.example.com/", array());
echo $trigger->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

trigger = @client.account.usage.triggers
  .create(:trigger_value => "1000",
          :usage_category => "sms",
          :callback_url => "http://www.example.com/")
puts trigger.usage_category
// 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.usage.Trigger;

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 URISyntaxException {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    Trigger trigger = Trigger
        .creator(new URI("http://www.example.com/"), "1000", Trigger.UsageCategory.SMS)
        .create();

    System.out.println(trigger.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.usage.triggers.create({
    triggerValue: "1000",
    usageCategory: "sms",
    callbackUrl: "http://www.example.com/"
}, function(err, trigger) {
    process.stdout.write(trigger.sid);
});
出力を表示
  • JSON
  • XML
{
   "usage_record_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Records.json?Category=sms", 
   "date_updated": "Sat, 13 Oct 2012 21:32:30 +0000", 
   "date_fired": null, 
   "friendly_name": "Trigger for sms at usage of 1000", 
   "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UTc142bed7b38c4f8186ef41a309814fd2.json", 
   "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 
   "callback_method": "POST", 
   "trigger_by": "usage", 
   "sid": "UTc142bed7b38c4f8186ef41a309814fd2", 
   "current_value": "57", 
   "date_created": "Sat, 13 Oct 2012 21:32:30 +0000", 
   "callback_url": "http://www.example.com", 
   "recurring": null, 
   "usage_category": "sms", 
   "trigger_value": "1000.000000"
}
<TwilioResponse>
   <UsageTrigger>
      <Sid>UTc142bed7b38c4f8186ef41a309814fd2</Sid>
      <AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
      <DateCreated>Sat, 13 Oct 2012 21:32:30 +0000</DateCreated>
      <DateUpdated>Sat, 13 Oct 2012 21:32:30 +0000</DateUpdated>
      <DateFired />
      <FriendlyName>Trigger for sms at usage of 1000</FriendlyName>
      <UsageCategory>sms</UsageCategory>
      <TriggerBy>usage</TriggerBy>
      <Recurring />
      <TriggerValue>1000.000000</TriggerValue>
      <CurrentValue>57</CurrentValue>
      <CallbackUrl>http://www.example.com</CallbackUrl>
      <CallbackMethod>POST</CallbackMethod>
      <UsageRecordUri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Records?Category=sms</UsageRecordUri>
      <Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UTc142bed7b38c4f8186ef41a309814fd2</Uri>
   </UsageTrigger>
</TwilioResponse>
パラメーターを指定した新しい利用限度トリガーの作成

HTTP PUT

サポートしません。

HTTP DELETE

サポートしません。

利用限度トリガーのコールバック

利用限度トリガーの利用料金が TriggerValue の値を超えると、トリガーが発行され、Twilio は利用限度トリガーの CallbackUrl に非同期 HTTP リクエストを送信します。 このリクエストは通常、利用限度を超えて 1 分以内に発行されます。

CallbackUrl リクエスト パラメーター

Twilio は次のパラメーターを利用限度トリガーの CallbackUrl に渡します。

パラメーター 説明
AccountSid ユーザーの Twilio アカウント ID です。アカウント ID は 34 文字で、必ず AC から始まります。
UsageTriggerSid 発行された利用限度トリガーのユニークな ID です。
DateFired トリガーが発行された日時の、GMT 表記です。
繰り返し単位 発行されたトリガーの、繰り返しの設定です。 繰り返しのないトリガーは、空になります。 繰り返しのあるトリガーは、dailymonthlyyearly のいずれかになります。
利用カテゴリー このト利用限度トリガーが監視する利用カテゴリーです。 サポートされる 利用カテゴリーのいずれか 1 つです。
単位 このトリガーを発行する 利用記録 の中のフィールドです。 countusageprice のいずれかです。 利用記録のドキュメントを参照してください。
トリガー値 利用限度トリガーを発行する値です。
CurrentUsageValue この利用限度トリガーが監視している利用料金の、現在の値です。
UsageRecordUri この利用限度トリガーが発行された時に、監視していた 利用記録 の URI です。
IdempotencyToken Twilio によって生成される、この利用限度トリガーの発行にユニークな、ランダムなトークンです。 利用限度トリガーの Callback のベスト プラクティスを参照してください。

利用限度トリガーの Callback のベスト プラクティス

利用限度トリガーの CallbackUrl のハンドラーを実装する際に、ハンドラーが HTTP リクエストを 2 回以上受け取る場合があります。 重複したリクエストを処理し、同じレスポンスを返すサービスを冪等 (idemponent)と呼びます。 それぞれの利用限度トリガーのコールバックには、ユニークな IdempotencyToken が付与されます。

例として dailyの 利用上限トリガー IdempotencyTokenが 2012-10-04に発動しています。

ACed70abd024d3f57a4027b5dc2ca88d5b-FIRES-UTc142bed7b38c4f8186ef41a309814fd2-2012-10-04

IdempotencyToken を使って、ユーザーのサービスへのリクエストを適切に処理し、同じ操作が重複して実行されないようにします。 たとえば、ユーザーのコールバック サービスで、請求通知をメールで送信する場合があります。 カスタマー エクスペリエンス向上のために、顧客への請求通知メールが 1 回だけ送付されるようにしなければなりません。

冪等 (indempotency) サービスを実装するには、 テスト アンド セット パターンを使います。 つまり、IdempotencyToken の有無をテストしてから、アプリケーションのロジックを処理します。 アプリケーションはすでにあるトークンを処理し、適切な次のステップを選択します。 請求通知メールの例では、顧客へのメールがすでに送信されている場合は、メールの送信をスキップし、HTTP のステータス コード 200 で応答します。

1 / 1
Loading Code Samples...
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.Usage;

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 trigger = TriggerResource.Fetch("UT33c6aeeba34e48f38d6899ea5b765ad4");

        Console.WriteLine(trigger.CurrentValue);
    }
}
<?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
$trigger = $client
    ->usage
    ->triggers("UT33c6aeeba34e48f38d6899ea5b765ad4")
    ->fetch();

echo $trigger->currentValue;
# 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)

trigger = client.usage.triggers.get("UT33c6aeeba34e48f38d6899ea5b765ad4")
print(trigger.current_value)
# 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
trigger = @client.usage.triggers('UT33c6aeeba34e48f38d6899ea5b765ad4').fetch

puts trigger.current_value
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UT33c6aeeba34e48f38d6899ea5b765ad4.json \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UT33c6aeeba34e48f38d6899ea5b765ad4 \
    -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.UsageTrigger;

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
    UsageTrigger trigger = client.getAccount().getUsageTrigger("UT33c6aeeba34e48f38d6899ea5b765ad4");
    System.out.println(trigger.getCurrentValue());
    
  }
}
# 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)

trigger = client.usage.triggers("UT33c6aeeba34e48f38d6899ea5b765ad4").fetch()
print(trigger.current_value)
// 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.usage.triggers('UT33c6aeeba34e48f38d6899ea5b765ad4')
  .fetch()
  .then((trigger) => trigger.currentValue);
// 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 trigger = twilio.GetUsageTrigger("UT33c6aeeba34e48f38d6899ea5b765ad4");
    
    Console.WriteLine(trigger.CurrentValue);
  }
}
<?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
$trigger = $client->account->usage_triggers->get("UT33c6aeeba34e48f38d6899ea5b765ad4");
echo $trigger->current_value;
# 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
@trigger = @client.account.usage.triggers.get("UT33c6aeeba34e48f38d6899ea5b765ad4")
puts @trigger.current_value
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.usage.Trigger;

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
    Trigger trigger = Trigger.fetcher("UT33c6aeeba34e48f38d6899ea5b765ad4").fetch();

    System.out.println(trigger.getCurrentValue());
  }
}
// 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.usage.triggers("UT33c6aeeba34e48f38d6899ea5b765ad4").get(function(err, trigger) {
    console.log(trigger.currentValue);
});
{
   "usage_record_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Records.json?Category=calls", 
   "date_updated": "Sat, 29 Sep 2012 19:47:54 +0000", 
   "date_fired": null, 
   "friendly_name": "Trigger for calls at usage of 500", 
   "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UT33c6aeeba34e48f38d6899ea5b765ad4.json", 
   "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 
   "callback_method": "POST", 
   "trigger_by": "usage", 
   "sid": "UT33c6aeeba34e48f38d6899ea5b765ad4", 
   "current_value": "21", 
   "date_created": "Sat, 29 Sep 2012 19:45:43 +0000", 
   "callback_url": "http://www.example.com/", 
   "recurring": null, 
   "usage_category": "calls", 
   "trigger_value": "500.000000"
}
<TwilioResponse>
   <UsageTrigger>
      <Sid>UT33c6aeeba34e48f38d6899ea5b765ad4</Sid>
      <AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
      <DateCreated>Sat, 29 Sep 2012 19:45:43 +0000</DateCreated>
      <DateUpdated>Sat, 29 Sep 2012 19:47:54 +0000</DateUpdated>
      <DateFired />
      <FriendlyName>Trigger for calls at usage of 500</FriendlyName>
      <UsageCategory>calls</UsageCategory>
      <TriggerBy>usage</TriggerBy>
      <Recurring />
      <TriggerValue>500.000000</TriggerValue>
      <CurrentValue>21</CurrentValue>
      <CallbackUrl>http://www.example.com/</CallbackUrl>
      <CallbackMethod>POST</CallbackMethod>
      <UsageRecordUri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Records?Category=calls</UsageRecordUri>
      <Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UT33c6aeeba34e48f38d6899ea5b765ad4</Uri>
   </UsageTrigger>
</TwilioResponse>
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.Usage;

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

        TriggerResource.Update(
            "UT33c6aeeba34e48f38d6899ea5b765ad4",
            friendlyName: "Monthly Maximum Call Usage",
            callbackUrl: new Uri("https://www.example.com/monthly-usage-trigger"));
    }
}
<?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
$trigger = $client
    ->usage
    ->triggers("UT33c6aeeba34e48f38d6899ea5b765ad4")
    ->update(
        array(
            "friendlyName" => "Monthly Maximum Call Usage",
            "callbackUrl" => "https://www.example.com/monthly-usage-trigger"
        )
    );

echo $trigger->dateFired->format('Y-m-d H:i:s');;
# 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)

trigger = client.usage.triggers.update("UT33c6aeeba34e48f38d6899ea5b765ad4", friendly_name="Monthly Maximum Call Usage",
    callback_url="https://www.example.com/monthly-usage-trigger")
print(trigger.date_fired)
# 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
trigger = @client.usage.triggers("UT33c6aeeba34e48f38d6899ea5b765ad4").fetch
trigger.update(:friendly_name => "Monthly Maximum Call Usage",
               :callback_url  => "https://www.example.com/monthly-usage-trigger")

puts trigger.date_fired
$ curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UT33c6aeeba34e48f38d6899ea5b765ad4.json \
    -d "FriendlyName=Monthly%20Maximum%20Call%20Usage" \
    -d "CallbackUrl=https://www.example.com/monthly-usage-trigger" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
$ curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UT33c6aeeba34e48f38d6899ea5b765ad4 \
    -d "FriendlyName=Monthly%20Maximum%20Call%20Usage" \
    -d "CallbackUrl=https://www.example.com/monthly-usage-trigger" \
    -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.UsageTrigger;
import com.twilio.sdk.resource.list.UsageTriggerList;
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);

    // Get an object from its sid. If you do not have a sid,
    // check out the list resource examples on this page
    UsageTrigger trigger = client.getAccount().getUsageTrigger("UT33c6aeeba34e48f38d6899ea5b765ad4");
    // Build a filter for the UsageTriggerList
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("FriendlyName", "Monthly Maximum Call Usage"));
    params.add(new BasicNameValuePair("CallbackUrl", "https://www.example.com/monthly-usage-trigger"));
    trigger.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)

trigger = client.usage.triggers("UT33c6aeeba34e48f38d6899ea5b765ad4").update(
    friendly_name="Monthly Maximum Call Usage",
    callback_url="https://www.example.com/monthly-usage-trigger"
)

print(trigger.date_fired)
// 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.usage.triggers('UT33c6aeeba34e48f38d6899ea5b765ad4')
  .update({
    friendlyName: 'Monthly Maximum Call Usage',
    callbackUrl: 'https://www.example.com/monthly-usage-trigger',
  })
  .then((trigger) => console.log(trigger.dateFired));
// 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);

    
    
    twilio.UpdateUsageTrigger("UT33c6aeeba34e48f38d6899ea5b765ad4", "Monthly Maximum Call Usage", "https://www.example.com/monthly-usage-trigger", null);
  }
}
<?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
$trigger = $client->account->usage_triggers->get("UT33c6aeeba34e48f38d6899ea5b765ad4");
$trigger->update(array(
        "FriendlyName" => "Monthly Maximum Call Usage",
    "CallbackUrl" => "https://www.example.com/monthly-usage-trigger"
    ));
echo $trigger->date_fired;
# 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
@trigger = @client.account.usage.triggers.get("UT33c6aeeba34e48f38d6899ea5b765ad4")
@trigger.update(:friendly_name => "Monthly Maximum Call Usage",
                :callback_url => "https://www.example.com/monthly-usage-trigger")
puts @trigger.date_fired
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.usage.Trigger;

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
    Trigger trigger = Trigger
        .updater("UT33c6aeeba34e48f38d6899ea5b765ad4")
        .setFriendlyName("Monthly Maximum Call Usage")
        .setCallbackUrl("https://www.example.com/monthly-usage-trigger")
        .update();

    System.out.println(trigger.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);

client.usage.triggers("UT33c6aeeba34e48f38d6899ea5b765ad4").update({
    friendlyName: "Monthly Maximum Call Usage",
    callbackUrl: "https://www.example.com/monthly-usage-trigger"
}, function(err, trigger) {
    console.log(trigger.dateFired);
});
{
   "usage_record_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Records.json?Category=calls", 
   "date_updated": "Sat, 13 Oct 2012 21:24:35 +0000", 
   "date_fired": null, 
   "friendly_name": "Monthly Maximum Call Usage", 
   "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UT33c6aeeba34e48f38d6899ea5b765ad4.json", 
   "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 
   "callback_method": "POST", 
   "trigger_by": "usage", 
   "sid": "UT33c6aeeba34e48f38d6899ea5b765ad4", 
   "current_value": "21", 
   "date_created": "Sat, 29 Sep 2012 19:45:43 +0000", 
   "callback_url": "https://www.example.com/monthly-usage-trigger", 
   "recurring": null, 
   "usage_category": "calls", 
   "trigger_value": "500.000000"
}
<TwilioResponse>
   <UsageTrigger>
      <Sid>UT33c6aeeba34e48f38d6899ea5b765ad4</Sid>
      <AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
      <DateCreated>Sat, 29 Sep 2012 19:45:43 +0000</DateCreated>
      <DateUpdated>Sat, 13 Oct 2012 21:24:35 +0000</DateUpdated>
      <DateFired />
      <FriendlyName>Monthly Maximum Call Usage</FriendlyName>
      <UsageCategory>calls</UsageCategory>
      <TriggerBy>usage</TriggerBy>
      <Recurring />
      <TriggerValue>500.000000</TriggerValue>
      <CurrentValue>21</CurrentValue>
      <CallbackUrl>https://www.example.com/monthly-usage-trigger</CallbackUrl>
      <CallbackMethod>POST</CallbackMethod>
      <UsageRecordUri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Records?Category=calls</UsageRecordUri>
      <Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UT33c6aeeba34e48f38d6899ea5b765ad4</Uri>
   </UsageTrigger>
</TwilioResponse>
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.Usage;

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 triggers = TriggerResource.Read(
            recurring: TriggerResource.RecurringEnum.Daily,
            usageCategory: TriggerResource.UsageCategoryEnum.Calls);

        foreach (var trigger in triggers)
        {
            Console.WriteLine(trigger.CurrentValue);
        }
    }
}
<?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);

$triggers = $client->usage->triggers->read(
    array(
        "Recurring" => "daily",
        "UsageCategory" => "calls"
    )
);

// Loop over the list of triggers and echo a property for each one
foreach ($triggers as $trigger) {
    echo $trigger->currentValue;
}
# 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 trigger objects with the properties described above
triggers = client.usage.triggers.list(recurring="daily",
    usage_category="calls")
# 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)


# Loop over triggers and print out a property for each one
triggers = @client.usage.triggers.list(:recurring => "daily",
                                       :usage_category => "calls")

triggers.each do |trigger|
  puts trigger.current_value
end
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers.json \
    -d "Recurring=daily" \
    -d "UsageCategory=calls" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers \
    -d "Recurring=daily" \
    -d "UsageCategory=calls" \
    -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.UsageTrigger;
import com.twilio.sdk.resource.list.UsageTriggerList;
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 UsageTriggerList
    Map<String, String> params = new HashMap<String, String>();
    
    params.put("Recurring", "daily");
    params.put("UsageCategory", "calls");
    
    UsageTriggerList triggers = client.getAccount().getUsageTriggers(params);
    
    // Loop over triggers and print out a property for each one.
    for (UsageTrigger trigger : triggers) {
      System.out.println(trigger.getCurrentValue());
    }
    
  }
}
# 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 trigger objects with the properties described above

triggers = client.usage.triggers.list(
    recurring="daily",
    usage_category="calls"
)
// 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);

const filterOpts = {
  recurring: 'daily',
  usageCategory: 'calls',
};

client.usage.triggers
  .each(filterOpts, (trigger) => console.log(trigger.currentValue));
// 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 triggers = twilio.ListUsageTriggers("daily", "calls", null);
    
    foreach (var trigger in triggers.UsageTriggers)
    {
      Console.WriteLine(trigger.CurrentValue);
    }
  }
}
<?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 triggers and echo a property for each one
foreach ($client->account->usage_triggers->getIterator(0, 50, array(
        "Recurring" => "daily",
    "UsageCategory" => "calls"
    )) as $trigger
) {
    echo $trigger->current_value;
}
# 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 triggers and print out a property for each one
@client.account.usage.triggers.list({
  :recurring => "daily",
  :usage_category => "calls"}).each do |trigger|
  puts trigger.current_value
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.usage.Trigger;

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<Trigger> triggers = Trigger.reader()
        .setUsageCategory(Trigger.UsageCategory.CALLS)
        .setRecurring(Trigger.Recurring.DAILY)
        .read();

    // Loop over triggers and print out a property for each one.
    for (Trigger trigger : triggers) {
      System.out.println(trigger.getCurrentValue());
    }
  }
}
// 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.usage.triggers.list({ recurring: "daily",
    usageCategory: "calls" }, function(err, data) {
    data.usageTriggers.forEach(function(trigger) {
        console.log(trigger.currentValue);
    });
});
{
   "first_page_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/.json?UsageCategory=calls&Recurring=daily&Page=0&PageSize=50",
   "previous_page_uri": null, 
   "usage_triggers": [
      {
         "usage_record_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Records/Today.json?Category=calls", 
         "date_updated": "Sat, 29 Sep 2012 19:42:57 +0000", 
         "date_fired": null, 
         "friendly_name": "a trigger", 
         "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers//UTc2db285b0cbf4c60a2f1a8db237a5fba.json", 
         "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 
         "callback_method": "POST", 
         "trigger_by": "count", 
         "sid": "UTc2db285b0cbf4c60a2f1a8db237a5fba", 
         "current_value": "0", 
         "date_created": "Sun, 23 Sep 2012 23:07:29 +0000", 
         "callback_url": "http://www.google.com", 
         "recurring": "daily", 
         "usage_category": "calls", 
         "trigger_value": "0.000000"
      }
   ], 
   "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers.json?UsageCategory=calls&Recurring=daily", 
   "page_size": 50,
   "next_page_uri": null,
   "page": 0
}
<TwilioResponse>
   <UsageTriggers pagesize="50" nextpageuri="" uri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/?UsageCategory=calls&Recurring=daily" firstpageuri="/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/?UsageCategory=calls&Recurring=daily&Page=0&PageSize=50" previouspageuri="" page="0">
      <UsageTrigger>
         <Sid>UTc2db285b0cbf4c60a2f1a8db237a5fba</Sid>
         <AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
         <DateCreated>Sun, 23 Sep 2012 23:07:29 +0000</DateCreated>
         <DateUpdated>Sat, 29 Sep 2012 19:42:57 +0000</DateUpdated>
         <DateFired />
         <FriendlyName>a trigger</FriendlyName>
         <UsageCategory>calls</UsageCategory>
         <TriggerBy>count</TriggerBy>
         <Recurring>daily</Recurring>
         <TriggerValue>0.000000</TriggerValue>
         <CurrentValue>0</CurrentValue>
         <CallbackUrl>http://www.google.com</CallbackUrl>
         <CallbackMethod>POST</CallbackMethod>
         <UsageRecordUri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Records/Today?Category=calls</UsageRecordUri>
         <Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers//UTc2db285b0cbf4c60a2f1a8db237a5fba</Uri>
      </UsageTrigger>
   </UsageTriggers>
</TwilioResponse>
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.Usage;

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 callbackUrl = new Uri("http://www.example.com/");
        const string triggerValue = "1000";
        var trigger = TriggerResource.Create(callbackUrl,
                                             triggerValue,
                                             TriggerResource.UsageCategoryEnum.Sms);

        Console.WriteLine(trigger.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);

$trigger = $client->usage->triggers->create(
    "http://www.example.com/", "1000", "sms"
);

echo $trigger->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)

trigger = client.usage.triggers.create(trigger_value="1000",
    usage_category="sms",
    callback_url="http://www.example.com/")
print(trigger.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)

trigger = @client.usage.triggers.create(
  :trigger_value  => "1000",
  :usage_category => "sms",
  :callback_url   => "http://www.example.com/")

puts trigger.usage_category
$ curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers.json \
    -d "TriggerValue=1000" \
    -d "UsageCategory=sms" \
    -d "CallbackUrl=http://www.example.com/" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
$ curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers \
    -d "TriggerValue=1000" \
    -d "UsageCategory=sms" \
    -d "CallbackUrl=http://www.example.com/" \
    -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.UsageTriggerFactory;
import com.twilio.sdk.resource.instance.UsageTrigger;
import com.twilio.sdk.resource.list.UsageTriggerList;
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 UsageTriggerList
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("TriggerValue", "1000"));
    params.add(new BasicNameValuePair("UsageCategory", "sms"));
    params.add(new BasicNameValuePair("CallbackUrl", "http://www.example.com/"));
    
    
    UsageTriggerFactory triggerFactory = client.getAccount().getUsageTriggerFactory();
    UsageTrigger trigger = triggerFactory.create(params);
    System.out.println(trigger.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)

trigger = client.usage.triggers.create(
    trigger_value="1000",
    usage_category="sms",
    callback_url="http://www.example.com/")

print(trigger.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.usage.triggers
  .create({
    triggerValue: '1000',
    usageCategory: 'sms',
    callbackUrl: 'http://www.example.com/',
  })
  .then((trigger) => process.stdout.write(trigger.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 trigger = twilio.CreateUsageTrigger("sms", "1000", "http://www.example.com/");
    
    Console.WriteLine(trigger.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);

$trigger = $client->account->usage_triggers->create("sms", "1000", "http://www.example.com/", array());
echo $trigger->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

trigger = @client.account.usage.triggers
  .create(:trigger_value => "1000",
          :usage_category => "sms",
          :callback_url => "http://www.example.com/")
puts trigger.usage_category
// 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.usage.Trigger;

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 URISyntaxException {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    Trigger trigger = Trigger
        .creator(new URI("http://www.example.com/"), "1000", Trigger.UsageCategory.SMS)
        .create();

    System.out.println(trigger.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.usage.triggers.create({
    triggerValue: "1000",
    usageCategory: "sms",
    callbackUrl: "http://www.example.com/"
}, function(err, trigger) {
    process.stdout.write(trigger.sid);
});
{
   "usage_record_uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Records.json?Category=sms", 
   "date_updated": "Sat, 13 Oct 2012 21:32:30 +0000", 
   "date_fired": null, 
   "friendly_name": "Trigger for sms at usage of 1000", 
   "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UTc142bed7b38c4f8186ef41a309814fd2.json", 
   "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 
   "callback_method": "POST", 
   "trigger_by": "usage", 
   "sid": "UTc142bed7b38c4f8186ef41a309814fd2", 
   "current_value": "57", 
   "date_created": "Sat, 13 Oct 2012 21:32:30 +0000", 
   "callback_url": "http://www.example.com", 
   "recurring": null, 
   "usage_category": "sms", 
   "trigger_value": "1000.000000"
}
<TwilioResponse>
   <UsageTrigger>
      <Sid>UTc142bed7b38c4f8186ef41a309814fd2</Sid>
      <AccountSid>ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</AccountSid>
      <DateCreated>Sat, 13 Oct 2012 21:32:30 +0000</DateCreated>
      <DateUpdated>Sat, 13 Oct 2012 21:32:30 +0000</DateUpdated>
      <DateFired />
      <FriendlyName>Trigger for sms at usage of 1000</FriendlyName>
      <UsageCategory>sms</UsageCategory>
      <TriggerBy>usage</TriggerBy>
      <Recurring />
      <TriggerValue>1000.000000</TriggerValue>
      <CurrentValue>57</CurrentValue>
      <CallbackUrl>http://www.example.com</CallbackUrl>
      <CallbackMethod>POST</CallbackMethod>
      <UsageRecordUri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Records?Category=sms</UsageRecordUri>
      <Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UTc142bed7b38c4f8186ef41a309814fd2</Uri>
   </UsageTrigger>
</TwilioResponse>