> ## 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.

# Seat licenses

> Sell seats of a plan inside another plan, such as Team at $20 a month with seats at $40 that each get their own 100 summaries a month.

> **Team:** $20 a month with 2 seats included, then $40 a seat. Each seat gets 100 summaries a month.

Sell seats that each come with their own plan: every member you assign gets the seat plan's credits and allowances, kept apart from the rest of the team, while the customer pays for the seats on one invoice.

A license lets a plan (the parent) sell seats of another plan (the seat plan). The seat plan is an ordinary plan with its own price and allowances, and the seats are counted on a `held` feature. Assign a seat to an [entity](https://docs.integrateledger.com/customers/entities.md), such as a user, and that entity gets the seat plan's allowances for the period.

**Seat licenses or per-seat pricing.** A [seat price](https://docs.integrateledger.com/pricing/per-seat.md) on a held item bills per seat and shares one allowance across the team. A license gives each seat its own allowance from the seat plan.

## The catalog

```ts ledger.config.ts theme={"system"}
import { defineCatalog, feature, plan } from "integrateledger-cli";

export default defineCatalog({
	features: [
		feature({ id: "seats", name: "Seats", type: "held" }),
		feature({ id: "summaries", name: "Summaries", type: "metered" }),
	],
	plans: [
		plan({
			id: "seat",
			name: "Seat",
			monthlyCredits: 0,
			priceCents: 4000,
			items: [{ featureId: "summaries", included: 100 }],
		}),
		plan({
			id: "team",
			name: "Team",
			monthlyCredits: 0,
			priceCents: 2000,
			licenses: [{ planId: "seat", seatFeatureId: "seats", includedSeats: 2, maxSeats: 50 }],
		}),
	],
});
```

```json ledger.catalog.json theme={"system"}
{
  "schemaVersion": 1,
  "features": [
    { "id": "seats", "name": "Seats", "type": "held" },
    { "id": "summaries", "name": "Summaries", "type": "metered" }
  ],
  "plans": [
    { "id": "seat", "name": "Seat", "monthlyCredits": 0, "priceCents": 4000,
      "items": [{ "featureId": "summaries", "included": 100 }] },
    { "id": "team", "name": "Team", "monthlyCredits": 0, "priceCents": 2000,
      "licenses": [{ "planId": "seat", "seatFeatureId": "seats", "includedSeats": 2, "maxSeats": 50 }] }
  ]
}
```

| Field | Required | What it sets |
| - | - | - |
| `planId` | Yes | The seat plan's ID |
| `seatFeatureId` | Yes | The `held` feature that counts the seats |
| `includedSeats` | Yes | Seats the parent's price includes: a whole number, 0 or more |
| `seatPriceCents` | No | The price of each seat past the included ones, in cents per the parent's billing interval, above 0. Left out: the seat plan's own price |
| `maxSeats` | No | The most seats one customer may hold, at least `includedSeats`. Left out: no maximum |

`GET /v1/plans` lists each plan's `licenses`, ordered by seat plan, with `seatPriceCents` and `maxSeats` only when they're set. A plan edit that leaves `licenses` out, such as the dashboard's plan form or `POST /v1/plans/{id}` without the field, keeps the current version's licenses.

## The seat price

A seat costs `seatPriceCents`, or the seat plan's own price when it's left out. When that price is above 0, Stripe sync creates a Stripe Price for the license (`ledger_price_role: license_seat`), recurring at the parent's billing interval, and the parent bills through Stripe even if its own price is \$0. Free seats need no Stripe Price.

The seat plan's own price is read when the parent's version is published and synced. To reprice seats on a parent version that's already synced, publish the parent again, or give its license a `seatPriceCents`.

## Sell seats

Attach the parent with `licenseSeats`, the total seats per seat plan, included ones counted:

```typescript TypeScript theme={"system"}
const result = await billing.attach({
	customerId: "acme",
	planId: "team",
	licenseSeats: [{ planId: "seat", seats: 5 }],
});
```

```python Python theme={"system"}
result = billing.attach(
    customer_id="acme",
    plan_id="team",
    license_seats=[{"plan_id": "seat", "seats": 5}],
)
```

```bash cURL theme={"system"}
curl https://api.integrateledger.com/v1/billing/attach \
  -H "Authorization: Bearer $LEDGER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"customerId": "acme", "planId": "team", "licenseSeats": [{"planId": "seat", "seats": 5}]}'
```

Team with 5 seats bills $20 for the plan and 3 × $40 for the seats past the 2 included, on one invoice: in Checkout, or on the saved card. Stripe's seat item holds the paid seats (3), and every renewal bills them again. A license left out of `licenseSeats` gets its included seats, with no seat line.

## Change the seat count

Send the new total, included seats counted, with an idempotency key:

```typescript TypeScript theme={"system"}
const change = await billing.setLicenseSeats({
	idempotencyKey: `seats_${seatChange.id}`, // saved when the customer confirmed
	body: { customerId: "acme", planId: "seat", seats: 8 },
});
if (change.status === "pending_payment" && change.paymentUrl) {
	return res.redirect(303, change.paymentUrl);
}
```

```python Python theme={"system"}
change = billing.set_license_seats(
    customer_id="acme",
    plan_id="seat",
    seats=8,
    idempotency_key=f"seats_{seat_change.id}",  # saved when the customer confirmed
)
if change["status"] == "pending_payment" and change.get("paymentUrl"):
    return redirect(change["paymentUrl"], code=303)
```

```bash cURL theme={"system"}
curl https://api.integrateledger.com/v1/licenses \
  -H "Authorization: Bearer $LEDGER_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: seats_sc_101" \
  -d '{"customerId": "acme", "planId": "seat", "seats": 8}'
```

* **Raising** bills the paid seats added at the seat price, prorated to the period end, on its own invoice to the saved card. The new seats are added once it's paid (`status: "applied"`); a card that needs the customer answers `pending_payment` with a `paymentUrl`. A new seat's holder gets the seat plan's allowance for what's left of the period, rounded down.
* **Lowering** takes effect at the period end (`status: "scheduled"`): the seats stay until the renewal, which bills the lower count.
* **The same total** changes nothing. Seats that cost nothing change at once, with no invoice.

The answer is `{ itemChangeId, status, paymentUrl, license }`, the license as it stands now; a retry with the same key answers the same change.

## Change the parent plan

Upgrading to a plan that sells the same seat plan (Team to Scale) moves the license with it, in the upgrade's one invoice: the seats, who holds them and what they've used carry over. The seat count is at least the new plan's `includedSeats`, and the paid seats move to its seat price, billed like the plan. An upgrade to a plan without those seats ends the license with the old plan once no seat is assigned.

## Assign and release seats

A seat sits empty until you assign it to an entity:

```typescript TypeScript theme={"system"}
const seat = await billing.assignLicenseSeat({ customerId: "acme", planId: "seat", entityId: "alice" });
```

```python Python theme={"system"}
seat = billing.assign_license_seat(customer_id="acme", plan_id="seat", entity_id="alice")
```

```bash cURL theme={"system"}
curl https://api.integrateledger.com/v1/licenses/assign \
  -H "Authorization: Bearer $LEDGER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"customerId": "acme", "planId": "seat", "entityId": "alice"}'
```

```json Response theme={"system"}
{ "planId": "seat", "entityId": "alice", "slot": 1 }
```

The entity gets the lowest free seat, and with it the seat plan's credits and metered allowances for the billing period. They're the entity's own: its tracks spend them before the shared pool, and the customer and other entities never spend them. [Get an entity](https://docs.integrateledger.com/api-reference/entities/get.md) lists its `seats`, and its `allowanceRemaining` counts the seat's credits.

* **Assigning is idempotent.** An entity that already holds a seat gets the same seat back, and nothing more is granted.
* **Releasing frees the seat.** [`POST /v1/licenses/release`](https://docs.integrateledger.com/api-reference/licenses/release) ends the entity's seat grants now, and the customer still pays for the seat.
* **Usage stays with the seat.** Assign a released seat to another entity and that entity gets what's left of the period's allowance. Each renewal gives every assigned seat the seat plan's full allowance; empty seats are granted when they're assigned.
* **Deleting an entity releases its seats.**
* **The seat feature follows.** Its held count is the number of assigned seats, and its limit is the license's seats: [check](https://docs.integrateledger.com/customers/check-and-track.md) and `GET /v1/customers` report it as a held balance (`included` the seats, `used` the assigned ones).

[List licenses](https://docs.integrateledger.com/api-reference/licenses/list.md) (`GET /v1/licenses?customerId=`) gives each license's `seats`, `includedSeats`, `assigned`, `available`, and who holds which slot. Assigning and releasing never change what the customer pays.

## The seat plan's features

An entity holding a seat gets the seat plan's features: its booleans are on for that entity, and its metered allowances are the entity's own, spent by its tracks (`entityId`). The seat plan's features go to seat holders only, never to the customer or to entities without a seat.

## Rules

* **Seats are counted, included ones too.** `licenseSeats.N.seats` is the total, from `includedSeats` (`400 below_included_seats`) up to `maxSeats` (`400 max_purchase_exceeded`), for a seat plan the parent licenses (`400 invalid_request`).
* **Seats sell on a Stripe-billed plan without a trial.** A free parent with free seats, or an attach that starts a trial, is `400 license_attach_unavailable`.
* **Seat changes go through `POST /v1/licenses`.** A seat count runs from `includedSeats` (`400 below_included_seats`) to `maxSeats` (`400 max_purchase_exceeded`), never below the seats assigned (`409 seats_assigned`, with `assigned`), one change at a time per bill (`409 subscription_change_pending`, a period-end one included). Seats a lowering removes stay unassignable until the renewal.
* **Seats move on upgrades between plans that license them.** A move to a plan without the customer's assigned seats is `409 license_in_use`: release them first. A downgrade from a plan with a license, or an upgrade or downgrade to a licensed plan from a bill without that license, is `400 license_change_unavailable`: cancel at the period end, then attach the new plan.
* **Cancelling the parent ends its license.**
* **A seat for every assignment.** With every seat held, assigning is `409 no_seats_available`; releasing an entity without a seat is `409 seat_not_assigned`.
* **Licenses are money terms.** Changing a plan's licenses publishes a new [plan version](https://docs.integrateledger.com/billing/plan-versions.md); their order doesn't matter.
* **The seat plan is a recurring base plan.** It isn't the parent itself, an add-on, a plan with licenses or [prepaid units](https://docs.integrateledger.com/pricing/prepaid-quantity.md), or a one-off plan.
* **One license per seat plan.** The parent is a recurring base plan, and neither plan has an item on the seat feature, which the license counts.
* **Same interval, or a seat price.** A seat plan billed at another interval from the parent needs `seatPriceCents`.

## What a push checks

A push checks that every license bills as written, and refuses one that doesn't, with an issue at `licenses.N.planId`, `licenses.N.seatFeatureId` or `licenses`, as `invalid_catalog` (`POST /v1/catalog`) or `invalid_request` (the plan endpoints):

| Code | Refused when |
| - | - |
| `license_plan_not_found` | `planId` isn't an active plan in the catalog |
| `license_plan_is_self` | `planId` is the parent itself |
| `license_plan_is_add_on` | The seat plan is an [add-on](https://docs.integrateledger.com/pricing/add-ons.md) |
| `license_plan_has_licenses` | The seat plan has licenses of its own |
| `license_plan_has_prepaid` | The seat plan sells [prepaid units](https://docs.integrateledger.com/pricing/prepaid-quantity.md) |
| `license_plan_must_recur` | The seat plan is a [lifetime plan](https://docs.integrateledger.com/pricing/lifetime.md) (`one_off`) |
| `license_duplicate_plan` | Two licenses on one parent name the same seat plan |
| `license_seat_feature_not_held` | `seatFeatureId` isn't a `held` feature |
| `license_seat_feature_in_items` | The parent or the seat plan has an item on the seat feature |
| `add_on_has_no_licenses` | The parent is an add-on |
| `licenses_must_recur` | The parent is a lifetime plan |
| `license_seat_interval_mismatch` | `seatPriceCents` is left out and the seat plan bills at another interval from the parent's |

A seat count that isn't a whole number, a `maxSeats` below `includedSeats`, or a `seatPriceCents` of 0 is refused as `invalid_request` (`invalid_catalog` on `POST /v1/catalog`). Every error is in [Errors](https://docs.integrateledger.com/errors.md#licenses).

## Related

* [Per-seat pricing](https://docs.integrateledger.com/pricing/per-seat.md): a price per seat on one plan, with a shared allowance.
* [Entities](https://docs.integrateledger.com/customers/entities.md): the users and workspaces seats are assigned to.
* [Plans per workspace or user](https://docs.integrateledger.com/pricing/entity-plans.md): a plan of its own for each entity.


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