NAME

Twilio::Rest::Api::V2010::Account::Usage::Trigger - The Trigger resource

SYNOPSIS

my $client = Twilio::Rest::Client->new($account_sid, $auth_token);

my $trigger = $client->usage->triggers->create($callback_url, $trigger_value, $usage_category, \%options);
for my $trigger ($client->usage->triggers->read({}, 20)) {
  ...
}
my $trigger = $client->usage->triggers($sid)->fetch;
$client->usage->triggers($sid)->update(\%options);
$client->usage->triggers($sid)->delete;

DESCRIPTION

Webhooks that notify you of usage thresholds

This file holds TriggerList, TriggerPage, TriggerContext and TriggerInstance. Methods that make a request throw Twilio::Exceptions::RestException on an error response.

TriggerList

Returned by $client->usage->triggers. See also Twilio::ListResource.

create

my $trigger = $client->usage->triggers->create($callback_url, $trigger_value, $usage_category, \%options);

Create a new UsageTrigger. Returns a TriggerInstance.

The required values are:

$callback_url

The URL we should call using callback_method when the trigger fires.

$trigger_value

The usage value at which the trigger should fire. For convenience, you can use an offset value such as +30 to specify a trigger_value that is 30 units more than the current usage value. Be sure to urlencode a + as %2B.

$usage_category

The usage category that the trigger should watch. Use one of the supported usage categories for this value.

The options are:

callback_method

The HTTP method we should use to call callback_url. Can be: GET or POST and the default is POST. One of GET or POST.

friendly_name

A descriptive string that you create to describe the resource. It can be up to 64 characters long.

recurring

One of daily, monthly, yearly or alltime.

trigger_by

One of count, usage or price.

read

my @records = $client->usage->triggers->read(\%options, $limit, $page_size);

Retrieve a list of usage-triggers belonging to the account used to make the request. Returns the records as a list, fetching as many pages as it needs.

The options are:

recurring

The frequency of recurring UsageTriggers to read. Can be: daily, monthly, or yearly to read recurring UsageTriggers. An empty value or a value of alltime reads non-recurring UsageTriggers. One of daily, monthly, yearly or alltime.

trigger_by

The trigger field of the UsageTriggers to read. Can be: count, usage, or price as described in the UsageRecords documentation. One of count, usage or price.

usage_category

The usage category of the UsageTriggers to read. Must be a supported usage categories.

stream

my $stream = $client->usage->triggers->stream(\%options, $limit, $page_size);

Takes the same arguments as "read", and returns a Twilio::Stream.

page

my $page = $client->usage->triggers->page(\%options, $page_size, $page_token, $page_number);

Fetches one page, and returns a Twilio::Page.

get_page

my $page = $client->usage->triggers->get_page($url);

Fetches the page at a URL given by Twilio.

get_context

my $context = $client->usage->triggers->get_context($sid);

Returns a TriggerContext, and makes no request.

TriggerPage

A Twilio::Page of TriggerInstance objects.

records_key

build_instance

Used by Twilio::Page.

TriggerContext

Returned by $client->usage->triggers($sid). It makes no request until one of these methods is called.

fetch

my $trigger = $client->usage->triggers($sid)->fetch;

Fetch and instance of a usage-trigger. Returns a TriggerInstance.

update

my $trigger = $client->usage->triggers($sid)->update(\%options);

Update an instance of a usage trigger. Returns a TriggerInstance.

The options are:

callback_method

The HTTP method we should use to call callback_url. Can be: GET or POST and the default is POST. One of GET or POST.

callback_url

The URL we should call using callback_method when the trigger fires.

friendly_name

A descriptive string that you create to describe the resource. It can be up to 64 characters long.

delete

$client->usage->triggers($sid)->delete;

Returns true.

TriggerInstance

See also Twilio::InstanceResource.

It has fetch, update and delete, which work as they do on the context.

Its fields are:

account_sid

The SID of the Account that the trigger monitors.

api_version

The API version used to create the resource.

callback_method

The HTTP method we use to call callback_url. Can be: GET or POST. One of GET or POST.

callback_url

The URL we call using the callback_method when the trigger fires.

current_value

The current value of the field the trigger is watching.

date_created

The date and time in GMT that the resource was created specified in RFC 2822 format. A Time::Piece object in UTC. See "date_time" in Twilio::Deserialize.

date_fired

The date and time in GMT that the trigger was last fired specified in RFC 2822 format. A Time::Piece object in UTC. See "date_time" in Twilio::Deserialize.

date_updated

The date and time in GMT that the resource was last updated specified in RFC 2822 format. A Time::Piece object in UTC. See "date_time" in Twilio::Deserialize.

friendly_name

The string that you assigned to describe the trigger.

recurring

One of daily, monthly, yearly or alltime.

sid

The unique string that that we created to identify the UsageTrigger resource.

trigger_by

One of count, usage or price.

trigger_value

The value at which the trigger will fire. Must be a positive, numeric value.

uri

The URI of the resource, relative to https://api.twilio.com.

usage_category

The usage category the trigger watches. Must be one of the supported usage categories.

usage_record_uri

The URI of the UsageRecord resource this trigger watches, relative to https://api.twilio.com.

CONSTRUCTORS

new

Objects here come from the methods above, so there is no need to call new directly.

LICENSE

Copyright (c) 2026 Francisco Zarabozo. Released under the MIT License.