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

# Plan versions

> Change prices and terms safely. Every change is a new version, current customers keep their terms, drafts are tested before they sell, and you move subscribers when you choose.

Change your pricing as often as you like without surprising a single customer. Plans are versioned, so changing a published plan creates a **new version**: customers who start the plan from then on get the new terms, and current subscribers keep theirs, at every renewal, until they change plan or you [move them](#move-subscribers-to-another-version).

Versions are numbered 1, 2, 3 in the order they were made. Each has a `status`:

| Status | What it is |
| - | - |
| `active` | The version attach starts. One per plan. |
| `draft` | The next version, ready to test before it sells. One per plan. |
| `legacy` | An older version. Its subscribers keep it, renewals included. |

Changing which version is active never moves a customer: subscribers stay on the version they started until they upgrade, downgrade, or you move them to another version.

## Change a plan

Edit your catalog file and run `npx integrateledger-cli diff` before you push. Changing any of a plan's fields creates a new version: its name, price, intervals, credits, overage terms, or its items (allowances, limits, flags and seat prices).

```
Plans
  ~ pro  Pro  new version · 1,000 credits/month, $29.00/month
      monthlyPriceCents  $20.00 → $29.00
      New plan version: customers who start this plan from now get these terms; current subscribers keep theirs
      Stripe: a new $29.00/month Price on the "Pro" Product
```

Then publish with `npx integrateledger-cli push --yes`.

* **Current subscribers keep their version**: its price, its grants at each renewal, and its items. The new version's Stripe Price is used only for new subscriptions.
* **To move subscribers onto the new terms**, [move them to the new version](#move-subscribers-to-another-version). To move one onto another plan, [upgrade or downgrade](https://docs.integrateledger.com/billing/upgrades-and-downgrades.md) them.
* **Per-customer overrides follow the plan ID**, not the version: an [overage override](https://docs.integrateledger.com/customers/overrides.md) for `pro` applies to every version of it.

## Prepare a draft

Put the next terms under `draft` in your catalog file. The active version keeps selling while you test the draft:

```json ledger.catalog.json theme={"system"}
{
  "id": "pro",
  "name": "Pro",
  "versionLabel": "2026-q4",
  "priceCents": 2900,
  "monthlyCredits": 1000,
  "draft": { "versionLabel": "2027-q1", "name": "Pro", "priceCents": 3900, "monthlyCredits": 1500 }
}
```

* A draft holds every plan field except `id`. A paid draft syncs to Stripe like any version, so promoting it is instant.
* In Sandbox, [attach the draft](https://docs.integrateledger.com/billing/checkout-and-attach.md#attach-a-specific-version) by naming it: `"planVersion": "2027-q1"`.
* Publishing different draft terms replaces the draft. A draft a Sandbox customer already uses stays as a legacy version, and the new draft gets the next number.
* A draft's own [usage limits](https://docs.integrateledger.com/pricing/usage-limits.md) and [alerts](https://docs.integrateledger.com/pricing/usage-alerts.md) change in place, as a plan's do: changing only those keeps the draft's version, and its Sandbox customers follow them at once. Promoting the draft makes them the plan's, for every customer on it.
* In a catalog file, leaving `draft` out removes it. On [`POST /v1/plans/{id}`](https://docs.integrateledger.com/api-reference/plans/update) and in the dashboard, leaving it out keeps the draft; send `"draft": null` to remove it.

## Promote it

Move the draft's terms up to the plan, delete `draft`, and push: Ledger sees the stored draft's terms and promotes it instead of making another version. Or promote it by number or label:

```typescript TypeScript theme={"system"}
await billing.promotePlanVersion({ id: "pro", version: "2027-q1" });
```

```python Python theme={"system"}
billing.promote_plan_version("pro", "2027-q1")
```

```bash cURL theme={"system"}
curl -X POST https://api.integrateledger.com/v1/plans/pro/versions/2027-q1/promote \
  -H "Authorization: Bearer $LEDGER_API_KEY"
```

From the CLI, run `npx integrateledger-cli versions promote pro 2027-q1`. The promoted version becomes active and keeps its number; the version that was active becomes legacy. Promoting the active version changes nothing (`"changed": false`).

## Roll back

Promote the older version again. New customers get its terms; customers who started the newer one keep it.

## Labels

`versionLabel` names a version, such as `2026-q4`, so you can attach, promote and migrate by name. Changing only a label doesn't make a version, and leaving `versionLabel` out keeps the label the version has.

A label stays with its version, so when new terms make a new version, give it a new label. The active version and the draft may swap labels. Attach, promote and the versions list take a label wherever they take a number.

## Grandfathering

To start a customer on an older price, [attach](https://docs.integrateledger.com/billing/checkout-and-attach.md#attach-a-specific-version) a legacy version by number or label, in Sandbox or Live: `{ "planId": "pro", "planVersion": 1 }`. They pay that version's Stripe Price and get its credits.

## Move subscribers to another version

A migration moves one version's subscribers to another version of the plan: at each subscriber's renewal, or now. Use it to bring existing customers onto a new price, or onto the same price with more credits.

### Preview

Preview the move first. Nothing moves until you run it:

```typescript TypeScript theme={"system"}
const preview = await billing.createPlanMigration({
	id: "pro",
	body: { fromVersion: 1, toVersion: "2027-q1", timing: "at_renewal" },
});
```

```python Python theme={"system"}
preview = billing.create_plan_migration(
    "pro", from_version=1, to_version="2027-q1", timing="at_renewal"
)
```

```bash cURL theme={"system"}
curl -X POST https://api.integrateledger.com/v1/plans/pro/migrations \
  -H "Authorization: Bearer $LEDGER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"fromVersion": 1, "toVersion": "2027-q1", "timing": "at_renewal"}'
```

```json theme={"system"}
{
  "migrationId": 4,
  "planId": "pro",
  "fromVersion": 1,
  "toVersion": 2,
  "timing": "at_renewal",
  "status": "draft",
  "customers": 118,
  "byChange": { "priceUp": 118, "priceDown": 0, "same": 0 },
  "progress": { "queued": 0, "scheduled": 0, "applied": 0 },
  "skipped": [{ "customerId": "user_123", "reason": "past_due" }]
}
```

* `fromVersion` and `toVersion` take a number or a label.
* `customers` counts who moves, and `byChange` splits them by price: `priceUp`, `priceDown` or `same`.
* `customerIds` limits the move to the customers you name, up to 1,000.

### Apply

Run the preview with an `Idempotency-Key`. Ledger moves the subscribers one at a time in the background:

```typescript TypeScript theme={"system"}
await billing.runPlanMigration({
	id: "pro",
	migrationId: preview.migrationId,
	idempotencyKey: `migrate_${preview.migrationId}`,
});
const migration = await billing.getPlanMigration({
	id: "pro",
	migrationId: preview.migrationId,
});
```

```python Python theme={"system"}
billing.run_plan_migration(
    "pro", preview["migrationId"], idempotency_key=f"migrate_{preview['migrationId']}"
)
migration = billing.get_plan_migration("pro", preview["migrationId"])
```

```bash cURL theme={"system"}
curl -X POST https://api.integrateledger.com/v1/plans/pro/migrations/4/run \
  -H "Authorization: Bearer $LEDGER_API_KEY" \
  -H "Idempotency-Key: migrate_4"

curl https://api.integrateledger.com/v1/plans/pro/migrations/4 \
  -H "Authorization: Bearer $LEDGER_API_KEY"
```

`status` goes from `draft` to `running` to `done`, and `progress` counts each move as `queued`, `scheduled` (waiting for its renewal) or `applied`. The same key again returns the migration unchanged, so a retry is always safe.

### At renewal or now

* **At renewal** (the default): the subscriber keeps the version they paid for until their period ends. Ledger swaps the Stripe price now, so the renewal bills the new version, and the renewal grants its credits and allowances.
* **Now**: the new version starts at once, with no proration and no charge. The subscriber gets its allowance less what they already used this period, in credits and each metered item, keeps the credits they rolled over, and its price bills from the next renewal.
* **Free versions** move the same way, without Stripe: at their next renewal, or now.

A customer's `currentPlan.version` says which version they are on.

### Skips

Ledger moves every subscriber it can move safely. The rest are skipped with a reason and keep their version, so you can run a new migration for them once the reason clears:

| `reason` | Why |
| - | - |
| `pending_change` | Another change is under way: an upgrade, a scheduled downgrade, a change to the subscription's items, or another move. |
| `stripe_state` | The Stripe subscription has a schedule, a pending update, a pause or a cancellation, or one version is free and the other paid, or one monthly and the other yearly. |
| `past_due` | The subscription is `past_due`, `unpaid` or paused: the customer owes a payment. |
| `trialing` | The customer is on a [free trial](https://docs.integrateledger.com/pricing/trials.md). |

### From the CLI

```bash theme={"system"}
npx integrateledger-cli versions migrate pro 1 2027-q1         # at each renewal
npx integrateledger-cli versions migrate pro 1 2027-q1 --now   # now
```

The CLI prints the preview (who moves, how their price changes, who is skipped) and asks before it runs: "y" in Sandbox, typed `live` in Live, or `--yes`. See [`ledger versions migrate`](https://docs.integrateledger.com/cli).

The API routes: [preview](https://docs.integrateledger.com/api-reference/plans/migrations-create.md), [run](https://docs.integrateledger.com/api-reference/plans/migrations-run.md) and [get](https://docs.integrateledger.com/api-reference/plans/migrations-get.md). Previewing and running need the **Billing** permission at Write; getting needs **Catalog** at Read.

## See every version

`GET /v1/plans` returns each plan's active `version`, its `versionLabel` and its `draft`. [`GET /v1/plans/{id}/versions`](https://docs.integrateledger.com/api-reference/plans/versions) lists every version, oldest first, with its status, label, terms and how many subscriptions are on it:

```typescript TypeScript theme={"system"}
const { versions } = await billing.listPlanVersions({ id: "pro" });
```

```python Python theme={"system"}
versions = billing.list_plan_versions("pro")["versions"]
```

```bash cURL theme={"system"}
curl https://api.integrateledger.com/v1/plans/pro/versions \
  -H "Authorization: Bearer $LEDGER_API_KEY"
```

From the CLI, run `npx integrateledger-cli versions list pro`.

## What changes in place

Plans are versioned. Features and credit packs change in place, for everyone, from the next request:

| You change | Takes effect |
| - | - |
| A plan's terms | A new version, for new subscribers only |
| A feature's `name` or `creditCost` | At once, for every customer. The next `track` charges the new cost |
| A feature's `type` | Set for good. For a new type, create a new feature |
| A credit pack's price or credits | At once, for new purchases |

## Archive a plan

Removing a plan from the file **archives** it, with its draft. It stops selling to new customers, and customers already on it keep it, with its Stripe Price and their Stripe subscriptions. Adding the ID back restores it.

## Rules

* A draft attaches in Sandbox only; Live answers `409 draft_sandbox_only` until you promote it.
* A `versionLabel` uses letters, numbers, `.`, `_` and `-`, has at least one character that isn't a digit, and is unique among the plan's versions. A label reused for new terms answers `400 invalid_request`.
* Run a migration with one `Idempotency-Key`; a different key on a running migration answers `409 idempotency_key_mismatch`.
* A feature's `type` is fixed (`feature_type_locked`).
* A credit pack's price or credits change once its open Checkouts finish (`409 purchase_pending`).
* Remove a feature from current plan versions before you archive it (`feature_in_use`).

> [!NOTE]
>
> **Other ways.** Plans can also be changed in the dashboard under **Plans**, or with the [plan endpoints](https://docs.integrateledger.com/api-reference/plans/update.md). `npx integrateledger-cli pull` brings those edits back into your file.


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