REST API: 利用限度トリガー

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

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

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

Trigger インスタンス リソース

リソースURI

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

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

リソースのプロパティ

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

名前 概要
account_sid

The account this trigger monitors. (🏢 not PII)

callback_method

The HTTP method Twilio will use when making a request to the CallbackUrl. GET or POST. (🏢 not PII)

callback_url

Twilio will make a request to this url when the trigger fires. (📇 PII MTL: 60 days)

current_value

The current value of the field the trigger is watching. (🏢 not PII)

date_created

The date the trigger was created, given as GMT RFC 2822 format. (🏢 not PII)

date_fired

The date the trigger was last fired, given as GMT RFC 2822 format. (🏢 not PII)

date_updated

The date the trigger was last updated, given as GMT RFC 2822 format. (🏢 not PII)

friendly_name

A user-specified, human-readable name for the trigger. (🏢 not PII)

繰り返し単位

How this trigger recurs. Empty for non-recurring triggers. One of daily, monthly, or yearly for recurring triggers. A trigger will only fire once during each recurring period. Recurring periods are in GMT. (🏢 not PII)

sid

The trigger's unique Sid. (🏢 not PII)

trigger_by

The field in the UsageRecord that fires the trigger. One of count, usage, or price, as described in the UsageRecords documentation. (🏢 not PII)

trigger_value

The value at which the trigger will fire. Must be a positive numeric value. (🏢 not PII)

uri

The URI for this resource, relative to https://api.twilio.com. (🏢 not PII)

usage_category

The usage category the trigger watches. One of the supported usage categories. (🏢 not PII)

usage_record_uri

The URI of the UsageRecord this trigger is watching, relative to https://api.twilio.com. (🏢 not PII)

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

HTTP GET

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

コードサンプルを読み込んでいます...
Language
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 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);
});
// 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 '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
sid = 'UT33c6aeeba34e48f38d6899ea5b765ad4'
@trigger = @client.account.usage.triggers.get(sid)
puts @trigger.current_value
// 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 '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
// 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)
// 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());
  }
}
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UT33c6aeeba34e48f38d6899ea5b765ad4 \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UT33c6aeeba34e48f38d6899ea5b765ad4.json \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
   "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 パラメーターの大文字と小文字は区別されます。

名前 概要
コールバックメソッド

Optional. The HTTP method Twilio will use when making a request to the CallbackUrl. GET or POST. (🏢 not PII)

CallbackUrl

Optional. Twilio will make a request to this url when the trigger fires. (📇 PII MTL: 60 days)

FriendlyName

Optional. A user-specified, human-readable name for the trigger. (🏢 not PII)

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

FriendlyName と CallbackUrl を変更します。

コードサンプルを読み込んでいます...
Language
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 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);
});
// 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 '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
sid = 'UT33c6aeeba34e48f38d6899ea5b765ad4'
trigger = client.account.usage.triggers.get(sid)
trigger.update(
  friendly_name: 'Monthly Maximum Call Usage',
  callback_url: 'https://www.example.com/monthly-usage-trigger'
)
puts trigger.date_fired
// 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 '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
// 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)
// 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());
  }
}
$ 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'
$ 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'
{
   "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 つまたは複数のクエリ パラメーターを指定して、リストをフィルターすることができます。 クエリ パラメーターの大文字と小文字は区別されますので、注意してください。

名前 概要
繰り返し単位

Optional. Only show UsageTriggers that count over this interval. One of daily, monthly, or yearly. To retrieve non-recurring triggers, leave this empty or use alltime. (🏢 not PII)

単位

Optional. Only show UsageTriggers that trigger by this field in the UsageRecord. Must be one of: count, usage, or price as described in the UsageRecords documentation. (🏢 not PII)

利用カテゴリー

Optional. Only show UsageTriggers that watch this usage category. Must be one of the supported usage categories. (🏢 not PII)

コードサンプルを読み込んでいます...
Language
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 Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.usage.triggers.list(
  {
    recurring: 'daily',
    usageCategory: 'calls',
  },
  (err, data) => {
    data.usageTriggers.forEach(trigger => {
      console.log(trigger.currentValue);
    });
  }
);
// 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 '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
// 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 '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
// 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"
)
// 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());
    }
  }
}
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers \
    -d "Recurring=daily" \
    -d "UsageCategory=calls" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
$ 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'
{
   "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 で削除してください。

パラメーター

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

名前 概要
CallbackUrl

Required. Twilio will make a request to this url when the trigger fires. (📇 PII MTL: 60 days)

TriggerValue

Required. The trigger will fire when usage reaches this value. For convenience, you can use an offset like +30, which tells Twilio to create the UsageTrigger with its TriggerValue 30 units higher than the current usage. (just be sure to urlencode the + as %2B). (🏢 not PII)

利用カテゴリー

Required. The trigger will watch this usage category. One of the supported usage categories. (🏢 not PII)

コールバックメソッド

Optional. Twilio will use this HTTP method when making a request to the CallbackUrl. GET or POST. The default is POST. (🏢 not PII)

FriendlyName

Optional. A human readable description of the new trigger. Maximum 64 characters. (🏢 not PII)

繰り返し単位

Optional. How this trigger recurs. Empty for non-recurring triggers. One of daily, monthly, or yearly for recurring triggers. A trigger will only fire once during each recurring period. Recurring periods are in GMT. (🏢 not PII)

単位

Optional. The field in the UsageRecord that will fire the trigger. One of count, usage, or price as described in the UsageRecords documentation. The default is usage. (🏢 not PII)

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

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

コードサンプルを読み込んでいます...
Language
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 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);
});
// 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 '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
// 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 '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
// 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)
// 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());
  }
}
$ 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'
$ 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'
{
   "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 のいずれかです。 利用記録のドキュメントを参照してください。
TriggerValue 利用限度トリガーを発行する値です。
CurrentValue この利用限度トリガーが監視している利用料金の、現在の値です。
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 で応答します。

ヘルプが必要ですか?

誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。

コードサンプルを読み込んでいます...
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 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);
});
// 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 '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
sid = 'UT33c6aeeba34e48f38d6899ea5b765ad4'
@trigger = @client.account.usage.triggers.get(sid)
puts @trigger.current_value
// 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 '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
// 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)
// 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());
  }
}
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UT33c6aeeba34e48f38d6899ea5b765ad4 \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers/UT33c6aeeba34e48f38d6899ea5b765ad4.json \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
   "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 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);
});
// 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 '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
sid = 'UT33c6aeeba34e48f38d6899ea5b765ad4'
trigger = client.account.usage.triggers.get(sid)
trigger.update(
  friendly_name: 'Monthly Maximum Call Usage',
  callback_url: 'https://www.example.com/monthly-usage-trigger'
)
puts trigger.date_fired
// 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 '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
// 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)
// 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());
  }
}
$ 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'
$ 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'
{
   "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 Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.usage.triggers.list(
  {
    recurring: 'daily',
    usageCategory: 'calls',
  },
  (err, data) => {
    data.usageTriggers.forEach(trigger => {
      console.log(trigger.currentValue);
    });
  }
);
// 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 '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
// 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 '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
// 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"
)
// 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());
    }
  }
}
$ curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Usage/Triggers \
    -d "Recurring=daily" \
    -d "UsageCategory=calls" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
$ 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'
{
   "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 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);
});
// 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 '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
// 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 '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
// 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)
// 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());
  }
}
$ 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'
$ 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'
{
   "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>