A billing alert is a resource that notifies you when a certain usage threshold on a meter is crossed. For example, you might create a billing alert to notify you when a certain user made 100 API requests.
Attributes
- idstring
Unique identifier for the object.
- objectstring
String representing the objectâs type. Objects of the same type share the same value.
- alert_
typeenum Defines the type of the alert.
Possible enum valuesusage_
threshold Use
usage_
if you intend for an alert to fire when a usage threshold on a meter is crossed.threshold - livemodeboolean
Has the value
true
if the object exists in live mode or the valuefalse
if the object exists in test mode. - statusnullable enum
Status of the alert. This can be active, inactive or archived.
- titlestring
Title of the alert.
- usage_
thresholdnullable object Encapsulates configuration of the alert to monitor usage on a specific Billing Meter.
{ "id": "alrt_12345", "object": "billing.alert", "title": "API Request usage alert", "livemode": true, "alert_type": "usage_threshold", "usage_threshold": { "gte": 10000, "meter": "mtr_12345", "recurrence": "one_time" }, "status": "active"}
Creates a billing alert
Parameters
- alert_
typeenumRequired The type of alert to create.
Possible enum valuesusage_
threshold Use
usage_
if you intend for an alert to fire when a usage threshold on a meter is crossed.threshold - titlestringRequired
The title of the alert.
- usage_
thresholdobject The configuration of the usage threshold.
Returns
Returns a billing alert
{ "id": "alrt_12345", "object": "billing.alert", "title": "API Request usage alert", "livemode": true, "alert_type": "usage_threshold", "usage_threshold": { "gte": 10000, "meter": "mtr_12345", "recurrence": "one_time" }, "status": "active"}
Retrieves a billing alert given an ID
Parameters
No parameters.
Returns
Returns the alert
{ "id": "alrt_12345", "object": "billing.alert", "title": "API Request usage alert", "livemode": true, "alert_type": "usage_threshold", "usage_threshold": { "gte": 10000, "meter": "mtr_12345", "recurrence": "one_time" }, "status": "active"}
Lists billing active and inactive alerts
Parameters
- alert_
typeenum Filter results to only include this type of alert.
Possible enum valuesusage_
threshold Use
usage_
if you intend for an alert to fire when a usage threshold on a meter is crossed.threshold - meterstring
Filter results to only include alerts with the given meter.
More parameters
- ending_
beforestring - limitinteger
- starting_
afterstring
Returns
Returns a list of billing alerts
{ "data": [ { "id": "alrt_12345", "object": "billing.alert", "title": "API Request usage alert", "livemode": true, "alert_type": "usage_threshold", "usage_threshold": { "gte": 10000, "meter": "mtr_12345", "recurrence": "one_time" }, "status": "active" }, { "id": "alrt_67890", "object": "billing.alert", "title": "API Request usage alert", "livemode": true, "alert_type": "usage_threshold", "usage_threshold": { "gte": 120, "meter": "mtr_67890", "recurrence": "one_time" }, "status": "active" } ]}