@commet/node 9.7.0 → 9.9.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 (64) hide show
  1. package/dist/index.d.mts +413 -52
  2. package/dist/index.d.ts +413 -52
  3. package/dist/index.js +39 -12
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +39 -12
  6. package/dist/index.mjs.map +1 -1
  7. package/docs/ai-onboarding/mcp-server.md +1 -1
  8. package/docs/api-reference/customers.md +6 -2
  9. package/docs/api-reference/generated-webhooks.md +2 -2
  10. package/docs/api-reference/index.md +2 -2
  11. package/docs/api-reference/offers.md +2 -2
  12. package/docs/api-reference/plans.md +16 -3
  13. package/docs/api-reference/promo-codes.md +3 -1
  14. package/docs/api-reference/subscriptions.md +84 -9
  15. package/docs/api-reference/usage.md +0 -4
  16. package/docs/documentation/cli.md +60 -49
  17. package/docs/documentation/create-api-key.md +3 -1
  18. package/docs/documentation/customers/customer-portal.md +10 -2
  19. package/docs/documentation/customers/manage-customers.md +2 -1
  20. package/docs/documentation/finance/payouts.md +11 -0
  21. package/docs/documentation/finance/supported-countries.md +5 -5
  22. package/docs/documentation/invoicing/handle-failed-payments.md +9 -9
  23. package/docs/documentation/payments/accept-one-time-payments.md +1 -1
  24. package/docs/documentation/payments/payment-orchestration.md +2 -0
  25. package/docs/documentation/payments/payment-providers.md +46 -0
  26. package/docs/documentation/payments/transactions-refunds-and-retries.md +1 -1
  27. package/docs/documentation/plans/add-ons.md +1 -1
  28. package/docs/documentation/plans/consumption-models.md +44 -9
  29. package/docs/documentation/plans/credit-packs.md +49 -1
  30. package/docs/documentation/plans/one-time-payments.md +3 -3
  31. package/docs/documentation/plans/plan-groups.md +46 -10
  32. package/docs/documentation/platform/dashboard-metrics-and-events.md +40 -9
  33. package/docs/documentation/sales/connect-dub-affiliates.md +52 -0
  34. package/docs/documentation/sales/introductory-offers.md +7 -13
  35. package/docs/documentation/sales/offers.md +10 -6
  36. package/docs/documentation/sales/promo-codes.md +47 -17
  37. package/docs/documentation/sales/promotional-offers.md +6 -7
  38. package/docs/documentation/sales/regional-prices.md +16 -0
  39. package/docs/documentation/sales/trial-periods.md +67 -40
  40. package/docs/documentation/subscriptions/manage-subscriptions.md +65 -2
  41. package/docs/documentation/subscriptions/pay-in-advance.md +4 -7
  42. package/docs/documentation/subscriptions/upgrade-and-downgrade-plans.md +20 -2
  43. package/docs/documentation/testing-sandbox.md +2 -0
  44. package/docs/documentation/usage/track-usage.md +23 -0
  45. package/docs/errors/customer_deleted.md +22 -0
  46. package/docs/errors/index.md +5 -0
  47. package/docs/errors/managed_by_integration.md +22 -0
  48. package/docs/errors/no_scheduled_plan_change.md +22 -0
  49. package/docs/errors/plan_balance_limit_reached.md +22 -0
  50. package/docs/errors/plan_credit_limit_reached.md +22 -0
  51. package/docs/knowledge-base/how-do-credits-credit-packs-and-customer-credits-differ.md +8 -8
  52. package/docs/knowledge-base/how-do-discounts-work.md +7 -5
  53. package/docs/knowledge-base/how-do-free-plans-work-without-payment.md +14 -8
  54. package/docs/knowledge-base/how-do-offers-promo-codes-and-card-promotions-work-together.md +1 -1
  55. package/docs/knowledge-base/how-do-trial-periods-work.md +30 -24
  56. package/docs/knowledge-base/how-does-billing-work.md +1 -0
  57. package/docs/knowledge-base/what-happens-when-a-payment-fails.md +11 -9
  58. package/docs/manifest.json +54 -2
  59. package/docs/platform-documentation.md +1 -0
  60. package/docs/schemas.md +51 -9
  61. package/docs/webhooks/introduction.md +14 -12
  62. package/docs/webhooks.md +53 -17
  63. package/docs/webhooks.openapi.json +857 -745
  64. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Introductory Offers
3
- description: Attach an existing Offer to a base plan price so Commet applies it automatically to eligible new subscriptions.
3
+ description: Attach an existing Offer to a base plan price so Commet applies its discount automatically to eligible new subscriptions.
4
4
  ---
5
5
 
6
6
  An Introductory Offer is not a separate Offer type. It is an existing Offer attached to one base plan price with introductory placement.
@@ -10,22 +10,16 @@ That placement adds two behaviors:
10
10
  - Commet selects the Offer automatically when no explicit override is supplied.
11
11
  - Commet checks introductory eligibility before applying it.
12
12
 
13
- Selectable price variants inherit the introductory placement from their base price.
13
+ Selectable price variants inherit the introductory placement from their base price. One-time prices can't have an Introductory Offer.
14
14
 
15
15
  ## Compatible phases
16
16
 
17
- An Offer used as introductory may contain:
18
-
19
- 1. One optional `free_trial` phase at the beginning.
20
- 2. At most one finite `percentage` or `amount_off` phase.
21
-
22
- It cannot use `fixed_price`, multiple discount phases, or an open-ended discount.
17
+ An Offer used as introductory contains exactly one finite `percentage` or `amount_off` phase. It cannot use `fixed_price` or an open-ended discount.
23
18
 
24
19
  ```typescript
25
20
  const onboarding = await commet.offers.create({
26
21
  name: 'Starter onboarding',
27
22
  phases: [
28
- { type: 'free_trial', durationDays: 14 },
29
23
  { type: 'percentage', durationCycles: 3, percentage: 3000 },
30
24
  ],
31
25
  })
@@ -35,7 +29,7 @@ In the Dashboard, open the plan price and choose **Add intro offer** to attach t
35
29
 
36
30
  ## Eligibility
37
31
 
38
- Current automatic eligibility excludes a customer who already has an `active` or `past_due` subscription in the organization. Other historical statuses do not create a lifetime ban.
32
+ Automatic eligibility excludes a customer who already has an `active`, `past_due`, or `paused` subscription in the organization. Other historical statuses do not create a lifetime ban.
39
33
 
40
34
  ## Selection at subscription creation
41
35
 
@@ -48,8 +42,8 @@ await commet.subscriptions.create({
48
42
 
49
43
  When `offerId` is omitted, Commet resolves the selected price and applies its introductory Offer if the customer is eligible.
50
44
 
51
- An explicit `offerId` applies that Offer directly instead. It cannot be combined with `promoCode`, `customTrialDays`, or `skipTrial: true`.
45
+ An explicit `offerId` applies that Offer directly instead. It cannot be combined with `promoCode` or `cardPromotionId`.
52
46
 
53
- ## Trials and compatibility fields
47
+ ## Trials
54
48
 
55
- `trialDays`, `customTrialDays`, and `skipTrial` remain supported API shortcuts. Internally, an accepted trial is recorded as a `free_trial` phase in the Offer Application. Prefer catalog Offers when the same terms should be named, reused, inspected, or distributed consistently.
49
+ Trial days belong to the plan price, not to the Offer. When the price has a trial, the introductory discount starts with the first invoice after it. See [Trial Periods](/docs/trial-periods).
@@ -1,9 +1,11 @@
1
1
  ---
2
2
  title: Offers
3
- description: Define reusable trials and temporary pricing terms independently from plans and distribution.
3
+ description: Define reusable discount phases independently from plans and distribution, then apply them automatically, directly, or through promo codes.
4
4
  ---
5
5
 
6
- An Offer is a reusable sequence of benefits. It defines **what changes**—a trial, a discount, or a temporary fixed price—without deciding which plan uses it or how a customer receives it.
6
+ An Offer is a reusable sequence of discount phases. It defines **what changes**—a discount or a temporary fixed price—without deciding which plan uses it or how a customer receives it.
7
+
8
+ Trials are not Offers. Set trial days on the plan price; see [Trial Periods](/docs/trial-periods).
7
9
 
8
10
  ## Offer phases
9
11
 
@@ -11,18 +13,16 @@ An Offer contains between 1 and 10 ordered phases:
11
13
 
12
14
  | Phase | Effect |
13
15
  | ------------- | --------------------------------------------------------------------------------- |
14
- | `free_trial` | Delays the first charge for a fixed number of days |
15
16
  | `percentage` | Reduces the plan base price by basis points |
16
17
  | `amount_off` | Subtracts an explicit amount for each configured currency |
17
18
  | `fixed_price` | Replaces the plan base price with an explicit amount for each configured currency |
18
19
 
19
- A free trial can appear only as the first phase. A discount phase may have a finite `durationCycles`, or `null` when it is the final open-ended phase.
20
+ A phase has a finite `durationCycles`, or `null` when it is the final open-ended phase. A `fixed_price` phase of `0` gives free billing cycles; the dashboard calls it **Free cycles**.
20
21
 
21
22
  ```typescript
22
23
  const launchOffer = await commet.offers.create({
23
24
  name: 'Launch sequence',
24
25
  phases: [
25
- { type: 'free_trial', durationDays: 14 },
26
26
  { type: 'percentage', durationCycles: 3, percentage: 5000 },
27
27
  { type: 'percentage', durationCycles: null, percentage: 2000 },
28
28
  ],
@@ -40,7 +40,7 @@ The Offer does not contain `purpose`, `planPriceIds`, eligibility, or redemption
40
40
  | **Promotional** | Your integration passes `offerId` | Explicit campaign, retention, or experiment assignment |
41
41
  | **Promo Code** | The customer enters a code | Redemption limits, plan restrictions, and expiration |
42
42
 
43
- The channel does not create another copy of the Offer. It only decides how the reusable terms reach a customer.
43
+ The channel does not create another copy of the Offer. It only decides how the reusable terms reach a customer. When the price has a trial, the discount starts with the first invoice after it.
44
44
 
45
45
  ## Accepted terms
46
46
 
@@ -54,3 +54,7 @@ When Commet quotes or applies an Offer, it records an immutable Offer Applicatio
54
54
  Editing, deactivating, or archiving the catalog Offer affects future applications only. Existing applications remain available for billing and audit.
55
55
 
56
56
  The v9 response is target-aware (`plan_price`, `addon`, or `credit_pack`) so new purchase surfaces do not require another breaking response change. Current public subscription, Introductory, direct, and Promo Code flows create `plan_price` applications.
57
+
58
+ ## Offers managed by an integration
59
+
60
+ An Offer created by an integration, such as [Dub](/docs/connect-dub-affiliates), has `managedBy` set to that integration. Its terms change only there: editing them returns `409 managed_by_integration`. Renaming it still works.
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  title: Promo Codes
3
- description: Distribute an existing Offer through a customer-entered checkout code.
3
+ description: Distribute an existing Offer through a customer-entered checkout code, limited to first purchases or applied on plan changes.
4
4
  ---
5
5
 
6
- A Promo Code is a distribution channel. The referenced Offer owns the economic terms; the code owns who can redeem them and when.
6
+ A Promo Code is a distribution channel. The referenced Offer owns the discount; the code owns who can redeem it and when.
7
7
 
8
8
  ## Create a compatible Offer
9
9
 
10
- A Promo Code can reference an Offer with ordered `percentage`, `amount_off`, or `fixed_price` phases. It can start with one `free_trial` phase when a discount follows it. Each discount phase before the last must have a finite duration.
10
+ A Promo Code can reference any Offer: ordered `percentage`, `amount_off`, or `fixed_price` phases where only the last phase may be open-ended.
11
11
 
12
12
  ```typescript
13
13
  const launchOffer = await commet.offers.create({
@@ -19,17 +19,7 @@ const launchOffer = await commet.offers.create({
19
19
  })
20
20
  ```
21
21
 
22
- For a trial followed by a discount, put the trial first:
23
-
24
- ```typescript
25
- const trialOffer = await commet.offers.create({
26
- name: 'Early access',
27
- phases: [
28
- { type: 'free_trial', durationDays: 14 },
29
- { type: 'percentage', durationCycles: 3, percentage: 2000 },
30
- ],
31
- })
32
- ```
22
+ A `fixed_price` phase of `0`, **Free cycles** in the dashboard, makes a code that gives free billing cycles. Checkout saves the card and settles the invoice at $0 without a charge.
33
23
 
34
24
  ## Create the code
35
25
 
@@ -41,6 +31,7 @@ const promoCode = await commet.promoCodes.create({
41
31
  maxRedemptions: 100,
42
32
  expiresAt: '2026-12-31T23:59:59.000Z',
43
33
  planIds: ['pln_pro'],
34
+ firstPurchaseOnly: true,
44
35
  })
45
36
  ```
46
37
 
@@ -49,17 +40,20 @@ The Promo Code owns:
49
40
  - the customer-facing code;
50
41
  - optional plan and billing-interval restrictions;
51
42
  - the redemption limit;
52
- - expiration and active state.
43
+ - expiration and active state;
44
+ - `firstPurchaseOnly`, which limits the code to a customer's first purchase. Default `false`.
45
+
46
+ A customer qualifies for a first-purchase code while they have no paid invoice above $0 and no `active` or `past_due` subscription on a paid plan. A customer in a trial qualifies.
53
47
 
54
48
  Updating the Offer changes future redemptions of codes that reference it. Each completed checkout counts one redemption and keeps an immutable Offer Application with the phases accepted at that checkout. Editing the Offer does not change earlier redemptions or their renewals.
55
49
 
56
- Clients pinned before `2026-07-24` receive only the first phase in the legacy Promo Code discount fields when that phase is `percentage` or `amount_off`. Codes starting with `free_trial` or `fixed_price` cannot be represented and are absent from those older Promo Code endpoints. Use the current Offer API to inspect the complete sequence.
50
+ Clients pinned before `2026-07-24` receive only the first phase in the legacy Promo Code discount fields when that phase is `percentage` or `amount_off`. Codes starting with `fixed_price` cannot be represented and are absent from those older Promo Code endpoints. Use the current Offer API to inspect the complete sequence.
57
51
 
58
52
  ## Checkout behavior
59
53
 
60
54
  The customer enters the code during checkout. Commet validates the code, resolves the referenced Offer in the checkout currency, and records an Offer Application with source `promo_code`.
61
55
 
62
- When the Offer starts with a trial, a new subscription checkout collects a payment method without charging. Applying that code to a pending first-payment checkout replaces it with a trial setup checkout. Trial codes cannot start a trial on an existing subscription's plan change. One redemption is recorded when setup completes; the first paid invoice follows the trial and uses the next phase. Renewals do not count as new redemptions.
56
+ When the price has a [trial](/docs/trial-periods) that requires a payment method, the customer can enter the code in the trial checkout. The trial starts without a charge and the discount starts with the first invoice after it. One redemption is recorded when the checkout completes. Renewals do not count as new redemptions.
63
57
 
64
58
  If an eligible automatic Introductory Offer applies, the code is rejected with `intro_offer_active`. A Promo Code also cannot be combined with an explicit `offerId`.
65
59
 
@@ -70,3 +64,39 @@ await commet.subscriptions.create({
70
64
  promoCode: 'LAUNCH50',
71
65
  })
72
66
  ```
67
+
68
+ A trial without a payment method has no checkout, so it can't start with a promo code.
69
+
70
+ ## Apply a code on a plan change
71
+
72
+ `changePlan` and `previewChange` accept `promoCode` for immediate changes. The preview quotes what the change charges.
73
+
74
+ ```typescript
75
+ await commet.subscriptions.changePlan({
76
+ id: 'sub_xxx',
77
+ newPlanId: 'pln_pro',
78
+ promoCode: 'LAUNCH50',
79
+ })
80
+ ```
81
+
82
+ From a free plan, the code opens the checkout with the discount applied and counts its use when the checkout is paid. Scheduled changes reject a promo code with `offer_not_applicable`.
83
+
84
+ ## Rejection reasons
85
+
86
+ A rejected code returns `400 validation_error` with `param: "promoCode"` and the reason in `details.reason`:
87
+
88
+ - `not_found`: no code with that text exists.
89
+ - `inactive`: the code is deactivated.
90
+ - `expired`: the expiration date passed.
91
+ - `max_redemptions_reached`: the redemption limit was reached.
92
+ - `first_purchase_only`: the customer already paid or has a paid subscription.
93
+ - `already_redeemed`: the customer already redeemed the code.
94
+ - `plan_not_eligible`: the code is restricted to other plans.
95
+ - `billing_interval_not_eligible`: the code is restricted to another billing interval.
96
+ - `intro_offer_active`: an Introductory Offer applies.
97
+
98
+ Checkout also rejects a positive total below the currency's minimum charge.
99
+
100
+ ## Codes managed by an integration
101
+
102
+ Codes created by an integration, such as [Dub](/docs/connect-dub-affiliates), have `managedBy` set. Changing their restrictions returns `409 managed_by_integration`; activating and deactivating them still works.
@@ -9,13 +9,12 @@ The Offer stays independent from plans and prices until your integration selects
9
9
 
10
10
  ## Create the terms
11
11
 
12
- Direct Offers may combine a free trial with ordered discount or fixed-price phases:
12
+ Direct Offers may combine ordered discount and fixed-price phases:
13
13
 
14
14
  ```typescript
15
15
  const retentionOffer = await commet.offers.create({
16
16
  name: 'Return to Pro',
17
17
  phases: [
18
- { type: 'free_trial', durationDays: 7 },
19
18
  { type: 'fixed_price', durationCycles: 2, prices: [
20
19
  { currency: 'usd', amount: 2900 },
21
20
  { currency: 'ars', amount: 3990000 },
@@ -39,9 +38,9 @@ await commet.subscriptions.create({
39
38
 
40
39
  The Offer must be active, inside its availability window, and resolvable in the selected currency. It does not need a prior association with the plan or price.
41
40
 
42
- An explicit `offerId` overrides automatic introductory selection. It cannot be combined with `promoCode`, `customTrialDays`, or `skipTrial: true`.
41
+ An explicit `offerId` overrides automatic introductory selection. It cannot be combined with `promoCode`. It combines with `customTrialDays` and `skipTrial`; when the price has a trial, the discount starts after it.
43
42
 
44
- Immediate plan changes, plan-change previews, and supported reactivation flows also accept `offerId`. Scheduled plan changes do not accept an Offer.
43
+ Immediate plan changes, plan-change previews, and supported reactivation flows also accept `offerId`. Scheduled plan changes do not accept an Offer or a promo code.
45
44
 
46
45
  ## Apply it to an active subscription
47
46
 
@@ -54,14 +53,14 @@ await commet.subscriptions.applyOffer({
54
53
  })
55
54
  ```
56
55
 
57
- Only one Offer applies at a time: while an accepted Offer still has active or upcoming discount phases, a new application is rejected. Once its phases are exhausted, the subscription accepts a new Offer. Offers with a free trial phase cannot be applied to an active subscription, and the discount applies to the plan base price only.
56
+ Only one Offer applies at a time: while an accepted Offer still has active or upcoming discount phases, a new application is rejected. Once its phases are exhausted, the subscription accepts a new Offer. The discount applies to the plan base price only.
58
57
 
59
58
  The applied Offer belongs to that subscription and plan: it ends with a cancellation and a plan change removes it.
60
59
 
61
- The same operation on a subscription with a pending payment checkout quotes or replaces the checkout discount instead; there it accepts an optional `expiresAt` for the quote.
60
+ The same operation on a subscription with a pending checkout quotes or replaces the checkout discount instead; there it accepts an optional `expiresAt` for the quote. When the price has a trial, the discount starts after it.
62
61
 
63
62
  ## Direct application or Promo Code?
64
63
 
65
64
  Use direct `offerId` when your application decides who receives the terms. Use a Promo Code when the customer should enter a code and the campaign needs redemption restrictions.
66
65
 
67
- A Promo Code can distribute multiple discount phases, including `fixed_price`, and can begin with a trial when a discount follows it. A trial-only Offer remains available for direct application.
66
+ A Promo Code can distribute the same Offers, including multiple phases and `fixed_price`.
@@ -12,6 +12,22 @@ Commet has two complementary pricing layers:
12
12
 
13
13
  Currency Pricing remains the fallback. Add Markets when country segmentation or selectable variants require it.
14
14
 
15
+ ## Set currency pricing
16
+
17
+ ```typescript
18
+ await commet.plans.setRegionalPricing({
19
+ id: 'pln_pro',
20
+ currency: 'gbp',
21
+ exchangeRate: 0.79,
22
+ })
23
+ ```
24
+
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
+
27
+ 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
+ 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
+
15
31
  ## Create a Market
16
32
 
17
33
  A Market is a top-level Sales resource. It does not require a plan or price.
@@ -1,80 +1,107 @@
1
1
  ---
2
2
  title: Trial Periods
3
- description: Use free-trial Offer phases for automatic onboarding or explicit campaigns.
3
+ description: Set free trial days on a plan price, with or without a payment method, and override them per subscription with customTrialDays or skipTrial.
4
4
  ---
5
5
 
6
- A trial is a `free_trial` phase in an Offer. It is not a separate discount system.
6
+ A trial is a number of free days set on a plan price. [Offers](/docs/offers) hold discounts only; a discount starts after the trial.
7
7
 
8
- The phase records how long payment is delayed. The application channel decides who receives it:
8
+ ## Set trial days on a price
9
9
 
10
- | Channel | Trial behavior |
11
- | ---------------------- | ------------------------------------------------------------------------------------------ |
12
- | Introductory placement | Applied automatically to an eligible new subscription |
13
- | Direct `offerId` | Applied explicitly by your application |
14
- | Promo Code | Customer enters a code for an Offer that starts with a trial and continues with a discount |
15
- | `customTrialDays` | Creates customer-specific trial terms without a reusable catalog Offer |
16
- | `skipTrial: true` | Bypasses the automatic trial |
17
-
18
- Promo Code trials require at least one discount phase after the trial. A code can be pre-applied at subscription creation or entered in a pending payment checkout, which then changes to a trial setup checkout.
19
-
20
- ## Reusable trial
21
-
22
- Create one Offer and reuse it:
10
+ In the dashboard, open **Plans**, select the plan, and choose **Edit price**. Enter the **Free trial** days and choose whether to **Require a payment method**.
23
11
 
24
12
  ```typescript
25
- const trialOffer = await commet.offers.create({
26
- name: '14-day onboarding',
27
- phases: [
28
- { type: 'free_trial', durationDays: 14 },
29
- ],
13
+ await commet.plans.updatePrice({
14
+ id: 'pln_xxx',
15
+ priceId: 'pp_xxx',
16
+ trialDays: 14,
30
17
  })
31
18
  ```
32
19
 
33
- Attach it to a base price in the Dashboard for automatic introductory selection, or pass it directly:
20
+ | Parameter | Type | Description |
21
+ | ---------------------------- | --------- | ------------------------------------------------------------------------------- |
22
+ | `trialDays` | `integer` | Free days before the first charge. `0` to `730`; `0` removes the trial |
23
+ | `trialRequiresPaymentMethod` | `boolean` | Default `true`. `false` starts the trial without checkout. Requires `trialDays` |
24
+
25
+ Price variants inherit the trial of their base price. One-time prices can't have a trial.
26
+
27
+ A subscription keeps the trial days it accepted. Changing `trialDays` affects only new subscriptions.
28
+
29
+ ## Start a trial with a payment method
34
30
 
35
31
  ```typescript
36
- await commet.subscriptions.create({
32
+ const { checkoutUrl } = await commet.subscriptions.create({
37
33
  customerId: 'user_123',
38
34
  planCode: 'pro',
39
- offerId: trialOffer.id,
40
35
  })
41
36
  ```
42
37
 
43
- An Offer can also continue into paid promotional phases after the trial.
38
+ Redirect the customer to `checkoutUrl`. Checkout saves the payment method without charging it, and the subscription becomes `trialing` with `trialEndsAt` set.
39
+
40
+ When the trial ends, Commet charges the current value of the selected price and the subscription becomes `active`. A promo code typed in the trial checkout discounts the first invoice after the trial.
44
41
 
45
- ## Customer-specific trial
42
+ ## Start a trial without a payment method
46
43
 
47
- Use `customTrialDays` when the terms are exclusive to one subscription and do not need a reusable catalog identity:
44
+ > **Warning**
45
+ >
46
+ > A price with `trialRequiresPaymentMethod: false` rejects `offerId`, `promoCode`, `cardPromotionId` and `provider` at creation with `400`. An organization that can't charge yet receives `403`.
48
47
 
49
48
  ```typescript
50
- await commet.subscriptions.create({
49
+ const subscription = await commet.subscriptions.create({
51
50
  customerId: 'user_123',
52
51
  planCode: 'pro',
53
- customTrialDays: 21,
54
52
  })
53
+ // subscription.status === 'trialing'
54
+ // subscription.checkoutUrl === null
55
+ // subscription.hasPaymentMethod === false
55
56
  ```
56
57
 
57
- Commet persists the accepted trial as a `custom` Offer Application with a `free_trial` phase.
58
+ The trial starts immediately, with no checkout and no charge. The customer adds a card from the [Customer Portal](/docs/customer-portal) (**Add card**) or through a link from `subscriptions.updatePaymentMethod`.
58
59
 
59
- ## Skip an automatic trial
60
+ When the trial ends without a card:
61
+
62
+ - The subscription moves to the [plan group's default plan](/docs/plan-groups#default-plan-and-signup-trial) and `subscription.plan_changed` fires.
63
+ - Without a default plan, the subscription is canceled with `cancelReason: "trial_ended_without_payment_method"`.
64
+ - No invoice is created. `trial.expired` fires in both cases.
65
+
66
+ With a card added, the trial ends like a trial that started with one.
67
+
68
+ During the trial, an immediate plan change returns `409 no_payment_method`. Scheduled changes still apply.
69
+
70
+ ## Override the trial per subscription
71
+
72
+ | Field | Effect |
73
+ | ----------------- | ----------------------------------------------------- |
74
+ | `customTrialDays` | Replaces the price's trial days for this subscription |
75
+ | `skipTrial: true` | Starts without a trial |
76
+
77
+ Both combine with `offerId`. The Offer's discount starts after the trial.
60
78
 
61
79
  ```typescript
62
80
  await commet.subscriptions.create({
63
81
  customerId: 'user_123',
64
82
  planCode: 'pro',
65
- skipTrial: true,
83
+ offerId: 'ofr_xxx',
84
+ customTrialDays: 21,
66
85
  })
67
86
  ```
68
87
 
69
- `offerId` cannot be combined with `customTrialDays` or `skipTrial: true`; the explicit Offer already defines the full sequence.
88
+ ## Eligibility
89
+
90
+ A customer gets one trial per plan. A customer who already had the plan, in a trial or paying, gets no trial and goes through the regular checkout, including with `customTrialDays`.
91
+
92
+ `prepaidPeriods` above `1` and `cancelAtPeriodEnd: true` skip the price's trial; with `customTrialDays` above `0` they return `400`. `cardPromotionId` skips a trial that requires a payment method.
70
93
 
71
- ## Checkout and billing
94
+ ## Trial webhooks
72
95
 
73
- The customer provides a payment method during checkout but is not charged immediately. After setup succeeds:
96
+ - [`trial.checkout_ready`](/docs/webhooks/trial-checkout-ready): the trial checkout link is ready.
97
+ - [`trial.started`](/docs/webhooks/trial-started): the trial began. Grant access.
98
+ - [`trial.will_end`](/docs/webhooks/trial-will-end): the trial ends within 3 days.
99
+ - [`trial.converted`](/docs/webhooks/trial-converted): the customer changed plan before the trial ended.
100
+ - [`trial.expired`](/docs/webhooks/trial-expired): the trial ran out.
74
101
 
75
- 1. the subscription becomes `trialing`;
76
- 2. `trialEndsAt` records the end of the free-trial phase;
77
- 3. Commet charges the current selected price when the trial ends;
78
- 4. any following Offer phase becomes active.
102
+ ## Limitations
79
103
 
80
- Accepted Offer phases remain immutable, but the selected catalog price does not. If the price changes during the trial, the first paid charge uses the current value of the selected price.
104
+ - `trialDays` accepts `0` to `730`. The dashboard accepts whole days from `1` to `730`; leave it empty for no trial.
105
+ - One trial per customer per plan.
106
+ - Trials don't combine with `prepaidPeriods` above `1` or `cancelAtPeriodEnd: true`.
107
+ - A trial without a payment method can't start with an Offer, promo code, card promotion or provider override.
@@ -97,7 +97,7 @@ $createdSubscription = $commet->subscriptions->create(
97
97
  );
98
98
  ```
99
99
 
100
- For a paid plan, redirect the customer to `checkoutUrl`. Free plans can activate without checkout and return `checkoutUrl: null`.
100
+ For a paid plan, redirect the customer to `checkoutUrl`. Free plans and [trials without a payment method](/docs/trial-periods#start-a-trial-without-a-payment-method) start without checkout and return `checkoutUrl: null`; `hasPaymentMethod` tells whether Commet can charge the subscription on its own.
101
101
 
102
102
  The normal path needs only `customerId` and either `planCode` or `planId`. Optional selection fields are:
103
103
 
@@ -108,7 +108,7 @@ The normal path needs only `customerId` and either `planCode` or `planId`. Optio
108
108
  | `offerId` | Your application selected an Offer directly; it overrides automatic introductory selection |
109
109
  | `promoCode` | The customer entered a Promo Code |
110
110
  | `initialSeats` | You know the initial seat quantities at creation |
111
- | `skipTrial` or `customTrialDays` | You intentionally override the configured trial |
111
+ | `skipTrial` or `customTrialDays` | You intentionally override the price's [trial](/docs/trial-periods) |
112
112
 
113
113
  Omitting `priceId` preserves default price and Market resolution. Omitting `offerId` preserves automatic Introductory Offer selection.
114
114
 
@@ -402,6 +402,8 @@ $subscription = $commet->subscriptions->cancel(id: 'sub_xxx');
402
402
 
403
403
  A normal paid active subscription schedules cancellation at period end unless `immediate: true` is sent. Free, pending-payment, and past-due relationships cancel immediately. Cancellation does not erase the stored subscription balance.
404
404
 
405
+ The API cancels even when the plan group has a [default plan](/docs/plan-groups#default-plan-and-signup-trial). A paid plan canceled from the Customer Portal moves to that default plan at period end instead.
406
+
405
407
  Canceling a paused subscription is immediate and discards its preserved time. Pending usage, overage, or seat adjustments may still produce a final invoice. To cancel while a future pause is scheduled, revoke that pause first.
406
408
 
407
409
  ## Reverse a scheduled cancellation
@@ -467,6 +469,67 @@ $subscription = $commet->subscriptions->uncancel(id: 'sub_xxx');
467
469
 
468
470
  `uncancel` works only before an end-of-period cancellation takes effect. It keeps the same subscription and current period.
469
471
 
472
+ ## Revoke a scheduled plan change
473
+
474
+ Keep the current plan when a downgrade or interval change is scheduled for the end of the period:
475
+
476
+ **TypeScript**
477
+
478
+ ```typescript
479
+ import { Commet } from "@commet/node";
480
+
481
+ const commet = new Commet({ apiKey: "ck_xxx" });
482
+
483
+ const subscription = await commet.subscriptions.revokeScheduledPlanChange({ id: "sub_xxx" });
484
+ ```
485
+
486
+ **Python**
487
+
488
+ ```python
489
+ from commet import Commet
490
+
491
+ commet = Commet("ck_xxx")
492
+
493
+ subscription = commet.subscriptions.revoke_scheduled_plan_change("sub_xxx")
494
+ ```
495
+
496
+ **Go**
497
+
498
+ ```go
499
+ client, err := commet.New("ck_xxx")
500
+ if err != nil {
501
+ log.Fatal(err)
502
+ }
503
+ ctx := context.Background()
504
+
505
+ subscription, err := client.Subscriptions.RevokeScheduledPlanChange(ctx, "sub_xxx")
506
+ if err != nil {
507
+ log.Fatal(err)
508
+ }
509
+ ```
510
+
511
+ **Java**
512
+
513
+ ```java
514
+ import co.commet.Commet;
515
+
516
+ var commet = Commet.builder().apiKey("ck_xxx").build();
517
+
518
+ var subscription = commet.subscriptions().revokeScheduledPlanChange("sub_xxx");
519
+ ```
520
+
521
+ **PHP**
522
+
523
+ ```php
524
+ use Commet\Commet;
525
+
526
+ $commet = new Commet('ck_xxx');
527
+
528
+ $subscription = $commet->subscriptions->revokeScheduledPlanChange(id: 'sub_xxx');
529
+ ```
530
+
531
+ This also revokes a scheduled move to the plan group's default plan. A subscription with nothing scheduled returns `409 no_scheduled_plan_change`.
532
+
470
533
  ## Recover a past-due subscription
471
534
 
472
535
  Reactivate retries the outstanding renewal charge and keeps the original billing relationship:
@@ -13,7 +13,7 @@ Paying in advance doesn't decide whether the subscription renews afterward. To s
13
13
 
14
14
  > **Warning**
15
15
  >
16
- > **Free trials don't combine with paying in advance.** With `prepaidPeriods` above `1` or `cancelAtPeriodEnd: true`, an explicit trial (`customTrialDays`, a trial Offer, or a trial Promo Code) returns `400`, and the plan's automatic introductory trial is skipped.
16
+ > **Free trials don't combine with paying in advance.** With `prepaidPeriods` above `1` or `cancelAtPeriodEnd: true`, `customTrialDays` above `0` returns `400` and the price's trial is skipped.
17
17
 
18
18
  ```bash
19
19
  curl -X POST https://commet.co/api/v1/subscriptions \
@@ -66,10 +66,10 @@ Commet voids an unpaid link and emits [`invoice.voided`](/docs/webhooks/invoice-
66
66
  | Response | Cause |
67
67
  | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
68
68
  | `400 validation_error` | The price is one-time or the plan is free |
69
- | `400 validation_error` | `offerId` has a free trial or was sent for a `pending_payment` subscription. `param` is `offerId` |
69
+ | `400 validation_error` | `offerId` is unavailable or was sent for a `pending_payment` subscription. `param` is `offerId` |
70
70
  | `400 validation_error` | An Offer bills on another interval. See [Offers billed on another interval](#offers-billed-on-another-interval) |
71
71
  | `400 validation_error` | The total is below the minimum charge, such as with a 100% Offer. `param` is `offerId` when you sent one, `periods` otherwise. The previous unpaid link stays payable |
72
- | `409 invalid_subscription_status` | The subscription isn't `active` or awaiting its first payment, it has a free trial, or a pause is scheduled |
72
+ | `409 invalid_subscription_status` | The subscription isn't `active` or awaiting its first payment, it starts with a free trial, or a pause is scheduled |
73
73
  | `409 charge_in_progress` | A payment for the link being replaced couldn't be canceled, such as a generated OXXO voucher |
74
74
 
75
75
  ## How each period is priced
@@ -89,10 +89,7 @@ Payment → $20
89
89
 
90
90
  For the first payment, the currency and country price are resolved at checkout, as for any subscription. Offers run for their full configured duration starting at the first paid period. An Offer assigned with `PUT /v1/subscriptions/{id}/offer` to a subscription with paid periods left starts at the first renewal that charges, after the last paid period.
91
91
 
92
- [Card Promotions](/docs/card-promotions) behave as on any subscription. [Promo Codes](/docs/promo-codes) do too, with two exceptions:
93
-
94
- - A link that adds periods to an active subscription keeps the price it was created with, so a Promo Code entered there is rejected with "Promo codes can't be used on a link that adds billing periods".
95
- - A trial Promo Code entered on a checkout that pays several periods or on a one-time purchase is rejected with "Trial codes can't be used when paying in advance".
92
+ [Card Promotions](/docs/card-promotions) behave as on any subscription. [Promo Codes](/docs/promo-codes) do too, with one exception: a link that adds periods to an active subscription keeps the price it was created with, so a Promo Code entered there is rejected with "Promo codes can't be used on a link that adds billing periods".
96
93
 
97
94
  ### Offers billed on another interval
98
95
 
@@ -14,15 +14,33 @@ Customers change plans through the [Customer Portal](/docs/customer-portal) or f
14
14
  | **Interval change (up)** | Applied immediately | Monthly → Yearly |
15
15
  | **Interval change (down)** | Takes effect at next renewal | Yearly → Monthly |
16
16
 
17
- Both plans must be in the same [Plan Group](/docs/plan-groups) for customers to change plans themselves through the portal. Free-to-paid changes require a new checkout — the customer is redirected to complete payment.
17
+ Both plans must be in the same [Plan Group](/docs/plan-groups) for customers to change plans themselves through the portal. Free-to-paid changes open a checkout for the customer to pay. When the new price has a [trial without a payment method](/docs/trial-periods#start-a-trial-without-a-payment-method) and the customer never had that plan, the trial starts at once instead.
18
+
19
+ Immediate changes accept an `offerId` or a [`promoCode`](/docs/promo-codes#apply-a-code-on-a-plan-change). Scheduled changes accept neither.
18
20
 
19
21
  An immediate upgrade is rejected with a seat-limit error when the customer's current seats exceed the target plan's included seats for a seat feature that is not unlimited and has overage disabled. Reduce seats first, or pick a plan with enough included seats. Interval-only changes and scheduled downgrades are not affected.
20
22
 
23
+ During a trial without a payment method, an immediate change returns `409 no_payment_method`. Scheduled changes still apply.
24
+
21
25
  If you need to expand features or limits temporarily without changing the subscription's plan, price, or billing cycle, use a [Plan Grant](/docs/plan-grants) instead.
22
26
 
27
+ ## Revoke a scheduled plan change
28
+
29
+ A scheduled downgrade or interval change can be revoked before it takes effect, so the subscription stays on its current plan:
30
+
31
+ - Customers choose **Keep current plan** in the portal.
32
+ - In the dashboard, open the subscription and choose **Revert plan change**.
33
+ - Through the API, call `DELETE /subscriptions/{id}/scheduled-plan-change`.
34
+
35
+ ```typescript
36
+ await commet.subscriptions.revokeScheduledPlanChange({ id: 'sub_xxx' })
37
+ ```
38
+
39
+ A subscription with nothing scheduled returns `409 no_scheduled_plan_change`. One whose payment authorization must be renewed first returns `409 no_payment_method`.
40
+
23
41
  ## Dashboard
24
42
 
25
- From a customer's subscription detail page, click **Change Plan** and select the new plan. The same upgrade/downgrade rules apply.
43
+ From a customer's subscription detail page, click **Change plan** and select the new plan. The same upgrade/downgrade rules apply.
26
44
 
27
45
  ## Learn more
28
46
 
@@ -30,6 +30,8 @@ await commet.usage.track({
30
30
  })
31
31
  ```
32
32
 
33
+ Commet doesn't send emails whose recipients are all on reserved domains: `example.com`, `example.net`, `example.org` and their subdomains, and the `.example`, `.test`, `.invalid`, and `.localhost` domains. They still show as sent. Use a real inbox to check customer emails.
34
+
33
35
  ## Dev Tools Panel
34
36
 
35
37
  A floating widget that appears on all sandbox pages. The [**Test Clock**](#test-clock) tab is available everywhere. The [**Test Data**](#test-data) tab (address and card presets) only appears on checkout pages.
@@ -273,3 +273,26 @@ $usageCheck = $commet->usage->check(
273
273
  featureCode: 'api_calls',
274
274
  );
275
275
  ```
276
+
277
+ ## Limit plan credit spending
278
+
279
+ When a credits plan has a [plan credit limit](/docs/consumption-models#limit-plan-credit-spending), an event that would spend more plan credits than the current day or week allows, and that purchased credits can't cover, is rejected with `402 plan_credit_limit_reached`. Nothing is deducted.
280
+
281
+ Usage Check reports the same case before you consume:
282
+
283
+ ```json
284
+ {
285
+ "allowed": false,
286
+ "reason": "plan_credit_limit_reached",
287
+ "consumptionModel": "credits",
288
+ "planCreditLimit": {
289
+ "credits": 100,
290
+ "interval": "day",
291
+ "spent": 100,
292
+ "remaining": 0,
293
+ "resetsAt": "2026-11-03T14:00:00.000Z"
294
+ }
295
+ }
296
+ ```
297
+
298
+ Only plan credits count toward the limit. Accepted events return the updated limit in `consumption.planCreditLimit`. Show `remaining` and `resetsAt` to the customer, or let them [buy credits](/docs/credit-packs#buy-a-chosen-quantity-of-credits), which the limit never caps.