@commet/node 9.8.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 (56) hide show
  1. package/dist/index.d.mts +216 -23
  2. package/dist/index.d.ts +216 -23
  3. package/dist/index.js +6 -6
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +6 -6
  6. package/dist/index.mjs.map +1 -1
  7. package/docs/api-reference/customers.md +2 -0
  8. package/docs/api-reference/generated-webhooks.md +2 -2
  9. package/docs/api-reference/index.md +1 -1
  10. package/docs/api-reference/plans.md +8 -3
  11. package/docs/api-reference/subscriptions.md +7 -5
  12. package/docs/documentation/cli.md +60 -49
  13. package/docs/documentation/create-api-key.md +3 -1
  14. package/docs/documentation/customers/customer-portal.md +10 -2
  15. package/docs/documentation/customers/manage-customers.md +2 -1
  16. package/docs/documentation/finance/payouts.md +11 -0
  17. package/docs/documentation/finance/supported-countries.md +5 -5
  18. package/docs/documentation/invoicing/handle-failed-payments.md +9 -9
  19. package/docs/documentation/payments/accept-one-time-payments.md +1 -1
  20. package/docs/documentation/payments/payment-orchestration.md +2 -0
  21. package/docs/documentation/payments/payment-providers.md +46 -0
  22. package/docs/documentation/payments/transactions-refunds-and-retries.md +1 -1
  23. package/docs/documentation/plans/add-ons.md +1 -1
  24. package/docs/documentation/plans/consumption-models.md +44 -9
  25. package/docs/documentation/plans/credit-packs.md +49 -1
  26. package/docs/documentation/plans/one-time-payments.md +3 -3
  27. package/docs/documentation/plans/plan-groups.md +46 -10
  28. package/docs/documentation/platform/dashboard-metrics-and-events.md +40 -9
  29. package/docs/documentation/sales/connect-dub-affiliates.md +52 -0
  30. package/docs/documentation/sales/introductory-offers.md +7 -13
  31. package/docs/documentation/sales/offers.md +10 -6
  32. package/docs/documentation/sales/promo-codes.md +47 -17
  33. package/docs/documentation/sales/promotional-offers.md +6 -7
  34. package/docs/documentation/sales/regional-prices.md +16 -0
  35. package/docs/documentation/sales/trial-periods.md +67 -40
  36. package/docs/documentation/subscriptions/manage-subscriptions.md +65 -2
  37. package/docs/documentation/subscriptions/pay-in-advance.md +4 -7
  38. package/docs/documentation/subscriptions/upgrade-and-downgrade-plans.md +20 -2
  39. package/docs/documentation/testing-sandbox.md +2 -0
  40. package/docs/documentation/usage/track-usage.md +23 -0
  41. package/docs/errors/index.md +1 -0
  42. package/docs/errors/plan_balance_limit_reached.md +22 -0
  43. package/docs/knowledge-base/how-do-credits-credit-packs-and-customer-credits-differ.md +8 -8
  44. package/docs/knowledge-base/how-do-discounts-work.md +7 -5
  45. package/docs/knowledge-base/how-do-free-plans-work-without-payment.md +14 -8
  46. package/docs/knowledge-base/how-do-offers-promo-codes-and-card-promotions-work-together.md +1 -1
  47. package/docs/knowledge-base/how-do-trial-periods-work.md +30 -24
  48. package/docs/knowledge-base/how-does-billing-work.md +1 -0
  49. package/docs/knowledge-base/what-happens-when-a-payment-fails.md +11 -9
  50. package/docs/manifest.json +12 -2
  51. package/docs/platform-documentation.md +1 -0
  52. package/docs/schemas.md +27 -14
  53. package/docs/webhooks/introduction.md +14 -12
  54. package/docs/webhooks.md +42 -6
  55. package/docs/webhooks.openapi.json +857 -745
  56. package/package.json +1 -1
@@ -45,7 +45,7 @@ Add-ons can be activated on any subscription with a payment method:
45
45
  | Status | Can activate add-ons |
46
46
  | ------------- | ------------------------------------------------- |
47
47
  | **Active** | Yes |
48
- | **Trialing** | Yes — card was captured during trial checkout |
48
+ | **Trialing** | Yes — with a saved payment method |
49
49
  | **Free plan** | Yes — first purchase prompts for a payment method |
50
50
 
51
51
  ## Manage add-ons
@@ -25,7 +25,7 @@ Customers pay a base price and get included usage. Overage beyond the included a
25
25
 
26
26
  ## Credits
27
27
 
28
- Customers receive credits with their subscription. Feature usage consumes credits. When credits run out, customers can purchase [Credit Packs](/docs/credit-packs) or wait for the next billing cycle.
28
+ Customers receive credits with their subscription. Feature usage consumes credits. When credits run out, customers can buy [Credit Packs or a chosen quantity](/docs/credit-packs), turn on [auto top-up](/docs/credit-packs#top-up-credits-automatically), or wait for the next billing cycle.
29
29
 
30
30
  | Feature | Credits per Use |
31
31
  | ------------------- | --------------- |
@@ -35,7 +35,42 @@ Customers receive credits with their subscription. Feature usage consumes credit
35
35
 
36
36
  > **Note**
37
37
  >
38
- > Plan credits reset each billing period. Credits purchased via Credit Packs **never expire**.
38
+ > Plan credits expire at each reset unless the plan rolls them over. Purchased credits **never expire**.
39
+
40
+ ### Roll over unused plan credits
41
+
42
+ ```typescript
43
+ await commet.plans.update({
44
+ id: 'pln_xxx',
45
+ unusedPlanCredits: { type: 'roll_over', maxPlanCredits: 2500 },
46
+ })
47
+ ```
48
+
49
+ At each reset, the new allocation is added to the unused plan credits instead of replacing them. `maxPlanCredits` caps the total after the reset, including the new allocation; credits above it expire. It must be at least the included credits of every price. `null` means no cap other than 2,147,483,647 credits.
50
+
51
+ ```
52
+ Plan grants 1,000 credits per month. maxPlanCredits: 2,500.
53
+
54
+ Month 1: 800 unused → 800 + 1,000 = 1,800
55
+ Month 2: 1,800 unused → 2,800, capped at 2,500. 300 expire.
56
+ ```
57
+
58
+ `{ type: 'expire' }` restores the default. Existing subscriptions apply a change from their next reset. A plan change applies the new plan's setting.
59
+
60
+ ### Limit plan credit spending
61
+
62
+ ```typescript
63
+ await commet.plans.update({
64
+ id: 'pln_xxx',
65
+ planCreditLimit: { credits: 100, interval: 'day' },
66
+ })
67
+ ```
68
+
69
+ `planCreditLimit` caps the plan credits a subscription spends per window: `day` is 24 hours and `week` is 7 days, starting at the time of day of the subscription's billing anchor. Purchased credits are never limited.
70
+
71
+ An event past the limit uses purchased credits. Without enough, [Track Usage](/docs/track-usage#limit-plan-credit-spending) rejects it with `402 plan_credit_limit_reached`. Raising or removing the limit applies at once; lowering it, adding it, or changing its interval applies from the next period.
72
+
73
+ In the dashboard, open **Plans**, select a credits plan, and edit **Credit rollover**, **Credit limit**, or **Credit purchases**.
39
74
 
40
75
  ## Balance
41
76
 
@@ -62,13 +97,13 @@ Set a margin percentage instead of a fixed price. Commet looks up the model's to
62
97
 
63
98
  ## Comparison
64
99
 
65
- | Aspect | Metered | Credits | Balance |
66
- | -------------------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------ | ----------------------------------------- |
67
- | **When exceeded** | Overage at period end | Blocked or buy packs | Overage at period end |
68
- | **Reset behavior** | Usage resets to 0 each period | Plan credits reset each period | Balance resets to plan amount each period |
69
- | **Purchased extras** | N/A | Credits persist forever | Top-ups reset at period |
70
- | **Reset frequency** | Weekly plans reset every 7 days. Monthly, quarterly, semiannual, yearly, one-time, and free plans reset monthly | Same | Same |
71
- | **Customer portal** | View usage | Buy credit packs | Add balance (top-up) |
100
+ | Aspect | Metered | Credits | Balance |
101
+ | -------------------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------- | ----------------------------------------- |
102
+ | **When exceeded** | Overage at period end | Blocked or buy credits | Overage at period end |
103
+ | **Reset behavior** | Usage resets to 0 each period | Plan credits reset or roll over each period | Balance resets to plan amount each period |
104
+ | **Purchased extras** | N/A | Credits persist forever | Top-ups reset at period |
105
+ | **Reset frequency** | Weekly plans reset every 7 days. Monthly, quarterly, semiannual, yearly, one-time, and free plans reset monthly | Same | Same |
106
+ | **Customer portal** | View usage | Buy credits, set auto top-up | Add balance (top-up) |
72
107
 
73
108
  ## Overage restrictions by plan type
74
109
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Credit Packs
3
- description: Configure credit packages that customers can purchase from the Commet Customer Portal.
3
+ description: Sell credit packs, let customers buy a chosen quantity of credits at the plan price, and top up credits automatically at a threshold.
4
4
  ---
5
5
 
6
6
  Credit Packs are additional credit packages customers can purchase when they run out of included plan credits. Only available for plans using the **Credits** [consumption model](/docs/consumption-models).
@@ -79,3 +79,51 @@ curl https://commet.co/api/v1/credit-packs \
79
79
  ```
80
80
 
81
81
  The `price` field is in **cents** (1000 = $10.00). Prices are always in USD.
82
+
83
+ ## Buy a chosen quantity of credits
84
+
85
+ Set a price per credit on the plan to let customers buy any whole quantity instead of a fixed pack. Open **Plans**, select a credits plan, and edit **Credit purchases**: **Price per credit** and an optional **Minimum purchase**.
86
+
87
+ ```typescript
88
+ await commet.subscriptions.purchaseCredits({
89
+ id: 'sub_xxx',
90
+ quantity: 500,
91
+ })
92
+ ```
93
+
94
+ Commet charges the saved payment method at the plan's price per credit and adds purchased credits. Send `creditPackId` instead of `quantity` to buy a pack. Both fire [`credits.purchased`](/docs/webhooks/credits-purchased).
95
+
96
+ | Response | Cause |
97
+ | ----------------------- | -------------------------------------------------------------------------- |
98
+ | `400 validation_error` | The quantity is below the plan's minimum, or the plan doesn't sell credits |
99
+ | `402 no_payment_method` | The subscription has no saved payment method Commet can charge |
100
+ | `402 payment_failed` | The charge was declined |
101
+
102
+ The effective minimum is the larger of the configured minimum and the smallest quantity that reaches the currency's minimum charge.
103
+
104
+ ## Top up credits automatically
105
+
106
+ Auto top-up buys credits with the saved payment method when the subscription's credits fall to a threshold.
107
+
108
+ ```typescript
109
+ await commet.subscriptions.updateAutoTopUp({
110
+ id: 'sub_xxx',
111
+ enabled: true,
112
+ threshold: 100,
113
+ quantity: 500,
114
+ maxPerPeriod: 3,
115
+ })
116
+ ```
117
+
118
+ | Parameter | Type | Description |
119
+ | -------------- | --------- | --------------------------------------------------------------- |
120
+ | `enabled` | `boolean` | Turns automatic purchases on or off |
121
+ | `threshold` | `integer` | Plan and purchased credits at or below which a top-up is bought |
122
+ | `quantity` | `integer` | Credits each top-up buys. At least the plan's minimum |
123
+ | `maxPerPeriod` | `integer` | Successful top-ups per credit renewal period. `1` to `100` |
124
+
125
+ Send only the fields that change. Enabling requires a plan with a price per credit. Read the current settings, `status`, `topUpsThisPeriod`, and `lastFailure` with `getAutoTopUp`.
126
+
127
+ Auto top-up pauses after 3 consecutive failed top-ups, or after one whose charge couldn't be refunded. It resumes when the payment method changes, a credit purchase succeeds, or you save it enabled again.
128
+
129
+ Customers turn it on and edit it in the [Customer Portal](/docs/customer-portal) under **Auto top-up**. In the dashboard, it appears on the subscription detail.
@@ -16,7 +16,7 @@ A one-time price charges the customer once at checkout and never bills again for
16
16
  >
17
17
  > This page covers one-time charges billed as a **plan**. To charge a customer once with **no subscription or plan** — a standalone invoice with tax and receipt — use [Accept One-Time Payments](/docs/accept-one-time-payments) instead.
18
18
 
19
- One-time plans behave like any other plan — they support [trials](/docs/trial-periods), [intro offers](/docs/introductory-offers), [add-ons](/docs/add-ons), and all [consumption models](/docs/consumption-models). The only differences are:
19
+ One-time plans behave like any other plan — they support [add-ons](/docs/add-ons) and all [consumption models](/docs/consumption-models). One-time prices can't have a [trial](/docs/trial-periods) or an [intro offer](/docs/introductory-offers). The other differences are:
20
20
 
21
21
  | Aspect | Behavior |
22
22
  | -------------------- | ------------------------------------------------------------------------- |
@@ -131,7 +131,7 @@ The initial invoice includes the plan base price as a one-time charge. After tha
131
131
 
132
132
  | Invoice | What's included |
133
133
  | --------------------- | ------------------------------------------------------------------------ |
134
- | **Initial** | `plan_base` (once) + any applicable intro offer discount |
134
+ | **Initial** | `plan_base` (once) |
135
135
  | **Subsequent cycles** | `feature_overage`, `feature_seats`, `addon_base` — only if charges exist |
136
136
 
137
137
  If there's no overage or additional charges at a billing cycle, no invoice is generated.
@@ -164,7 +164,7 @@ curl -X POST https://commet.co/api/v1/subscriptions \
164
164
 
165
165
  - The cancellation is scheduled from creation: the response already shows `cancelAtPeriodEnd: true` and `cancellation` before the customer pays.
166
166
  - 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
- - Free trials don't combine with it. An explicit trial (`customTrialDays`, a trial Offer, or a trial Promo Code) returns `400`, the plan's automatic introductory trial is skipped, and a trial Promo Code entered at checkout is rejected.
167
+ - Free trials don't combine with it: `customTrialDays` above `0` returns `400` and the price's trial is skipped.
168
168
  - When the purchase ends, Commet emits [`subscription.canceled`](/docs/webhooks/subscription-canceled).
169
169
 
170
170
  To make it renew, [reverse the scheduled cancellation](/docs/manage-subscriptions#reverse-a-scheduled-cancellation) through the API with `POST /v1/subscriptions/{id}/uncancel`. If the customer paid with a method Commet can't charge again, such as OXXO, and has no saved card, the request returns `409 subscription_uncancel_failed`.
@@ -1,24 +1,60 @@
1
1
  ---
2
2
  title: Plan Groups
3
- description: Group plans together to enable self-service upgrades and downgrades in the Commet Customer Portal.
3
+ description: Group plans for self-service upgrades and downgrades, and choose the default free plan and signup trial that new and departing customers land on.
4
4
  ---
5
5
 
6
- Plan Groups let customers upgrade or downgrade between plans themselves through the [Customer Portal](/docs/customer-portal). Without a Plan Group, customers won't see upgrade/downgrade options in their portal.
6
+ A plan group is the [upgrade and downgrade path](/docs/what-happens-when-a-customer-changes-plans) between plans. Without a plan group, customers won't see upgrade or downgrade options in the [Customer Portal](/docs/customer-portal).
7
7
 
8
8
  ## Plan group components
9
9
 
10
- | Component | Description | Example |
11
- | -------------- | ----------------------------------------- | ------------------ |
12
- | **Group Name** | Name for the collection | "Standard Plans" |
13
- | **Plans** | Plans in the group, ordered low to high | Free, Starter, Pro |
14
- | **Hierarchy** | Drag-and-drop order defining upgrade path | Lowest tier first |
10
+ | Component | Description | Example |
11
+ | ---------------- | ----------------------------------------------------------- | ------------------ |
12
+ | **Group Name** | Name for the collection | "Standard Plans" |
13
+ | **Plans** | Plans in the group, ordered low to high | Free, Starter, Pro |
14
+ | **Hierarchy** | Drag-and-drop order defining upgrade path | Lowest tier first |
15
+ | **Default plan** | Free plan customers land on when a paid plan or trial ends | Free |
16
+ | **Signup trial** | Paid plan new customers start on, as a trial without a card | Pro |
15
17
 
16
18
  ## Create a plan group in the dashboard
17
19
 
18
- Go to **Plan Groups** and click **Create Plan Group**. Name the group, add your plans, then drag and drop to arrange them from lowest to highest tier. Each plan can only belong to one group. Plans with [Regional Prices](/docs/regional-prices) can be added, but all plans in a group must support the same set of currencies so any subscriber can move between them.
20
+ Go to **Plans** → **Groups** and click **Create Group**. Name the group, add your plans, then drag and drop to arrange them from lowest to highest tier. Each plan can only belong to one group. Plans with [Regional Prices](/docs/regional-prices) can be added, but all plans in a group must support the same set of currencies so any subscriber can move between them.
19
21
 
20
22
  This order defines the upgrade path and display order in the Customer Portal.
21
23
 
22
- ## Learn more
24
+ ## Default plan and signup trial
23
25
 
24
- - [What Happens When a Customer Changes Plans](/docs/what-happens-when-a-customer-changes-plans)
26
+ Open the group and choose **Set as default** on a free plan, or **Set as signup trial** on a paid plan whose default price has a [trial without a payment method](/docs/trial-periods#start-a-trial-without-a-payment-method). A group has at most one of each.
27
+
28
+ A customer created with `planGroupId` starts at once on:
29
+
30
+ - the signup trial, when the group has one and the customer never had that plan;
31
+ - otherwise the default plan;
32
+ - otherwise no plan.
33
+
34
+ ```typescript
35
+ await commet.customers.create({
36
+ email: 'user@example.com',
37
+ planGroupId: 'plg_xxx',
38
+ })
39
+ ```
40
+
41
+ `customers.createBatch` accepts the same `planGroupId` for every customer in the batch. A customer that already has an open subscription keeps it.
42
+
43
+ A paid plan of the group moves to the default plan instead of being canceled when:
44
+
45
+ - the customer cancels it from the Customer Portal, at period end;
46
+ - its payment authorization is revoked;
47
+ - every payment retry fails;
48
+ - a trial without a payment method ends without a card.
49
+
50
+ Canceling through the API still cancels. A scheduled move to the default plan can be revoked like any [scheduled plan change](/docs/upgrade-and-downgrade-plans#revoke-a-scheduled-plan-change).
51
+
52
+ Removing the default plan makes later endings regular cancellations. Moves already scheduled keep their target.
53
+
54
+ ## Limitations
55
+
56
+ - The default plan must be a free plan in the group.
57
+ - A signup trial plan can't remove the trial without a payment method from its default price.
58
+ - A customer gets the signup trial once per plan.
59
+ - `planGroupId` for a group with neither a default plan nor a signup trial returns `400`.
60
+ - `planGroupId` for a group with a signup trial returns `403` while the organization can't charge yet.
@@ -1,17 +1,48 @@
1
1
  ---
2
2
  title: Dashboard Metrics and Usage Events
3
- description: Understand MRR, revenue, churn, active subscriptions, and the usage-event explorer.
3
+ description: Customize the dashboard home, filter it by period, plan and currency, and see how MRR, revenue, churn and the usage-event explorer work.
4
4
  ---
5
5
 
6
- The dashboard summarizes confirmed billing records. Use it for operational review, not as a replacement for your accounting ledger or product analytics.
6
+ The dashboard home summarizes confirmed billing records. Use it for operational review, not as a replacement for your accounting ledger or product analytics.
7
7
 
8
- | Metric | Current calculation |
9
- | ------------------------ | ------------------------------------------------------------------------------------------ |
10
- | **MRR** | Latest successful gross payment per active subscription, normalized by billing interval |
11
- | **Total revenue** | Successful gross transactions paid during the current calendar month |
12
- | **Revenue growth** | Percentage change between current and previous monthly recurring revenue |
13
- | **Churn** | Subscriptions canceled in the last 30 days divided by the eligible subscription population |
14
- | **Active subscriptions** | Current subscriptions whose persisted status is `active` |
8
+ ## Customize the dashboard
9
+
10
+ Click **Customize** on the dashboard home. Drag widgets to reorder them, drag a widget to the hidden area to hide it, or click **Add widget** to show a hidden one. Click **Save** to keep the layout, or **Reset** to restore the default.
11
+
12
+ The layout is saved for you and this organization in your browser. By default the home shows Revenue, Successful Payments, Active Subscriptions, New Customers, New Paid Subscriptions, and MRR, plus Revenue by Plan when you have more than one plan. Provider Volume is available with more than one payment provider.
13
+
14
+ Hover the info icon next to a widget title to see how it is calculated. Most widgets open a detail page when clicked.
15
+
16
+ ## Filter by period, plan, and currency
17
+
18
+ The period, comparison, plan, and currency filters live in the URL, so a shared link opens the same view. Periods range from **Today** to **All time** or a **Custom range**, and their boundaries are in UTC.
19
+
20
+ The currency selector lists **All currencies**, USD, and every currency your organization has received:
21
+
22
+ - **All currencies** sums every payment in USD. A non-USD payment is converted at the previous UTC day's rate when it was made.
23
+ - A specific currency shows only the payments made in that currency, in that currency. Nothing is converted.
24
+
25
+ ## Metric definitions
26
+
27
+ | Widget | Calculation |
28
+ | ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
29
+ | **Revenue** | Successful payments excluding tax. Fully refunded or disputed payments are excluded; partial refunds keep the original amount |
30
+ | **Successful Payments** | Successful transactions, including payments later refunded or disputed |
31
+ | **MRR** | Effective recurring prices net of recurring discounts at period end, normalized to a month. Excludes tax, usage overage, one-time charges, and proration |
32
+ | **MRR after scheduled churn** | MRR of subscriptions still in service at period end, leaving out subscriptions scheduled to cancel before then. Hidden by default |
33
+ | **ARR** | MRR at period end × 12. A run rate, not cash collected |
34
+ | **Active Subscriptions** | Subscriptions entitled to service at period end: active, past due, or scheduled to cancel after the cutoff |
35
+ | **New Customers** | Customers created in the period. The currency filter does not apply |
36
+ | **New Paid Subscriptions** | Subscriptions whose first successful payment happened in the period, even if later refunded or disputed |
37
+ | **Churned Subscriptions** | Subscriptions that reached `canceled` in the period. **User Churned** and **Dunning Churned** split them by whether exhausted payment retries caused the cancellation |
38
+ | **Churned MRR** | Effective recurring price, net of recurring discounts and normalized to a month, at each cancellation |
39
+ | **Dunning Amount Recovered** | Recurring invoice totals recovered by a payment retry or manual recovery |
40
+ | **Dunning Payments Recovered** | Payment retries or manual recoveries that settled a recurring invoice |
41
+ | **Revenue by Plan** | Revenue grouped by plan, top three |
42
+ | **Provider Volume** | Successful payments by payment provider, with the comparison period dotted |
43
+ | **Seats** | Each customer's latest seat count per seat feature at period end. The currency filter does not apply |
44
+
45
+ Churn widgets count from June 4, 2026. A paused subscription is out of MRR and is not churn.
15
46
 
16
47
  Metrics are cached and can lag recent writes briefly. Investigate an exact payment in **Transactions** and its accounting result in **Invoices**.
17
48
 
@@ -0,0 +1,52 @@
1
+ ---
2
+ title: Connect Dub Affiliates
3
+ description: Connect Dub so partners earn commission on every sale Commet charges, and sync Dub partner discounts and codes as Offers and promo codes.
4
+ ---
5
+
6
+ Dub is an affiliate platform. Connected to Commet, it receives every sale Commet charges so partners earn their commission, and its partner discounts and codes become [Offers](/docs/offers) and [promo codes](/docs/promo-codes).
7
+
8
+ ## 1. Connect Dub
9
+
10
+ Open **Settings → Integrations**, and on the Dub card choose **Connect**. Paste an API key from your Dub workspace.
11
+
12
+ - Live organizations need a Dub workspace on the Business plan or higher and an API key with All permissions.
13
+ - Sandbox organizations use a Dub staging workspace. Partner emails still go out, and no payouts are made.
14
+
15
+ Commet validates the key by reading your Dub catalog and stores it encrypted. Only owners and admins can connect or manage Dub.
16
+
17
+ ## 2. Sync partner codes
18
+
19
+ On the Dub card, choose **Manage** and copy the **Code sync** URL. In Dub, go to **Settings → Webhooks** and create a webhook with that URL and the `discount_code.created` and `discount_code.deleted` events.
20
+
21
+ Each event makes Commet read the Dub catalog again. Without the webhook, new codes don't reach Commet.
22
+
23
+ ## How Dub records appear in Commet
24
+
25
+ | In Dub | In Commet |
26
+ | ---------------- | ---------------------------------------------------------------- |
27
+ | Partner discount | Offer with `managedBy: "dub"` |
28
+ | Partner code | Promo code with `firstPurchaseOnly: true` and `managedBy: "dub"` |
29
+
30
+ Their terms change only in Dub. Editing them in Commet returns `409 managed_by_integration`. Renaming an Offer and activating or deactivating a code still work.
31
+
32
+ A Dub code whose text already exists as a Commet promo code is not imported. **Manage** lists it under **Codes not imported**.
33
+
34
+ ## What Commet sends to Dub
35
+
36
+ Sales match Dub customers by the customer's `externalId`, the same ID you track leads with in Dub.
37
+
38
+ - Every invoice Commet charges is sent as a sale.
39
+ - Refunds mark the sale refunded.
40
+ - Cancellations, trial starts, customer updates, and code deletions are sent too.
41
+
42
+ Commet retries a failed send for up to 3 days. Billing is never affected. Sends that still fail appear under **Not reaching Dub** in **Manage**, with **Resend**.
43
+
44
+ ## Disconnect Dub
45
+
46
+ Choose **Disconnect** in **Manage**. Commet stops sending sales, refunds, and subscription changes to Dub, and stops following its discounts and codes. Their Offers and promo codes keep working as regular ones.
47
+
48
+ ## Limitations
49
+
50
+ - Invoices first charged before Dub was connected are not sent.
51
+ - Term changes in Dub reach Commet on the next code sync event.
52
+ - Dub codes are first-purchase only: customers who already paid are refused with `first_purchase_only`.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Introductory Offers
3
- description: Attach an existing Offer to a base plan price so Commet applies it automatically to eligible new subscriptions.
3
+ description: Attach an existing Offer to a base plan price so Commet applies its discount automatically to eligible new subscriptions.
4
4
  ---
5
5
 
6
6
  An Introductory Offer is not a separate Offer type. It is an existing Offer attached to one base plan price with introductory placement.
@@ -10,22 +10,16 @@ That placement adds two behaviors:
10
10
  - Commet selects the Offer automatically when no explicit override is supplied.
11
11
  - Commet checks introductory eligibility before applying it.
12
12
 
13
- Selectable price variants inherit the introductory placement from their base price.
13
+ Selectable price variants inherit the introductory placement from their base price. One-time prices can't have an Introductory Offer.
14
14
 
15
15
  ## Compatible phases
16
16
 
17
- An Offer used as introductory may contain:
18
-
19
- 1. One optional `free_trial` phase at the beginning.
20
- 2. At most one finite `percentage` or `amount_off` phase.
21
-
22
- It cannot use `fixed_price`, multiple discount phases, or an open-ended discount.
17
+ An Offer used as introductory contains exactly one finite `percentage` or `amount_off` phase. It cannot use `fixed_price` or an open-ended discount.
23
18
 
24
19
  ```typescript
25
20
  const onboarding = await commet.offers.create({
26
21
  name: 'Starter onboarding',
27
22
  phases: [
28
- { type: 'free_trial', durationDays: 14 },
29
23
  { type: 'percentage', durationCycles: 3, percentage: 3000 },
30
24
  ],
31
25
  })
@@ -35,7 +29,7 @@ In the Dashboard, open the plan price and choose **Add intro offer** to attach t
35
29
 
36
30
  ## Eligibility
37
31
 
38
- Current automatic eligibility excludes a customer who already has an `active` or `past_due` subscription in the organization. Other historical statuses do not create a lifetime ban.
32
+ Automatic eligibility excludes a customer who already has an `active`, `past_due`, or `paused` subscription in the organization. Other historical statuses do not create a lifetime ban.
39
33
 
40
34
  ## Selection at subscription creation
41
35
 
@@ -48,8 +42,8 @@ await commet.subscriptions.create({
48
42
 
49
43
  When `offerId` is omitted, Commet resolves the selected price and applies its introductory Offer if the customer is eligible.
50
44
 
51
- An explicit `offerId` applies that Offer directly instead. It cannot be combined with `promoCode`, `customTrialDays`, or `skipTrial: true`.
45
+ An explicit `offerId` applies that Offer directly instead. It cannot be combined with `promoCode` or `cardPromotionId`.
52
46
 
53
- ## Trials and compatibility fields
47
+ ## Trials
54
48
 
55
- `trialDays`, `customTrialDays`, and `skipTrial` remain supported API shortcuts. Internally, an accepted trial is recorded as a `free_trial` phase in the Offer Application. Prefer catalog Offers when the same terms should be named, reused, inspected, or distributed consistently.
49
+ Trial days belong to the plan price, not to the Offer. When the price has a trial, the introductory discount starts with the first invoice after it. See [Trial Periods](/docs/trial-periods).
@@ -1,9 +1,11 @@
1
1
  ---
2
2
  title: Offers
3
- description: Define reusable trials and temporary pricing terms independently from plans and distribution.
3
+ description: Define reusable discount phases independently from plans and distribution, then apply them automatically, directly, or through promo codes.
4
4
  ---
5
5
 
6
- An Offer is a reusable sequence of benefits. It defines **what changes**—a trial, a discount, or a temporary fixed price—without deciding which plan uses it or how a customer receives it.
6
+ An Offer is a reusable sequence of discount phases. It defines **what changes**—a discount or a temporary fixed price—without deciding which plan uses it or how a customer receives it.
7
+
8
+ Trials are not Offers. Set trial days on the plan price; see [Trial Periods](/docs/trial-periods).
7
9
 
8
10
  ## Offer phases
9
11
 
@@ -11,18 +13,16 @@ An Offer contains between 1 and 10 ordered phases:
11
13
 
12
14
  | Phase | Effect |
13
15
  | ------------- | --------------------------------------------------------------------------------- |
14
- | `free_trial` | Delays the first charge for a fixed number of days |
15
16
  | `percentage` | Reduces the plan base price by basis points |
16
17
  | `amount_off` | Subtracts an explicit amount for each configured currency |
17
18
  | `fixed_price` | Replaces the plan base price with an explicit amount for each configured currency |
18
19
 
19
- A free trial can appear only as the first phase. A discount phase may have a finite `durationCycles`, or `null` when it is the final open-ended phase.
20
+ A phase has a finite `durationCycles`, or `null` when it is the final open-ended phase. A `fixed_price` phase of `0` gives free billing cycles; the dashboard calls it **Free cycles**.
20
21
 
21
22
  ```typescript
22
23
  const launchOffer = await commet.offers.create({
23
24
  name: 'Launch sequence',
24
25
  phases: [
25
- { type: 'free_trial', durationDays: 14 },
26
26
  { type: 'percentage', durationCycles: 3, percentage: 5000 },
27
27
  { type: 'percentage', durationCycles: null, percentage: 2000 },
28
28
  ],
@@ -40,7 +40,7 @@ The Offer does not contain `purpose`, `planPriceIds`, eligibility, or redemption
40
40
  | **Promotional** | Your integration passes `offerId` | Explicit campaign, retention, or experiment assignment |
41
41
  | **Promo Code** | The customer enters a code | Redemption limits, plan restrictions, and expiration |
42
42
 
43
- The channel does not create another copy of the Offer. It only decides how the reusable terms reach a customer.
43
+ The channel does not create another copy of the Offer. It only decides how the reusable terms reach a customer. When the price has a trial, the discount starts with the first invoice after it.
44
44
 
45
45
  ## Accepted terms
46
46
 
@@ -54,3 +54,7 @@ When Commet quotes or applies an Offer, it records an immutable Offer Applicatio
54
54
  Editing, deactivating, or archiving the catalog Offer affects future applications only. Existing applications remain available for billing and audit.
55
55
 
56
56
  The v9 response is target-aware (`plan_price`, `addon`, or `credit_pack`) so new purchase surfaces do not require another breaking response change. Current public subscription, Introductory, direct, and Promo Code flows create `plan_price` applications.
57
+
58
+ ## Offers managed by an integration
59
+
60
+ An Offer created by an integration, such as [Dub](/docs/connect-dub-affiliates), has `managedBy` set to that integration. Its terms change only there: editing them returns `409 managed_by_integration`. Renaming it still works.
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  title: Promo Codes
3
- description: Distribute an existing Offer through a customer-entered checkout code.
3
+ description: Distribute an existing Offer through a customer-entered checkout code, limited to first purchases or applied on plan changes.
4
4
  ---
5
5
 
6
- A Promo Code is a distribution channel. The referenced Offer owns the economic terms; the code owns who can redeem them and when.
6
+ A Promo Code is a distribution channel. The referenced Offer owns the discount; the code owns who can redeem it and when.
7
7
 
8
8
  ## Create a compatible Offer
9
9
 
10
- A Promo Code can reference an Offer with ordered `percentage`, `amount_off`, or `fixed_price` phases. It can start with one `free_trial` phase when a discount follows it. Each discount phase before the last must have a finite duration.
10
+ A Promo Code can reference any Offer: ordered `percentage`, `amount_off`, or `fixed_price` phases where only the last phase may be open-ended.
11
11
 
12
12
  ```typescript
13
13
  const launchOffer = await commet.offers.create({
@@ -19,17 +19,7 @@ const launchOffer = await commet.offers.create({
19
19
  })
20
20
  ```
21
21
 
22
- For a trial followed by a discount, put the trial first:
23
-
24
- ```typescript
25
- const trialOffer = await commet.offers.create({
26
- name: 'Early access',
27
- phases: [
28
- { type: 'free_trial', durationDays: 14 },
29
- { type: 'percentage', durationCycles: 3, percentage: 2000 },
30
- ],
31
- })
32
- ```
22
+ A `fixed_price` phase of `0`, **Free cycles** in the dashboard, makes a code that gives free billing cycles. Checkout saves the card and settles the invoice at $0 without a charge.
33
23
 
34
24
  ## Create the code
35
25
 
@@ -41,6 +31,7 @@ const promoCode = await commet.promoCodes.create({
41
31
  maxRedemptions: 100,
42
32
  expiresAt: '2026-12-31T23:59:59.000Z',
43
33
  planIds: ['pln_pro'],
34
+ firstPurchaseOnly: true,
44
35
  })
45
36
  ```
46
37
 
@@ -49,17 +40,20 @@ The Promo Code owns:
49
40
  - the customer-facing code;
50
41
  - optional plan and billing-interval restrictions;
51
42
  - the redemption limit;
52
- - expiration and active state.
43
+ - expiration and active state;
44
+ - `firstPurchaseOnly`, which limits the code to a customer's first purchase. Default `false`.
45
+
46
+ A customer qualifies for a first-purchase code while they have no paid invoice above $0 and no `active` or `past_due` subscription on a paid plan. A customer in a trial qualifies.
53
47
 
54
48
  Updating the Offer changes future redemptions of codes that reference it. Each completed checkout counts one redemption and keeps an immutable Offer Application with the phases accepted at that checkout. Editing the Offer does not change earlier redemptions or their renewals.
55
49
 
56
- Clients pinned before `2026-07-24` receive only the first phase in the legacy Promo Code discount fields when that phase is `percentage` or `amount_off`. Codes starting with `free_trial` or `fixed_price` cannot be represented and are absent from those older Promo Code endpoints. Use the current Offer API to inspect the complete sequence.
50
+ Clients pinned before `2026-07-24` receive only the first phase in the legacy Promo Code discount fields when that phase is `percentage` or `amount_off`. Codes starting with `fixed_price` cannot be represented and are absent from those older Promo Code endpoints. Use the current Offer API to inspect the complete sequence.
57
51
 
58
52
  ## Checkout behavior
59
53
 
60
54
  The customer enters the code during checkout. Commet validates the code, resolves the referenced Offer in the checkout currency, and records an Offer Application with source `promo_code`.
61
55
 
62
- When the Offer starts with a trial, a new subscription checkout collects a payment method without charging. Applying that code to a pending first-payment checkout replaces it with a trial setup checkout. Trial codes cannot start a trial on an existing subscription's plan change. One redemption is recorded when setup completes; the first paid invoice follows the trial and uses the next phase. Renewals do not count as new redemptions.
56
+ When the price has a [trial](/docs/trial-periods) that requires a payment method, the customer can enter the code in the trial checkout. The trial starts without a charge and the discount starts with the first invoice after it. One redemption is recorded when the checkout completes. Renewals do not count as new redemptions.
63
57
 
64
58
  If an eligible automatic Introductory Offer applies, the code is rejected with `intro_offer_active`. A Promo Code also cannot be combined with an explicit `offerId`.
65
59
 
@@ -70,3 +64,39 @@ await commet.subscriptions.create({
70
64
  promoCode: 'LAUNCH50',
71
65
  })
72
66
  ```
67
+
68
+ A trial without a payment method has no checkout, so it can't start with a promo code.
69
+
70
+ ## Apply a code on a plan change
71
+
72
+ `changePlan` and `previewChange` accept `promoCode` for immediate changes. The preview quotes what the change charges.
73
+
74
+ ```typescript
75
+ await commet.subscriptions.changePlan({
76
+ id: 'sub_xxx',
77
+ newPlanId: 'pln_pro',
78
+ promoCode: 'LAUNCH50',
79
+ })
80
+ ```
81
+
82
+ From a free plan, the code opens the checkout with the discount applied and counts its use when the checkout is paid. Scheduled changes reject a promo code with `offer_not_applicable`.
83
+
84
+ ## Rejection reasons
85
+
86
+ A rejected code returns `400 validation_error` with `param: "promoCode"` and the reason in `details.reason`:
87
+
88
+ - `not_found`: no code with that text exists.
89
+ - `inactive`: the code is deactivated.
90
+ - `expired`: the expiration date passed.
91
+ - `max_redemptions_reached`: the redemption limit was reached.
92
+ - `first_purchase_only`: the customer already paid or has a paid subscription.
93
+ - `already_redeemed`: the customer already redeemed the code.
94
+ - `plan_not_eligible`: the code is restricted to other plans.
95
+ - `billing_interval_not_eligible`: the code is restricted to another billing interval.
96
+ - `intro_offer_active`: an Introductory Offer applies.
97
+
98
+ Checkout also rejects a positive total below the currency's minimum charge.
99
+
100
+ ## Codes managed by an integration
101
+
102
+ Codes created by an integration, such as [Dub](/docs/connect-dub-affiliates), have `managedBy` set. Changing their restrictions returns `409 managed_by_integration`; activating and deactivating them still works.
@@ -9,13 +9,12 @@ The Offer stays independent from plans and prices until your integration selects
9
9
 
10
10
  ## Create the terms
11
11
 
12
- Direct Offers may combine a free trial with ordered discount or fixed-price phases:
12
+ Direct Offers may combine ordered discount and fixed-price phases:
13
13
 
14
14
  ```typescript
15
15
  const retentionOffer = await commet.offers.create({
16
16
  name: 'Return to Pro',
17
17
  phases: [
18
- { type: 'free_trial', durationDays: 7 },
19
18
  { type: 'fixed_price', durationCycles: 2, prices: [
20
19
  { currency: 'usd', amount: 2900 },
21
20
  { currency: 'ars', amount: 3990000 },
@@ -39,9 +38,9 @@ await commet.subscriptions.create({
39
38
 
40
39
  The Offer must be active, inside its availability window, and resolvable in the selected currency. It does not need a prior association with the plan or price.
41
40
 
42
- An explicit `offerId` overrides automatic introductory selection. It cannot be combined with `promoCode`, `customTrialDays`, or `skipTrial: true`.
41
+ An explicit `offerId` overrides automatic introductory selection. It cannot be combined with `promoCode`. It combines with `customTrialDays` and `skipTrial`; when the price has a trial, the discount starts after it.
43
42
 
44
- Immediate plan changes, plan-change previews, and supported reactivation flows also accept `offerId`. Scheduled plan changes do not accept an Offer.
43
+ Immediate plan changes, plan-change previews, and supported reactivation flows also accept `offerId`. Scheduled plan changes do not accept an Offer or a promo code.
45
44
 
46
45
  ## Apply it to an active subscription
47
46
 
@@ -54,14 +53,14 @@ await commet.subscriptions.applyOffer({
54
53
  })
55
54
  ```
56
55
 
57
- Only one Offer applies at a time: while an accepted Offer still has active or upcoming discount phases, a new application is rejected. Once its phases are exhausted, the subscription accepts a new Offer. Offers with a free trial phase cannot be applied to an active subscription, and the discount applies to the plan base price only.
56
+ Only one Offer applies at a time: while an accepted Offer still has active or upcoming discount phases, a new application is rejected. Once its phases are exhausted, the subscription accepts a new Offer. The discount applies to the plan base price only.
58
57
 
59
58
  The applied Offer belongs to that subscription and plan: it ends with a cancellation and a plan change removes it.
60
59
 
61
- The same operation on a subscription with a pending payment checkout quotes or replaces the checkout discount instead; there it accepts an optional `expiresAt` for the quote.
60
+ The same operation on a subscription with a pending checkout quotes or replaces the checkout discount instead; there it accepts an optional `expiresAt` for the quote. When the price has a trial, the discount starts after it.
62
61
 
63
62
  ## Direct application or Promo Code?
64
63
 
65
64
  Use direct `offerId` when your application decides who receives the terms. Use a Promo Code when the customer should enter a code and the campaign needs redemption restrictions.
66
65
 
67
- A Promo Code can distribute multiple discount phases, including `fixed_price`, and can begin with a trial when a discount follows it. A trial-only Offer remains available for direct application.
66
+ A Promo Code can distribute the same Offers, including multiple phases and `fixed_price`.