---
name: lago-billing
description: Plan and implement secure Lago usage metering and billing integrations. Use when an agent needs to work with Lago customers, events, subscriptions, invoices, entitlements, API keys, webhooks, or SDKs.
---

# Lago billing integration

Use Lago's public documentation and OpenAPI description as the source of truth. Start with the developer hub at `https://getlago.com/developers`, then consult the exact API operation in `https://getlago.com/api/openapi.yaml`.

## Workflow

1. Confirm the Lago region and API base URL.
2. Obtain a scoped server-side API key and send it as a bearer credential.
3. Define stable external customer, subscription, and transaction identifiers.
4. Create the customer and subscription before sending metering events.
5. Make event ingestion idempotent by using a unique transaction ID for every event.
6. Validate webhook signatures before processing billing events.
7. Handle structured `401`, `403`, `404`, and `422` errors explicitly.

## Safety

- Never expose Lago API keys in browser code, logs, prompts, or generated artifacts.
- Prefer read-only or narrowly scoped keys when the task does not require writes.
- Confirm identifiers and affected records before destructive or billing-changing operations.
- Use a test organization or non-production deployment for integration validation.

## Resources

- Developer hub: `https://getlago.com/developers`
- Authentication: `https://getlago.com/auth.md`
- API reference: `https://getlago.com/docs/api-reference/intro`
- Complete OpenAPI: `https://getlago.com/api/openapi.yaml`
- Webhooks: `https://getlago.com/docs/api-reference/webhooks/format---signature`
- Agent discovery MCP: `https://getlago.com/mcp`
- Full documentation MCP: `https://docs.getlago.com/mcp`
