@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
@@ -454,7 +454,7 @@
454
454
  "description": "Fired when a canceled subscription is reactivated and its reactivation charge succeeds.",
455
455
  "playground": "none"
456
456
  },
457
- "content": "## When this fires\n\nA canceled subscription was reactivated through `reactivate` and the reactivation charge succeeded. Commet generates a fresh invoice, charges the saved payment method, and sets the status back to `active` with a billing period anchored to the reactivation date.\n\nThe subscription returns to `active` at the same time, so `customer.state_changed` also fires. Restore access on either event.\n\nThis is distinct from two similar events. `subscription.activated` fires on a subscription's first activation. `payment.recovered` fires when a `past_due` subscription is recovered — that path keeps the original invoice and billing anchor, while reactivation issues a new invoice and resets the anchor to now.\n\nReactivation requires the plan to still be available in the subscription's currency. If the reactivation charge declines, no event fires and the API returns a `recoveryUrl` the customer can use to add a new card and pay."
457
+ "content": "## When this fires\n\nA canceled subscription was reactivated through `reactivate` and the reactivation charge succeeded. Commet generates a fresh invoice, charges the saved payment method, and sets the status back to `active` with a billing period anchored to the reactivation date.\n\nThe subscription returns to `active` at the same time, so `customer.state_changed` also fires. Restore access on either event.\n\nThis is distinct from two similar events. `subscription.activated` fires on a subscription's first activation. `payment.recovered` fires when a `past_due` subscription is recovered — that path keeps the original invoice and billing anchor, while reactivation issues a new invoice and resets the anchor to now.\n\nThe subscription returns on the latest [version](/plan-versions#reactivate-a-canceled-subscription) of what was bought, which must sell the subscription's currency. If the reactivation charge declines, no event fires and the API returns a `recoveryUrl` the customer can use to add a new card and pay."
458
458
  }
459
459
  }
460
460
  },
@@ -2115,6 +2115,236 @@
2115
2115
  }
2116
2116
  }
2117
2117
  },
2118
+ "subscription.version_changed": {
2119
+ "post": {
2120
+ "summary": "subscription.version_changed",
2121
+ "description": "Fired when a subscription moves to another version of its plan: a move applied now or a scheduled move that took effect at renewal. Making an experiment current moves nobody, so it sends none. The plan stays the same; the version's prices and features apply from now on.",
2122
+ "tags": [
2123
+ "Webhooks"
2124
+ ],
2125
+ "requestBody": {
2126
+ "required": true,
2127
+ "content": {
2128
+ "application/json": {
2129
+ "schema": {
2130
+ "type": "object",
2131
+ "properties": {
2132
+ "id": {
2133
+ "type": "string"
2134
+ },
2135
+ "event": {
2136
+ "type": "string",
2137
+ "const": "subscription.version_changed"
2138
+ },
2139
+ "timestamp": {
2140
+ "type": "string"
2141
+ },
2142
+ "organizationId": {
2143
+ "type": "string"
2144
+ },
2145
+ "mode": {
2146
+ "type": "string",
2147
+ "enum": [
2148
+ "live",
2149
+ "sandbox"
2150
+ ]
2151
+ },
2152
+ "apiVersion": {
2153
+ "type": "string"
2154
+ },
2155
+ "data": {
2156
+ "type": "object",
2157
+ "properties": {
2158
+ "subscriptionId": {
2159
+ "type": "string",
2160
+ "description": "The subscription ID."
2161
+ },
2162
+ "customerId": {
2163
+ "type": "string",
2164
+ "description": "The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId."
2165
+ },
2166
+ "fromVersionId": {
2167
+ "type": "string",
2168
+ "description": "The version the subscription left."
2169
+ },
2170
+ "toVersionId": {
2171
+ "type": "string",
2172
+ "description": "The version the subscription is on now."
2173
+ },
2174
+ "currency": {
2175
+ "type": "string",
2176
+ "description": "The currency the subscription pays in."
2177
+ },
2178
+ "billingInterval": {
2179
+ "type": "string",
2180
+ "description": "The billing interval the subscription pays."
2181
+ }
2182
+ },
2183
+ "required": [
2184
+ "subscriptionId",
2185
+ "customerId",
2186
+ "fromVersionId",
2187
+ "toVersionId",
2188
+ "currency",
2189
+ "billingInterval"
2190
+ ],
2191
+ "additionalProperties": false
2192
+ }
2193
+ },
2194
+ "required": [
2195
+ "id",
2196
+ "event",
2197
+ "timestamp",
2198
+ "organizationId",
2199
+ "mode",
2200
+ "apiVersion",
2201
+ "data"
2202
+ ],
2203
+ "additionalProperties": false
2204
+ },
2205
+ "example": {
2206
+ "event": "subscription.version_changed",
2207
+ "timestamp": "2026-06-23T14:30:00.000Z",
2208
+ "organizationId": "8f14e45f-ceea-4e7a-9c3d-1c2b3a4d5e6f",
2209
+ "mode": "live",
2210
+ "apiVersion": "2026-08-27",
2211
+ "data": {
2212
+ "subscriptionId": "sub_1a2b3c4d",
2213
+ "customerId": "user_123",
2214
+ "fromVersionId": "plnrel_v3",
2215
+ "toVersionId": "plnrel_v4",
2216
+ "currency": "usd",
2217
+ "billingInterval": "monthly"
2218
+ }
2219
+ }
2220
+ }
2221
+ }
2222
+ },
2223
+ "responses": {
2224
+ "200": {
2225
+ "description": "Return any 2xx status code to acknowledge receipt of the event."
2226
+ }
2227
+ },
2228
+ "x-mint": {
2229
+ "href": "/webhooks/subscription-version-changed",
2230
+ "metadata": {
2231
+ "title": "subscription.version_changed",
2232
+ "description": "Fired when a subscription moves to another version of its plan, now or at its renewal.",
2233
+ "playground": "none"
2234
+ },
2235
+ "content": "## When this fires\n\nA subscription moves to another version of the same plan:\n\n- right away, after [Change subscription version](/api-reference/subscriptions/change-subscription-version) or a plan move made now;\n- at its renewal, when a move scheduled for the end of the period takes effect.\n\nFrom this event the subscription has the destination version's features, limits and included credits or balance. A move made now charges the new version's price from the next renewal; a move never creates a proration charge or refund.\n\n`currency` is the subscription's currency, which a move never changes. `billingInterval` is the interval it pays after the move.\n\n| Moment | Event | What to do |\n| --- | --- | --- |\n| Move scheduled for renewal | None. The subscription shows it in `scheduledVersionChange`. | Show the upcoming change if your UI lists plan terms. |\n| Move takes effect | `subscription.version_changed` | Refresh the features and limits you keep for the subscription. |\n| Scheduled move no longer happens | `subscription.version_change_canceled` | Remove the upcoming change. |\n\nA trialing subscription with a pending move moves when its trial ends, so its first charge is already on the destination version. A subscription that ends or changes to another plan instead of renewing on its plan never moves and sends neither event.\n\nOnly endpoints that list this event receive it. New event types are not added to existing endpoints: add it to the endpoint's events in **Settings → Webhooks** or with [Update webhook endpoint](/api-reference/webhooks/update-webhook-endpoint)."
2236
+ }
2237
+ }
2238
+ },
2239
+ "subscription.version_change_canceled": {
2240
+ "post": {
2241
+ "summary": "subscription.version_change_canceled",
2242
+ "description": "Fired when a scheduled move to another plan version will no longer take effect because the subscription no longer fit the version at its renewal, or because the merchant revoked the scheduled version change or canceled the plan move. A new move that replaces it, a move made now, a plan change or an immediate cancellation sends none. The subscription stays on its version; reason says why.",
2243
+ "tags": [
2244
+ "Webhooks"
2245
+ ],
2246
+ "requestBody": {
2247
+ "required": true,
2248
+ "content": {
2249
+ "application/json": {
2250
+ "schema": {
2251
+ "type": "object",
2252
+ "properties": {
2253
+ "id": {
2254
+ "type": "string"
2255
+ },
2256
+ "event": {
2257
+ "type": "string",
2258
+ "const": "subscription.version_change_canceled"
2259
+ },
2260
+ "timestamp": {
2261
+ "type": "string"
2262
+ },
2263
+ "organizationId": {
2264
+ "type": "string"
2265
+ },
2266
+ "mode": {
2267
+ "type": "string",
2268
+ "enum": [
2269
+ "live",
2270
+ "sandbox"
2271
+ ]
2272
+ },
2273
+ "apiVersion": {
2274
+ "type": "string"
2275
+ },
2276
+ "data": {
2277
+ "type": "object",
2278
+ "properties": {
2279
+ "subscriptionId": {
2280
+ "type": "string",
2281
+ "description": "The subscription ID."
2282
+ },
2283
+ "customerId": {
2284
+ "type": "string",
2285
+ "description": "The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId."
2286
+ },
2287
+ "toVersionId": {
2288
+ "type": "string",
2289
+ "description": "The version the subscription was going to move to."
2290
+ },
2291
+ "reason": {
2292
+ "type": "string",
2293
+ "description": "Why the move was canceled: canceled_by_merchant, version_change_failed when the move could not be applied at renewal, or the code of what the subscription no longer fits (addon_unavailable, seat_limit_exceeded, price_not_found, missing_regional_price)."
2294
+ }
2295
+ },
2296
+ "required": [
2297
+ "subscriptionId",
2298
+ "customerId",
2299
+ "toVersionId",
2300
+ "reason"
2301
+ ],
2302
+ "additionalProperties": false
2303
+ }
2304
+ },
2305
+ "required": [
2306
+ "id",
2307
+ "event",
2308
+ "timestamp",
2309
+ "organizationId",
2310
+ "mode",
2311
+ "apiVersion",
2312
+ "data"
2313
+ ],
2314
+ "additionalProperties": false
2315
+ },
2316
+ "example": {
2317
+ "event": "subscription.version_change_canceled",
2318
+ "timestamp": "2026-06-23T14:30:00.000Z",
2319
+ "organizationId": "8f14e45f-ceea-4e7a-9c3d-1c2b3a4d5e6f",
2320
+ "mode": "live",
2321
+ "apiVersion": "2026-08-27",
2322
+ "data": {
2323
+ "subscriptionId": "sub_1a2b3c4d",
2324
+ "customerId": "user_123",
2325
+ "toVersionId": "plnrel_v4",
2326
+ "reason": "addon_unavailable"
2327
+ }
2328
+ }
2329
+ }
2330
+ }
2331
+ },
2332
+ "responses": {
2333
+ "200": {
2334
+ "description": "Return any 2xx status code to acknowledge receipt of the event."
2335
+ }
2336
+ },
2337
+ "x-mint": {
2338
+ "href": "/webhooks/subscription-version-change-canceled",
2339
+ "metadata": {
2340
+ "title": "subscription.version_change_canceled",
2341
+ "description": "Fired when a move to another plan version scheduled for renewal will no longer happen.",
2342
+ "playground": "none"
2343
+ },
2344
+ "content": "## When this fires\n\nA move to another version that was waiting for the subscription's renewal will not happen, and the subscription stays on its version. `toVersionId` is the version it was going to move to, and `reason` says why:\n\n| `reason` | What happened |\n| --- | --- |\n| `canceled_by_merchant` | You canceled the move with [Revoke scheduled version change](/api-reference/subscriptions/revoke-scheduled-version-change), or canceled the plan move for every subscriber or for this one. |\n| `addon_unavailable` | At renewal the subscription has an active add-on the destination version does not sell. |\n| `seat_limit_exceeded` | At renewal the subscription has more seats than the destination version allows. |\n| `price_not_found` | The destination version does not sell the price the subscription pays. |\n| `missing_regional_price` | The destination version does not sell the subscription's currency. A move never changes the currency. |\n| `version_change_failed` | The move could not be applied at renewal. |\n\nA move made now has nothing pending, so it never fires this event. Neither does a new move that replaces the pending one, a change to another plan, or a subscription that ends instead of renewing: the pending move is dropped and `scheduledVersionChange` becomes `null`. To move the subscription later, resolve what `reason` names and request the move again.\n\nOnly endpoints that list this event receive it. New event types are not added to existing endpoints: add it to the endpoint's events in **Settings → Webhooks** or with [Update webhook endpoint](/api-reference/webhooks/update-webhook-endpoint)."
2345
+ }
2346
+ }
2347
+ },
2118
2348
  "subscription.past_due": {
2119
2349
  "post": {
2120
2350
  "summary": "subscription.past_due",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commet/node",
3
- "version": "9.9.0",
3
+ "version": "9.11.0",
4
4
  "description": "Commet SDK for Node.js - Billing and usage tracking",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",