@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
package/docs/schemas.md CHANGED
@@ -168,6 +168,12 @@ Generated from Commet API version `2026-08-27`.
168
168
  - `object` (`"balance_topup"`, required)
169
169
  - `livemode` (`boolean`, required)
170
170
 
171
+ ### BusinessTaxId
172
+
173
+ - `country` (`string`, required)
174
+ - `type` (`string`, required)
175
+ - `value` (`string`, required)
176
+
171
177
  ### ClaimLink
172
178
 
173
179
  - `url` (`string`, required)
@@ -205,6 +211,7 @@ Generated from Commet API version `2026-08-27`.
205
211
  - `billingDayOfMonth` (`number | null`, required)
206
212
  - `nextBillingDate` (`string | null`, required)
207
213
  - `checkoutUrl` (`string | null`, required)
214
+ - `hasPaymentMethod` (`boolean`, required) — Whether Commet can charge this subscription on its own at its next charge (the trial end or the renewal). A trial that started without a payment method reports false until the customer adds one for this subscription; a payment method saved for another subscription does not count. A subscription on a free plan reports false.
208
215
  - `createdAt` (`string`, required)
209
216
  - `updatedAt` (`string`, required)
210
217
  - `offerApplications` (`Array<SubscriptionOfferApplication>`, required)
@@ -265,6 +272,7 @@ Generated from Commet API version `2026-08-27`.
265
272
  - `email` (`string`, required)
266
273
  - `taxDocument` (`string | null`, required)
267
274
  - `documentType` (`string | null`, required)
275
+ - `businessTaxId` (`BusinessTaxId | null`, required)
268
276
  - `timezone` (`string | null`, required)
269
277
  - `metadata` (`Record<string, unknown> | null`, required)
270
278
  - `createdAt` (`string`, required)
@@ -413,6 +421,13 @@ Variants:
413
421
  - `object` (`"invoice"`, required)
414
422
  - `livemode` (`boolean`, required)
415
423
 
424
+ ### ManagedBy
425
+
426
+ Variants:
427
+
428
+ - `"dub"`
429
+ - `null`
430
+
416
431
  ### Market
417
432
 
418
433
  - `id` (`string`, required)
@@ -428,11 +443,12 @@ Variants:
428
443
 
429
444
  - `id` (`string`, required)
430
445
  - `name` (`string`, required)
431
- - `phases` (`Array<{ type: "free_trial"; durationDays: number } | { type: "percentage"; durationCycles: number | null; durationInterval: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | null; percentage: number } | { type: "amount_off"; durationCycles: number | null; durationInterval: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | null; amounts: Array<{ currency: string; amount: number }> } | { type: "fixed_price"; durationCycles: number | null; durationInterval: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | null; prices: Array<{ currency: string; amount: number }> }>`, required)
446
+ - `phases` (`Array<{ type: "percentage"; durationCycles: number | null; durationInterval: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | null; percentage: number } | { type: "amount_off"; durationCycles: number | null; durationInterval: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | null; amounts: Array<{ currency: string; amount: number }> } | { type: "fixed_price"; durationCycles: number | null; durationInterval: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | null; prices: Array<{ currency: string; amount: number }> }>`, required)
432
447
  - `metadata` (`Record<string, unknown>`, required)
433
448
  - `startsAt` (`string | null`, required)
434
449
  - `endsAt` (`string | null`, required)
435
450
  - `active` (`boolean`, required)
451
+ - `managedBy` (`ManagedBy`, required) — Integration that manages this record, or null when the merchant does. While an integration manages it, its terms change only in that integration and edits answer 409 managed_by_integration.
436
452
  - `createdAt` (`string`, required)
437
453
  - `updatedAt` (`string`, required)
438
454
  - `object` (`"offer"`, required)
@@ -505,14 +521,18 @@ Variants:
505
521
  - `isPublic` (`boolean`, required)
506
522
  - `isDefault` (`boolean`, required)
507
523
  - `isFree` (`boolean`, required)
508
- - `blockOnExhaustion` (`boolean | null`, required)
524
+ - `blockOnExhaustion` (`boolean | null`, required) — Credits and balance plans: true stops usage when the plan and purchased amounts run out; false lets usage continue and bills the missing amount as overage at the next renewal (credits at the price per credit). Trials and free plans always stop.
525
+ - `unusedPlanCredits` (`{ type: "expire" } | { type: "roll_over"; maxPlanCredits: number | null } | null`, required) — Credits plans only; null for other consumption models. What happens to unused plan credits at each reset. Purchased credits never expire and never count toward maxPlanCredits.
526
+ - `planCreditLimit` (`{ credits: number; interval: "day" | "week" } | null`, required) — Credits plans only. The most plan credits a subscription spends per day or per week; null means no limit.
527
+ - `unusedPlanBalance` (`{ type: "expire" } | { type: "roll_over"; maxPlanBalance: number | null } | null`, required) — Balance plans only; null for other consumption models. What happens to unused plan balance at each reset. Purchased balance never expires and never counts toward maxPlanBalance.
528
+ - `planBalanceLimit` (`{ amount: number; interval: "day" | "week" } | null`, required) — Balance plans only. The most plan balance a subscription spends per day or per week, in USD cents; null means no limit.
509
529
  - `sortOrder` (`number`, required)
510
530
  - `planGroupId` (`string | null`, required)
511
531
  - `metadata` (`Record<string, unknown> | null`, required)
512
532
  - `createdAt` (`string`, required)
513
533
  - `updatedAt` (`string`, required)
514
534
  - `features` (`Array<{ code: string; name: string; type: FeatureType; unitName: string | null; enabled: boolean; includedAmount: number | null; unlimited: boolean; overage: { enabled: boolean; model: "per_unit" | null; unitPrice: number | null } | null; regionalPrices: Array<{ currency: string; overageUnitPrice: number | null; autoSynced: boolean }> }>`, required)
515
- - `prices` (`Array<{ id: string; billingInterval: BillingInterval; price: number; isDefault: boolean; trialDays: number; includedBalance: number | null; includedCredits: number | null; offerId: string | null; inheritsFromPriceId: string | null; metadata: Record<string, unknown>; marketPrices: Array<{ marketGroupId: string; currency: string; price: number }>; regionalPrices: Array<{ currency: string; price: number; includedBalance: number | null; autoSynced: boolean }> }>`, required)
535
+ - `prices` (`Array<{ id: string; billingInterval: BillingInterval; price: number; isDefault: boolean; trialDays: number; trialRequiresPaymentMethod: boolean | null; includedBalance: number | null; includedCredits: number | null; offerId: string | null; inheritsFromPriceId: string | null; metadata: Record<string, unknown>; marketPrices: Array<{ marketGroupId: string; currency: string; price: number }>; regionalPrices: Array<{ currency: string; price: number; includedBalance: number | null; autoSynced: boolean }> }>`, required)
516
536
  - `exchangeRates` (`Array<{ currency: string; exchangeRate: number }>`, required)
517
537
  - `object` (`"plan"`, required)
518
538
  - `livemode` (`boolean`, required)
@@ -592,6 +612,7 @@ Variants:
592
612
  - `price` (`number`, required) — Price in the currency's minor unit (for example, cents for USD).
593
613
  - `isDefault` (`boolean`, required)
594
614
  - `trialDays` (`number`, required)
615
+ - `trialRequiresPaymentMethod` (`boolean | null`, required) — Whether the price's free trial needs a payment method to start. When false, a new subscription starts trialing right away without checkout; without a payment method added by the trial end, the customer moves to the plan group's default plan, or the subscription is canceled when there is none. Null when the price has no trial.
595
616
  - `includedBalance` (`number | null`, required)
596
617
  - `includedCredits` (`number | null`, required)
597
618
  - `offerId` (`string | null`, required) — Automatic introductory offer for this price.
@@ -656,6 +677,8 @@ Variants:
656
677
  - `expiresAt` (`string | null`, required)
657
678
  - `isActive` (`boolean`, required)
658
679
  - `redemptionCount` (`number`, required)
680
+ - `firstPurchaseOnly` (`boolean`, required) — Whether the code only applies to a customer's first purchase: one with no paid invoice above zero and no paid subscription.
681
+ - `managedBy` (`ManagedBy`, required) — Integration that manages this record, or null when the merchant does. While an integration manages it, its terms change only in that integration and edits answer 409 managed_by_integration.
659
682
  - `createdAt` (`string`, required)
660
683
  - `updatedAt` (`string`, required)
661
684
  - `object` (`"promo_code"`, required)
@@ -760,6 +783,7 @@ Variants:
760
783
  - `billingDayOfMonth` (`number | null`, required)
761
784
  - `nextBillingDate` (`string | null`, required)
762
785
  - `checkoutUrl` (`string | null`, required)
786
+ - `hasPaymentMethod` (`boolean`, required) — Whether Commet can charge this subscription on its own at its next charge (the trial end or the renewal). A trial that started without a payment method reports false until the customer adds one for this subscription; a payment method saved for another subscription does not count. A subscription on a free plan reports false.
763
787
  - `createdAt` (`string`, required)
764
788
  - `updatedAt` (`string`, required)
765
789
  - `offerApplications` (`Array<SubscriptionOfferApplication>`, required)
@@ -767,8 +791,8 @@ Variants:
767
791
  - `planGrant` (`{ id: string; plan: { id: string; name: string }; expiresAt: string | null }`, optional)
768
792
  - `consumptionModel` (`ConsumptionModel | null`, required)
769
793
  - `features` (`Array<{ code: string; name: string; type: "boolean"; enabled: boolean; baseAccess?: { enabled: boolean } | null } | { code: string; name: string; type: "usage"; usage?: { current: number; included: number; overageQuantity: number; overageUnitPrice?: number; unlimited?: boolean }; baseAccess?: { included: number; unlimited: boolean } | null } | { code: string; name: string; type: "seats"; usage: { current: number; included: number; overageQuantity: number; overageUnitPrice?: number; unlimited?: boolean }; baseAccess?: { included: number; unlimited: boolean } | null } | { code: string; name: string; type: "quota"; usage?: { current: number; included: number; overageQuantity: number; overageUnitPrice?: number; unlimited?: boolean }; baseAccess?: { included: number; unlimited: boolean } | null }>`, required)
770
- - `credits` (`{ remaining: number; included: number; purchased: number } | null`, required)
771
- - `balance` (`{ remaining: number; included: number; currency: string } | null`, required)
794
+ - `credits` (`{ remaining: number; included: number; purchased: number; plan: number; total: number } | null`, required)
795
+ - `balance` (`{ remaining: number; included: number; currency: string; plan: number; purchased: number; total: number } | null`, required)
772
796
  - `priceId` (`string | null`, required)
773
797
  - `object` (`"subscription"`, required)
774
798
  - `livemode` (`boolean`, required)
@@ -781,6 +805,20 @@ Variants:
781
805
  - `object` (`"subscription_addon"`, required)
782
806
  - `livemode` (`boolean`, required)
783
807
 
808
+ ### SubscriptionAutoTopUp
809
+
810
+ - `enabled` (`boolean`, required) — Whether top-ups run automatically: credits bought on a credits plan, balance added on a balance plan. Always false when the plan does not sell credits or has balance top-ups turned off.
811
+ - `threshold` (`number | null`, required) — The available amount at or below which a top-up runs, or null when never configured: credits (plan plus purchased) on a credits plan, minor units of the subscription currency (plan plus purchased balance) on a balance plan.
812
+ - `quantity` (`number | null`, required) — Credits each top-up buys on a credits plan, or null when never configured or on a balance plan.
813
+ - `amount` (`number | null`, required) — Minor units of the subscription currency each top-up adds on a balance plan, charged plus tax, or null when never configured or on a credits plan.
814
+ - `maxPerPeriod` (`number | null`, required) — Maximum top-ups per renewal period, or null when never configured.
815
+ - `status` (`"active" | "paused" | "off"`, required) — active tops up when the available amount reaches the threshold; paused stops after three consecutive failed top-ups, or after one whose charge could not be refunded, until the payment method changes, a credit purchase or balance top-up succeeds or it is saved enabled again; off tops up nothing.
816
+ - `topUpsThisPeriod` (`number`, required) — Top-ups made in the current renewal period.
817
+ - `periodResetsAt` (`string | null`, required) — When the top-up count of the period resets, or null before the subscription starts its first period.
818
+ - `lastFailure` (`{ reason: "payment_declined" | "no_payment_method" | "quantity_below_minimum" | "amount_below_minimum" | "purchase_failed"; at: string } | null`, required) — The last top-up that failed, or null when none has failed.
819
+ - `object` (`"subscription_auto_top_up"`, required)
820
+ - `livemode` (`boolean`, required)
821
+
784
822
  ### SubscriptionOfferApplication
785
823
 
786
824
  - `id` (`string`, required)
@@ -834,6 +872,7 @@ Variants:
834
872
  - `billingDayOfMonth` (`number | null`, required)
835
873
  - `nextBillingDate` (`string | null`, required)
836
874
  - `checkoutUrl` (`string | null`, required)
875
+ - `hasPaymentMethod` (`boolean`, required) — Whether Commet can charge this subscription on its own at its next charge (the trial end or the renewal). A trial that started without a payment method reports false until the customer adds one for this subscription; a payment method saved for another subscription does not count. A subscription on a free plan reports false.
837
876
  - `createdAt` (`string`, required)
838
877
  - `updatedAt` (`string`, required)
839
878
  - `offerApplications` (`Array<SubscriptionOfferApplication>`, required)
@@ -937,8 +976,8 @@ Variants:
937
976
  Variants:
938
977
 
939
978
  - `{ allowed: boolean; subscriptionStatus: string; featureCode: string; quantity: number; reason?: string; message?: string; consumptionModel: "metered"; current: number; remaining: number; unlimited: boolean; included: number; overageEnabled: boolean; overageUnitPrice: number | null; object: "usage_check"; livemode: boolean }`
940
- - `{ allowed: boolean; subscriptionStatus: string; featureCode: string; quantity: number; reason?: string; message?: string; consumptionModel: "credits"; creditsPerUnit: number; estimatedCredits: number; planCredits: number; purchasedCredits: number; totalCredits: number; object: "usage_check"; livemode: boolean }`
941
- - `{ allowed: boolean; subscriptionStatus: string; featureCode: string; quantity: number; reason?: string; message?: string; consumptionModel: "balance"; unitPrice: number; estimatedAmount: number; currentBalance: number; blockOnExhaustion: boolean; currency: string; object: "usage_check"; livemode: boolean }`
979
+ - `{ allowed: boolean; subscriptionStatus: string; featureCode: string; quantity: number; reason?: string; message?: string; consumptionModel: "credits"; creditsPerUnit: number; estimatedCredits: number; planCredits: number; purchasedCredits: number; totalCredits: number; planCreditLimit: { credits: number; interval: "day" | "week"; spent: number; remaining: number; resetsAt: string } | null; blockOnExhaustion: boolean; object: "usage_check"; livemode: boolean }`
980
+ - `{ allowed: boolean; subscriptionStatus: string; featureCode: string; quantity: number; reason?: string; message?: string; consumptionModel: "balance"; unitPrice: number; estimatedAmount: number; currentBalance: number; planBalance: number; purchasedBalance: number; totalBalance: number; planBalanceLimit: { amount: number; interval: "day" | "week"; spent: number; remaining: number; resetsAt: string } | null; blockOnExhaustion: boolean; currency: string; object: "usage_check"; livemode: boolean }`
942
981
 
943
982
  ### UsageEvent
944
983
 
@@ -950,7 +989,7 @@ Variants:
950
989
  - `ts` (`string`, required)
951
990
  - `createdAt` (`string`, required)
952
991
  - `properties` (`Array<{ property: string; value: string }>`, required)
953
- - `consumption` (`{ model: "credits" | "balance"; deducted: number; remaining: number; blocked: boolean }`, optional)
992
+ - `consumption` (`{ model: "credits" | "balance"; deducted: number; remaining: number; blocked: boolean; planCreditLimit?: { credits: number; interval: "day" | "week"; spent: number; remaining: number; resetsAt: string } | null; planBalanceLimit?: { amount: number; interval: "day" | "week"; spent: number; remaining: number; resetsAt: string } | null }`, optional)
954
993
  - `object` (`"usage_event"`, required)
955
994
  - `livemode` (`boolean`, required)
956
995
 
@@ -998,7 +1037,10 @@ Variants:
998
1037
 
999
1038
  ### WebhookBalance
1000
1039
 
1001
- - `currentBalance` (`number`, required)
1040
+ - `currentBalance` (`number`, required) — The available balance, plan plus purchased, in rate scale. Equal to totalBalance.
1041
+ - `planBalance` (`number`, required) — The plan part in rate scale: spent first, replaced or rolled over at each reset, negative while overage is owed.
1042
+ - `purchasedBalance` (`number`, required) — The purchased part in rate scale: top-ups and manual adjustments, spent after the plan part and kept until the subscription ends.
1043
+ - `totalBalance` (`number`, required) — planBalance plus purchasedBalance, in rate scale.
1002
1044
 
1003
1045
  ### WebhookBankRef
1004
1046
 
@@ -462,9 +462,11 @@ After 8 failed attempts (the initial delivery plus 7 retries), the delivery is m
462
462
 
463
463
  ## Auto-disable for broken endpoints
464
464
 
465
- If three events in a row fail to deliver, Commet automatically disables the endpoint so it stops consuming retries. You'll get a second email confirming the endpoint was turned off.
465
+ Commet disables an endpoint when its three most recent deliveries with a final outcome all failed after their 8 attempts, even if newer deliveries are still retrying. A successful delivery among those three, including a test event, keeps the endpoint active. You get one email when the endpoint is disabled, with a link to it.
466
466
 
467
- Once you've fixed the issue on your receiver, re-enable the endpoint from the Commet dashboard under **Settings → Webhooks → Endpoints**. Events that arrived while the endpoint was disabled are not replayed automatically — contact support if you need to backfill any missed events.
467
+ Deliveries still retrying when the endpoint is disabled are stopped: Commet doesn't call your receiver again for them or send their failure emails.
468
+
469
+ Once you've fixed the issue on your receiver, re-enable the endpoint in **Settings → Webhooks**: choose **Re-enable** in the endpoint's menu, or **Re-enable endpoint** in its detail. The next delivery that fails all its attempts disables it again unless a success lands first. Events that arrived while the endpoint was disabled are not replayed automatically — contact support if you need to backfill any missed events.
468
470
 
469
471
  You can monitor delivery status, inspect payloads, and retry individual deliveries from the dashboard at any time.
470
472
 
@@ -472,14 +474,14 @@ You can monitor delivery status, inspect payloads, and retry individual deliveri
472
474
 
473
475
  Every `subscription.*` webhook includes a `status` field. These are the valid values and which ones grant access to your product:
474
476
 
475
- | Status | Grants access? | Meaning |
476
- | ----------------- | ------------------ | -------------------------------------------------------------------------------------------------------------- |
477
- | `draft` | No | Internal setup state before any event is fired |
478
- | `pending_payment` | **No** | Subscription created, waiting for the first charge to confirm |
479
- | `trialing` | **Yes** | Trial active; card captured, no charge yet |
480
- | `active` | **Yes** | Paid and current |
481
- | `past_due` | Yes (grace period) | A renewal charge failed; dunning retries in progress — usage and seats keep working, new purchases are blocked |
482
- | `canceled` | No | Terminal — the cancellation executed at period end, or dunning exhausted its retries |
477
+ | Status | Grants access? | Meaning |
478
+ | ----------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
479
+ | `draft` | No | Internal setup state before any event is fired |
480
+ | `pending_payment` | **No** | Subscription created, waiting for the first charge to confirm |
481
+ | `trialing` | **Yes** | Trial active, with or without a payment method; no charge yet |
482
+ | `active` | **Yes** | Paid and current |
483
+ | `past_due` | Yes (grace period) | A renewal charge failed; dunning retries in progress — usage and seats keep working, new purchases are blocked |
484
+ | `canceled` | No | Terminal — the cancellation executed at period end, dunning exhausted its retries, or a trial without a payment method ended without a card |
483
485
 
484
486
  Typical flow:
485
487
 
@@ -490,8 +492,8 @@ draft → pending_payment → trialing → active ⇄ past_due
490
492
  canceled
491
493
  ```
492
494
 
493
- - Without a trial, `pending_payment` goes straight to `active` when the first charge confirms; with one, it goes to `trialing`.
494
- - `trialing → active` happens when the trial converts — and also when it expires: trial expiry activates the subscription and regular billing begins.
495
+ - Without a trial, `pending_payment` goes straight to `active` when the first charge confirms; with one, it goes to `trialing`. A [trial without a payment method](/docs/trial-periods#start-a-trial-without-a-payment-method) starts in `trialing` with no checkout.
496
+ - `trialing → active` happens when the trial converts — and also when it expires: trial expiry activates the subscription and regular billing begins. A trial without a payment method that ends without a card moves to the plan group's default plan (`subscription.plan_changed`) or is canceled.
495
497
  - `active ⇄ past_due`: a failed renewal starts dunning; a recovered payment returns the subscription to `active`.
496
498
  - `canceled` is terminal, reached when a scheduled cancellation executes at period end or when dunning exhausts its retries.
497
499
 
package/docs/webhooks.md CHANGED
@@ -6,7 +6,7 @@ The complete contract, with every field description and example, is in [webhooks
6
6
 
7
7
  ## subscription.created
8
8
 
9
- Fired when a subscription record is created with status pending_payment. The first charge has not been confirmed yet — do NOT grant access here. Wait for subscription.activated.
9
+ Fired when a subscription record is created, usually with status pending_payment: the first charge has not been confirmed yet — do NOT grant access here; wait for subscription.activated. A trial whose price requires no payment method is created already trialing, together with trial.started.
10
10
 
11
11
  ### Data
12
12
 
@@ -137,7 +137,7 @@ Fired when a subscription is actually terminated. A scheduled cancellation fires
137
137
  - `customerId` (`string`, required) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
138
138
  - `status` (`string`, required) — Always "canceled" for this event. Revoke access when you receive this.
139
139
  - `canceledAt` (`string`, optional) — ISO 8601 datetime when the cancellation was requested or triggered.
140
- - `cancelReason` (`string | null`, required) — The reason for cancellation, if provided. Set to "dunning_exhausted" when all payment retries fail. Historical refund-triggered cancellations may have "refund".
140
+ - `cancelReason` (`string | null`, required) — The reason for cancellation, if provided. Set to "dunning_exhausted" when all payment retries fail, and to "trial_ended_without_payment_method" when a trial without a payment method ends with no card and no default plan. Historical refund-triggered cancellations may have "refund".
141
141
  - `endDate` (`string`, optional) — ISO 8601 datetime when the subscription ended. Matches the billing period end for scheduled cancellations; for immediate terminations it is the moment of termination.
142
142
 
143
143
  ## subscription.updated
@@ -209,7 +209,7 @@ Fired when a plan change (downgrade or shorter interval) is scheduled for the en
209
209
 
210
210
  ## subscription.plan_change_revoked
211
211
 
212
- Fired when a scheduled plan change is replaced by a different one before it executes. The replacement also fires subscription.plan_change_scheduled with the new target plan.
212
+ Fired when a scheduled plan change will no longer take effect: it was revoked through the API, the dashboard or the customer portal, an immediate plan change or an immediate cancellation voided it, or a different change replaced it. A replacement also fires subscription.plan_change_scheduled with the new target plan.
213
213
 
214
214
  ### Data
215
215
 
@@ -235,7 +235,7 @@ Fired when a recurring payment fails on a previously paid subscription and its s
235
235
 
236
236
  ## trial.started
237
237
 
238
- Fired when a subscription enters its trial period after checkout. Grant access here — trialing subscriptions have full access until trialEndsAt.
238
+ Fired when a subscription enters its trial period: after checkout, or right away when the price's trial requires no payment method. Grant access here — trialing subscriptions have full access until trialEndsAt.
239
239
 
240
240
  ### Data
241
241
 
@@ -260,7 +260,7 @@ Fired when a trialing customer converts to a paid subscription before the trial
260
260
 
261
261
  ## trial.expired
262
262
 
263
- Fired when a trial period runs out and the billing cycle activates the subscription. The first regular invoice is generated right after — this is the natural trial-to-paid transition.
263
+ Fired when a trial period runs out. With a payment method the billing cycle activates the subscription and generates the first regular invoice right after — the natural trial-to-paid transition. A trial without a payment method instead moves to the plan group's default plan (subscription.plan_changed) or is canceled with cancelReason trial_ended_without_payment_method (subscription.canceled), without an invoice.
264
264
 
265
265
  ### Data
266
266
 
@@ -286,7 +286,7 @@ Predictive event fired once, 3 days before a trial ends. Use it to remind the cu
286
286
 
287
287
  ## trial.checkout_ready
288
288
 
289
- Fired when a trial checkout link is ready to share with the customer. Completing this checkout saves a payment method and starts the trial (trial.started) — the customer is not charged until the trial ends.
289
+ Fired when a trial checkout link is ready to share with the customer. Completing this checkout saves a payment method and starts the trial (trial.started) — the customer is not charged until the trial ends. Not fired for a trial whose price requires no payment method, which starts without checkout.
290
290
 
291
291
  ### Data
292
292
 
@@ -584,6 +584,17 @@ Fired when a customer replaces their default payment method through the customer
584
584
  - `paymentMethod` (`PaymentMethod | null`, required) — The payment method: card, oxxo, or mercado_pago. Null when unknown.
585
585
  - `card` (`WebhookCardInfo | null`, required) — Card display metadata for the new method: brand, last4, expMonth, expYear. Null when the method is not a card or its details cannot be retrieved.
586
586
 
587
+ ## payment_method.detached
588
+
589
+ Fired when a saved payment method is removed from a customer: the customer unlinked it at the payment provider (for example, revoking a Mercado Pago authorization), or removed it through the customer portal. Removing a method never changes the customer's subscriptions; a renewal that finds no usable method follows the usual failed-payment recovery.
590
+
591
+ ### Data
592
+
593
+ - `customerId` (`string`, required) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
594
+ - `paymentMethod` (`PaymentMethod | null`, required) — The payment method: card, oxxo, or mercado_pago. Null when unknown.
595
+ - `card` (`WebhookCardInfo | null`, required) — Card display metadata of the removed method: brand, last4, expMonth, expYear. Null when the method is not a card or its details cannot be retrieved.
596
+ - `reason` (`"unlinked_at_provider" | "removed_by_customer"`, required) — Why the method was removed: `unlinked_at_provider` when the customer revoked it at the payment provider, `removed_by_customer` when the customer removed it through the customer portal.
597
+
587
598
  ## customer.created
588
599
 
589
600
  Fired when a customer is created, via the API (including batch create), SDK, or dashboard. The payload is the customer resource exactly as GET /customers returns it.
@@ -596,6 +607,7 @@ Fired when a customer is created, via the API (including batch create), SDK, or
596
607
  - `email` (`string`, required) — The customer's email.
597
608
  - `taxDocument` (`string | null`, required) — The customer's tax identification number, if provided.
598
609
  - `documentType` (`string | null`, required) — The local tax document type label inferred from the customer's country (e.g. CUIT, RFC, RUT), or null when no tax document was provided.
610
+ - `businessTaxId` (`{ country: string; type: string; value: string } | null`, required) — The business tax ID saved for the customer (EU VAT number, Peruvian RUC), or null when the customer has none.
599
611
  - `timezone` (`string | null`, required) — The customer's timezone.
600
612
  - `metadata` (`Record<string, unknown> | null`, required) — Custom key-value metadata you attached to the customer.
601
613
  - `createdAt` (`string`, required) — ISO 8601 datetime when the customer was created.
@@ -613,6 +625,7 @@ Fired when a customer's details change (email, name, timezone, externalId, or me
613
625
  - `email` (`string`, required) — The customer's email.
614
626
  - `taxDocument` (`string | null`, required) — The customer's tax identification number, if provided.
615
627
  - `documentType` (`string | null`, required) — The local tax document type label inferred from the customer's country (e.g. CUIT, RFC, RUT), or null when no tax document was provided.
628
+ - `businessTaxId` (`{ country: string; type: string; value: string } | null`, required) — The business tax ID saved for the customer (EU VAT number, Peruvian RUC), or null when the customer has none.
616
629
  - `timezone` (`string | null`, required) — The customer's timezone.
617
630
  - `metadata` (`Record<string, unknown> | null`, required) — Custom key-value metadata you attached to the customer.
618
631
  - `createdAt` (`string`, required) — ISO 8601 datetime when the customer was created.
@@ -634,7 +647,7 @@ Aggregate entitlement event answering one question: what can this customer acces
634
647
  - `features` (`Array<{ code: string; name: string; unitName: string | null; allowed: boolean; type: "boolean"; enabled: boolean } | { code: string; name: string; unitName: string | null; allowed: boolean; type: "usage"; consumption: { model: "metered"; period: { start: string; end: string }; unitsUsed: number; includedUnits: number; remainingUnits?: number; unlimited: boolean; overage: { enabled: boolean; units: number; unitPrice?: { amount: number; currency: string; scale: 10000 } } } | { model: "credits"; period: { start: string; end: string }; unitsUsed: number; creditsPerUnit: number; creditsConsumed: number; availableUnits: number } | { model: "balance"; period: { start: string; end: string }; unitsUsed: number; spent: { amount: number; currency: string }; availableUnits?: number; unitPrice?: { amount: number; currency: string; scale: 10000 } } } | { code: string; name: string; unitName: string | null; allowed: boolean; type: "seats"; usage: { period: { start: string; end: string }; unitsUsed: number; includedUnits: number; remainingUnits?: number; unlimited: boolean; overage: { enabled: boolean; units: number; unitPrice?: { amount: number; currency: string; scale: 10000 } } } } | { code: string; name: string; unitName: string | null; allowed: boolean; type: "quota"; usage: { period: { start: string; end: string }; unitsUsed: number; includedUnits: number; remainingUnits?: number; unlimited: boolean; overage: { enabled: boolean; units: number; unitPrice?: { amount: number; currency: string; scale: 10000 } }; billedUnits: number } }>`, required) — Current feature access, discriminated by type. Boolean features expose enabled; usage features expose model-specific consumption; seats and quota expose usage allowances.
635
648
  - `seats` (`Array<WebhookSeatSummary>`, required) — Summary of seats-type features: code, current, included, remaining, unlimited.
636
649
  - `credits` (`WebhookCreditsBalance | null`, required) — For credits plans: planCredits, purchasedCredits, totalCredits. Null otherwise.
637
- - `balance` (`WebhookBalance | null`, required) — For balance plans: currentBalance in rate scale (10000 = $1.00). Null otherwise.
650
+ - `balance` (`WebhookBalance | null`, required) — For balance plans, in rate scale (10000 = 1.00 of the subscription currency): currentBalance (the available total), planBalance, purchasedBalance and totalBalance. Null otherwise.
638
651
 
639
652
  ## plan_grant.created
640
653
 
@@ -734,7 +747,7 @@ Fired after an active plan grant is durably revoked. The payload is the grant sn
734
747
 
735
748
  ## credits.granted
736
749
 
737
- Fired when non-purchase credits are granted to a subscription: plan-included credits at the start of each billing period, or a manual adjustment from the dashboard. Credit pack purchases fire credits.purchased instead.
750
+ Fired when non-purchase credits are granted to a subscription: plan-included credits at the start of each billing period, or a manual adjustment from the dashboard. Credit purchases through the API, automatic top-ups, or the customer portal fire credits.purchased instead.
738
751
 
739
752
  ### Data
740
753
 
@@ -745,7 +758,7 @@ Fired when non-purchase credits are granted to a subscription: plan-included cre
745
758
 
746
759
  ## credits.purchased
747
760
 
748
- Fired when a customer buys a credit pack through the customer portal and the payment succeeds. Purchased credits never expire — unlike plan credits, they survive period resets. Plan-included credit grants fire credits.granted instead.
761
+ Fired when a customer buys a credit pack or a chosen quantity of credits through the API, an automatic top-up, or the customer portal and the payment succeeds. Purchased credits never expire — unlike plan credits, they survive period resets. Plan-included credit grants fire credits.granted instead.
749
762
 
750
763
  ### Data
751
764
 
@@ -753,24 +766,24 @@ Fired when a customer buys a credit pack through the customer portal and the pay
753
766
  - `customerId` (`string`, required) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
754
767
  - `invoiceId` (`string`, required) — The invoice issued for the purchase.
755
768
  - `invoiceNumber` (`string`, required) — The human-readable invoice number.
756
- - `creditPackName` (`string`, required) — The purchased credit pack's name.
769
+ - `creditPackName` (`string`, required) — The purchased credit pack's name, or Credit purchase for a chosen quantity of credits.
757
770
  - `credits` (`number`, required) — The number of credits purchased.
758
771
 
759
772
  ## credits.low
760
773
 
761
- Fired when a subscription's remaining credits cross below 10% of the credits granted for the current period. Emitted once per billing period, when the crossing happens.
774
+ Fired when a subscription's available credits (plan plus purchased) cross below 10% of their last refill: a period reset, a purchase or a manual adjustment. Emitted once per crossing, the same rule as balance.low.
762
775
 
763
776
  ### Data
764
777
 
765
778
  - `subscriptionId` (`string`, required) — The subscription ID.
766
779
  - `customerId` (`string`, required) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
767
780
  - `remainingCredits` (`number`, required) — Total credits remaining (plan plus purchased).
768
- - `thresholdCredits` (`number`, required) — The low-credit threshold that was crossed: 10% of the period's granted plan credits.
769
- - `periodCredits` (`number`, required) — The plan credits granted at the last period reset.
781
+ - `thresholdCredits` (`number`, required) — The low-credit threshold that was crossed: 10% of the last refill.
782
+ - `periodCredits` (`number`, required) — The credits added by the last refill: a period reset, a purchase or a manual adjustment.
770
783
 
771
784
  ## credits.depleted
772
785
 
773
- Fired when a subscription's credits hit zero. Usage requests that need more credits than remain are rejected from this point. Also fires customer.state_changed with trigger credits_depleted.
786
+ Fired each time a subscription's available credits cross to zero or below. Usage that needs more credits than remain is rejected from this point, unless the plan allows overage, which is billed at its price per credit at the next renewal. Also fires customer.state_changed with trigger credits_depleted.
774
787
 
775
788
  ### Data
776
789
 
@@ -780,17 +793,29 @@ Fired when a subscription's credits hit zero. Usage requests that need more cred
780
793
 
781
794
  ## credits.expired
782
795
 
783
- Fired at the period reset when unused plan credits from the previous period are discarded. Plan credits expire at period end; purchased credits never expire and are not affected.
796
+ Fired at a reset when unused plan credits are discarded. On a plan whose unused plan credits expire, every unused plan credit expires at each reset. On a plan that rolls them over, a reset keeps them, up to the plan's maxPlanCredits when it has one, and only the excess expires. A change to another credits plan applies the new plan's terms the same way. Purchased credits never expire and are not affected.
784
797
 
785
798
  ### Data
786
799
 
787
800
  - `subscriptionId` (`string`, required) — The subscription ID.
788
801
  - `customerId` (`string`, required) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
789
- - `expiredCredits` (`number`, required) — The unused plan credits that were discarded.
802
+ - `expiredCredits` (`number`, required) — The plan credits that were discarded.
803
+
804
+ ## balance.granted
805
+
806
+ Fired when non-purchase balance is granted to a subscription: the plan balance at the start of each billing period, or a manual adjustment from the dashboard or the API, which goes to the purchased balance. Balance top-ups fire balance.topped_up instead.
807
+
808
+ ### Data
809
+
810
+ - `subscriptionId` (`string`, required) — The subscription ID.
811
+ - `customerId` (`string`, required) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
812
+ - `amount` (`number`, required) — The balance granted in rate scale (10000 = 1.00 of the subscription currency).
813
+ - `currency` (`string`, required) — The subscription currency.
814
+ - `reason` (`string`, required) — Why the balance was granted: period_reset or manual_adjustment.
790
815
 
791
816
  ## balance.topped_up
792
817
 
793
- Fired when a customer on a balance plan tops up their prepaid balance through the customer portal and the payment succeeds.
818
+ Fired when a balance top-up succeeds: through the API, an automatic top-up or the customer portal. The amount goes to the purchased balance, which is spent after the plan balance and kept until the subscription ends.
794
819
 
795
820
  ### Data
796
821
 
@@ -824,6 +849,17 @@ Fired when a subscription's prepaid balance crosses to zero or below. With block
824
849
  - `currentBalance` (`number`, required) — The balance after depletion in rate scale. Zero, or negative when overage is allowed.
825
850
  - `currency` (`string`, required) — The subscription currency.
826
851
 
852
+ ## balance.expired
853
+
854
+ Fired at a reset when unused plan balance is discarded. On a plan whose unused plan balance expires, all of it expires at each reset. On a plan that rolls it over, a reset keeps it, up to the plan's maxPlanBalance when it has one, and only the excess expires. An overage debt invoiced at the renewal counts as nothing left over. Purchased balance never expires and is not affected.
855
+
856
+ ### Data
857
+
858
+ - `subscriptionId` (`string`, required) — The subscription ID.
859
+ - `customerId` (`string`, required) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
860
+ - `expiredAmount` (`number`, required) — The plan balance that was discarded, in rate scale (10000 = 1.00 of the subscription currency).
861
+ - `currency` (`string`, required) — The subscription currency.
862
+
827
863
  ## quota.threshold_reached
828
864
 
829
865
  Fired when a metered feature's usage crosses 80% of its included quantity for the current period. Emitted once per feature per billing period, when the crossing happens.