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

# Versioning

> How Pricing as Code versions your catalog: drafts, publishing, what existing customers keep and deprecating products.

A **catalog version** is a published snapshot of your meters, benefits, products, custom fields and catalog settings. With [Pricing as Code](https://polar.sh/docs/features/pricing-as-code/overview.md), every publish creates one. New checkouts sell the latest version, while customers who bought from an earlier one keep what they bought.

That's what lets you change pricing without worrying about existing customers. If you raise the price of Pro in a new version, your current Pro subscribers keep renewing at the price they signed up for.

## Draft, current and archived

An organization has at most one draft and one current version at a time.

| Status | What it is |
| - | - |
| Draft | Saved with `polar config draft`, not published. Nothing changes for customers |
| Current | The published version. New checkouts sell what is in it |
| Archived | Replaced by a later version. Customers who bought from it keep what they bought |

Running `polar config draft` again replaces the draft, and if your file matches the current version again, the draft is discarded.

If you edit the file after drafting, run `polar config draft` again before you publish. `publish` warns you when the two differ, and it needs the owner or admin role.

## Names

Give a version a name with `polar config draft --name` to record why it changed. Versions you don't name are numbered `v1`, `v2` and so on.

```bash Terminal theme={null}
polar config draft --name 'Spring launch'
```

If you're already selling on Polar, `polar config init` publishes your existing catalog as the first version. If you're new, you start from an empty catalog.

## What existing customers keep

Publishing changes what new customers buy, not existing subscriptions or what customers already have.

* **Renewals** continue at the price of the version the customer bought.
* **Benefits** granted from an earlier version stay granted, because publishing doesn't grant or revoke anything.
* **Plan changes** move a customer to a product in the current version. A customer can't switch to a product from an archived version, and the Customer Portal only offers current products.

## Use external IDs in your code

> [!NOTE]
>
> Available from API version 2027-01.

The external ID is the lookup key you give each meter, benefit and product in your config, and it stays the same in every version. A Polar ID belongs to one version of an entry, so it changes when you publish a change to that entry. A stored Polar ID can go stale: a checkout for a product ID from an archived version fails, because that version is no longer sold.

Pass the external ID instead. Polar resolves it to the version on sale.

```typescript TypeScript theme={null}
import { createPolar } from "@polar-sh/sdk/2027-01";

const polar = createPolar({
  accessToken: process.env.POLAR_ACCESS_TOKEN!,
  environment: "sandbox",
});

const checkout = await polar.checkouts.create({
  external_products: ["pro"],
  external_customer_id: "user_123",
});
```

```python Python theme={null}
import os

from polar.v2027_01 import Polar

polar = Polar(os.environ["POLAR_ACCESS_TOKEN"], environment="sandbox")

checkout = polar.checkouts.create(
    external_products=["pro"],
    external_customer_id="user_123",
)
```

```bash cURL theme={null}
curl -s -X POST https://sandbox-api.polar.sh/v1/checkouts/ \
  -H "Authorization: Bearer $POLAR_ACCESS_TOKEN" \
  -H "Polar-Version: 2027-01" \
  -H "Content-Type: application/json" \
  -d '{ "external_products": ["pro"], "external_customer_id": "user_123" }'
```

| Your app wants to | Pass |
| - | - |
| Sell a product | `external_products` when creating a checkout |
| Change a subscription's plan | `external_product_id` when updating the subscription |
| Check or grant a customer's benefit | `external_benefit_id` when listing or creating benefit grants |
| Read or credit a customer's meter | `external_meter_id` on customer meters |
| Filter subscriptions by product | `external_product_id` |
| Fetch the product, benefit or meter itself | `external_id` and `catalog_status=live` when listing products, benefits or meters |

Keep `catalog_status=live` when you list. Without it the list also returns drafted and archived versions. Products and meters also expose `catalog_id` and `is_current`.

Subscriptions, orders and benefit grants keep the Polar ID of the version they were created from. To check which plan a customer has, compare `product.external_id`, not `product.id`.

Checkout links and discounts follow along on their own. When you publish, checkout links switch to the new version of their products and drop the products you removed, and a discount limited to a product applies to every version of it.

## Stop selling something

You can't remove a product from the file while customers still use it, and `polar config validate` reports it as an error if you try. Mark it deprecated instead:

```ts polar.config.ts theme={null}
legacy_pro: product('Pro (2025)')
  .prices(fixed().amount(usd(19)))
  .recurring('monthly')
  .deprecated(),
```

In JSON, set `"deprecated": true` on the entry.

A deprecated entry is left out of the next version, so it stops being sold while the customers who have it keep it. Once nobody uses it, `polar config prune` removes it from your file without changing anything on Polar.

## Learn more

| Resource | Description |
| - | - |
| [Pricing as Code](https://polar.sh/docs/features/pricing-as-code/overview.md) | What it is and what changes when you adopt it |
| [Billing config](https://polar.sh/docs/integrate/cli/config.md) | Set up, write, draft and publish a billing config |
| [`polar config` reference](https://polar.sh/docs/integrate/cli/reference/config) | Every subcommand and flag |
| [Orders and subscriptions](https://polar.sh/docs/concepts/orders-and-subscriptions.md) | How subscriptions renew and change plans |


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