Skip to main content
The Lago API is the REST API for the contracts billing engine. Use it to build a product catalog, price it with rate cards, package it in plans and bill customers through contracts.
API v2 is in beta. Endpoints return the X-Lago-Endpoint-Status: beta header.

Base URLs

Self-hosted instances expose the same paths under /api/v2 on your API host.

Authentication

Every request uses a bearer API key. Create and rotate keys in the dashboard. See API keys.
Keep API keys server-side. Never ship them in client code or commit them to a repository. Most catalog and contract endpoints require the product catalog to be enabled on the organization. Each endpoint also checks the read or write permission of the API key on its resource. The requirement is stated on each endpoint page.

Conventions

  • JSON bodies, wrapped by resource. A create or update request wraps its fields in the resource key, for example {"contract": {...}}.
  • Codes and external IDs as identifiers. Catalog objects use your code. Customers and contracts use your external_id. Invoices, fees and payments use the lago_id that Lago returns.
  • PUT and PATCH. Both update a resource. Each endpoint page lists the accepted fields.
  • Cursor pagination. Lists use limit, after and before. See Pagination.
  • Opt-in expansions. Related objects are returned only when you ask with expands[]. See Expansions.
  • Structured errors. Failures return a code and a details array. See Errors.
  • Beta header. Responses carry X-Lago-Endpoint-Status: beta.

API scope

This reference documents the native v2 endpoints only: product catalog, rate cards, plans, contracts, billing, customers, organizations, billing entities, billable metrics, events, logs and webhook endpoints. Only the documented actions and expansions are supported. Some other /api/v2 paths fall back to v1 controllers and are not described here. Use the v1 API reference for subscriptions and the features v2 does not cover yet. The complete machine-readable contract is the OpenAPI specification. Generate clients from it and review diffs before upgrading.

Your first invoice

Go from product to contract to invoice with the API.

Contracts vs subscriptions

What changed between v1 and v2, and which one to use.

Create a contract

POST /contracts

Ingest an event

POST /events with external_contract_id