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

# Seats with credits per member

> Charge per seat and give every member their own monthly credits on top of a shared team pool.

> **Team:** \$20 a seat a month. Each member gets 500 AI credits a month, and the team shares 2,000 more.

Ledger bills each seat and gives every member their own monthly credits, with a shared team pool behind them. A plan's `monthlyCredits` is the team's pool; to give each member their own credits, combine a [seat price](https://docs.integrateledger.com/pricing/per-seat.md) with an [entity](https://docs.integrateledger.com/customers/entities.md) per member that has an `allowanceCredits`. Ledger bills the seats; your app adds and removes the entities as members come and go.

## 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: "ai_answer", name: "AI answer", creditCost: 1 }),
	],
	plans: [
		plan({
			id: "team",
			name: "Team",
			monthlyCredits: 2000, // the team's shared pool
			priceCents: 0,
			items: [
				{
					featureId: "seats",
					unlimited: true,
					price: { model: "per_unit", unitAmountCents: 2000 },
				},
			],
		}),
	],
	creditPacks: [],
});
```

```json ledger.catalog.json theme={"system"}
{
  "schemaVersion": 1,
  "features": [
    { "id": "seats", "name": "Seats", "type": "held" },
    { "id": "ai_answer", "name": "AI answer", "creditCost": 1 }
  ],
  "plans": [
    { "id": "team", "name": "Team", "monthlyCredits": 2000, "priceCents": 0,
      "items": [{ "featureId": "seats", "unlimited": true,
        "price": { "model": "per_unit", "unitAmountCents": 2000 } }] }
  ],
  "addOns": []
}
```

The per-member 500 lives on each entity, as its `allowanceCredits`.

## The calls

**A member joins:** add a seat, then give them an entity. A track with no `quantity` adds one. Changing entities needs a key with `billing:write`.

```typescript TypeScript theme={"system"}
await billing.trackUsage({
	customerId: team.id,
	featureId: "seats",
	requestId: `seat-add-${membership.id}`,
});
await billing.upsertEntity({
	customerId: team.id,
	entityId: member.id,
	allowanceCredits: 500,
});
```

```python Python theme={"system"}
billing.track_usage(
    customer_id=team.id,
    feature_id="seats",
    request_id=f"seat-add-{membership.id}",
)
billing.upsert_entity(customer_id=team.id, entity_id=member.id, allowance_credits=500)
```

```bash cURL theme={"system"}
curl https://api.integrateledger.com/v1/track \
  -H "Authorization: Bearer $LEDGER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"customerId": "team_42", "featureId": "seats", "request_id": "seat-add-m_901"}'

curl https://api.integrateledger.com/v1/entities \
  -H "Authorization: Bearer $LEDGER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"customerId": "team_42", "entityId": "user_7", "allowanceCredits": 500}'
```

**A member uses AI:** pass their `entityId` to check and track. Their 500 go first, then the team's shared 2,000.

```typescript TypeScript theme={"system"}
await billing.trackUsage({
	customerId: team.id,
	featureId: "ai_answer",
	requestId: answer.id,
	entityId: member.id,
});
```

```python Python theme={"system"}
billing.track_usage(
    customer_id=team.id,
    feature_id="ai_answer",
    request_id=answer.id,
    entity_id=member.id,
)
```

```bash cURL theme={"system"}
curl https://api.integrateledger.com/v1/track \
  -H "Authorization: Bearer $LEDGER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"customerId": "team_42", "featureId": "ai_answer", "request_id": "answer_5521", "entityId": "user_7"}'
```

**A member leaves:** remove the seat with `quantity: -1`, and delete the entity.

```typescript TypeScript theme={"system"}
await billing.trackUsage({
	customerId: team.id,
	featureId: "seats",
	requestId: `seat-remove-${membership.id}`,
	quantity: -1,
});
await billing.deleteEntity({ customerId: team.id, entityId: member.id });
```

```python Python theme={"system"}
billing.track_usage(
    customer_id=team.id,
    feature_id="seats",
    request_id=f"seat-remove-{membership.id}",
    quantity=-1,
)
billing.delete_entity(customer_id=team.id, entity_id=member.id)
```

```bash cURL theme={"system"}
curl https://api.integrateledger.com/v1/track \
  -H "Authorization: Bearer $LEDGER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"customerId": "team_42", "featureId": "seats", "request_id": "seat-remove-m_901", "quantity": -1}'

curl -X DELETE "https://api.integrateledger.com/v1/entities/user_7?customerId=team_42" \
  -H "Authorization: Bearer $LEDGER_API_KEY"
```

**Reconcile** on a schedule: `track` the seats with `count` set to your member count, and compare [`listEntities`](https://docs.integrateledger.com/api-reference/entities/list) with your members.

## Rules

* **Your app keeps seats and entities in step.** Ledger bills the seat count and grants each entity's allowance; it creates, deletes and counts entities when you call it. If your app adds a seat and fails before `upsertEntity`, retry `upsertEntity` to grant the member's allowance.
* **Every member gets the full allowance.** A member added on day 28 gets all 500 credits for that period, while their seat is prorated by Stripe. Deleting an entity ends its unspent allowance at once.
* **Allowances follow the plan.** Entity allowances are granted for the customer's plan period, while the customer has a plan, and reset with it.
* **Allowances and caps apply to credits features.** On metered, held and boolean features, `entityId` labels the use, and an [entity plan](https://docs.integrateledger.com/pricing/entity-plans.md) adds its own items.
* **Spending without `entityId`** draws on the shared pool and leaves members' allowances untouched.
* **The seat price pays for the allowance.** Allowances are credits on top of the plan, with no invoice line of their own.

## Related

* [Per-seat pricing](https://docs.integrateledger.com/pricing/per-seat.md): seat prices, proration and invoices.
* [Entities](https://docs.integrateledger.com/customers/entities.md): allowances, caps and how entities spend.
* [Limits](https://docs.integrateledger.com/pricing/limits.md): `count` and reconciling a held count.


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