Skip to product information

Meter AI Tokens to Lago Credits via Webhook Receipt

Meter AI Tokens to Lago Credits via Webhook Receipt

 (200+Reviews)
Regular price £16.99
Regular price £16.99 Sale price
SAVE Sold out
⬇
Instant Digital Download
∞
Unlimited Downloads
★
Lifetime Access in Your Account
🔥
128+ Sold
Popular with n8n builders
âš¡
23 people viewing
High interest right now
✅
9 added today
Fast-moving digital product
Meter AI Tokens to Lago Credits via Webhook Receipt

Meter AI Tokens to Lago Credits via Webhook Receipt

Regular price £16.99
Regular price £16.99 Sale price
SAVE Sold out

Automatically meter AI token usage and translate it into Lago credits (with a webhook receipt)

This n8n workflow receives AI token metering via a webhook, estimates the prepaid cost in Lago, records the usage as a Lago event, and returns an HTTP receipt that warns you when credits are at (or below) a configurable threshold.

What this workflow does

  • Receives a POST webhook with subscription identifiers, token counts, and metering details.
  • Validates and normalizes input (including an optional timestamp). Invalid requests return a 400 JSON error response.
  • Estimates pay-in-advance fees in Lago for the provided metric and sums the returned fee amounts.
  • Fetches the customer’s Lago prepaid wallet and converts the estimated fee into credits to compute a projected post-usage credit balance.
  • Sends the usage event to Lago, using the provided transaction ID for idempotency.
  • Builds a JSON receipt that includes estimated cost and projected balance, and returns HTTP 202 with a status that flags low credits when at/below the configured threshold.

Use cases

  • SaaS metering: Track model token consumption per customer and automatically charge against Lago prepaid credits.
  • Usage-aware budgeting: Proactively detect when customers are nearing a credit cutoff using the webhook receipt warning.
  • Operations automation: Centralize token metering logic in n8n while keeping Lago as the billing source of record.

Technical details

  • n8n nodes: webhook, if, set, code, sticky note, respond to webhook.
  • Lago integration: uses Lago community node credentials to estimate fees, fetch prepaid wallet info, and send the usage event with idempotency via transaction ID.
  • Setup notes: create a billable metric in Lago (e.g., Sum aggregation on a units property) and add it to an active plan as a pay-in-advance charge so fee estimation works.
View full details