Skip to main content

Overview

Usage alerts notify you when a Contract’s usage or spend crosses thresholds you define. Common use cases:
  1. Let customers set and manage their own usage limits and budgets;
  2. Warn customers whose usage is climbing fast, before it reaches their bill; or
  3. Stop serving usage when a customer reaches the limit you defined for them.
Usage alerts on Contracts are a premium feature, in beta. Contact the Lago team to enable them on your organization.

Create an alert

An alert is tied to a specific Contract. You can create one on a pending or active Contract:
  1. Open the Contract and select Alerts in its overview;
  2. Click Create alert;
  3. Enter a name and a code for the alert;
  4. Select the alert type, Usage units or Usage amount;
  5. In Include, select a product, and optionally one of its product filters. A usage amount alert can also cover every product;
  6. Set the thresholds and their codes;
  7. Optionally, set Notify when resolved to True on a threshold to also receive alert.resolved;
  8. Optionally, turn on Recurring alert after last threshold; and
  9. Click Create alert to confirm.
The Create an alert on contract form, with a usage units alert on the LLM tokens product and a 1,000,000 units threshold

Create an alert on a Contract

The Alerts tab lists every alert of the Contract with its name and code.
The Alerts tab of the Hooli Enterprise Contract, listing eight alerts such as Monthly spend, Opus tokens and Video minutes

Alerts of a Contract

Alert types

  • Usage amount (usage_amount): the amount of the usage in scope for the current billing period, before taxes. Values are in cents of the Contract currency, so "100000" is 1,000.00.
  • Usage units (usage_units): the number of units in scope for the current billing period. A units alert needs a product in its scope.

Scope

The scope sets which usage the alert measures. It takes one entry at most. The product, and the filter if any, must be priced on the Contract. A fixed product cannot be used.

Thresholds

  • An alert takes up to 20 thresholds, the recurring one included.
  • One threshold can be recurring. It repeats every value above the highest non-recurring threshold.
  • Each threshold notifies on triggered. Add resolved to notify_on to also be notified when the value goes back below it. A threshold that opts in needs a code.

Billing period

Each Rate Card is measured on its own current billing period, so the Rate Cards of one Contract can reset on different dates. When a Rate Card’s period restarts, its usage leaves the alert’s value and its thresholds can trigger again. This also happens when a new rate takes effect during the period. A restart never sends alert.resolved. Usage on a recurring billable metric never resets.

Alert notifications

Listen for the alert.triggered webhook. It names the alert, the Contract evaluated, the value that crossed the line, and every threshold crossed. currency is set on usage_amount alerts and null on usage_units alerts.

Alert resolution

Thresholds that opt in with notify_on: ["triggered", "resolved"] send alert.resolved when the value is back below them, or when an update raises or removes them. The reason is recovered, threshold_updated or threshold_removed.

Contract lifecycle

  • Only the active Contract is evaluated. Alerts created on a pending Contract are evaluated once it is active.
  • When the Contract is terminated, its alerts stop being evaluated and stay readable.
  • Alerts follow the Contract’s external_id. A new Contract created with the same external_id picks them up.
  • If a product or filter leaves the Contract, its alerts are kept and skipped. If the product or filter is deleted, its alerts are deleted.

Limitations

  • An alert is evaluated after new events or after it is created or updated, close to real time. Its first evaluation sends alert.triggered for every threshold already passed;
  • Each alert code must be unique per Contract, and only one alert per type and scope can exist on a Contract; and
  • The API key needs the alert permission.