> ## Documentation Index
> Fetch the complete documentation index at: https://getlago.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Use Lago's OpenAPI specification

> Read exact v2 API schemas, generate clients, and build agent tools from the Lago API v2 OpenAPI contract.

The [v2 OpenAPI specification](https://swagger.getlago.com/openapi-v2.yaml) describes the native `/api/v2` operations: product catalog, rate cards, plans, contracts, billing, customers, organizations, billing entities, billable metrics, events, logs, and webhook endpoints. It lists request fields, responses, and authentication for each operation. Read or download it without a Lago account. You need an organization's API key to call its authenticated operations.

> [!NOTE]
>
> API v2 is in beta. Endpoints return the `X-Lago-Endpoint-Status: beta` header.

Lago publishes one document per API version:

| API | Specification |
| - | - |
| v2 (Contracts, beta) | `https://swagger.getlago.com/openapi-v2.yaml` |
| v1 | `https://swagger.getlago.com/openapi.yaml` |

The v2 document only lists endpoints checked against their v2 implementation. Some other `/api/v2` paths fall back to v1 controllers and are not described in it. Do not assume a v1 endpoint exists in v2 or returns the same shape. Features v2 does not cover yet work with `/api/v1` only and are described in the [v1 specification](https://getlago.com/docs/guide/lago-open-api.md).

## Choose the right interface

| Task | Start with |
| - | - |
| Configure the catalog, inspect data, or call v2 endpoints from a terminal or coding agent | [Lago CLI](https://getlago.com/docs/v2/guide/lago-cli/overview.md), under `lago v2` |
| Check exact fields, generate a client, or build API tools for an agent | v2 OpenAPI specification |
| Integrate billing into your application's server-side code | Official SDK v2 client or the [v2 REST API](https://getlago.com/docs/v2/api-reference/intro.md) |

OpenAPI describes the API. The CLI, SDKs, and tools execute requests. An agent with HTTP access can use the API directly. Neither the CLI nor the Lago plugin is a prerequisite for that path.

The [Python](https://github.com/getlago/lago-python-client/blob/main/docs/api-v2.md), [JavaScript](https://github.com/getlago/lago-javascript-client/blob/main/docs/api-v2.md), [Ruby](https://github.com/getlago/lago-ruby-client/blob/main/docs/api-v2.md), and [Go](https://github.com/getlago/lago-go-client/blob/main/docs/api-v2.md) SDKs ship a v2 client generated from this specification, in beta. The [Lago MCP server](https://getlago.com/docs/guide/ai-agents/mcp-server.md) exposes v1 operations only. It has no contract or product catalog tools.

## Use the contract with an agent or generator

```bash theme={"dark"}
curl -fsSL https://swagger.getlago.com/openapi-v2.yaml -o lago-openapi-v2.yaml
```

Give the downloaded contract to your coding agent or OpenAPI-compatible generator. Use the relevant operation's request schema, required fields, response schema, and security requirements. Consult the [contracts guides](https://getlago.com/docs/v2/guide/contracts/overview.md) for billing behavior and sequencing.

* Select the API region and organization explicitly. Cloud US uses `https://api.getlago.com/api/v2`. Cloud EU uses `https://api.eu.getlago.com/api/v2`. Self-hosted instances expose the same paths under `/api/v2` on your API host.
* Keep API keys server-side and outside prompts or generated source files.
* Most catalog and contract operations require the product catalog to be enabled on the organization. A valid schema does not mean the organization can call the operation.
* v2 lists use cursor pagination (`limit`, `after`, `before`), related objects are returned only through `expands[]`, and errors carry a `code` and a `details` array. Generated clients must handle these. See [Pagination](https://getlago.com/docs/v2/api-reference/pagination.md), [Expansions](https://getlago.com/docs/v2/api-reference/expansions.md), and [Errors](https://getlago.com/docs/v2/api-reference/errors.md).
* Pin the contract revision when generating a client or tool, and review contract changes before regenerating. v2 is in beta, so operation and field names can change between revisions. The [OpenAPI repository](https://github.com/getlago/lago-openapi) tracks the source in `src/v2/` and the bundle in `openapi-v2.yaml`. `lago version` reports the v2 contract bundled with an installed CLI release as `spec_v2_version` and `spec_v2_sha256`.
* Review write requests and test in an isolated organization before changing production billing. A schema describes a request's shape. It does not authorize the operation or confirm the intended amount.

## Explore with Swagger or Postman

Browse the v2 operations in [Swagger](https://swagger.getlago.com/?urls.primaryName=API+v2+%28beta%29). The selector at the top of the page switches between v1 and v2.

Lago does not publish a Postman collection for v2. To import the contract into Postman:

1. Open **Import** and choose the option to import from a link.
2. Enter `https://swagger.getlago.com/openapi-v2.yaml` and complete the import.
3. Generate a collection from the imported API if needed.
4. Set the base URL for your region: `https://api.getlago.com/api/v2` (US), `https://api.eu.getlago.com/api/v2` (EU), or your self-hosted host followed by `/api/v2`. Provide your organization's API key through Postman's secret or environment controls.

Check the destination and request body before executing a write. For a complete walkthrough from product to invoice, see [your first invoice](https://getlago.com/docs/v2/guide/introduction/your-first-invoice.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.