Skip to main content

Overview

An alert tells you when a value crosses a threshold with alert.triggered. Alert resolution adds the other half: alert.resolved, sent when the value is back on the safe side of that threshold. Use it to close an automation loop on webhooks alone:
  1. Usage hits a hard cap: alert.triggered, you pause the customer’s jobs. A usage correction brings it back under: alert.resolved, you resume them.
  2. A wallet balance hits 0: alert.triggered, you suspend usage. The customer tops up: alert.resolved, you re-open access.
Resolution is opt-in per threshold. A threshold that does not opt in behaves exactly as before. It works with every usage alert and credits consumption alert type.

How it works

Each threshold is either ok or in alarm: A value sitting exactly on the line is still in alarm. With a hard threshold at 10,000 units, 10,000 is in alarm and 9,999 resolves. With a critical threshold at 0, a balance of 0 is in alarm and any positive balance resolves. Lago sends one notification per state change:
  • ok → in alarm sends alert.triggered, as today;
  • in alarm → ok sends alert.resolved, if the threshold opted in; and
  • a threshold in alarm never triggers again until it resolves, so a value hovering above the line does not produce a storm of events.
When one evaluation clears several thresholds (a large top-up, a large correction), Lago sends a single alert.resolved listing every opted-in threshold that recovered. Thresholds are paired by code. This is why a threshold must have a code to opt in.

Configure resolution

Resolution is set per threshold. Every existing threshold starts at False (triggered only), so nothing changes until you opt a threshold in.
Usage alerts and credits consumption alerts share the same thresholds table. To opt a threshold in:
  1. Open the alert form from the Alerts tab of a subscription (Create alerts) or of a wallet (Create alert), or edit an existing alert;
  2. Give the threshold a Threshold code;
  3. Set Notify when resolved to True on that threshold; and
  4. Click Create alert or Save edits.
The form checks the rules before saving:
  • A threshold set to True needs a code: “Add a threshold code to notify when this threshold is resolved”.
  • That code must be unique within the alert: “This code is used by another threshold. Use a unique code to notify when resolved”.
  • On the recurring threshold, Notify when resolved stays at False and cannot be changed.
As soon as one threshold is set to True, the form reminds you that your webhook endpoints must listen to alert.resolved, with a link to Webhooks that opens in a new tab, so your draft stays open.On a wallet, the Alerts tab shows the Notify when resolved value of each threshold, recurring threshold included.

Updating notify_on through the API

  • Omitted: the current setting is kept, matched by threshold code. A threshold whose code changes starts from the default.
  • null: resets to the default ["triggered"].
  • A string instead of a list ("resolved"): rejected with value_is_invalid.

API validation

Subscribe your webhook endpoint

alert.resolved is a new webhook type. An endpoint that receives all events gets it automatically. An endpoint that listens to selected events must add it:
  • Dashboard: Developers > Webhooks, edit the endpoint, and check alert.resolved in the Alerts category.
  • API: add alert.resolved to the endpoint’s event_types.
See webhook messages.

The alert.resolved webhook

Resolution reasons

threshold_updated and threshold_removed are sent as soon as the edit is saved, with no change in usage or balance.

Edge cases

Treat deletion and termination as the end of the guardrail. If your system blocked a customer on an alert you then delete, or on a subscription that ends, lift that block on your side.

Billing period renewal

A renewal is never a recovery. Usage returning to zero at the start of a period sends no alert.resolved. What happens to thresholds at renewal depends on what the alert watches: Usage measured before a renewal but processed after it still counts toward the period it belongs to.

Limitations

  • Recurring thresholds cannot opt in to resolution. One recurring threshold stands for an unbounded series of lines, so a resolution could not say which one cleared.
  • Thresholds must have a code, unique within the alert, to opt in. The Dashboard blocks the save until both are true.
  • A threshold resolves on its own line. There is no separate resolve margin (hysteresis): a top-up of 0.01 above a critical threshold at 0 sends alert.resolved. Pick the threshold value accordingly.
  • Usage alerts are evaluated as events are processed, about every minute. Wallet alerts are evaluated on each balance movement, within seconds. Edits resolve immediately.
  • The API does not expose a per-threshold state. To reconcile after missed webhooks, compare the current usage or balance with your thresholds, or use the in_alarm_thresholds of the last alert.resolved you received.
  • Lifetime usage rarely goes down. Resolution on lifetime alerts only fires after a correction, for example a voided invoice leaving the invoiced total.