@commet/node 9.12.0 → 9.13.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 (40) hide show
  1. package/dist/index.d.mts +298 -495
  2. package/dist/index.d.ts +298 -495
  3. package/dist/index.js +11 -11
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +11 -11
  6. package/dist/index.mjs.map +1 -1
  7. package/docs/api-reference/addons.md +8 -15
  8. package/docs/api-reference/api-keys.md +1 -1
  9. package/docs/api-reference/credit-packs.md +2 -2
  10. package/docs/api-reference/customers.md +7 -19
  11. package/docs/api-reference/offers.md +9 -5
  12. package/docs/api-reference/payments.md +1 -1
  13. package/docs/api-reference/plan-groups.md +2 -2
  14. package/docs/api-reference/plans.md +28 -44
  15. package/docs/api-reference/portal.md +3 -8
  16. package/docs/api-reference/promo-codes.md +3 -3
  17. package/docs/api-reference/quota.md +6 -21
  18. package/docs/api-reference/subscriptions.md +38 -55
  19. package/docs/api-reference/test-clock.md +3 -8
  20. package/docs/api-reference/usage.md +6 -11
  21. package/docs/documentation/create-api-key.md +4 -2
  22. package/docs/documentation/invoicing/handle-failed-payments.md +12 -3
  23. package/docs/documentation/plans/one-time-payments.md +1 -0
  24. package/docs/documentation/sales/offers.md +21 -3
  25. package/docs/documentation/sales/promo-codes.md +2 -2
  26. package/docs/documentation/sales/promotional-offers.md +1 -1
  27. package/docs/documentation/subscriptions/manage-subscriptions.md +3 -3
  28. package/docs/documentation/subscriptions/pay-in-advance.md +6 -4
  29. package/docs/errors/already_has_active_subscription.md +1 -1
  30. package/docs/errors/charge_failed.md +1 -1
  31. package/docs/errors/no_payment_method.md +1 -1
  32. package/docs/errors/payment_failed.md +1 -1
  33. package/docs/errors/subscription_not_active.md +1 -1
  34. package/docs/errors/validation_error.md +1 -1
  35. package/docs/knowledge-base/how-do-discounts-work.md +3 -3
  36. package/docs/knowledge-base/what-happens-when-a-payment-fails.md +6 -6
  37. package/docs/schemas.md +6 -4
  38. package/docs/webhooks.md +2 -0
  39. package/docs/webhooks.openapi.json +22 -4
  40. package/package.json +1 -1
@@ -25,13 +25,13 @@ Deactivate an add-on from a subscription.
25
25
 
26
26
  `POST /subscriptions/{id}/addons` · operation `activate-addon`
27
27
 
28
- Activate an add-on on a subscription. Creates the activation invoice and charges a prorated amount for the current billing period; the add-on is active once the payment is confirmed. Without a saved payment method, send successUrl to receive a checkout that charges the activation and saves the method. Rejected with 409 while the add-on is active or an activation of it is still processing. An add-on that the subscription's plan version does not sell is rejected with addon_unavailable.
28
+ Activate an add-on on a subscription. Creates the activation invoice and charges a prorated amount for the current billing period; the add-on is active once the payment is confirmed. Send successUrl to receive, when there is no saved payment method or it is declined, a checkout that charges the activation and saves the method. Rejected with 409 while the add-on is active or an activation of it is still processing. An add-on that the subscription's plan version does not sell is rejected with addon_unavailable.
29
29
 
30
30
  ### Parameters
31
31
 
32
32
  - `id` (`string`, required)
33
33
  - `addonId` (`string`, required)
34
- - `successUrl` (`string`, optional) — Where the customer returns after paying. When it is set and the subscription has no saved payment method, the response has status `requires_checkout` and a `checkoutUrl` where the customer pays this purchase and saves the method in one step. Without it, the request is rejected when there is no saved payment method. A saved method is always charged directly, and a declined charge is rejected either way.
34
+ - `successUrl` (`string`, optional) — Where the customer returns after paying. When it is set and the subscription has no saved payment method, or the saved method is declined or asks for authentication, the response has status `requires_checkout` and a `checkoutUrl` where the customer pays this purchase and saves the method in one step. Without it, the request is rejected in both cases. A saved method is always charged directly first, and a payment that fails for any other reason is rejected either way.
35
35
 
36
36
  ### Request options
37
37
 
@@ -111,13 +111,13 @@ Adjust a subscription's balance or credits by a signed amount. Positive adds, ne
111
111
 
112
112
  `POST /subscriptions/{id}/balance/topup` · operation `topup-balance`
113
113
 
114
- Top up a balance subscription. Creates the top-up invoice and charges the customer's payment method for the amount plus tax. Once the payment is confirmed, adds the amount to the subscription's purchased balance (after paying back any overage owed on the plan balance), marks the invoice paid and emits `balance.topped_up`. Purchased balance is spent after the plan balance and is kept until the subscription ends. Without a saved payment method, send successUrl to receive a checkout that charges the top-up and saves the method. Rejected with 400 when the subscription is not on a balance plan, its plan has top-ups turned off, or the amount is below the effective minimum: the plan's minimum top-up in the subscription currency, raised to the currency's minimum charge.
114
+ Top up a balance subscription. Creates the top-up invoice and charges the customer's payment method for the amount plus tax. Once the payment is confirmed, adds the amount to the subscription's purchased balance (after paying back any overage owed on the plan balance), marks the invoice paid and emits `balance.topped_up`. Purchased balance is spent after the plan balance and is kept until the subscription ends. Send successUrl to receive, when there is no saved payment method or it is declined, a checkout that charges the top-up and saves the method. Rejected with 400 when the subscription is not on a balance plan, its plan has top-ups turned off, or the amount is below the effective minimum: the plan's minimum top-up in the subscription currency, raised to the currency's minimum charge.
115
115
 
116
116
  ### Parameters
117
117
 
118
118
  - `id` (`string`, required)
119
119
  - `amount` (`number`, required) — The amount to add, in minor units of the subscription currency (cents; whole units for zero-decimal currencies).
120
- - `successUrl` (`string`, optional) — Where the customer returns after paying. When it is set and the subscription has no saved payment method, the response has status `requires_checkout` and a `checkoutUrl` where the customer pays this purchase and saves the method in one step. Without it, the request is rejected when there is no saved payment method. A saved method is always charged directly, and a declined charge is rejected either way.
120
+ - `successUrl` (`string`, optional) — Where the customer returns after paying. When it is set and the subscription has no saved payment method, or the saved method is declined or asks for authentication, the response has status `requires_checkout` and a `checkoutUrl` where the customer pays this purchase and saves the method in one step. Without it, the request is rejected in both cases. A saved method is always charged directly first, and a payment that fails for any other reason is rejected either way.
121
121
 
122
122
  ### Request options
123
123
 
@@ -133,7 +133,7 @@ Top up a balance subscription. Creates the top-up invoice and charges the custom
133
133
 
134
134
  `POST /subscriptions/{id}/cancel` · operation `cancel-subscription`
135
135
 
136
- Cancel immediately or at period end and return the updated subscription.
136
+ Cancel immediately or at period end and return the updated subscription. When the plan's group has a default free plan, a paid subscription moves to that plan instead of ending: now when `immediate` is true, otherwise at the end of the period or trial as a scheduled plan change that `POST /subscriptions/{id}/uncancel` undoes. The move sends `subscription.plan_change_scheduled` and `subscription.plan_changed` with the `reason` as `cancelReason`, never `subscription.canceled`. Cancelling the default plan itself ends the subscription.
137
137
 
138
138
  ### Parameters
139
139
 
@@ -160,15 +160,13 @@ Upgrade or change billing interval immediately, optionally applying an Offer by
160
160
  ### Parameters
161
161
 
162
162
  - `id` (`string`, required)
163
- - `newPlanId` (`string`, optional)
164
163
  - `newBillingInterval` (`"weekly" | "monthly" | "quarterly" | "semiannual" | "yearly"`, optional)
165
164
  - `successUrl` (`string`, optional)
166
- - `offerId` (`string`, optional)
167
- - `promoCode` (`string`, optional)
168
-
169
- ### Valid parameter combinations
170
-
171
- - `promoCode`
165
+ - `offerId` (`string`, optional) — Cannot be combined with `promoCode`.
166
+ - `promoCode` (`string`, optional) — Promo code whose Offer prices the change, validated with the checkout's rules: a code the checkout would refuse returns 400 validation_error with the checkout's reason in details.reason. Cannot be combined with `offerId`.
167
+ - `newPlanId` (`string`, optional) — The plan's ID (`pln_…`) or its code. Cannot be combined with `planCode`.
168
+ - `planCode` (`string`, optional) — Code of the destination plan, or `<plan code>:<experiment code>` to change to the experiment's latest version while it runs (the plan's current version once the experiment is won or archived). Same rules as planCode on subscription creation. Cannot be combined with `newPlanId`.
169
+ - `planVersionId` (`string`, optional) — Public ID of a published version of the destination plan, current or not, including a running experiment's versions. The change is priced, checked out and activated on that version. Only for an immediate change to another paid plan, and not with an experiment code. When omitted, the change lands on the plan's current version, or the version its experiment code sells. Requires `newPlanId` or `planCode`.
172
170
 
173
171
  ### Request options
174
172
 
@@ -207,19 +205,14 @@ Move a subscription to a newer published version of its plan, now or at the end
207
205
 
208
206
  `POST /subscriptions/{id}/credits` · operation `purchase-credits`
209
207
 
210
- Purchase a fixed credit pack or choose a whole credit quantity at the subscription plan price and minimum. Creates the purchase invoice, charges the saved payment method and adds the purchased credits once the payment is confirmed. Without a saved payment method, send successUrl to receive a checkout that charges the purchase and saves the method. A credit pack that the subscription's plan version does not sell is rejected with credit_pack_unavailable.
208
+ Purchase a fixed credit pack or choose a whole credit quantity at the subscription plan price and minimum. Creates the purchase invoice, charges the saved payment method and adds the purchased credits once the payment is confirmed. Send successUrl to receive, when there is no saved payment method or it is declined, a checkout that charges the purchase and saves the method. A credit pack that the subscription's plan version does not sell is rejected with credit_pack_unavailable.
211
209
 
212
210
  ### Parameters
213
211
 
214
212
  - `id` (`string`, required)
215
- - `creditPackId` (`string`, optional)
216
- - `quantity` (`number`, optional)
217
- - `successUrl` (`string`, optional) — Where the customer returns after paying. When it is set and the subscription has no saved payment method, the response has status `requires_checkout` and a `checkoutUrl` where the customer pays this purchase and saves the method in one step. Without it, the request is rejected when there is no saved payment method. A saved method is always charged directly, and a declined charge is rejected either way.
218
-
219
- ### Valid parameter combinations
220
-
221
- - `creditPackId`
222
- - `quantity`
213
+ - `creditPackId` (`string`, optional) — Required unless `quantity` is sent. Cannot be combined with `quantity`.
214
+ - `quantity` (`number`, optional) — Required unless `creditPackId` is sent. Cannot be combined with `creditPackId`.
215
+ - `successUrl` (`string`, optional) — Where the customer returns after paying. When it is set and the subscription has no saved payment method, or the saved method is declined or asks for authentication, the response has status `requires_checkout` and a `checkoutUrl` where the customer pays this purchase and saves the method in one step. Without it, the request is rejected in both cases. A saved method is always charged directly first, and a payment that fails for any other reason is rejected either way.
223
216
 
224
217
  ### Request options
225
218
 
@@ -241,7 +234,7 @@ Apply a direct Offer to a subscription. On a pending checkout it quotes or repla
241
234
 
242
235
  - `id` (`string`, required)
243
236
  - `offerId` (`string`, required)
244
- - `expiresAt` (`string`, optional)
237
+ - `expiresAt` (`string`, optional) — Only for a pending payment checkout, and later than the current time.
245
238
 
246
239
  ### Request options
247
240
 
@@ -381,15 +374,12 @@ Preview proration details for an immediate plan change without applying it. Free
381
374
  ### Parameters
382
375
 
383
376
  - `id` (`string`, required)
384
- - `planId` (`string`, required)
385
377
  - `billingInterval` (`"weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | "one_time"`, optional)
386
- - `offerId` (`string`, optional)
387
- - `promoCode` (`string`, optional)
388
-
389
- ### Valid parameter combinations
390
-
391
- - `planId`
392
- - `planId` + `promoCode`
378
+ - `offerId` (`string`, optional) — Cannot be combined with `promoCode`.
379
+ - `promoCode` (`string`, optional) — Promo code whose Offer prices the change, validated with the checkout's rules: a code the checkout would refuse returns 400 validation_error with the checkout's reason in details.reason. Cannot be combined with `offerId`.
380
+ - `planId` (`string`, optional) — The plan's ID (`pln_…`) or its code. Required unless `planCode` is sent. Cannot be combined with `planCode`.
381
+ - `planCode` (`string`, optional) — Code of the destination plan, or `<plan code>:<experiment code>` to change to the experiment's latest version while it runs (the plan's current version once the experiment is won or archived). Same rules as planCode on subscription creation. Required unless `planId` is sent. Cannot be combined with `planId`.
382
+ - `planVersionId` (`string`, optional) — Public ID of a published version of the destination plan, current or not, including a running experiment's versions. The change is priced, checked out and activated on that version. Only for an immediate change to another paid plan, and not with an experiment code. When omitted, the change lands on the plan's current version, or the version its experiment code sells.
393
383
 
394
384
  ### Request options
395
385
 
@@ -405,7 +395,7 @@ Preview proration details for an immediate plan change without applying it. Free
405
395
 
406
396
  `POST /subscriptions/{id}/reactivate` · operation `reactivate-subscription`
407
397
 
408
- Reactivates a subscription. A past_due subscription retries its outstanding renewal charge (recovering to active on success). A canceled subscription generates a fresh invoice, charges the saved card, and resets the billing period; when that invoice totals zero, for example under an Offer, it is marked paid without a charge and the subscription becomes active at once, still requiring a saved payment method. On a successful charge the subscription becomes active; a declined charge returns an error with a recoveryUrl in the error details that can be sent to the customer to update their card. A canceled subscription may apply an Offer by offerId; past-due recovery cannot.
398
+ Reactivates a subscription. A past_due subscription retries its outstanding renewal charge (recovering to active on success). A canceled subscription generates a fresh invoice, charges the saved card, and resets the billing period; when that invoice totals zero, for example under an Offer, it is marked paid without a charge and the subscription becomes active at once, still requiring a saved payment method. On a successful charge the subscription becomes active; a declined charge returns an error with a recoveryUrl in the error details that can be sent to the customer to update their card. A past_due subscription without a payment method returns no_payment_method with the same recoveryUrl. A canceled subscription may apply an Offer by offerId; past-due recovery cannot.
409
399
 
410
400
  ### Parameters
411
401
 
@@ -514,7 +504,7 @@ Cancel the move to another plan version pending for the next renewal, so the sub
514
504
 
515
505
  `POST /subscriptions/{id}/uncancel` · operation `uncancel-subscription`
516
506
 
517
- Revert a scheduled cancellation and return the updated subscription. Only works before cancellation takes effect.
507
+ Revert a scheduled cancellation and return the updated subscription. Only works before cancellation takes effect. When the cancellation scheduled a move to the group's default plan instead, it reverts that move: the subscription keeps its plan and renews normally.
518
508
 
519
509
  ### Parameters
520
510
 
@@ -550,10 +540,12 @@ Get the active subscription for a customer. Returns null if none.
550
540
 
551
541
  `GET /subscriptions` · operation `list-subscriptions`
552
542
 
553
- List all subscriptions. Filter by customer ID or status.
543
+ List subscriptions, newest first. Filter by customer ID, status or plan version. Send `limit` or `cursor` to receive them in pages and follow `nextCursor` while `hasMore` is true; without them the response holds every matching subscription, up to 80,000.
554
544
 
555
545
  ### Parameters
556
546
 
547
+ - `cursor` (`string`, optional)
548
+ - `limit` (`number`, optional)
557
549
  - `customerId` (`string`, optional)
558
550
  - `status` (`SubscriptionStatus`, optional)
559
551
  - `planVersionId` (`string`, optional)
@@ -568,7 +560,7 @@ List all subscriptions. Filter by customer ID or status.
568
560
 
569
561
  `POST /subscriptions` · operation `create-subscription`
570
562
 
571
- Create a subscription for a customer. Commet selects the default price when priceId is omitted. The subscription starts at the base USD price; market and currency are resolved from the buyer's request country when the checkout opens. Without an offer override, Commet applies the price's automatic introductory Offer. Pass offerId to apply an active compatible Offer directly, or cardPromotionId to preselect a card-eligible Promotional Offer for the initial checkout when card promotions are enabled for the organization. For the initial checkout, provider accepts either a processor name or an exact payment connection ID. When the price's free trial requires no payment method, the subscription starts trialing right away with no checkout (checkoutUrl null, hasPaymentMethod false); it cannot be combined with offerId, promoCode, cardPromotionId or provider, and an organization that cannot charge yet receives 403.
563
+ Create a subscription for a customer. Commet selects the default price when priceId is omitted. The subscription starts at the base USD price; market and currency are resolved from the buyer's request country when the checkout opens. Without an offer override, Commet applies the price's automatic introductory Offer. Pass offerId to apply an active compatible Offer directly, or cardPromotionId to preselect a card-eligible Promotional Offer for the initial checkout when card promotions are enabled for the organization. For the initial checkout, provider accepts either a processor name or an exact payment connection ID. When the price's free trial requires no payment method, the subscription starts trialing right away with no checkout (checkoutUrl null, hasPaymentMethod false); it cannot be combined with offerId, promoCode, cardPromotionId, provider or paymentMethodTypes, and an organization that cannot charge yet receives 403. When the customer already has a past_due subscription, the 409 error details carry its subscriptionId, its status and, while its renewal is unpaid, a recoveryUrl where the customer can pay it.
572
564
 
573
565
  ### Parameters
574
566
 
@@ -576,30 +568,21 @@ Create a subscription for a customer. Commet selects the default price when pric
576
568
  - `billingInterval` (`"weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | "one_time" | null`, optional)
577
569
  - `priceId` (`string`, optional) — Public price ID. When omitted, Commet selects the default price for the billing interval and still applies its market pricing.
578
570
  - `initialSeats` (`Record<string, number>`, optional)
579
- - `provider` (`"stripe" | "commet" | "dlocal" | string`, optional) — Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present.
580
- - `paymentMethodTypes` (`Array<"card" | "mercado_pago" | "oxxo" | "google_pay" | "smartpix" | "apple_pay" | "link">`, optional) — Payment methods the initial checkout may offer. Restricts what the checkout already offers for the buyer's country, currency and payment connection; it never enables a method the connection does not have and never changes routing. When none of them is available to the buyer, the checkout shows that it cannot accept payments.
571
+ - `provider` (`"stripe" | "commet" | "dlocal" | string`, optional) — Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present. Not available on free plans or with a free trial that requires no payment method.
572
+ - `paymentMethodTypes` (`Array<"card" | "mercado_pago" | "oxxo" | "google_pay" | "smartpix" | "apple_pay" | "link">`, optional) — Payment methods the initial checkout may offer. Restricts what the checkout already offers for the buyer's country, currency and payment connection; it never enables a method the connection does not have and never changes routing. When none of them is available to the buyer, the checkout shows that it cannot accept payments. Not available on free plans or with a free trial that requires no payment method.
581
573
  - `name` (`string`, optional)
582
574
  - `startDate` (`string`, optional)
583
575
  - `successUrl` (`string`, optional)
584
- - `prepaidPeriods` (`number`, optional) — Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true.
585
- - `cancelAtPeriodEnd` (`boolean`, optional) — Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method.
586
- - `planVersionId` (`string`, optional) — Public ID of a published version of the plan, current or not, including an experiment's versions. The subscription is created on that version and stays on it: checkout charges its price and activation grants its credits, add-ons and credit packs. When omitted, the subscription gets the current version, or the version an experiment code (planCode `<plan code>:<experiment code>`) sells.
587
- - `offerId` (`string`, optional)
588
- - `promoCode` (`string`, optional)
589
- - `customTrialDays` (`number`, optional) — Trial length in days, replacing the price's trial. A customer who already had this plan, in a trial or paying, gets no trial and goes through the regular checkout.
590
- - `skipTrial` (`boolean`, optional)
591
- - `planId` (`string`, optional)
592
- - `planCode` (`string`, optional) — The plan code, or an experiment code as `<plan code>:<experiment code>` to sell the version the experiment sells.
593
- - `cardPromotionId` (`string`, optional) — Public card promotion ID. The offer is shown immediately and remains conditional on card eligibility until checkout confirmation.
594
-
595
- ### Valid parameter combinations
596
-
597
- - `customerId` + `planId`
598
- - `customerId` + `planCode`
599
- - `customerId` + `offerId` + `planId`
600
- - `customerId` + `offerId` + `planCode`
601
- - `customerId` + `cardPromotionId` + `planId`
602
- - `customerId` + `cardPromotionId` + `planCode`
576
+ - `prepaidPeriods` (`number`, optional) — Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true. Above 1, needs a paid recurring price, cannot take an Offer whose phases bill on another interval and cannot be combined with `customTrialDays` above 0.
577
+ - `cancelAtPeriodEnd` (`boolean`, optional) — Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method. When the plan's group has a default free plan, it moves to that plan then instead of ending. When true, needs a paid recurring price and cannot be combined with `customTrialDays` above 0.
578
+ - `planVersionId` (`string`, optional) — Public ID of a published version of the plan, current or not, including an experiment's versions. The subscription is created on that version and stays on it: checkout charges its price and activation grants its credits, add-ons and credit packs. When omitted, the subscription gets the current version, or the version an experiment code (planCode `<plan code>:<experiment code>`) sells. Cannot be combined with an experiment code in `planCode`.
579
+ - `offerId` (`string`, optional) — Cannot be combined with `promoCode`. Cannot be combined with `cardPromotionId`.
580
+ - `promoCode` (`string`, optional) — Cannot be combined with `offerId`. Cannot be combined with `cardPromotionId`.
581
+ - `customTrialDays` (`number`, optional) — Trial length in days, replacing the price's trial. A customer who already had this plan, in a trial or paying, gets no trial and goes through the regular checkout. Above 0, cannot be combined with `prepaidPeriods` above 1 or with `cancelAtPeriodEnd` true. Cannot be combined with `cardPromotionId`.
582
+ - `skipTrial` (`boolean`, optional) — Cannot be `true` with `cardPromotionId`.
583
+ - `cardPromotionId` (`string`, optional) — Public card promotion ID. The offer is shown immediately and remains conditional on card eligibility until checkout confirmation. Cannot be combined with `offerId`. Cannot be combined with `promoCode`. Cannot be combined with `customTrialDays`. Cannot be used when `skipTrial` is `true`.
584
+ - `planId` (`string`, optional) — Required unless `planCode` is sent. Cannot be combined with `planCode`.
585
+ - `planCode` (`string`, optional) — The plan code, or an experiment code as `<plan code>:<experiment code>` to sell the version the experiment sells. Required unless `planId` is sent. Cannot be combined with `planId`.
603
586
 
604
587
  ### Request options
605
588
 
@@ -34,7 +34,7 @@ Returns the organization's current test clock state and latest durable run. Sand
34
34
 
35
35
  ## advance
36
36
 
37
- `commet.testClock.advance(params, options?)`
37
+ `commet.testClock.advance(params?, options?)`
38
38
 
39
39
  `POST /test-clock` · operation `advance-test-clock`
40
40
 
@@ -42,13 +42,8 @@ Starts a durable run that moves the test clock forward and processes every billi
42
42
 
43
43
  ### Parameters
44
44
 
45
- - `advanceDays` (`number`, optional)
46
- - `frozenTime` (`string`, optional)
47
-
48
- ### Valid parameter combinations
49
-
50
- - `advanceDays`
51
- - `frozenTime`
45
+ - `advanceDays` (`number`, optional) — Required unless `frozenTime` is sent. Cannot be combined with `frozenTime`.
46
+ - `frozenTime` (`string`, optional) — Required unless `advanceDays` is sent. Cannot be combined with `advanceDays`.
52
47
 
53
48
  ### Request options
54
49
 
@@ -35,17 +35,12 @@ Track a usage event for a metered feature. Deducts from balance/credits if appli
35
35
  - `eventId` (`string`, optional)
36
36
  - `timestamp` (`string`, optional)
37
37
  - `properties` (`Array<{ property: string; value: string }>`, optional)
38
- - `model` (`string`, optional)
39
- - `inputTokens` (`number`, optional)
40
- - `outputTokens` (`number`, optional)
41
- - `value` (`number`, optional)
42
- - `cacheReadTokens` (`number`, optional)
43
- - `cacheWriteTokens` (`number`, optional)
44
-
45
- ### Valid parameter combinations
46
-
47
- - `featureCode` + `customerId` + `model` + `inputTokens` + `outputTokens`
48
- - `featureCode` + `customerId`
38
+ - `model` (`string`, optional) — Required when `inputTokens`, `outputTokens`, `cacheReadTokens` or `cacheWriteTokens` is sent. Cannot be combined with `value`.
39
+ - `inputTokens` (`number`, optional) — Required when `model`, `outputTokens`, `cacheReadTokens` or `cacheWriteTokens` is sent. Cannot be combined with `value`.
40
+ - `outputTokens` (`number`, optional) — Required when `model`, `inputTokens`, `cacheReadTokens` or `cacheWriteTokens` is sent. Cannot be combined with `value`.
41
+ - `value` (`number`, optional) — Defaults to `1` unless `model` is sent. Cannot be combined with `model`, `inputTokens`, `outputTokens`, `cacheReadTokens` or `cacheWriteTokens`.
42
+ - `cacheReadTokens` (`number`, optional) — Requires `model`, `inputTokens` and `outputTokens`. Cannot be combined with `value`.
43
+ - `cacheWriteTokens` (`number`, optional) — Requires `model`, `inputTokens` and `outputTokens`. Cannot be combined with `value`.
49
44
 
50
45
  ### Request options
51
46
 
@@ -16,7 +16,7 @@ Choose the path that fits where you are working. You only need one to get starte
16
16
  1. Select your **sandbox organization** in the dashboard.
17
17
  2. Go to **Settings → API Keys** and click **Create API Key**.
18
18
  3. Choose **Full Access** for a backend or **AI Agents** to select resource permissions.
19
- 4. Enter a descriptive name of up to 32 characters, such as `Local development`, and choose **Expires In (Days)**. The dashboard accepts **1–365 days** and defaults to **365**.
19
+ 4. Enter a descriptive name of up to 32 characters, such as `Local development`. A key created from the dashboard does not expire.
20
20
  5. Create the key and copy it before closing the dialog. The full secret is shown only once.
21
21
 
22
22
  ### CLI
@@ -110,7 +110,9 @@ For other languages, follow the [Python](/docs/integrate-with-python), [Go](/doc
110
110
 
111
111
  ## Rotate and promote to live
112
112
 
113
- Use a separate key for each application or deployment that needs independent rotation. To replace a key before it expires:
113
+ Keys created from the dashboard or by linking the CLI do not expire. Keys created through the API, `commet api-keys create` or MCP expire after `expiresInDays`, 365 when omitted; **Expires** in the dashboard and `expiresAt` in [List API keys](/docs/api-reference/api-keys/list-api-keys) show the date. An expired key stops authenticating and cannot be extended.
114
+
115
+ Use a separate key for each application or deployment that needs independent rotation. To replace a key:
114
116
 
115
117
  1. Create a replacement in the **same organization**.
116
118
  2. Update the secret in every process using the old key and deploy or restart those processes.
@@ -11,7 +11,7 @@ When a renewal payment fails, the subscription moves to `past_due` and enters du
11
11
  2. The failed invoice is marked as `outstanding`
12
12
  3. The customer keeps service: usage events and seat events still work (usage accrues as debt)
13
13
  4. The customer receives an email notification
14
- 5. Commet retries the charge on a fixed schedule (dunning)
14
+ 5. Commet retries the charge on the calendar of your retry window (dunning)
15
15
 
16
16
  If a retry succeeds, the subscription returns to `active`. If all retries fail, the invoice is marked as `uncollectible` and the subscription is canceled. When the plan's group has a [default plan](/docs/plan-groups#default-plan-and-signup-trial), the subscription moves to it instead and `subscription.plan_changed` fires.
17
17
 
@@ -30,7 +30,16 @@ Initial checkout card declines do not emit `payment.failed`; the checkout respon
30
30
 
31
31
  ## Automatic retries
32
32
 
33
- Retries run on day 1, day 3, day 5, and day 7 after the original failure (4 retries). The calendar is anchored to the failure and never moves. After the last failed retry the subscription is canceled, or moves to the plan group's default plan.
33
+ You choose how long Commet retries in **Settings → Revenue recovery**: 7, 14, 21 or 30 days. Each window has a fixed calendar counted from the original failure, and 7 days is the default:
34
+
35
+ | Window | Retries | Days after the failure |
36
+ | ---------------- | ------- | ----------------------------- |
37
+ | 7 days (default) | 4 | 1, 3, 5 and 7 |
38
+ | 14 days | 6 | 1, 3, 5, 7, 10 and 13 |
39
+ | 21 days | 8 | 1, 3, 5, 9, 11, 13, 15 and 20 |
40
+ | 30 days | 8 | 1, 3, 5, 9, 14, 19, 24 and 29 |
41
+
42
+ A subscription never retries for longer than its billing period: weekly subscriptions always use the 7-day calendar, and monthly subscriptions use the 21-day calendar when the window is 30 days. A subscription keeps the window it had when its payment failed, even if you change the setting later. The calendar is anchored to the failure and never moves. After the last failed retry the subscription is canceled, or moves to the plan group's default plan.
34
43
 
35
44
  Manual retries from the Customer Portal or [`reactivate`](#retry-the-charge-server-to-server) use the default payment method and have separate daily limits. They do not consume automatic retry slots or start another charge while an automatic retry is in progress.
36
45
 
@@ -179,7 +188,7 @@ The SDK exposes three server-side recovery primitives. For `past_due` subscripti
179
188
  `reactivate` charges the subscription's saved payment method. It works on both `past_due` and `canceled` subscriptions, with different effects:
180
189
 
181
190
  - `past_due`: retries the same outstanding renewal invoice. The billing anchor stays fixed. On success the subscription returns to `active` and `payment.recovered` fires.
182
- - `canceled`: generates a fresh invoice, resets the billing period anchor to now, and charges the saved card. On success the subscription returns to `active` and `subscription.reactivated` fires. Requires the plan to still be available in the subscription's currency, otherwise it returns `PLAN_UNAVAILABLE` (422).
191
+ - `canceled`: generates a fresh invoice, resets the billing period anchor to now, and charges the saved card. On success the subscription returns to `active` and `subscription.reactivated` fires. When the fresh invoice totals zero, for example under an Offer with a fixed price of 0, it is marked paid without a charge, the subscription returns to `active` at once, and `subscription.reactivated` fires with `invoiceTotal: 0`; a saved payment method is still required. Requires the plan to still be available in the subscription's currency, otherwise it returns `PLAN_UNAVAILABLE` (422).
183
192
 
184
193
  ```typescript
185
194
  const result = await commet.subscriptions.reactivate({ id: 'sub_123' })
@@ -163,6 +163,7 @@ curl -X POST https://commet.co/api/v1/subscriptions \
163
163
  ```
164
164
 
165
165
  - The cancellation is scheduled from creation: the response already shows `cancelAtPeriodEnd: true` and `cancellation` before the customer pays.
166
+ - The checkout shows `1 month · one-time payment, doesn't renew`, or the periods paid, and no charges after them.
166
167
  - The purchase keeps ending even if the customer saves a card through a payment method update link, and the Customer Portal doesn't offer **Keep subscription** for it.
167
168
  - Free trials don't combine with it: `customTrialDays` above `0` returns `400` and the price's trial is skipped.
168
169
  - When the purchase ends, Commet emits [`subscription.canceled`](/docs/webhooks/subscription-canceled).
@@ -30,7 +30,25 @@ const launchOffer = await commet.offers.create({
30
30
  })
31
31
  ```
32
32
 
33
- The Offer does not contain `purpose`, `planPriceIds`, eligibility, or redemption rules.
33
+ The Offer does not contain `purpose`, `planPriceIds`, eligibility, or redemption rules. It can carry two optional limits: the plans and the billing interval it applies to.
34
+
35
+ ## Limit an Offer to plans or a billing interval
36
+
37
+ An Offer applies to any plan and any billing interval, and it stays with the subscription when the customer changes either one. Two optional limits narrow that:
38
+
39
+ | Field | Limit |
40
+ | ----------------- | --------------------------------------------------------------------------------------------- |
41
+ | `planIds` | The Offer applies only to subscriptions on these plans. An empty list means every plan. |
42
+ | `billingInterval` | The Offer applies only to subscriptions billed on this interval. `null` means every interval. |
43
+
44
+ In the dashboard, open **Limits (optional)** in the Offer form and choose **Subscription billing interval** and **Applicable plans**. The Offer page shows them as **Applies to** and **Billing interval**. Through the API, send `planIds` and `billingInterval` when you create or update the Offer. An update that omits a limit keeps it; `planIds: []` and `billingInterval: null` remove it.
45
+
46
+ A limit acts at two moments:
47
+
48
+ - **When the Offer is applied.** A limited Offer cannot be applied to a subscription on another plan or interval. With `offerId`, creating the subscription returns `400 validation_error` on `offerId`, an immediate plan change and `PUT /subscriptions/{id}/offer` return `400 offer_not_applicable`, and a plan-change preview returns `404 offer_not_found`. A [Promo Code](/docs/promo-codes) of the Offer is rejected with `plan_not_eligible` or `billing_interval_not_eligible`, and a [Card Promotion](/docs/card-promotions) of the Offer does not apply.
49
+ - **When the customer changes plan or billing interval.** The applied Offer ends with the change when the new plan or interval is outside the limit. Inside the limit, it continues as [any discount does](/docs/how-do-discounts-work#plan-changes).
50
+
51
+ Limits are read when the change happens. A limit you add later also reaches customers who already have the Offer, the next time they change plan or billing interval.
34
52
 
35
53
  ## Apply the same Offer in different ways
36
54
 
@@ -51,10 +69,10 @@ When Commet quotes or applies an Offer, it records an immutable Offer Applicatio
51
69
  - the resolved currency and amounts when available;
52
70
  - the exact accepted phases and dates.
53
71
 
54
- Editing, deactivating, or archiving the catalog Offer affects future applications only. Existing applications remain available for billing and audit.
72
+ Editing, deactivating, or archiving the catalog Offer affects future applications only. Existing applications remain available for billing and audit. The plan and interval limits are the exception: they are read each time the customer changes plan or billing interval.
55
73
 
56
74
  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
75
 
58
76
  ## Offers managed by an integration
59
77
 
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.
78
+ 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 and changing its plan and interval limits still work.
@@ -91,8 +91,8 @@ A rejected code returns `400 validation_error` with `param: "promoCode"` and the
91
91
  - `max_redemptions_reached`: the redemption limit was reached.
92
92
  - `first_purchase_only`: the customer already paid or has a paid subscription.
93
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.
94
+ - `plan_not_eligible`: the code, or its Offer, is limited to other plans.
95
+ - `billing_interval_not_eligible`: the code, or its Offer, is limited to another billing interval.
96
96
  - `intro_offer_active`: an Introductory Offer applies.
97
97
 
98
98
  Checkout also rejects a positive total below the currency's minimum charge.
@@ -36,7 +36,7 @@ await commet.subscriptions.create({
36
36
  })
37
37
  ```
38
38
 
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.
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, but an Offer [limited to other plans or another billing interval](/docs/offers#limit-an-offer-to-plans-or-a-billing-interval) is rejected.
40
40
 
41
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.
42
42
 
@@ -329,7 +329,7 @@ The response includes `subscriptionId`, `invoiceId`, and `status`. An immediate
329
329
  | `422`, `no_payment_method` | A period-end resume needs a saved payment method. |
330
330
  | `500`, `internal_error` | An internal failure prevented completion; this is distinct from a declined payment. |
331
331
 
332
- A declined resume keeps its invoice outstanding. Automatic payment retries follow days 1, 3, 5, and 7 from the original failure and reuse that invoice. The subscription stays paused during retries. If all retries fail, it is canceled and the resume invoice becomes uncollectible. Manual resume attempts do not consume automatic retry slots.
332
+ A declined resume keeps its invoice outstanding. Automatic payment retries follow the calendar of your [retry window](/docs/handle-failed-payments#automatic-retries) from the original failure and reuse that invoice. The subscription stays paused during retries. If all retries fail, it is canceled and the resume invoice becomes uncollectible. Manual resume attempts do not consume automatic retry slots.
333
333
 
334
334
  A period-end resume uses the base price of the subscription's plan version when its new invoice is created. An outstanding resume invoice keeps its original amounts and included credits or balance on retry, even if the catalog changes again. Accepted Introductory Offers and discounts preserve their unconsumed terms; resume does not grant a new Introductory Offer or redeem a promo code again.
335
335
 
@@ -689,11 +689,11 @@ $commet = new Commet('ck_xxx');
689
689
  $recoveryLink = $commet->subscriptions->createRecoveryLink(id: 'sub_xxx');
690
690
  ```
691
691
 
692
- Automatic dunning retries are anchored to the original decline on days 1, 3, 5, and 7. A successful retry returns the subscription to `active`.
692
+ Automatic dunning retries are anchored to the original decline and follow the calendar of your [retry window](/docs/handle-failed-payments#automatic-retries). A successful retry returns the subscription to `active`.
693
693
 
694
694
  ## Reactivate a canceled subscription
695
695
 
696
- The same `reactivate` operation charges the saved payment method, reuses the subscription record, and starts a fresh period anchored to the reactivation date. You may pass an `offerId`; accepted phases are persisted as an immutable Offer Application.
696
+ The same `reactivate` operation charges the saved payment method, reuses the subscription record, and starts a fresh period anchored to the reactivation date. You may pass an `offerId`; accepted phases are persisted as an immutable Offer Application. When the reactivation invoice totals zero, for example under an Offer with a fixed price of 0, it is marked paid without a charge and the subscription becomes active at once; a saved payment method is still required.
697
697
 
698
698
  The subscription returns on the latest version of what was bought: the plan's current version for a plan code, the experiment's latest version for an experiment code (the plan's current version once the experiment is no longer running), and the same version for `planVersionId`. Add-ons that version doesn't sell are deactivated. If it doesn't sell the subscription's currency, reactivation returns `422 missing_regional_price`.
699
699
 
@@ -105,10 +105,12 @@ A Promo Code for that Offer entered on a prepaid checkout is rejected with "This
105
105
 
106
106
  ## What the customer sees at checkout
107
107
 
108
- | Purchase | Checkout shows |
109
- | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------- |
110
- | Renews after the paid periods | `3 months · then $10.00/mo` or `2 quarters · then $30.00/qtr` |
111
- | One-time purchase, a subscription scheduled to end, or a first payment with a method that can't renew (OXXO) | `3 months · one-time payment, doesn't renew` |
108
+ | Purchase | Checkout shows |
109
+ | ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------- |
110
+ | Renews after the paid periods | `3 months · then $10.00/mo` or `2 quarters · then $30.00/qtr` |
111
+ | One-time purchase, a subscription scheduled to end, or a first payment with a method that can't renew (OXXO) | `3 months · one-time payment, doesn't renew`, or `1 month · one-time payment, doesn't renew` for a single period |
112
+
113
+ A single period that renews keeps the plan interval, such as `per month`. A purchase that doesn't renew shows no charges after its paid periods, even with a discount. The pending payment page and an unavailable checkout show the same label.
112
114
 
113
115
  On a link that adds periods to an active subscription, the label follows whether the subscription renews, not the method chosen in that checkout. An OXXO payment on a card subscription shows `then …`.
114
116
 
@@ -9,7 +9,7 @@ The customer already has a draft, trialing, active, or past-due subscription tha
9
9
 
10
10
  ## What to do
11
11
 
12
- Inspect the existing subscription and continue, recover, cancel, or change it instead of creating a conflicting subscription.
12
+ Inspect the existing subscription and continue, recover, cancel, or change it instead of creating a conflicting subscription. When it is past due, details carry its subscriptionId, its status and, while its renewal is unpaid, a recoveryUrl where the customer can pay it.
13
13
 
14
14
  The response `message`, `param`, and `details` fields describe the condition observed by the specific operation.
15
15
 
@@ -9,7 +9,7 @@ The charge required by the subscription operation failed.
9
9
 
10
10
  ## What to do
11
11
 
12
- Use the response message and decline information to resolve the payment failure.
12
+ Use the response message and decline information to resolve the payment failure. When a subscription reactivation or resume was declined, details.recoveryUrl is a link where the customer can pay it.
13
13
 
14
14
  The response `message`, `param`, and `details` fields describe the condition observed by the specific operation.
15
15
 
@@ -9,7 +9,7 @@ The subscription has no reusable payment method for this operation.
9
9
 
10
10
  ## What to do
11
11
 
12
- Collect or update the customer's payment method through the supported checkout or payment-method flow.
12
+ Collect or update the customer's payment method through the supported checkout or payment-method flow. When a subscription is reactivated or resumed, details.recoveryUrl is a link where the customer can pay it; when a paid plan change is requested, details.checkoutUrl is a link where the customer pays the change.
13
13
 
14
14
  The response `message`, `param`, and `details` fields describe the condition observed by the specific operation.
15
15
 
@@ -9,7 +9,7 @@ The operation could not complete its payment or required tax calculation.
9
9
 
10
10
  ## What to do
11
11
 
12
- Follow the operation-specific response message and details to correct the payment method, provider condition, or tax calculation failure.
12
+ Follow the operation-specific response message and details to correct the payment method, provider condition, or tax calculation failure. When a card is declined on a plan change, a purchase that sent successUrl or a one-time charge, details.checkoutUrl is a link where the customer pays it with another method.
13
13
 
14
14
  The response `message`, `param`, and `details` fields describe the condition observed by the specific operation.
15
15
 
@@ -9,7 +9,7 @@ The subscription status does not permit the requested operation.
9
9
 
10
10
  ## What to do
11
11
 
12
- Read the current subscription status and use the lifecycle operation supported for that state.
12
+ Read the current subscription status and use the lifecycle operation supported for that state. When the subscription is past due, details.recoveryUrl is a link where the customer can pay its debt.
13
13
 
14
14
  The response `message`, `param`, and `details` fields describe the condition observed by the specific operation.
15
15
 
@@ -9,7 +9,7 @@ The request failed validation. The response message, param, and details identify
9
9
 
10
10
  ## What to do
11
11
 
12
- Correct the condition identified by the response before sending the request again.
12
+ Correct the condition identified by the response before sending the request again. When a purchase for a past-due subscription is refused, details.recoveryUrl is a link where the customer can pay its debt.
13
13
 
14
14
  The response `message`, `param`, and `details` fields describe the condition observed by the specific operation.
15
15
 
@@ -52,9 +52,9 @@ Renewal after: $40.00
52
52
  ```
53
53
 
54
54
  - A percentage is the same percentage of the new price. An amount off is the same amount.
55
- - A `fixed_price` phase, free cycles included, is the price of the plan it was accepted on: it ends with the change, and the other phases of the Offer continue.
55
+ - A `fixed_price` phase, free cycles included, keeps its price on the new plan for the cycles it had left. A phase counted in its own `durationInterval` ends when the change moves the subscription to another billing interval, and the other phases of the Offer continue.
56
56
  - When the billing interval changes, the discount keeps the time it had left. With two monthly cycles left, a yearly charge made within those two months is discounted in full and the next yearly renewal is not.
57
- - A Promo Code or Card Promotion restricted to plans or to a billing interval ends with the change when the new plan or interval is outside its restriction.
57
+ - An Offer, Promo Code or Card Promotion limited to plans or to a billing interval ends with the change when the new plan or interval is outside its limit. See [how to limit an Offer](/docs/offers#limit-an-offer-to-plans-or-a-billing-interval).
58
58
  - A change that passes its own `offerId` or `promoCode` applies that Offer with its full duration and ends the previous one. Scheduled plan changes accept neither.
59
59
  - A move to a free plan ends the discount.
60
60
 
@@ -73,4 +73,4 @@ Total: $130.00
73
73
 
74
74
  > **Note**
75
75
  >
76
- > Accepted phases are stored in an immutable Offer Application. Editing, deactivating, or archiving the catalog Offer changes future applications only.
76
+ > Accepted phases are stored in an immutable Offer Application. Editing, deactivating, or archiving the catalog Offer changes future applications only, except its plan and interval limits, which are read at each plan change.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Payment Failures
3
- description: Usage and seats keep working while Commet retries a failed charge on days 1, 3, 5 and 7; if all fail, the subscription ends or moves to the default plan.
3
+ description: Usage and seats keep working while Commet retries a failed charge for the window you chose; if all retries fail, the subscription ends or moves to the default plan.
4
4
  ---
5
5
 
6
6
  When a payment fails, your customer's usage and seats keep working while Commet retries the charge — but new purchases are blocked. If all retries fail, their subscription is canceled, or moves to the plan group's [default plan](/docs/plan-groups#default-plan-and-signup-trial).
@@ -18,11 +18,11 @@ All retries fail
18
18
  → Paid access is revoked
19
19
  ```
20
20
 
21
- | Stage | Access | What's happening |
22
- | --------------------- | --------------------------------------- | ---------------------------------------------------------------------------------- |
23
- | Payment fails | **Usage and seats keep working** | Subscription moves to `past_due`, invoice becomes `outstanding`, retries scheduled |
24
- | During grace period | **Usage and seats keep working** | Automatic retries on day 1, day 3, day 5, and day 7; usage keeps accruing as debt |
25
- | All retries exhausted | Revoked, or limited to the default plan | Subscription canceled or moved to the default plan, invoice marked `uncollectible` |
21
+ | Stage | Access | What's happening |
22
+ | --------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
23
+ | Payment fails | **Usage and seats keep working** | Subscription moves to `past_due`, invoice becomes `outstanding`, retries scheduled |
24
+ | During grace period | **Usage and seats keep working** | Automatic retries during the [retry window](/docs/handle-failed-payments#automatic-retries) you chose (7 days by default); usage keeps accruing as debt |
25
+ | All retries exhausted | Revoked, or limited to the default plan | Subscription canceled or moved to the default plan, invoice marked `uncollectible` |
26
26
 
27
27
  > **Warning**
28
28
  >