Lago webhooks
Lago webhooks are HTTP POST messages that tell your application when something changes in your Lago billing, such as an invoice being finalized or a subscription starting.
How Lago webhooks work
Webhooks push billing changes to your server as they happen, so you don't have to poll the Lago API. An organization can have up to 10 endpoints, each with its own list of message types, and Lago sends a POST with a JSON body to every endpoint subscribed to the type.
webhook_type says what happened, such as invoice.created. object_type names the key that holds the object, so that message has an invoice key, and the X-Lago-Unique-Key header identifies the message. Lago documents no version for its messages, and it adds new types over time.
Key facts
JWT, RSA, HMAC-SHA256 Two schemes, chosen per endpoint: check which one yours uses.
{raw body} HMAC mode signs the body as sent. In JWT mode the token's data claim carries the body, and you compare it with what you received.
Setting up Lago webhooks
- Create an endpoint under Developers > Webhooks in the Lago app, or with
POST /api/v1/webhook_endpoints, then choose its signature and message types. Lago uses JWT unless you choose HMAC. - Choose HMAC for an endpoint that points at Hookdeck Event Gateway. To change an existing one, send
PUT /api/v1/webhook_endpoints/{lago_id}withsignature_algoset tohmac. - Test locally with the Hookdeck CLI:
hookdeck listen 3000 lago --path /webhooks/lagogives you a public URL that forwards to your machine. - Resend a failed message from the webhook logs, under the endpoint's Deliveries tab in Developers > Webhooks.
Delivery behaviour
not published for Lago Cloud; self-hosted defaults to 30 seconds, set with LAGO_WEBHOOK_TIMEOUT_SECONDS Retries 3 attempts the first call plus 2 retries, with growing waits; self-hosted sets the total with LAGO_WEBHOOK_ATTEMPTS After the last attempt error in the logs you can retry the message from the webhook logs Ordering not guaranteed Lago advises tolerating reordering and fetching current state from the API Known failure modes
From Hookdeck's Lago guide →-
Duplicate deliveries
Lago sends a message again after an error response or a network issue. Record each
Handle duplicates →X-Lago-Unique-Keyand process each value once. -
Out-of-order delivery
Lago advises integrations to tolerate reordering. Fetch the object's current state from the API when your next step depends on it.
Handle ordering → -
Messages missed after an outage
Lago makes up to 3 attempts per message, then shows an error in the webhook logs. Retry failed messages from the logs and reconcile against the API after any outage.
Retries and failed messages → -
HMAC checks fail on a new endpoint
Lago signs with JWT unless you choose HMAC, so an HMAC check can't match a default endpoint's signature. If
Other Lago limits →X-Lago-Signature-Algorithmsaysjwt, change the endpoint or verify the token instead.
Lago webhook best practices
- Verify every signature.
Read
X-Lago-Signature-Algorithmfirst, because each endpoint signs with either JWT or HMAC. - Acknowledge fast and queue the work.
Lago's guide lists
200,201,202and204as acknowledgements. Store the message, send one of them, then process it in the background. - Deduplicate on the unique key.
Lago tells you to use
X-Lago-Unique-Keyto process a message only once, so record each value with a unique constraint. - Re-read state before acting. Lago advises tolerating reordering, and treating its API as the source of truth when a message and your stored state disagree.
- Accept types you don't recognize.
Lago adds message types over time, so acknowledge an unknown
webhook_typerather than failing it. - Prefer HMAC where header size matters. JWT carries the payload in the signature header, which can grow large enough for some servers to reject it.
Common Lago webhook events
Invoices
invoice.created | Invoice is finalized |
invoice.generated | Invoice PDF is ready |
invoice.payment_status_updated | Payment provider's information changes an invoice's payment status |
invoice.payment_failure | Invoice payment hits an error, often no valid payment method |
invoice.payment_overdue | Invoice payment becomes overdue |
Subscriptions
subscription.started | Subscription starts, including after a plan change |
subscription.terminated | Subscription ends, including after a plan change |
subscription.trial_ended | Subscription's free trial ends |
subscription.usage_threshold_reached | Progressive billing threshold is crossed |
Usage and credits
alert.triggered | Alert threshold is crossed |
wallet.depleted_ongoing_balance | Wallet's ongoing balance reaches zero or below |
events.errors | Hourly health check finds usage events that fail validation |
Events by resource
| Resource | Events | Payloads |
|---|---|---|
invoice | 13 | 13 |
customer | 11 | 7 |
subscription | 8 | 8 |
coupon | 4 | 4 |
order_form | 4 | 4 |
wallet | 4 | 4 |
add_on | 3 | 3 |
billable_metric | 3 | 3 |
credit_note | 3 | 2 |
feature | 3 | 3 |
5 more resources, including Other Lago events. All 83 events →
In this hub
| Webhook events → | Every covered Lago event, with payloads where the registry has them. |
| MCP events → | How an agent subscribes to Lago events as MCP events. |
| Verify signatures → | Signature facts, verification code and common failures. |
| Production guide → | Production problems, such as timeouts and retries, and how to handle them. |
| Agent skill → | Install the webhook skill in your coding agent. npx skills add hookdeck/webhook-skills --skill lago-webhooks |
Keep Lago's three attempts from costing you a billing event.
Point an HMAC-signed Lago endpoint at Hookdeck Event Gateway. It verifies the signature, queues each message and retries to your service on your schedule.