Create
Create a new alert
Parameters
Type of the alert
Name of the alert
Threshold value of the alert policy. Depending upon the alert type, this number may represent a financial amount, the days remaining, or a percentage reached.
For alerts of type usage_threshold_reached, specifies which billable metric to track the usage for.
An array of strings, representing a way to filter the credit grant this alert applies to, by looking at the credit_grant_type field on the credit grant. This field is only defined for CreditPercentage and CreditBalance alerts
ID of the credit's currency, defaults to USD. If the specific alert type requires a pricing unit/currency, find the ID in the Metronome app.
A list of custom field filters for alert types that support advanced filtering. Only present for contract invoices.
If provided, will create this alert for this specific customer. To create an alert for all customers, do not specify a customer_id.
If true, the alert will evaluate immediately on customers that already meet the alert threshold. If false, it will only evaluate on future customers that trigger the alert threshold. Defaults to true.
Only present for spend_threshold_reached alerts. Scope alert to a specific group key on individual line items.
Only supported for invoice_total_reached alerts. A list of invoice types to evaluate.
If provided, will create this alert for this specific plan. To create an alert for all customers, do not specify a plan_id.
Prevents the creation of duplicates. If a request to create a record is made with a previously used uniqueness key, a new record will not be created and the request will fail with a 409 error.
Returns
require "metronome_sdk"
metronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")
alert = metronome.v1.alerts.create(
alert_type: :spend_threshold_reached,
name: "$100 spend threshold reached",
threshold: 10000
)
puts(alert)
{
"data": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
}
}