@commet/node 9.9.0 → 9.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/index.d.mts +932 -59
  2. package/dist/index.d.ts +932 -59
  3. package/dist/index.js +209 -13
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +209 -13
  6. package/dist/index.mjs.map +1 -1
  7. package/docs/ai-onboarding/mcp-server.md +2 -0
  8. package/docs/api-reference/addons.md +3 -1
  9. package/docs/api-reference/credit-packs.md +3 -1
  10. package/docs/api-reference/customers.md +3 -3
  11. package/docs/api-reference/generated-webhooks.md +2 -2
  12. package/docs/api-reference/index.md +3 -3
  13. package/docs/api-reference/invoices.md +4 -3
  14. package/docs/api-reference/plans.md +487 -6
  15. package/docs/api-reference/subscriptions.md +45 -4
  16. package/docs/api-reference/transactions.md +2 -1
  17. package/docs/documentation/api-versioning.md +8 -2
  18. package/docs/documentation/cli.md +4 -0
  19. package/docs/documentation/customers/customer-portal.md +2 -2
  20. package/docs/documentation/invoicing/manage-invoices.md +1 -1
  21. package/docs/documentation/plans/add-ons.md +16 -5
  22. package/docs/documentation/plans/balance-and-top-ups.md +1 -1
  23. package/docs/documentation/plans/consumption-models.md +23 -3
  24. package/docs/documentation/plans/create-plans.md +5 -1
  25. package/docs/documentation/plans/credit-packs.md +22 -10
  26. package/docs/documentation/plans/plan-groups.md +1 -1
  27. package/docs/documentation/plans/plan-versions.md +267 -0
  28. package/docs/documentation/sales/regional-prices.md +23 -9
  29. package/docs/documentation/sales/trial-periods.md +3 -3
  30. package/docs/documentation/subscriptions/manage-subscriptions.md +50 -13
  31. package/docs/documentation/subscriptions/upgrade-and-downgrade-plans.md +2 -0
  32. package/docs/errors/addon_has_activations.md +2 -2
  33. package/docs/errors/addon_unavailable.md +22 -0
  34. package/docs/errors/credit_pack_unavailable.md +22 -0
  35. package/docs/errors/currency_held_by_balance_plan.md +22 -0
  36. package/docs/errors/currency_held_by_customer_credit.md +22 -0
  37. package/docs/errors/currency_held_by_fixed_amount_discount.md +22 -0
  38. package/docs/errors/currency_held_by_payment_method.md +22 -0
  39. package/docs/errors/currency_held_by_prepaid_period.md +22 -0
  40. package/docs/errors/currency_held_by_scheduled_pause.md +22 -0
  41. package/docs/errors/index.md +14 -2
  42. package/docs/errors/missing_regional_price.md +3 -3
  43. package/docs/errors/plan_experiment_not_found.md +22 -0
  44. package/docs/errors/plan_version_not_found.md +22 -0
  45. package/docs/errors/subscribers_do_not_fit.md +22 -0
  46. package/docs/errors/version_not_newer.md +22 -0
  47. package/docs/knowledge-base/how-do-free-plans-work-without-payment.md +4 -3
  48. package/docs/knowledge-base/how-do-trial-periods-work.md +3 -3
  49. package/docs/knowledge-base/how-does-billing-work.md +26 -28
  50. package/docs/knowledge-base/how-does-quota-based-billing-work.md +12 -22
  51. package/docs/knowledge-base/how-does-seat-based-billing-work.md +12 -22
  52. package/docs/knowledge-base/what-happens-when-a-customer-changes-plans.md +11 -8
  53. package/docs/knowledge-base/what-happens-when-you-change-your-prices.md +34 -29
  54. package/docs/knowledge-base/what-invoices-do-customers-receive-and-when.md +1 -1
  55. package/docs/manifest.json +227 -2
  56. package/docs/platform-documentation.md +1 -0
  57. package/docs/schemas.md +128 -13
  58. package/docs/webhooks/introduction.md +3 -1
  59. package/docs/webhooks.md +27 -2
  60. package/docs/webhooks.openapi.json +231 -1
  61. package/package.json +1 -1
@@ -45,11 +45,17 @@ A new version ships whenever a breaking change needs one — sometimes several l
45
45
  Non-breaking changes ship continuously and never require a version bump:
46
46
 
47
47
  - New fields added to responses
48
- - New event types
48
+ - New event types. An endpoint receives only the events it lists, so a new type reaches an endpoint only after you add it
49
49
  - New API endpoints
50
50
  - New optional request parameters
51
51
  - New values in existing enums, such as a new billing interval. Your integration should accept values it does not recognize instead of failing
52
52
 
53
+ ### Plan edits publish plan versions
54
+
55
+ Editing a plan's prices, features or credit and balance rules through the API, MCP or CLI publishes a new version of the plan. New buyers get the new version; existing subscriptions keep the version they are on until you move them with [Change subscription version](/docs/api-reference/subscriptions/change-subscription-version) or [Move subscribers to a plan version](/docs/api-reference/plans/create-plan-move). Before plan versions, some of these edits also changed existing subscriptions, at once or at their renewal.
56
+
57
+ This is a change in product behavior, not in the shape of requests or responses. Unlike the breaking changes listed above, it did not ship behind a new API version: it applies to every API version, including pinned ones.
58
+
53
59
  ## Backward compatibility policy
54
60
 
55
61
  When a new version is released:
@@ -97,4 +103,4 @@ Webhook payloads include an `apiVersion` field in the envelope so you always kno
97
103
  }
98
104
  ```
99
105
 
100
- Each webhook endpoint can be pinned independently. When migrating, create a second endpoint pinned to the new version — both receive every event, each transformed to its own version. Once the new endpoint is working, delete the old one.
106
+ Each webhook endpoint can be pinned independently. When migrating, create a second endpoint pinned to the new version — both receive every event they list, each transformed to its own version. Once the new endpoint is working, delete the old one.
@@ -118,6 +118,8 @@ After `commet pull`, your SDK calls get autocomplete for plan codes and feature
118
118
 
119
119
  Push your local `commet.config.ts` to Commet. Creates or updates features and plans to match your config.
120
120
 
121
+ A plan whose prices, features or credit and balance rules change gets a new current version. New buyers get it; existing subscriptions stay on their version until you move them through the API or MCP, with [Change subscription version](/docs/api-reference/subscriptions/change-subscription-version) or [Move subscribers to a plan version](/docs/api-reference/plans/create-plan-move).
122
+
121
123
  ```bash
122
124
  commet push
123
125
  ```
@@ -328,6 +330,8 @@ commet subscriptions update-auto-top-up --id sub_xxx --enabled true --threshold
328
330
 
329
331
  Create plans, attach features and prices, and configure regional pricing.
330
332
 
333
+ Commands that change a plan's prices, features or credit and balance rules publish a new current version of the plan. New buyers get it; existing subscriptions stay on their version until you move them through the API or MCP, with [Change subscription version](/docs/api-reference/subscriptions/change-subscription-version) or [Move subscribers to a plan version](/docs/api-reference/plans/create-plan-move).
334
+
331
335
  **`commet plans create`**
332
336
 
333
337
  Create a plan.
@@ -9,8 +9,8 @@ Self-service page where customers manage their subscription, view usage, change
9
9
 
10
10
  - View current subscription and billing cycle
11
11
  - See usage across all features
12
- - Upgrade or downgrade plans (requires a [Plan Group](/docs/plan-groups)), and keep the current plan when a change is scheduled (**Keep current plan**)
13
- - Purchase [Credit Packs](/docs/credit-packs), a chosen quantity of credits, balance top-ups, and [Add-ons](/docs/add-ons)
12
+ - Upgrade or downgrade to group plans that sell their currency (requires a [Plan Group](/docs/plan-groups)), and keep the current plan when a change is scheduled (**Keep current plan**)
13
+ - Purchase the [Credit Packs](/docs/credit-packs) and [Add-ons](/docs/add-ons) their [plan version](/docs/plan-versions) sells, a chosen quantity of credits, and balance top-ups
14
14
  - Turn on and edit [auto top-up](/docs/credit-packs#top-up-credits-automatically) for credits
15
15
  - Add a card during a [trial without a payment method](/docs/trial-periods#start-a-trial-without-a-payment-method) (**Add card**)
16
16
  - Manage saved payment methods and billing details
@@ -215,7 +215,7 @@ $invoice = $commet->invoices->updateStatus(
215
215
  );
216
216
  ```
217
217
 
218
- Only outstanding invoices can be marked `paid` or `void`. This records an external settlement or a deliberate write-off; it does not create a provider transaction.
218
+ Only outstanding invoices can be marked `paid` or `void`. This records an external settlement or a deliberate write-off; it does not create a provider transaction. A credit purchase, top-up or add-on invoice still awaiting payment confirmation can't be marked `paid` by hand: it is paid when the payment provider confirms the payment. Marking it `void` cancels the purchase; if the payment is confirmed later, it is refunded.
219
219
 
220
220
  ## Send or download
221
221
 
@@ -36,7 +36,7 @@ Add-ons declare their own consumption model. Boolean add-ons are compatible with
36
36
 
37
37
  Go to **Add-ons** and click **Create Add-on**. Configure the name, base price, feature, and consumption model. For metered add-ons, set included units and overage rate. For credits, set the credit cost per unit.
38
38
 
39
- The feature dropdown only shows features not already assigned to another add-on. Once created, the add-on is available to any customer whose plan is compatible.
39
+ The feature dropdown only shows features not already assigned to another add-on. Once created, the add-on is sold on the current version of every compatible plan, or of the plans you choose in `planIds`.
40
40
 
41
41
  ## Availability by subscription status
42
42
 
@@ -48,6 +48,17 @@ Add-ons can be activated on any subscription with a payment method:
48
48
  | **Trialing** | Yes — with a saved payment method |
49
49
  | **Free plan** | Yes — first purchase prompts for a payment method |
50
50
 
51
+ ## Add-ons and plan versions
52
+
53
+ Each [plan version](/docs/plan-versions) lists the add-ons it sells, with their prices. Creating or editing an add-on publishes a new version of each plan that sells it:
54
+
55
+ - New customers get the add-on and its price on the plan's current version.
56
+ - Existing subscribers keep the add-ons and prices of their version. Activating an add-on their version doesn't sell returns `409 addon_unavailable` until you [move them](/docs/plan-versions#move-subscribers) to a version that sells it.
57
+ - A subscription with an active add-on can't move to a version that doesn't sell it until the add-on is removed. A plan move can remove it at renewal with `removeAddonIds`.
58
+ - A canceled subscription that is [reactivated](/docs/plan-versions#reactivate-a-canceled-subscription) returns on the latest version of what was bought, and the add-ons that version doesn't sell are deactivated.
59
+
60
+ Send `planIds` when you create or update an add-on to choose the plans that sell it. Left out on create, or empty, every plan sells it, including plans created later. Removing a plan returns `409 addon_has_activations` while a subscription of that plan has the add-on active.
61
+
51
62
  ## Manage add-ons
52
63
 
53
64
  Add-ons are managed through the dashboard, the customer portal, or the API.
@@ -58,7 +69,7 @@ Add-ons are managed through the dashboard, the customer portal, or the API.
58
69
  | **Activate / deactivate** | Dashboard (subscription detail), Customer Portal, or the API |
59
70
  | **List active add-ons** | API, Dashboard, or Customer Portal |
60
71
 
61
- Activate or deactivate an add-on on a subscription via the SDK. Activation charges the prorated amount for the current period; deactivation stops the feature immediately with no refund.
72
+ Activate or deactivate an add-on on a subscription via the SDK. Activation charges the prorated amount for the current period and the add-on is active once the payment is confirmed: the response's `status` is `active`, or `processing` when the payment method confirms later, such as Pix. Activating it again while that payment is processing returns `409`. Deactivation stops the feature immediately with no refund.
62
73
 
63
74
  ```typescript
64
75
  await commet.subscriptions.activateAddon({
@@ -208,7 +219,7 @@ When a customer activates a $50/month add-on on day 11 of a 31-day period (20 da
208
219
  | **Prorated** | $50 × (20/31) = **$32.26** |
209
220
  | **Invoice type** | `addon_activation` |
210
221
 
211
- The charge goes through the subscription's payment provider immediately with its own invoice.
222
+ The charge goes through the subscription's payment provider immediately with its own invoice. The add-on activates when the payment is confirmed; a declined payment voids the invoice and leaves the add-on inactive.
212
223
 
213
224
  ### Recurring invoices
214
225
 
@@ -228,13 +239,13 @@ Subtotal $213.00
228
239
 
229
240
  ### Multi-currency
230
241
 
231
- Add-on prices are defined in USD. For non-USD subscriptions, the price is converted using the plan's exchange rate — the same mechanism used for plan base prices.
242
+ Add-on prices are defined in USD. For non-USD subscriptions, the price is converted using the plan's exchange rate — the same mechanism used for plan base prices. A plan version can also set an add-on's price by hand for a country in the [Regional prices](/docs/regional-prices#set-prices-by-country) tab.
232
243
 
233
244
  ## Customer portal
234
245
 
235
246
  Customers can self-service add-ons from the portal:
236
247
 
237
- - **Available add-ons** — see compatible add-ons with pricing
248
+ - **Available add-ons** — see the compatible add-ons their plan version sells, with pricing
238
249
  - **Activate** — confirmation dialog with prorated charge preview
239
250
  - **Active add-ons** — manage active add-ons
240
251
  - **Deactivate** — instant, no refund
@@ -159,7 +159,7 @@ $balanceTopup = $commet->subscriptions->topupBalance(
159
159
  );
160
160
  ```
161
161
 
162
- A top-up charges the payment method attached to the subscription. Customers can also buy balance from the [Customer Portal](/docs/customer-portal).
162
+ A top-up creates its invoice and charges the payment method attached to the subscription. The balance is added once the payment is confirmed: the response's `status` is `succeeded`, or `processing` when the payment method confirms later, such as Pix. A declined payment adds nothing and voids the invoice. Customers can also buy balance from the [Customer Portal](/docs/customer-portal).
163
163
 
164
164
  ## Enforce before spending
165
165
 
@@ -55,7 +55,7 @@ Month 1: 800 unused → 800 + 1,000 = 1,800
55
55
  Month 2: 1,800 unused → 2,800, capped at 2,500. 300 expire.
56
56
  ```
57
57
 
58
- `{ type: 'expire' }` restores the default. Existing subscriptions apply a change from their next reset. A plan change applies the new plan's setting.
58
+ `{ type: 'expire' }` restores the default. Changing it publishes a new [plan version](/docs/plan-versions); each subscription keeps its version's setting until you move it. A plan change applies the new plan's setting.
59
59
 
60
60
  ### Limit plan credit spending
61
61
 
@@ -68,9 +68,29 @@ await commet.plans.update({
68
68
 
69
69
  `planCreditLimit` caps the plan credits a subscription spends per window: `day` is 24 hours and `week` is 7 days, starting at the time of day of the subscription's billing anchor. Purchased credits are never limited.
70
70
 
71
- An event past the limit uses purchased credits. Without enough, [Track Usage](/docs/track-usage#limit-plan-credit-spending) rejects it with `402 plan_credit_limit_reached`. Raising or removing the limit applies at once; lowering it, adding it, or changing its interval applies from the next period.
71
+ An event past the limit uses purchased credits. Without enough, [Track Usage](/docs/track-usage#limit-plan-credit-spending) rejects it with `402 plan_credit_limit_reached`. Changing the limit publishes a new plan version; each subscription keeps its version's limit until you move it.
72
72
 
73
- In the dashboard, open **Plans**, select a credits plan, and edit **Credit rollover**, **Credit limit**, or **Credit purchases**.
73
+ In the dashboard, open **Plans**, select a credits plan, and edit **Carry-over**, **Credit limit**, or **Buying credits** under **Credit rules**. The changes go into a draft until you publish it.
74
+
75
+ ### Make plan credits unlimited
76
+
77
+ ```bash
78
+ curl -X PATCH https://commet.co/api/v1/plans/pln_xxx \
79
+ -H "x-api-key: $COMMET_API_KEY" \
80
+ -H "Content-Type: application/json" \
81
+ -d '{
82
+ "unlimitedPlanCredits": true,
83
+ "planCreditLimit": { "credits": 300, "interval": "day" }
84
+ }'
85
+ ```
86
+
87
+ With `unlimitedPlanCredits`, usage never spends plan credits: every event is accepted and still recorded per feature, so you see what each customer consumed. An unlimited plan includes no set amount, so every price includes `0` credits and unused credits can't roll over.
88
+
89
+ `planCreditLimit` still applies. Past the limit, purchased credits are spent, then usage is rejected with `402 plan_credit_limit_reached` until the next window. Without a limit, purchased credits are never spent, so the plan sells no credits or packs. Automatic top-ups don't run while plan credits are unlimited.
90
+
91
+ Usage checks, usage events, feature access and the subscription's `credits` report `unlimited: true` and leave out the plan credit numbers. The same field is `unlimitedPlanBalance` on a balance plan. Changing it publishes a new plan version; moving a subscription to an unlimited version at once expires its unused plan credits.
92
+
93
+ In the dashboard, open **Plans**, select a credits plan, and choose **Unlimited** in **Plan credits** under **What's included**. The change goes into a draft until you publish it.
74
94
 
75
95
  ## Balance
76
96
 
@@ -24,6 +24,10 @@ A free plan has a price of $0 and no billing cycle. Customers are activated imme
24
24
 
25
25
  Go to **Plans** and click **Create Plan**. Fill in each component from the table above, then save. For detailed feature configuration, see [Configure Features](/docs/configure-features).
26
26
 
27
+ ## Edit a plan
28
+
29
+ Editing a plan's prices, trials, features, rules, add-ons, credit packs, or country prices publishes a new [plan version](/docs/plan-versions). New customers get it; existing subscribers keep their version until you move them. In the dashboard, edits go into a draft that you publish when ready. The name, description, and visibility are not versioned and change at once with **Edit details**.
30
+
27
31
  ## Retrieve plans via SDK
28
32
 
29
33
  ### TypeScript
@@ -107,7 +111,7 @@ curl "https://commet.co/api/v1/plans?includePrivate=true" \
107
111
  -H "x-api-key: $COMMET_API_KEY"
108
112
  ```
109
113
 
110
- Get a specific plan:
114
+ Get a specific plan. Plan reads return the terms of the current version; list a plan's versions with `GET /plans/{id}/versions`.
111
115
 
112
116
  ### TypeScript
113
117
 
@@ -19,7 +19,16 @@ Credit packs can be purchased on any subscription with a payment method — incl
19
19
 
20
20
  ## Create credit packs in the dashboard
21
21
 
22
- Go to **Credit Packs** and click **Create Credit Pack**. Pack names must be unique within your organization. Packs are available to all credits-based plans.
22
+ Go to **Credit Packs** and click **Create Credit Pack**. Pack names must be unique within your organization. A new pack is sold on the current version of every credits plan, or of the plans you choose in `planIds`.
23
+
24
+ ## Credit packs and plan versions
25
+
26
+ Each [plan version](/docs/plan-versions) lists the credit packs it sells, with their prices. Creating or editing a pack publishes a new version of each plan that sells it:
27
+
28
+ - New customers can buy the pack at its price on the plan's current version.
29
+ - Existing subscribers keep the packs and prices of their version. Buying a pack their version doesn't sell returns `409 credit_pack_unavailable` until you [move them](/docs/plan-versions#move-subscribers) to a version that sells it.
30
+
31
+ Send `planIds` when you create or update a pack to choose the plans that sell it. Left out on create, or empty, every plan sells it, including plans created later.
23
32
 
24
33
  ## List credit packs via SDK
25
34
 
@@ -78,11 +87,11 @@ curl https://commet.co/api/v1/credit-packs \
78
87
  }
79
88
  ```
80
89
 
81
- The `price` field is in **cents** (1000 = $10.00). Prices are always in USD.
90
+ The `price` field is the USD price in **cents** (1000 = $10.00). For other currencies, Commet converts it with the plan's exchange rate, unless the plan version sets the pack's price by hand for the buyer's country in the [Regional prices](/docs/regional-prices#set-prices-by-country) tab.
82
91
 
83
92
  ## Buy a chosen quantity of credits
84
93
 
85
- Set a price per credit on the plan to let customers buy any whole quantity instead of a fixed pack. Open **Plans**, select a credits plan, and edit **Credit purchases**: **Price per credit** and an optional **Minimum purchase**.
94
+ Set a price per credit on the plan to let customers buy any whole quantity instead of a fixed pack. Open **Plans**, select a credits plan, and edit **Buying credits** under **Credit rules**: the **Price per credit** and an optional minimum. The change goes into a draft until you [publish it](/docs/plan-versions#edit-in-the-dashboard).
86
95
 
87
96
  ```typescript
88
97
  await commet.subscriptions.purchaseCredits({
@@ -91,13 +100,14 @@ await commet.subscriptions.purchaseCredits({
91
100
  })
92
101
  ```
93
102
 
94
- Commet charges the saved payment method at the plan's price per credit and adds purchased credits. Send `creditPackId` instead of `quantity` to buy a pack. Both fire [`credits.purchased`](/docs/webhooks/credits-purchased).
103
+ Commet creates the purchase invoice, charges the saved payment method at the price per credit of the subscription's plan version and adds the purchased credits once the payment is confirmed. Send `creditPackId` instead of `quantity` to buy a pack. The response's `status` is `succeeded` when the credits were added, or `processing` when the payment method confirms later, such as Pix: the credits are added and [`credits.purchased`](/docs/webhooks/credits-purchased) fires when the payment is confirmed. A declined payment adds nothing and voids the invoice.
95
104
 
96
- | Response | Cause |
97
- | ----------------------- | -------------------------------------------------------------------------- |
98
- | `400 validation_error` | The quantity is below the plan's minimum, or the plan doesn't sell credits |
99
- | `402 no_payment_method` | The subscription has no saved payment method Commet can charge |
100
- | `402 payment_failed` | The charge was declined |
105
+ | Response | Cause |
106
+ | ----------------------------- | -------------------------------------------------------------------------- |
107
+ | `400 validation_error` | The quantity is below the plan's minimum, or the plan doesn't sell credits |
108
+ | `402 no_payment_method` | The subscription has no saved payment method Commet can charge |
109
+ | `402 payment_failed` | The charge was declined |
110
+ | `409 credit_pack_unavailable` | The subscription's plan version doesn't sell the pack |
101
111
 
102
112
  The effective minimum is the larger of the configured minimum and the smallest quantity that reaches the currency's minimum charge.
103
113
 
@@ -124,6 +134,8 @@ await commet.subscriptions.updateAutoTopUp({
124
134
 
125
135
  Send only the fields that change. Enabling requires a plan with a price per credit. Read the current settings, `status`, `topUpsThisPeriod`, and `lastFailure` with `getAutoTopUp`.
126
136
 
127
- Auto top-up pauses after 3 consecutive failed top-ups, or after one whose charge couldn't be refunded. It resumes when the payment method changes, a credit purchase succeeds, or you save it enabled again.
137
+ While a credit purchase is still processing, auto top-up does not buy again. A top-up confirmed later counts in the period it was triggered; one declined later counts as a failed top-up.
138
+
139
+ Auto top-up pauses after 3 consecutive failed top-ups, or after one whose charge couldn't be refunded. It resumes when the payment method changes, a credit purchase is paid, or you save it enabled again.
128
140
 
129
141
  Customers turn it on and edit it in the [Customer Portal](/docs/customer-portal) under **Auto top-up**. In the dashboard, it appears on the subscription detail.
@@ -17,7 +17,7 @@ A plan group is the [upgrade and downgrade path](/docs/what-happens-when-a-custo
17
17
 
18
18
  ## Create a plan group in the dashboard
19
19
 
20
- Go to **Plans** → **Groups** and click **Create Group**. Name the group, add your plans, then drag and drop to arrange them from lowest to highest tier. Each plan can only belong to one group. Plans with [Regional Prices](/docs/regional-prices) can be added, but all plans in a group must support the same set of currencies so any subscriber can move between them.
20
+ Go to **Plans** → **Groups** and click **Create Group**. Name the group, add your plans, then drag and drop to arrange them from lowest to highest tier. Each plan can only belong to one group. Plans in a group can sell different currencies and countries with [Regional Prices](/docs/regional-prices). A subscriber can switch only to group plans that sell its currency in its country: the Customer Portal shows only those, and the API rejects the others with `422 missing_regional_price`.
21
21
 
22
22
  This order defines the upgrade path and display order in the Customer Portal.
23
23
 
@@ -0,0 +1,267 @@
1
+ ---
2
+ title: Plan Versions
3
+ description: "Edit a plan without changing what existing subscribers pay: publish a new version or an experiment, then move subscribers when you choose."
4
+ ---
5
+
6
+ Every subscription is pinned to one version of its plan. A version holds the complete terms: prices, trials, features, credit and balance rules, add-ons, credit packs, and country prices. The plan points at its current version, which every new buyer gets.
7
+
8
+ Editing a plan publishes a new version and moves nobody. Existing subscribers keep the prices, features, and rules of their version, at renewal too, until you move them.
9
+
10
+ ## What a version holds
11
+
12
+ | Versioned | Not versioned |
13
+ | ------------------------------------------------------------------------------------ | ------------------------------------------------------ |
14
+ | Prices per billing interval, trial days, and the interval shown first | Name and description |
15
+ | The Introductory Offer of each price | Visibility |
16
+ | Features, included amounts, overage prices, and limits | [Market](/docs/regional-prices#create-a-market) prices |
17
+ | Credit and balance rules: carry-over, spending limits, credit purchases, and top-ups | |
18
+ | The add-ons and credit packs the plan sells, with their prices | |
19
+ | Countries with their currency and prices | |
20
+
21
+ **Edit details** changes the name, description, and visibility at once, for everyone. Market prices apply to every version: an edit to a Market price reaches the subscribers who pay it at their next renewal.
22
+
23
+ The plan's versions are numbered 1, 2, 3. An experiment's own versions carry its code, such as `price-test 2`.
24
+
25
+ ## Edit in the dashboard
26
+
27
+ Open a plan from **Plans**. The version menu opens the current version, drafts, experiments, and older versions. The plan page has six tabs:
28
+
29
+ | Tab | What it shows |
30
+ | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
31
+ | **Plan** | The prices, features, rules, add-ons, and credit packs of the version you opened |
32
+ | **Regional prices** | The version's countries, with their currency and prices |
33
+ | **Subscribers** | The plan's subscribers with their version and any move pending, with its date, plus **Needs a change** |
34
+ | **Versions** | The published versions with what changed in each, and the plan's drafts |
35
+ | **Experiments** | Each experiment with its status, the version it sells, and its subscribers |
36
+ | **Moves** | Every move with how many subscribers moved, are on track, need a change, or were left out. A move not yet finished can be canceled here |
37
+
38
+ 1. Edit any version. The first change starts a draft from it. A draft is saved as you edit, and nobody sees it until you publish it. A removed price, feature, add-on, or credit pack stays in place, struck through, with **Undo**. Disabling a feature appears in the changes as **Disabled**; only removing it appears as removed.
39
+ 2. The plan header shows the draft's number of changes. Open it to review **Changes in this draft** and undo any of them, or choose **Discard draft**.
40
+ 3. Choose **Review and publish** in the header, then publish it as:
41
+ - **The current version**, which new buyers get.
42
+ - **A new experiment**, sold only through its own code. Only for drafts started from the current version.
43
+ - **Next version of an experiment**, for drafts started from an experiment's latest version.
44
+ 4. Choose what happens to subscribers of earlier versions: **Keep them on their version**, **Move them at their next renewal**, or **Move them now**. When some of them don't fit the new version, the dialog lists each one with what would make it fit.
45
+
46
+ A draft publishes exactly its content. A draft started from an older version undoes what later versions changed, and the review lists those changes.
47
+
48
+ Publishing stops while a country is missing a price, or when the current version would drop the trial without a payment method of the plan group's [signup trial](/docs/plan-groups#default-plan-and-signup-trial).
49
+
50
+ To move subscribers later, open **Subscribers**, select them, and choose **Move to another version**.
51
+
52
+ ## Edit through the API
53
+
54
+ Every plan edit made through the API, MCP, or the CLI publishes a new current version at once and moves nobody. That includes adding, changing, or removing prices and features, regional pricing, and the credit and balance rules of `PATCH /plans/{id}`. New buyers get the new version; existing subscribers stay on theirs until you [move them](#move-subscribers).
55
+
56
+ To prepare several changes and publish them together, start a draft:
57
+
58
+ ```bash
59
+ curl -X POST https://commet.co/api/v1/plans/pln_xxx/drafts \
60
+ -H "x-api-key: $COMMET_API_KEY" \
61
+ -H "commet-version: 2026-08-27" \
62
+ -H "Content-Type: application/json" \
63
+ -d '{}'
64
+ ```
65
+
66
+ The draft starts from the current version unless you send `fromVersionId`. Change it with `PATCH /plans/{id}/drafts/{draftId}` and the blocks `prices`, `countries`, `rules`, and `undo`. Each block you send replaces that block, so `prices` lists every interval the draft sells:
67
+
68
+ ```bash
69
+ curl -X PATCH https://commet.co/api/v1/plans/pln_xxx/drafts/plr_draft \
70
+ -H "x-api-key: $COMMET_API_KEY" \
71
+ -H "commet-version: 2026-08-27" \
72
+ -H "Content-Type: application/json" \
73
+ -d '{"prices":[{"billingInterval":"monthly","price":5900,"isDefault":true},{"billingInterval":"yearly","price":59000}]}'
74
+ ```
75
+
76
+ Publish it with `"preview": true` first to check everything without publishing:
77
+
78
+ ```bash
79
+ curl -X POST https://commet.co/api/v1/plans/pln_xxx/drafts/plr_draft/publish \
80
+ -H "x-api-key: $COMMET_API_KEY" \
81
+ -H "commet-version: 2026-08-27" \
82
+ -H "Content-Type: application/json" \
83
+ -d '{"publishAs":"current","move":"period_end","preview":true}'
84
+ ```
85
+
86
+ | Field | Values |
87
+ | ----------- | ------------------------------------------------------------------------------------------------------------ |
88
+ | `publishAs` | `current`, `experiment` with `experimentCode`, or `experiment_version` |
89
+ | `move` | `keep` (default), `period_end`, or `now`, for subscribers of earlier versions. An experiment takes no `move` |
90
+ | `changes` | Per-subscriber changes that make each one fit. See [Resolve conflicts](#resolve-conflicts) |
91
+
92
+ Features and the add-ons and credit packs a plan sells are not part of an API draft: their own endpoints publish a new version at once. Introductory Offers are set in a dashboard draft.
93
+
94
+ `POST /plans/{id}/versions` publishes a new current version without a draft. It changes only money terms: prices, included credits or balance, per-currency amounts, and the carry-over cap.
95
+
96
+ ## Move subscribers
97
+
98
+ Only you move subscribers, and a move changes a subscription's version, never its plan. Move one subscription with `change-version`:
99
+
100
+ ```bash
101
+ curl -X POST https://commet.co/api/v1/subscriptions/sub_xxx/change-version \
102
+ -H "x-api-key: $COMMET_API_KEY" \
103
+ -H "commet-version: 2026-08-27" \
104
+ -H "Content-Type: application/json" \
105
+ -d '{"planVersionId":"plr_new","effective":"period_end"}'
106
+ ```
107
+
108
+ Repeating the same request changes nothing, and a new one replaces the pending move. Move many at once with `POST /plans/{id}/moves`, sending `subscriptionIds` (up to 10,000) or `fromVersionId` to move every subscription of that version:
109
+
110
+ ```bash
111
+ curl -X POST https://commet.co/api/v1/plans/pln_xxx/moves \
112
+ -H "x-api-key: $COMMET_API_KEY" \
113
+ -H "commet-version: 2026-08-27" \
114
+ -H "Content-Type: application/json" \
115
+ -d '{"fromVersionId":"plr_old","toVersionId":"plr_new","effective":"period_end","preview":true}'
116
+ ```
117
+
118
+ | `effective` | What changes |
119
+ | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
120
+ | `now` | Features, limits, and included credits or balance change today, without resetting usage. The new price is charged from the next renewal |
121
+ | `period_end` | Everything changes at the next renewal. Until then nothing in the current period changes: balance, usage checks, features, and access stay as they are |
122
+
123
+ A move never prorates or refunds. With `now`, a larger included amount first pays any plan credit or balance debt, a smaller one never creates new debt, and purchased credits and balance are untouched.
124
+
125
+ ### What a move keeps
126
+
127
+ - **Currency, country, interval, and price.** A move keeps a subscription's currency unless you ask to charge it in USD. A version that doesn't sell its currency returns `422 missing_regional_price`, and one that doesn't sell the price it pays returns `404 price_not_found`.
128
+ - **Charge in USD.** When the version doesn't sell the currency a subscriber pays in its country, or the USD price of its country, send `currency: "usd"` with the move: from its next renewal it pays the version's USD price for its country, or the USD base price. The currency changes only at a renewal, even for a move made now, and the usage of the period that closes is charged at the USD base rates of the version it leaves. Nothing is converted: when something keeps the subscription in its currency, the move is refused with a code that names it: `currency_held_by_payment_method` (it pays through dLocal), `currency_held_by_customer_credit`, `currency_held_by_balance_plan`, `currency_held_by_fixed_amount_discount`, `currency_held_by_prepaid_period` or `currency_held_by_scheduled_pause`. The same is checked again at the renewal; if it no longer fits, the move is canceled with that code as the `reason` of `subscription.version_change_canceled`.
129
+ - **Market prices.** A subscription that pays a Market price keeps paying it.
130
+ - **Free or paid.** A free version moves only to a free version, and a paid one only to a paid one (`400 validation_error`).
131
+
132
+ ### Who can move
133
+
134
+ - Subscriptions move only to a newer version (`422 version_not_newer`). One on a running experiment moves only to a later version of that experiment.
135
+ - Only `active`, `trialing`, and `past_due` subscriptions move; `change-version` rejects the others with `409 invalid_subscription_status`. A plan move leaves out the others, such as paused ones, and listed subscriptions already on the destination; they stay on their version. A scheduled cancellation, pause, downgrade, or interval change doesn't leave a subscription out.
136
+ - A one-time subscription never renews, so it moves only now. `change-version` with `period_end` returns `409 invalid_subscription_status`, and a plan move at renewal leaves it out.
137
+ - An active add-on the version doesn't sell (`409 addon_unavailable`), or more seats than the version allows (`400 seat_limit_exceeded`), keeps a subscription from moving until you resolve it.
138
+
139
+ ### Resolve conflicts
140
+
141
+ A plan move, a publish with `move`, and an experiment archive check every subscriber first. If any of them doesn't fit, nobody moves and the response is `409 subscribers_do_not_fit`, listing each one with the reasons. Send a change for each one in `changes`:
142
+
143
+ | Change | Effect at the subscriber's renewal |
144
+ | --------------------- | --------------------------------------------------------------------------------------------- |
145
+ | `billingInterval` | Moves it to another interval the version sells |
146
+ | `seatLimit: true` | Lowers its seats to the version's limit |
147
+ | `removeAddonIds` | Stops charging the listed add-ons |
148
+ | `currency: "usd"` | Charges it in USD when the version doesn't sell its currency, or the USD price of its country |
149
+ | `keepOnVersion: true` | Leaves it on its version |
150
+
151
+ ```json
152
+ {
153
+ "fromVersionId": "plr_old",
154
+ "toVersionId": "plr_new",
155
+ "effective": "now",
156
+ "changes": [{ "subscriptionId": "sub_xxx", "removeAddonIds": ["adn_xxx"] }]
157
+ }
158
+ ```
159
+
160
+ A subscriber with a change always moves at its renewal, even in a move made now.
161
+
162
+ ### When a move at renewal applies
163
+
164
+ A move at renewal waits for the subscription's next renewal, the date `scheduledVersionChange.effectiveAt` shows. The renewal invoices the new period on the new version and sends one `subscription.version_changed`.
165
+
166
+ | Subscription | When it moves |
167
+ | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
168
+ | `active` | At the end of its current period |
169
+ | `trialing` | When the trial ends. Its first charge is already on the new version |
170
+ | `past_due` | It keeps its version while Commet collects the overdue renewal. Once that's paid, it moves at the end of the period it paid for; `effectiveAt` shows that date meanwhile |
171
+ | Paused and resumed, or changing interval | At its next renewal after that, with that date |
172
+
173
+ A subscription that ends instead of renewing ends on its version, whether by a cancellation at the end of its period or trial, exhausted dunning, the suspension of the organization, or an immediate cancellation. It sends no version webhook, `scheduledVersionChange` becomes `null`, and its plan move stops waiting for it. A change to another plan, now or at that renewal, such as a scheduled downgrade or the plan group's default plan, lands on the other plan's current version, also without a version webhook.
174
+
175
+ While a cancellation or a downgrade is scheduled, the API and the Subscribers tab still show the move with its date. If the cancellation or downgrade is revoked, the subscription moves at its renewal.
176
+
177
+ ### Track and cancel moves
178
+
179
+ - `GET /plans/{id}/moves` lists the plan's moves, and `GET /plans/{id}/moves/{moveId}` reports each subscriber as `moving`, `moved`, `needs_a_change`, `left_out`, `canceled`, or `kept_on_version`.
180
+ - A change of one subscription with `change-version` is recorded as a move of that one subscriber. It appears in `GET /plans/{id}/moves` and the **Moves** tab like any other move.
181
+ - `POST /plans/{id}/moves/{moveId}/cancel` cancels the move for everyone who hasn't moved yet. `POST /plans/{id}/moves/{moveId}/subscriptions/{subscriptionId}/cancel` cancels it for one.
182
+ - `DELETE /subscriptions/{id}/scheduled-version-change` revokes one subscription's pending move.
183
+
184
+ Canceling or revoking a pending move sends `subscription.version_change_canceled` with `reason: "canceled_by_merchant"` for each subscriber it cancels, and records them as `canceled`.
185
+
186
+ A move scheduled for renewal is checked again at the renewal. If the subscription no longer fits, it renews on its version and appears in `GET /plans/{id}/needs-a-change` and under **Needs a change** on the Subscribers tab. Each entry carries the `moveId` of the move it couldn't complete. Move it again with a change, or leave it with `POST /plans/{id}/needs-a-change/{subscriptionId}/keep`.
187
+
188
+ ## Run an experiment
189
+
190
+ An experiment sells a version only to the buyers you send to it; everyone else keeps buying the current version. Publish a draft started from the current version as **A new experiment**, or create one with `POST /plans/{id}/experiments`. Its code uses lowercase letters, numbers, hyphens, and underscores, and is never reused in the plan.
191
+
192
+ Sell it by sending the experiment code after the plan code:
193
+
194
+ ```bash
195
+ curl -X POST https://commet.co/api/v1/subscriptions \
196
+ -H "x-api-key: $COMMET_API_KEY" \
197
+ -H "commet-version: 2026-08-27" \
198
+ -H "Content-Type: application/json" \
199
+ -d '{"customerId":"user_123","planCode":"pro:price-test"}'
200
+ ```
201
+
202
+ An unknown experiment code returns `404 plan_experiment_not_found`.
203
+
204
+ | Action | Endpoint | Result |
205
+ | ------------------------ | -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
206
+ | Publish its next version | `POST /plans/{id}/experiments/{code}/versions` | Its code sells the new version; earlier subscribers of the experiment stay on theirs |
207
+ | Make it current | `POST /plans/{id}/experiments/{code}/make-current` | Its latest version becomes the plan's current version with the next number. Its subscribers are already on it, and its code sells the current version from then on |
208
+ | Archive it | `POST /plans/{id}/experiments/{code}/archive` | Its code sells the current version, so links already shared keep working. `subscribers` chooses `keep`, `period_end`, or `now` for its subscribers |
209
+
210
+ Making an experiment current through the API moves nobody else. The dashboard also asks what happens to subscribers of earlier versions.
211
+
212
+ ## Sell a specific version
213
+
214
+ Send `planVersionId` on `POST /subscriptions` to create the subscription on any published version, current or not, including an experiment's versions. Checkout charges that version's price, and activation grants its credits, add-ons, and credit packs. Sending `planVersionId` with an experiment code returns `400`.
215
+
216
+ ## Unpaid checkouts
217
+
218
+ A checkout that hasn't been paid isn't a subscriber yet, so it follows the latest version of what was requested:
219
+
220
+ | Requested with | The checkout charges |
221
+ | -------------------------------------------- | ------------------------------------------------------------- |
222
+ | The plan code, such as `pro` | The plan's current version |
223
+ | An experiment code, such as `pro:price-test` | The experiment's latest version, never the plan's current one |
224
+ | `planVersionId` | That version |
225
+
226
+ Its link charges that version without a new request. Repeating the same `POST /subscriptions` after you edit the plan reuses the checkout: the response is `200` with the same subscription ID and `checkoutUrl`.
227
+
228
+ A different request replaces it: another plan, experiment, version, interval, or price, the plan code after an experiment code, or `planVersionId` instead of a code or the other way round. The old subscription is canceled, its invoice is voided, and its link stops working.
229
+
230
+ ## Reactivate a canceled subscription
231
+
232
+ Reactivating a canceled subscription returns it on the latest version of what was bought:
233
+
234
+ - the plan's current version, when it was bought with the plan code;
235
+ - the experiment's latest version, when it was bought with an experiment code, or the plan's current version once the experiment is no longer running;
236
+ - the same version, when it was bought with `planVersionId`.
237
+
238
+ Add-ons that version doesn't sell are deactivated. A version that doesn't sell the subscription's currency returns `422 missing_regional_price`. Reactivating a `past_due` subscription keeps its version.
239
+
240
+ ## Add-ons, credit packs, and countries
241
+
242
+ Each version lists the add-ons and credit packs it sells, with their prices. Creating or editing an add-on or credit pack publishes a new version of each plan that sells it. A subscriber buys only what its version sells: an add-on or pack added in a newer version returns `409 addon_unavailable` or `409 credit_pack_unavailable` until you move the subscriber. See [Add-ons](/docs/add-ons#add-ons-and-plan-versions) and [Credit Packs](/docs/credit-packs#credit-packs-and-plan-versions).
243
+
244
+ Each version also sets countries with their own currency and prices. See [Set prices by country](/docs/regional-prices#set-prices-by-country).
245
+
246
+ ## Read versions
247
+
248
+ | Request | Returns |
249
+ | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
250
+ | `GET /plans/{id}/versions` | The plan's published versions, newest first, with their prices and subscription counts |
251
+ | `GET /plans/{id}/versions/{versionId}` | One version |
252
+ | `GET /plans/{id}/versions/{versionId}/changes?against={otherVersionId}` | Every term that differs between two versions. A disabled feature reads `Disabled`; a removed term has `after: null` |
253
+
254
+ Versions published before Commet recorded every term are not listed, and reading one by ID returns `404 plan_version_not_found`.
255
+
256
+ Every subscription includes `planVersion`, with its `id` and `label`, and `scheduledVersionChange`, with the `planVersionId`, `label`, and `effectiveAt` of the move pending for its next renewal, or `null`. See [When a move at renewal applies](#when-a-move-at-renewal-applies). Filter `GET /subscriptions` by version with `planVersionId`.
257
+
258
+ ## Webhooks
259
+
260
+ | Event | When it fires |
261
+ | --------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
262
+ | [`subscription.version_changed`](/docs/webhooks/subscription-version-changed) | A subscription changed version: a move made now or a scheduled move at renewal. Making an experiment current moves nobody, so it sends none |
263
+ | [`subscription.version_change_canceled`](/docs/webhooks/subscription-version-change-canceled) | A pending move will not happen. `reason` is `canceled_by_merchant` when you canceled or revoked it, `version_change_failed`, or the code of what the subscription no longer fits |
264
+
265
+ Neither is sent when the subscription ends or changes to another plan before the move applies, or when a new move replaces the pending one.
266
+
267
+ Both reach only the webhook endpoints that list them. Add them to your endpoint's events to receive them.
@@ -1,14 +1,15 @@
1
1
  ---
2
2
  title: Markets and Regional Pricing
3
- description: Combine currency pricing, reusable country Markets, and selectable price variants.
3
+ description: Set plan prices per currency or per country, group countries into reusable Markets, and offer selectable price variants.
4
4
  ---
5
5
 
6
- Commet has two complementary pricing layers:
6
+ Commet has these complementary pricing layers:
7
7
 
8
- | Layer | Use it for |
9
- | -------------------- | ------------------------------------------------------------------------- |
10
- | **Currency Pricing** | Define plan, balance, and overage values in one presentment currency |
11
- | **Markets** | Group countries that should resolve explicit price and currency overrides |
8
+ | Layer | Use it for |
9
+ | -------------------- | ----------------------------------------------------------------------------------- |
10
+ | **Currency Pricing** | Define plan, balance, and overage values in one presentment currency |
11
+ | **Country prices** | Give a country its own currency and prices in a [plan version](/docs/plan-versions) |
12
+ | **Markets** | Group countries that should resolve explicit price and currency overrides |
12
13
 
13
14
  Currency Pricing remains the fallback. Add Markets when country segmentation or selectable variants require it.
14
15
 
@@ -22,12 +23,24 @@ await commet.plans.setRegionalPricing({
22
23
  })
23
24
  ```
24
25
 
25
- With only `currency` and `exchangeRate`, Commet derives every price, included balance, and overage from the USD values. Send `prices` or `features` to set exact amounts instead.
26
+ With only `currency` and `exchangeRate`, Commet derives every price, included balance, and overage from the USD values. Send `prices` or `features` to set exact amounts instead. Each change publishes a new [plan version](/docs/plan-versions); existing subscribers keep theirs until you move them.
26
27
 
27
28
  Supported currencies: USD, ARS, BOB, BRL, CAD, CLP, CNY, COP, EUR, GBP, HKD, INR, JPY, KRW, MXN, PEN, PYG, SGD, THB, TWD, and UYU.
28
29
 
29
30
  A currency applies to the countries that use it. Buyers in the United Kingdom pay in GBP, and EUR covers the euro countries. Buyers in a country without a configured currency pay the USD base price.
30
31
 
32
+ ## Set prices by country
33
+
34
+ In the dashboard, the plan's **Regional prices** tab sets prices country by country in a draft:
35
+
36
+ 1. Choose **Add a country** and the currency it pays in, USD included.
37
+ 2. Set each price **By hand**, or follow the USD base at an exchange rate.
38
+ 3. Set the country's prices for the add-ons and credit packs the plan sells, the same way.
39
+
40
+ Publishing the draft publishes every country together in one plan version. A country missing a price blocks publishing. Through the API, the `countries` block of `PATCH /plans/{id}/drafts/{draftId}` sets the same terms.
41
+
42
+ A subscriber pays the prices of its own country in its version; a buyer from a country the version doesn't list pays the USD base price. A move to another version keeps a subscription's currency, and a version that doesn't sell it can't receive the subscription unless the move charges it in USD from its next renewal (see [Move subscribers](/docs/plan-versions#move-subscribers)). The same applies when a canceled subscription is reactivated on the latest version of what was bought: if that version doesn't sell its currency, reactivation returns `422 missing_regional_price`.
43
+
31
44
  ## Create a Market
32
45
 
33
46
  A Market is a top-level Sales resource. It does not require a plan or price.
@@ -95,8 +108,9 @@ Omitting `priceId` keeps normal default-price and Market resolution.
95
108
 
96
109
  ## Renewal and archival
97
110
 
98
- - A subscription stores the selected price identity.
99
- - Renewals use that price row's current catalog value.
111
+ - A subscription stores the selected price identity and its plan version.
112
+ - Renewals use the price of the subscription's plan version. Market prices are not versioned: renewals use the Market price's current value.
113
+ - A version move keeps a subscriber's Market price, and a draft can't drop a currency that a Market price uses.
100
114
  - A variant inherits every Market it does not override.
101
115
  - Archiving hides a price from new selection without breaking existing subscriptions.
102
116
  - A referenced Market cannot be deleted.