POST/2010-04-01/Accounts/{AccountSid}/Usage/Triggers.json

Create a usage trigger

Creates a usage trigger for an account to monitor a usage category and value. Supply CallbackUrl, TriggerValue, and UsageCategory; choose TriggerBy and Recurring to configure what the trigger monitors and how often it can fire. The callback method defaults to POST when omitted.

  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

1 parameter · 7 body fields
AccountSidstringrequired
The account SID, in the format `AC` followed by 32 hexadecimal characters.

Optional usage trigger configuration. CallbackUrl, TriggerValue, and UsageCategory are required.

CallbackUrlstringrequired
The URL we should call using `callback_method` when the trigger fires.
TriggerValuestringrequired
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`.
UsageCategorystringrequired
The usage category that the trigger should watch. Use one of the supported [usage categories](https://www.twilio.com/docs/usage/api/usage-record#usage-categories) for this value.
CallbackMethodstringoptional
The HTTP method we should use to call `callback_url`. Can be: `GET` or `POST` and the default is `POST`.
Allowed:GETPOST
FriendlyNamestringoptional
A descriptive string that you create to describe the resource. It can be up to 64 characters long.
Recurringstringoptional
The frequency of a recurring UsageTrigger. Can be: `daily`, `monthly`, or `yearly` for recurring triggers or empty for non-recurring triggers. A trigger will only fire once during each period. Recurring times are in GMT.
Allowed:dailymonthlyyearlyalltime
TriggerBystringoptional
The field in the [UsageRecord](https://www.twilio.com/docs/usage/api/usage-record) resource that fires the trigger. Can be: `count`, `usage`, or `price`, as described in the [UsageRecords documentation](https://www.twilio.com/docs/usage/api/usage-record#usage-count-price).
Allowed:countusageprice

1 status code
201Returns the created usage trigger, including its account and trigger SIDs, callback settings, current value, dates, recurrence, trigger field and value, and usage category.
account_sidstringoptional
The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that the trigger monitors.
api_versionstringoptional
The API version used to create the resource.
callback_methodstringoptional
The HTTP method we use to call `callback_url`. Can be: `GET` or `POST`.
Allowed:GETPOST
callback_urlstringoptional
The URL we call using the `callback_method` when the trigger fires.
current_valuestringoptional
The current value of the field the trigger is watching.
date_createdstringoptional
The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
date_firedstringoptional
The date and time in GMT that the trigger was last fired specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
date_updatedstringoptional
The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
friendly_namestringoptional
The string that you assigned to describe the trigger.
recurringstringoptional
The frequency of a recurring UsageTrigger. Can be: `daily`, `monthly`, or `yearly` for recurring triggers or empty for non-recurring triggers. A trigger will only fire once during each period. Recurring times are in GMT.
Allowed:dailymonthlyyearlyalltime
sidstringoptional
The unique string that that we created to identify the UsageTrigger resource.
trigger_bystringoptional
The field in the [UsageRecord](https://www.twilio.com/docs/usage/api/usage-record) resource that fires the trigger. Can be: `count`, `usage`, or `price`, as described in the [UsageRecords documentation](https://www.twilio.com/docs/usage/api/usage-record#usage-count-price).
Allowed:countusageprice
trigger_valuestringoptional
The value at which the trigger will fire. Must be a positive, numeric value.
uristringoptional
The URI of the resource, relative to `https://api.twilio.com`.
usage_categorystringoptional
The usage category the trigger watches. Must be one of the supported [usage categories](https://www.twilio.com/docs/usage/api/usage-record#usage-categories).
usage_record_uristringoptional
The URI of the [UsageRecord](https://www.twilio.com/docs/usage/api/usage-record) resource this trigger watches, relative to `https://api.twilio.com`.

Error handling

CallbackUrl, TriggerValue, and UsageCategory are required. The AccountSid path parameter must be a 34-character SID beginning with AC followed by 32 hexadecimal characters. CallbackUrl must be a URI, CallbackMethod must be GET or POST, Recurring must be daily, monthly, yearly, or alltime, and TriggerBy must be count, usage, or price; FriendlyName can be up to 64 characters. Use a supported usage category for UsageCategory; encode a leading plus sign in an offset TriggerValue as %2B.