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

# Build with AI agents

> Hand Ledger to your coding agent. It models your pricing, adds check and track to your backend and verifies it in Sandbox, starting without an account.

Your coding agent can add Ledger billing to your app in one session: it models your pricing, publishes the catalog, wires check and track into your backend and verifies the result in Sandbox. Paste this into Claude Code, Codex, Cursor or any other agent in your app's repository:

```text Prompt wrap theme={"system"}
Add Ledger billing to my app: docs.integrateledger.com/skill.md
```

The agent runs the [Ledger skills](#ledger-skills) in Sandbox, without a key from you. The rest of this page covers the skills, a keyless Sandbox, and the machine-readable docs.

## Ledger skills

Four [agent skills](https://agentskills.io) take your agent through onboarding. The prompt above starts the first, which hands over to `ledger-catalog` and `ledger-integrate`; both load `ledger-concepts` first.

| Skill | What it does | Where it comes from |
| - | - | - |
| `ledger-setup` | Runs onboarding from start to finish: reads your pricing, connects to your Sandbox, then hands over to `ledger-catalog` and `ledger-integrate` | [`/skill.md`](https://docs.integrateledger.com/skill.md) |
| `ledger-concepts` | Defines Ledger's objects (features, plans, credits, reservations, entities, controls, overage, subscriptions) and their rules, so the other skills model your pricing correctly | `npx integrateledger-cli@0.4.1 skills` |
| `ledger-catalog` | Interviews you about your pricing (allowances, limits, flags, credits, AI usage, seats, add-ons, rewards, overage), writes `ledger.catalog.json`, shows the table and diff, and publishes to Sandbox after your yes | `npx integrateledger-cli@0.4.1 skills` |
| `ledger-integrate` | Adds check and track to one flow in your backend, including AI calls priced by model and tokens, verifies it in Sandbox, and measures the latency | `npx integrateledger-cli@0.4.1 skills` |

`ledger skills` (and `ledger init`) writes the three CLI skills to `.agents/skills/` in your repository, so they match the CLI version that runs their commands:

```bash theme={"system"}
npx integrateledger-cli@0.4.1 skills
```

```text Written theme={"system"}
.agents/skills/ledger-catalog/SKILL.md
.agents/skills/ledger-catalog/references/ai-credits.md
.agents/skills/ledger-catalog/references/rewards.md
.agents/skills/ledger-concepts/SKILL.md
.agents/skills/ledger-concepts/references/controls.md
.agents/skills/ledger-concepts/references/credits-and-balances.md
.agents/skills/ledger-concepts/references/customer-entity.md
.agents/skills/ledger-concepts/references/feature.md
.agents/skills/ledger-concepts/references/overage.md
.agents/skills/ledger-concepts/references/plan-items.md
.agents/skills/ledger-concepts/references/plan.md
.agents/skills/ledger-concepts/references/reservations.md
.agents/skills/ledger-concepts/references/subscription-lifecycle.md
.agents/skills/ledger-integrate/SKILL.md
.agents/skills/ledger-integrate/references/ai-calls.md
.agents/skills/ledger-integrate/references/feature-types.md
```

`ledger-setup` is served at [`docs.integrateledger.com/skill.md`](https://docs.integrateledger.com/skill.md), so the prompt always starts the current one. Codex, Cursor and other agents read `.agents/skills/`. For Claude Code and agents that read their own folder, the CLI's last line links them:

```bash theme={"system"}
npx skills add ./.agents/skills --agent claude-code --skill '*' -y
```

Run `ledger skills` again after upgrading the CLI.

The skills run in Sandbox, never print your key, and publish nothing until you approve the diff.

## A Sandbox without an account

Your agent can start before you make an API key. With no `LEDGER_API_KEY` set, the setup skill runs `ledger agent start`, which makes a Ledger Sandbox for your app with no account and gives the agent its key. It then shows you two choices:

* **You already have a Ledger account.** Open the approval link the agent shows you, within 10 minutes, and choose **Connect agent**. The agent gets a Sandbox key for your own workspace instead (`ledger agent wait`), and the Sandbox it made is removed if nothing was built in it.
* **You don't.** The agent carries on in its Sandbox. At the end it gives you a claim link (`ledger agent claim`): open it within 10 minutes, sign up, and the Sandbox, with everything the agent set up, becomes your workspace. The agent's key keeps working.

Going Live is always your step, from the dashboard.

`ledger agent init` does the whole setup in one run: it gitignores `.env` and `.ledger/`, writes the skills, reuses a working Sandbox key or makes a Sandbox as `agent start` does, and prints the workspace, the approval link if it made one, and the next step (`--json` for agents). Running it again changes nothing.

Other agents can use the same routes the CLI does: `POST /v1/agent/provision` with `{ "name" }` returns `{ workspaceId, apiKey, approval: { url, pollToken, expiresAt } }`. `POST /v1/agent/approval/poll` with `{ "pollToken" }` answers `pending`, `denied` or `expired`, or once `{ status: "approved", workspaceId, apiKey }`. With the provisioned key, `POST /v1/agent/approval` makes a new approval link and `POST /v1/agent/claim` a claim link. These routes are for agents; your app itself uses the SDKs.

## Sources for agents

| Source | URL | Use it for |
| - | - | - |
| Docs index | [`/llms.txt`](https://docs.integrateledger.com/llms.txt) | Every page with a one-line description. Start here. |
| Full docs | [`/llms-full.txt`](https://docs.integrateledger.com/llms-full.txt) | Every page in one Markdown file. |
| Any page as Markdown | Add `.md` to its URL, for example [`/quickstart.md`](https://docs.integrateledger.com/quickstart.md) | One page, without the site around it. |
| OpenAPI spec | [`/openapi.json`](https://docs.integrateledger.com/openapi.json) | Every endpoint, field and response, for codegen and tool definitions. |
| Docs MCP server | `https://docs.integrateledger.com/mcp` | Search and read these docs from Claude, Cursor or any MCP client. |

Every page also has a menu at the top, next to the title, to copy it as Markdown, open it in Claude or ChatGPT, or connect the MCP server to Cursor or VS Code.

## Connect the docs MCP server

```bash Claude Code theme={"system"}
claude mcp add --transport http ledger-docs https://docs.integrateledger.com/mcp
```

```json Cursor (.cursor/mcp.json) theme={"system"}
{
  "mcpServers": {
    "ledger-docs": {
      "url": "https://docs.integrateledger.com/mcp"
    }
  }
}
```

The server answers questions from these docs. It reads the docs alone, so your workspace and the Ledger API stay private to your keys.

## Integrate without the skills

For any agent, with or without skills, paste this instead. It plans first, then builds the integration in Sandbox.

```text Prompt wrap theme={"system"}
Integrate Ledger, usage-based billing on Stripe with docs at https://docs.integrateledger.com, into this app.

Read https://docs.integrateledger.com/llms.txt first, then the pages you need as Markdown (append .md to a page URL), starting with /how-ledger-works.md and /pricing/choose-a-model.md. The OpenAPI spec is at https://docs.integrateledger.com/openapi.json.

1. Propose a catalog for this app and wait for my approval: features, each with a type (metered for usage with a monthly allowance, held for counts such as projects or seats, boolean for on/off features, credits for actions priced from one shared balance), and plans with an item for each feature they include (an allowance, a limit or unlimited), a price, and any overage, seat price or credit packs. Include one free plan.
2. Use the official SDK for this codebase's language (`integrateledger` 0.4.0 on npm or PyPI). Read the key from the LEDGER_API_KEY environment variable on the server. Never send it to the browser.
3. Write the approved catalog to ledger.catalog.json (or ledger.config.ts in a JavaScript project) and publish it with `npx integrateledger-cli push --yes`, using the Sandbox key.
4. Create or get a Ledger customer for each user, with our own user ID as customerId. Attach the free plan on signup.
5. Gate each billed action with POST /v1/check, then call POST /v1/track after it succeeds, with a request_id unique to that action. For held features, track quantity 1 when one is added and -1 when one is removed. Handle allowed: false and its reason (no_plan, feature_not_in_plan, limit_reached, insufficient_credits, overage_cap_reached) with an upgrade offer, and the same codes as a 409 from track.
6. Add a billing page: plan, each feature's balance, plan Checkout and upgrades, and stop or resume renewal. Re-read state from the backend after Checkout; never trust the redirect.
7. Write tests for the check and track paths, and tell me how to try them with Stripe test cards.
```

## Rules

* The skills and `ledger agent init` accept Sandbox keys (`ledger_test_`) and refuse Live keys.
* Agent keys reach Sandbox. You go Live from the dashboard.
* Approval and claim links expire after 10 minutes.
* Each network address can make 2 keyless Sandboxes an hour.
* A keyless Sandbox nobody claims is deleted after 30 days without activity.

## Next steps

> [card] [Quickstart](https://docs.integrateledger.com/quickstart.md)
>
> The same integration, step by step.

> [card] [API reference](https://docs.integrateledger.com/api-reference/introduction.md)
>
> Every endpoint, with requests and responses.


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