Overview
An alert tells you when a value crosses a threshold withalert.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:
- 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. - A wallet balance hits 0:
alert.triggered, you suspend usage. The customer tops up:alert.resolved, you re-open access.
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.
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.- Dashboard
- API
Usage alerts and credits consumption alerts share the same thresholds table. To opt a threshold in:
- Open the alert form from the Alerts tab of a subscription (Create alerts) or of a wallet (Create alert), or edit an existing alert;
- Give the threshold a Threshold code;
- Set Notify when resolved to True on that threshold; and
- Click Create alert or Save edits.
- 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.
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 withvalue_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.resolvedin the Alerts category. - API: add
alert.resolvedto the endpoint’sevent_types.
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 noalert.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
criticalthreshold at 0 sendsalert.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_thresholdsof the lastalert.resolvedyou received. - Lifetime usage rarely goes down. Resolution on lifetime alerts only fires after a correction, for example a voided invoice leaving the invoiced total.