@commet/node 9.2.0 → 9.4.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 (195) hide show
  1. package/dist/index.d.mts +370 -21
  2. package/dist/index.d.ts +370 -21
  3. package/dist/index.js +30 -6
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +30 -6
  6. package/dist/index.mjs.map +1 -1
  7. package/docs/api-reference/addons.md +1 -1
  8. package/docs/api-reference/api-keys.md +3 -2
  9. package/docs/api-reference/credit-packs.md +1 -1
  10. package/docs/api-reference/customers.md +2 -2
  11. package/docs/api-reference/feature-access.md +1 -1
  12. package/docs/api-reference/features.md +1 -1
  13. package/docs/api-reference/generated-webhooks.md +3 -3
  14. package/docs/api-reference/index.md +2 -2
  15. package/docs/api-reference/invoices.md +1 -1
  16. package/docs/api-reference/markets.md +1 -1
  17. package/docs/api-reference/offers.md +1 -1
  18. package/docs/api-reference/payments.md +1 -1
  19. package/docs/api-reference/payouts.md +1 -1
  20. package/docs/api-reference/plan-groups.md +1 -1
  21. package/docs/api-reference/plans.md +4 -4
  22. package/docs/api-reference/portal.md +1 -1
  23. package/docs/api-reference/promo-codes.md +1 -1
  24. package/docs/api-reference/provisioning.md +1 -1
  25. package/docs/api-reference/quota.md +1 -1
  26. package/docs/api-reference/seats.md +1 -1
  27. package/docs/api-reference/subscriptions.md +81 -2
  28. package/docs/api-reference/test-clock.md +1 -1
  29. package/docs/api-reference/transactions.md +1 -1
  30. package/docs/api-reference/usage.md +1 -1
  31. package/docs/documentation/api-versioning.md +1 -1
  32. package/docs/documentation/choose-a-billing-model.md +48 -26
  33. package/docs/documentation/create-api-key.md +101 -25
  34. package/docs/documentation/introduction.md +63 -41
  35. package/docs/documentation/payments/transactions-refunds-and-retries.md +7 -1
  36. package/docs/documentation/sales/promotional-offers.md +18 -1
  37. package/docs/documentation/sdk-reference.md +9 -9
  38. package/docs/documentation/subscriptions/manage-subscriptions.md +113 -12
  39. package/docs/errors/addon_already_active.md +1 -1
  40. package/docs/errors/addon_has_activations.md +1 -1
  41. package/docs/errors/addon_not_active.md +1 -1
  42. package/docs/errors/addon_not_found.md +1 -1
  43. package/docs/errors/already_has_active_subscription.md +1 -1
  44. package/docs/errors/already_scheduled.md +1 -1
  45. package/docs/errors/api_key_not_found.md +1 -1
  46. package/docs/errors/card_promotions_not_available.md +1 -1
  47. package/docs/errors/charge_failed.md +1 -1
  48. package/docs/errors/charge_in_progress.md +1 -1
  49. package/docs/errors/claim_not_pending.md +1 -1
  50. package/docs/errors/credit_pack_not_found.md +1 -1
  51. package/docs/errors/customer_not_found.md +1 -1
  52. package/docs/errors/duplicate.md +1 -1
  53. package/docs/errors/endpoint_deprecated.md +1 -1
  54. package/docs/errors/endpoint_not_available.md +1 -1
  55. package/docs/errors/feature_already_exists.md +1 -1
  56. package/docs/errors/feature_disabled.md +1 -1
  57. package/docs/errors/feature_in_use.md +1 -1
  58. package/docs/errors/feature_not_found.md +1 -1
  59. package/docs/errors/feature_not_in_plan.md +1 -1
  60. package/docs/errors/forbidden.md +1 -1
  61. package/docs/errors/free_plan_change_not_supported.md +1 -1
  62. package/docs/errors/idempotency_in_progress.md +1 -1
  63. package/docs/errors/idempotency_key_mismatch.md +1 -1
  64. package/docs/errors/idempotency_unavailable.md +1 -1
  65. package/docs/errors/included_limit_reached.md +1 -1
  66. package/docs/errors/index.md +1 -1
  67. package/docs/errors/insufficient_balance.md +1 -1
  68. package/docs/errors/insufficient_credits.md +1 -1
  69. package/docs/errors/insufficient_seats.md +1 -1
  70. package/docs/errors/internal_error.md +1 -1
  71. package/docs/errors/invalid_json.md +1 -1
  72. package/docs/errors/invalid_subscription_status.md +1 -1
  73. package/docs/errors/invoice_not_found.md +1 -1
  74. package/docs/errors/market_group_in_use.md +1 -1
  75. package/docs/errors/market_group_not_found.md +1 -1
  76. package/docs/errors/market_in_use.md +1 -1
  77. package/docs/errors/market_not_found.md +1 -1
  78. package/docs/errors/missing_regional_price.md +1 -1
  79. package/docs/errors/model_not_found.md +1 -1
  80. package/docs/errors/no_active_subscription.md +1 -1
  81. package/docs/errors/no_change_requested.md +1 -1
  82. package/docs/errors/no_outstanding_invoice.md +1 -1
  83. package/docs/errors/no_payment_method.md +1 -1
  84. package/docs/errors/no_prices_configured.md +1 -1
  85. package/docs/errors/not_found.md +1 -1
  86. package/docs/errors/not_scheduled_for_cancellation.md +1 -1
  87. package/docs/errors/offer_not_applicable.md +1 -1
  88. package/docs/errors/offer_not_found.md +1 -1
  89. package/docs/errors/one_time_subscription_not_cancelable.md +1 -1
  90. package/docs/errors/organization_already_claimed.md +1 -1
  91. package/docs/errors/payment_failed.md +1 -1
  92. package/docs/errors/payment_method_not_found.md +1 -1
  93. package/docs/errors/payment_not_cancelable.md +1 -1
  94. package/docs/errors/payment_not_found.md +1 -1
  95. package/docs/errors/payouts_not_available_in_sandbox.md +1 -1
  96. package/docs/errors/plan_change_scheduled.md +1 -1
  97. package/docs/errors/plan_group_not_found.md +1 -1
  98. package/docs/errors/plan_not_found.md +1 -1
  99. package/docs/errors/plan_unavailable.md +1 -1
  100. package/docs/errors/plans_not_in_same_group.md +1 -1
  101. package/docs/errors/price_in_use.md +1 -1
  102. package/docs/errors/price_not_found.md +1 -1
  103. package/docs/errors/pricing_mode_mismatch.md +1 -1
  104. package/docs/errors/promo_code_expired.md +1 -1
  105. package/docs/errors/promo_code_not_found.md +1 -1
  106. package/docs/errors/provider_unsupported.md +1 -1
  107. package/docs/errors/rate_limited.md +1 -1
  108. package/docs/errors/sandbox_only.md +1 -1
  109. package/docs/errors/seat_limit_exceeded.md +1 -1
  110. package/docs/errors/subscription_activation_failed.md +1 -1
  111. package/docs/errors/subscription_already_canceled.md +1 -1
  112. package/docs/errors/subscription_cancel_failed.md +1 -1
  113. package/docs/errors/subscription_creation_failed.md +1 -1
  114. package/docs/errors/subscription_has_open_dispute.md +1 -1
  115. package/docs/errors/subscription_not_active.md +1 -1
  116. package/docs/errors/subscription_not_found.md +1 -1
  117. package/docs/errors/subscription_required.md +1 -1
  118. package/docs/errors/subscription_uncancel_failed.md +1 -1
  119. package/docs/errors/transaction_not_found.md +1 -1
  120. package/docs/errors/unauthorized.md +1 -1
  121. package/docs/errors/validation_error.md +1 -1
  122. package/docs/errors/webhook_not_found.md +1 -1
  123. package/docs/knowledge-base/what-happens-when-you-refund-or-retry-a-transaction.md +2 -2
  124. package/docs/manifest.json +121 -85
  125. package/docs/platform-documentation.md +6 -0
  126. package/docs/schemas.md +35 -1
  127. package/docs/webhooks/addon-activated.md +1 -1
  128. package/docs/webhooks/addon-deactivated.md +1 -1
  129. package/docs/webhooks/balance-depleted.md +1 -1
  130. package/docs/webhooks/balance-low.md +1 -1
  131. package/docs/webhooks/balance-topped-up.md +1 -1
  132. package/docs/webhooks/checkout-ready.md +1 -1
  133. package/docs/webhooks/credits-depleted.md +1 -1
  134. package/docs/webhooks/credits-expired.md +1 -1
  135. package/docs/webhooks/credits-granted.md +1 -1
  136. package/docs/webhooks/credits-low.md +1 -1
  137. package/docs/webhooks/credits-purchased.md +1 -1
  138. package/docs/webhooks/customer-created.md +1 -1
  139. package/docs/webhooks/customer-state-changed.md +2 -2
  140. package/docs/webhooks/customer-updated.md +1 -1
  141. package/docs/webhooks/invoice-created.md +1 -1
  142. package/docs/webhooks/invoice-overdue.md +1 -1
  143. package/docs/webhooks/invoice-upcoming.md +1 -1
  144. package/docs/webhooks/invoice-voided.md +1 -1
  145. package/docs/webhooks/meta.json +6 -0
  146. package/docs/webhooks/payment-dispute-resolved.md +1 -1
  147. package/docs/webhooks/payment-disputed.md +1 -1
  148. package/docs/webhooks/payment-failed.md +144 -3
  149. package/docs/webhooks/payment-link-canceled.md +1 -1
  150. package/docs/webhooks/payment-link-completed.md +44 -2
  151. package/docs/webhooks/payment-link-created.md +1 -1
  152. package/docs/webhooks/payment-link-failed.md +44 -2
  153. package/docs/webhooks/payment-method-attached.md +6 -2
  154. package/docs/webhooks/payment-method-updated.md +7 -8
  155. package/docs/webhooks/payment-received.md +160 -3
  156. package/docs/webhooks/payment-recovered.md +6 -2
  157. package/docs/webhooks/payment-refunded.md +3 -3
  158. package/docs/webhooks/payment-retry-failed.md +1 -1
  159. package/docs/webhooks/payout-available.md +1 -1
  160. package/docs/webhooks/payout-created.md +1 -1
  161. package/docs/webhooks/payout-failed.md +1 -1
  162. package/docs/webhooks/payout-paid.md +1 -1
  163. package/docs/webhooks/plan-grant-created.md +1 -1
  164. package/docs/webhooks/plan-grant-expired.md +1 -1
  165. package/docs/webhooks/plan-grant-revoked.md +1 -1
  166. package/docs/webhooks/plan-grant-updated.md +1 -1
  167. package/docs/webhooks/quota-exceeded.md +1 -1
  168. package/docs/webhooks/quota-threshold-reached.md +1 -1
  169. package/docs/webhooks/seats-limit-reached.md +1 -1
  170. package/docs/webhooks/seats-updated.md +1 -1
  171. package/docs/webhooks/subscription-activated.md +1 -1
  172. package/docs/webhooks/subscription-canceled.md +5 -4
  173. package/docs/webhooks/subscription-cancellation-revoked.md +1 -1
  174. package/docs/webhooks/subscription-cancellation-scheduled.md +1 -1
  175. package/docs/webhooks/subscription-created.md +1 -1
  176. package/docs/webhooks/subscription-past-due.md +1 -1
  177. package/docs/webhooks/subscription-pause-revoked.md +27 -0
  178. package/docs/webhooks/subscription-pause-scheduled.md +35 -0
  179. package/docs/webhooks/subscription-pause-updated.md +31 -0
  180. package/docs/webhooks/subscription-paused.md +35 -0
  181. package/docs/webhooks/subscription-plan-change-revoked.md +1 -1
  182. package/docs/webhooks/subscription-plan-change-scheduled.md +1 -1
  183. package/docs/webhooks/subscription-plan-changed.md +1 -1
  184. package/docs/webhooks/subscription-reactivated.md +1 -1
  185. package/docs/webhooks/subscription-resume-failed.md +33 -0
  186. package/docs/webhooks/subscription-resumed.md +35 -0
  187. package/docs/webhooks/subscription-updated.md +1 -1
  188. package/docs/webhooks/trial-checkout-ready.md +1 -1
  189. package/docs/webhooks/trial-converted.md +1 -1
  190. package/docs/webhooks/trial-expired.md +1 -1
  191. package/docs/webhooks/trial-started.md +1 -1
  192. package/docs/webhooks/trial-will-end.md +1 -1
  193. package/docs/webhooks/usage-recorded.md +1 -1
  194. package/docs/webhooks.md +96 -7
  195. package/package.json +1 -1
@@ -1,47 +1,123 @@
1
1
  ---
2
- lastModified: 2026-08-16
2
+ lastModified: 2026-09-25
3
3
  title: Create an API Key
4
- description: Create a sandbox key, keep it on your server, and rotate it without interrupting billing.
4
+ description: Create a sandbox API key from the dashboard, CLI, or MCP, store it on your server, and rotate it safely.
5
5
  ---
6
6
 
7
- Your API key selects one Commet organization and environment. A sandbox key can only access sandbox data; a live key can only access live data.
7
+ An API key gives your server access to one Commet organization. Start with a **sandbox organization** while building your integration.
8
8
 
9
- ## Create a sandbox key
9
+ New full-access keys start with `ck_sandbox_` or `ck_live_`; new restricted keys start with `rk_sandbox_` or `rk_live_`. Existing `ck_` keys remain valid. The organization that created the key determines which data it can reach. Both environments use `https://commet.co/api/v1`.
10
10
 
11
- 1. Open your sandbox organization in the dashboard.
12
- 2. Go to **Settings → API Keys**.
13
- 3. Create a key with a name that identifies the application or environment.
14
- 4. Copy the key when it is shown and store it in your server's secret manager.
11
+ ## Create a key
12
+
13
+ Choose the path that fits where you are working. You only need one to get started.
14
+
15
+ ### Dashboard
16
+
17
+ 1. Select your **sandbox organization** in the dashboard.
18
+ 2. Go to **Settings → API Keys** and click **Create API Key**.
19
+ 3. Choose **Full Access** for a backend or **AI Agents** to select resource permissions.
20
+ 4. Enter a descriptive name, such as `Local development`, and choose **Expires In (Days)**. The dashboard accepts **1–365 days** and defaults to **365**.
21
+ 5. Create the key and copy it before closing the dialog. The full secret is shown only once.
22
+
23
+ ### CLI
24
+
25
+ Install the [Commet CLI](/docs/cli), sign in through your browser, and link the project to your sandbox organization:
26
+
27
+ ```bash
28
+ npm install -g commet
29
+ commet login
30
+ commet link
31
+ ```
32
+
33
+ Choose the organization marked **sandbox**. Linking a new organization generates a key for CLI resource commands and saves it in `.commet/config.json`. The CLI adds `.commet/` to `.gitignore`. Keep that directory private.
34
+
35
+ This configures the CLI; it does **not** set `COMMET_API_KEY` for your application. To create a separate application key after linking:
36
+
37
+ ```bash
38
+ commet api-keys create --name "Local development" --expires-in-days 365
39
+ ```
40
+
41
+ Save the returned `apiKey` as described below. Resource commands use `COMMET_API_KEY` from the environment before the linked project's key, so check which credential is active before creating or deleting keys.
42
+
43
+ ### MCP
44
+
45
+ Connect your agent to the [Commet MCP server](/docs/mcp-server) at `https://commet.co/mcp/v2`. With OAuth, you can sign in through your browser and select a **sandbox organization** without an existing API key. The connection stays fixed to that organization.
46
+
47
+ Ask the agent to create an application key using `api_create_api_key` with these arguments:
48
+
49
+ ```json
50
+ {
51
+ "body": {
52
+ "name": "Local development",
53
+ "expiresInDays": 365
54
+ }
55
+ }
56
+ ```
57
+
58
+ The response contains the full secret only once. Have the agent store it directly in the intended local secret file or secret manager when your tools support that. Do not paste an existing secret into the conversation or ask the agent to repeat it in a message.
59
+
60
+ Already authenticating with a full-access API key? You can create replacements with `POST /api/v1/api-keys`. That request creates another key for the same organization. See [Create API key](/docs/api-reference/api-keys/create-api-key) for the request and response.
61
+
62
+ ## Limit key permissions
63
+
64
+ Leave `permissions` out to create a full-access key. Provide resource grants to create a restricted key. For example, a key with `customer: ["read"]` can read customers but cannot change them. Write access requires both `"read"` and `"write"`. An empty object (`{}`) grants no resource access.
65
+
66
+ A restricted key with `api_key: ["read", "write"]` can create restricted keys with the same or fewer permissions. These keys expire no later than the key that creates them. Restricted keys cannot edit or delete API keys.
67
+
68
+ ```typescript
69
+ const key = await commet.apiKeys.create({
70
+ name: "Customer reader",
71
+ permissions: { customer: ["read"] },
72
+ })
73
+ ```
74
+
75
+ The full secret is returned once. Save it in your secret store before leaving the response.
76
+
77
+ ## Store the key on your server
78
+
79
+ For local development, save the key in a git-ignored environment file:
15
80
 
16
81
  ```bash title=".env.local"
17
- COMMET_API_KEY=ck_sandbox_xxxxxxxxx
82
+ COMMET_API_KEY=ck_replace_with_your_key
18
83
  ```
19
84
 
20
- Commet does not show the full secret again. If it is lost, create a replacement and delete the old key after the new deployment is healthy.
85
+ Load this variable into your server process using your framework's environment support. For production, use your deployment's secret store. Never expose the key in browser code, public environment variables, logs, screenshots, or source control.
86
+
87
+ Commet stores a hash of the key and cannot show the full secret again. If you lose it, create a replacement.
88
+
89
+ ## Use the key in your SDK
21
90
 
22
- ## Initialize the SDK on the server
91
+ For Node.js, install the SDK:
92
+
93
+ ```bash
94
+ npm install @commet/node
95
+ ```
96
+
97
+ Initialize it in server code after loading the environment:
23
98
 
24
99
  ```typescript
25
100
  import { Commet } from "@commet/node"
26
101
 
27
- export const commet = new Commet({
28
- apiKey: process.env.COMMET_API_KEY,
29
- })
30
- ```
102
+ const apiKey = process.env.COMMET_API_KEY
103
+ if (!apiKey) {
104
+ throw new Error("COMMET_API_KEY is required")
105
+ }
31
106
 
32
- Never expose the key in browser code, public environment variables, logs, screenshots, or agent prompts. Requests sent directly to the REST API authenticate with the `x-api-key` header.
107
+ export const commet = new Commet({ apiKey })
108
+ ```
33
109
 
34
- ## Use separate keys per environment
110
+ For other languages, follow the [Python](/docs/integrate-with-python), [Go](/docs/integrate-with-go), [Java](/docs/integrate-with-java), or [PHP](/docs/integrate-with-php) integration guide. Direct REST requests authenticate with the `x-api-key` header.
35
111
 
36
- Keep sandbox and live credentials in different deployment environments. A safe promotion flow is:
112
+ ## Rotate and promote to live
37
113
 
38
- 1. Build and test with the sandbox key.
39
- 2. Verify checkout, webhooks, and a renewal with the [Test Clock](/docs/testing-sandbox).
40
- 3. Add a live key to the production secret store.
41
- 4. Deploy without copying sandbox IDs into live configuration.
114
+ Use a separate key for each application or deployment that needs independent rotation. To replace a key before it expires:
42
115
 
43
- ## Rotate a key
116
+ 1. Create a replacement in the **same organization**.
117
+ 2. Update the secret in every process using the old key and deploy or restart those processes.
118
+ 3. Verify a successful read with the replacement and confirm the application is using it.
119
+ 4. Delete the old key from **Settings → API Keys** or through [Delete API key](/docs/api-reference/api-keys/delete-api-key).
44
120
 
45
- Create the replacement first, deploy it, verify successful requests, and only then delete the previous key. Keys can also be managed through the generated [API Keys reference](/docs/api-reference/api-keys/list-api-keys).
121
+ For production, create a key in your **live organization** and store it separately from sandbox credentials. Do not copy sandbox customer, plan, or subscription IDs into live configuration. Before switching, verify checkout, webhooks, and a renewal in sandbox with the [Test Clock](/docs/testing-sandbox).
46
122
 
47
- Use one key per workload when you need independent rotation or audit boundaries. Do not reuse a developer's local key in production.
123
+ Next, follow the [quickstart](/docs/choose-a-billing-model) to complete your first subscription payment in sandbox.
@@ -1,58 +1,80 @@
1
1
  ---
2
- lastModified: 2026-08-16
2
+ lastModified: 2026-09-07
3
3
  title: Introduction
4
- description: Commet is a billing and payments platform for SaaS and AI products.
4
+ description: Measure consumption, manage subscriptions, and accept payments for your SaaS or AI product with Commet.
5
5
  ---
6
6
 
7
- Commet is a billing and payments platform for SaaS and AI products. It handles recurring billing, taxes, compliance, and payouts so you can focus on your product.
7
+ Commet is a billing and payments platform for SaaS and AI products. It connects what your customers use with what they pay: subscriptions, usage charges, credits, and one-time payments.
8
8
 
9
- To build your first complete flow:
9
+ You define what you sell and how you price it. Commet manages the billing cycle, invoices, and payment flows. Your application reports consumption and uses Commet's access checks and events to decide what each customer can do.
10
10
 
11
- 1. [Create a sandbox API key](/docs/create-api-key).
12
- 2. [Choose the billing model](/docs/choose-a-billing-model) that matches what customers buy.
13
- 3. Follow the quickstart for your language, then run the matching [example application](/docs/examples).
14
- 4. Confirm subscription and payment outcomes with signed webhooks.
11
+ - [**Quickstart**](/docs/choose-a-billing-model)
12
+ - [**Build with an agent**](/docs/mcp-server)
15
13
 
16
- ## Quickstart
14
+ ## What can you build with Commet?
17
15
 
18
- - [**Next.js**](/docs/integrate-with-nextjs)
19
- - [**Remix**](/docs/integrate-with-remix)
20
- - [**Nuxt**](/docs/integrate-with-nuxt)
21
- - [**SvelteKit**](/docs/integrate-with-sveltekit)
22
- - [**Astro**](/docs/integrate-with-astro)
23
- - [**Express**](/docs/integrate-with-express)
24
- - [**Hono**](/docs/integrate-with-hono)
25
- - [**Bun**](/docs/integrate-with-bun)
16
+ ### Subscriptions that match your product
26
17
 
27
- ## The Plan-First Model
18
+ Sell a monthly or annual plan with a fixed price, usage charges, or a combination of both. Define [features](/docs/configure-features) such as API calls, team seats, storage, or access to a capability, then package them into [plans](/docs/create-plans).
28
19
 
29
- You define what you sell, package it into a plan, and connect it to a customer. Billing runs automatically from there.
20
+ A [subscription](/docs/manage-subscriptions) connects a customer to a plan. Commet manages its billing cycle and invoices as the subscription renews or changes. You can offer [trials](/docs/trial-periods), handle [upgrades and downgrades](/docs/upgrade-and-downgrade-plans), and configure [failed-payment recovery](/docs/handle-failed-payments).
30
21
 
31
- 1. **Features** — define capabilities like API calls, seats, or SSO access
32
- 2. **Plan** — bundle features with pricing and a consumption model
33
- 3. **Customer** — assign the plan and a subscription is created
34
- 4. **Billing** — invoices, usage tracking, and payments happen without intervention
22
+ ### Pricing based on consumption
35
23
 
36
- ## Consumption Models
24
+ An AI request, an API call, and a stored file represent different kinds of usage. Commet lets you define how that usage affects the customer's bill or available allowance.
37
25
 
38
- Every plan uses one consumption model. This defines how customers consume and pay for features.
26
+ Each plan has one [consumption model](/docs/consumption-models):
39
27
 
40
- | Model | How it works | Examples |
41
- | ----------- | ------------------------------------------ | -------------------------- |
42
- | **Metered** | Base price + overage billed at period end | Twilio, Resend, AWS |
43
- | **Credits** | Prepaid credits consumed by usage | Midjourney, Cursor, Replit |
44
- | **Balance** | Prepaid dollar balance drawn down by usage | Supabase, Railway, Vercel |
28
+ | Model | How it treats usage |
29
+ | ----------- | ------------------------------------------------------------------------------------------------------------------ |
30
+ | **Metered** | Measures usage against each feature's included allowance, with overage charges when configured. |
31
+ | **Credits** | Deducts credits from a shared pool as customers use features. |
32
+ | **Balance** | Converts usage into monetary amounts drawn from the customer's balance, with overage behavior defined by the plan. |
45
33
 
46
- Models are mutually exclusive — each plan uses exactly one. [Learn more about consumption models](/docs/consumption-models).
34
+ Your application [reports usage](/docs/track-usage) to Commet. For AI products, [token billing](/docs/ai-token-billing) uses the model and token counts you report to calculate consumption with your configured margin. You can also manage [team seats](/docs/seat-management) and [quantities such as stored resources](/docs/quota-management).
47
35
 
48
- ## Explore
36
+ ### One-time purchases and optional extras
49
37
 
50
- - [**Customers**](/docs/manage-customers)
51
- - [**Plans**](/docs/create-plans)
52
- - [**Subscriptions**](/docs/manage-subscriptions)
53
- - [**Usage Tracking**](/docs/track-usage)
54
- - [**Invoicing**](/docs/invoices-and-billing-cycles)
55
- - [**Payments**](/docs/accept-one-time-payments)
56
- - [**Customer Portal**](/docs/customer-portal)
57
- - [**Finance & Payouts**](/docs/finance-overview)
58
- - [**SDK Reference**](/docs/sdk-reference)
38
+ [Accept a one-time payment](/docs/accept-one-time-payments) without creating a plan or subscription. This is useful for a standalone purchase or service alongside your recurring product.
39
+
40
+ For subscribers, offer [add-ons](/docs/add-ons) to extend a plan, [credit packs](/docs/credit-packs) for more consumption, or [balance top-ups](/docs/balance-and-top-ups). These give customers a way to buy more without changing their entire subscription.
41
+
42
+ ### A billing experience customers can manage themselves
43
+
44
+ Use checkout to collect payment and the [customer portal](/docs/customer-portal) to let customers view invoices, update payment methods, and review usage. Configure [plan groups](/docs/plan-groups) to offer self-service plan changes.
45
+
46
+ You can also create reusable [offers](/docs/offers), distribute them through [promo codes](/docs/promo-codes), and configure [regional prices](/docs/regional-prices) for different markets and currencies.
47
+
48
+ ## Choose how you accept payments
49
+
50
+ Use Commet's [Merchant of Record](/docs/merchant-of-record) offering, or connect your own [Stripe or dLocal account](/docs/payment-providers).
51
+
52
+ For payments processed through its Merchant of Record offering, Commet handles tax collection and remittance, compliance, refunds, and disputes on your behalf. With your own Stripe or dLocal account, you remain the merchant and manage funds and payouts with that provider. Commet provides the billing layer in either setup.
53
+
54
+ The guides cover [payment routing](/docs/payment-orchestration), [transactions and refunds](/docs/transactions-refunds-and-retries), and [finance and payouts](/docs/finance-overview). Before using Commet as Merchant of Record, review [supported countries](/docs/supported-countries) and [verification requirements](/docs/payouts-verification).
55
+
56
+ ## Integrate the way you work
57
+
58
+ Start in the dashboard to configure your product, then connect your application with an [API key](/docs/create-api-key). Choose a guide for your stack:
59
+
60
+ | Stack | Integration guides |
61
+ | ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
62
+ | **JavaScript and TypeScript** | [Next.js](/docs/integrate-with-nextjs), [Nuxt](/docs/integrate-with-nuxt), [SvelteKit](/docs/integrate-with-sveltekit), [Express](/docs/integrate-with-express), or the [Node.js SDK reference](/docs/sdk-reference). |
63
+ | **Python** | [Python](/docs/integrate-with-python), [FastAPI](/docs/integrate-with-fastapi), [Django](/docs/integrate-with-django), and [Flask](/docs/integrate-with-flask). |
64
+ | **Go, Java, and PHP** | [Go](/docs/integrate-with-go), [Java](/docs/integrate-with-java), [PHP](/docs/integrate-with-php), and [Laravel](/docs/integrate-with-laravel). |
65
+
66
+ Using Better Auth? The [Commet plugin](/docs/better-auth) connects customer creation and billing to your authentication flow. For complete applications you can adapt, explore the [examples](/docs/examples).
67
+
68
+ ### Tools for developers and agents
69
+
70
+ The [CLI](/docs/cli) lets you manage Commet from your terminal and work with billing configuration as code. The [REST API reference](/docs/api-reference) documents the endpoints available to your own tools and integrations.
71
+
72
+ For an AI coding assistant, install the [Commet skill](/docs/commet-skill) for integration guidance. Connect the [MCP server](/docs/mcp-server) when the assistant also needs to read documentation and work with resources in your organization. The skill provides guidance; MCP provides access to tools.
73
+
74
+ ## Connect billing to your application
75
+
76
+ Build your first flow in [sandbox](/docs/testing-sandbox), where you can exercise checkout and billing without real charges. Use [access and usage checks](/docs/track-usage) in your application to enforce the plan you sell.
77
+
78
+ Connect [signed webhooks](/docs/webhooks/introduction) to keep your application in sync with subscription and payment outcomes. Review [error handling](/docs/error-handling) before moving the integration to production.
79
+
80
+ Ready to start? Follow the [quickstart](/docs/choose-a-billing-model) to create a feature, plan, customer, subscription, and test payment in order.
@@ -1,5 +1,5 @@
1
1
  ---
2
- lastModified: 2026-08-16
2
+ lastModified: 2026-09-24
3
3
  title: Transactions, Refunds, and Retries
4
4
  description: Inspect provider-neutral payment attempts, refund successful charges, and retry failed renewals safely.
5
5
  ---
@@ -68,6 +68,10 @@ $transactionsListResult = $commet->transactions->list();
68
68
 
69
69
  One invoice can have multiple transactions when a renewal is retried. The original failed transaction remains immutable; a retry creates a new attempt.
70
70
 
71
+ `provider` names the processor. `paymentMethod` names the method used for that attempt (`card`, `mercado_pago`, or `oxxo`), or is `null` when unknown. It stays tied to the transaction if the customer changes their saved method later.
72
+
73
+ `subPaymentMethod` describes how a Mercado Pago charge was funded when dLocal reports it: `credit_card`, `debit_card`, `prepaid_card`, `bank_transfer`, or `account_money`. It is `null` when unavailable or unknown. The dashboard also shows the card brand and last four digits when dLocal provides them for that charge.
74
+
71
75
  ## Refund a successful transaction
72
76
 
73
77
  **TypeScript**
@@ -131,6 +135,8 @@ $refund = $commet->transactions->refund(id: 'transaction_xxx');
131
135
 
132
136
  The operation requests a full refund and returns its actual provider-neutral status. Do not grant the refund in your product before the result is confirmed. Handle [`payment.refunded`](/docs/webhooks/payment-refunded) idempotently for downstream access or balance changes.
133
137
 
138
+ The subscription and its renewal schedule stay as they were, even when the payment is fully refunded. To end the subscription, [cancel it separately](/docs/manage-subscriptions).
139
+
134
140
  ## Retry a failed renewal
135
141
 
136
142
  **TypeScript**
@@ -1,5 +1,5 @@
1
1
  ---
2
- lastModified: 2026-07-31
2
+ lastModified: 2026-08-21
3
3
  title: Promotional Offers
4
4
  description: Apply any compatible Offer directly for campaigns, retention, and experiments.
5
5
  ---
@@ -44,6 +44,23 @@ An explicit `offerId` overrides automatic introductory selection. It cannot be c
44
44
 
45
45
  Immediate plan changes, plan-change previews, and supported reactivation flows also accept `offerId`. Scheduled plan changes do not accept an Offer.
46
46
 
47
+ ## Apply it to an active subscription
48
+
49
+ For retention, apply an Offer to a subscription that is already active. The discount phases start at the next billing cycle, so the current period stays untouched and the next invoice carries the discount:
50
+
51
+ ```typescript
52
+ await commet.subscriptions.applyOffer({
53
+ id: 'sub_123',
54
+ offerId: retentionOffer.id,
55
+ })
56
+ ```
57
+
58
+ 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.
59
+
60
+ The applied Offer belongs to that subscription and plan: it ends with a cancellation and a plan change removes it.
61
+
62
+ 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.
63
+
47
64
  ## Direct application or Promo Code?
48
65
 
49
66
  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.
@@ -1,5 +1,5 @@
1
1
  ---
2
- lastModified: 2026-08-16
2
+ lastModified: 2026-09-23
3
3
  title: SDK Reference
4
4
  description: Configuration, environments, and pagination
5
5
  ---
@@ -20,14 +20,14 @@ The installed package includes version-matched agent documentation at `node_modu
20
20
 
21
21
  ## Options
22
22
 
23
- | Option | Type | Default | Description |
24
- | ------------ | ------- | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
25
- | `apiKey` | string | required | Your API key (starts with `ck_`). The org that owns the key decides whether calls run against sandbox or live data. |
26
- | `apiVersion` | string | version the SDK release was built against | API version pin, sent as the `Commet-Version` header on every request. See [API versioning](/docs/api-versioning). |
27
- | `debug` | boolean | `false` | Log requests/responses |
28
- | `timeout` | number | `30000` | Request timeout (ms) |
29
- | `retries` | number | `3` | Max retry attempts |
30
- | `telemetry` | boolean | `true` | Send anonymous client info (SDK version, runtime, platform) with requests. Set to `false` to disable. |
23
+ | Option | Type | Default | Description |
24
+ | ------------ | ------- | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
25
+ | `apiKey` | string | required | Your full-access (`ck_`) or restricted (`rk_`) API key. The org that owns it decides whether calls run against sandbox or live data. |
26
+ | `apiVersion` | string | version the SDK release was built against | API version pin, sent as the `Commet-Version` header on every request. See [API versioning](/docs/api-versioning). |
27
+ | `debug` | boolean | `false` | Log requests/responses |
28
+ | `timeout` | number | `30000` | Request timeout (ms) |
29
+ | `retries` | number | `3` | Max retry attempts |
30
+ | `telemetry` | boolean | `true` | Send anonymous client info (SDK version, runtime, platform) with requests. Set to `false` to disable. |
31
31
 
32
32
  ## Sandbox vs live
33
33
 
@@ -1,7 +1,7 @@
1
1
  ---
2
- lastModified: 2026-08-17
2
+ lastModified: 2026-09-04
3
3
  title: Manage Subscriptions
4
- description: Create, retrieve, cancel, uncancel, and reactivate subscriptions with SDK v9.
4
+ description: Create, retrieve, pause, resume, cancel, and reactivate subscriptions.
5
5
  ---
6
6
 
7
7
  Install the Commet Skill so your coding agent can implement the current subscription lifecycle and verify the result.
@@ -16,16 +16,15 @@ Subscriptions connect a customer to a plan and drive checkout, invoices, feature
16
16
 
17
17
  The persisted statuses are:
18
18
 
19
- | Status | Meaning |
20
- | ----------------- | ------------------------------------- |
21
- | `draft` | Created but not ready for billing |
22
- | `pending_payment` | Waiting for checkout |
23
- | `trialing` | Trial access is active |
24
- | `active` | Billing normally |
25
- | `past_due` | Renewal failed and dunning is active |
26
- | `canceled` | Billing and subscription access ended |
27
-
28
- Commet does not expose a paused or expired subscription status.
19
+ | Status | Meaning |
20
+ | ----------------- | --------------------------------------- |
21
+ | `draft` | Created but not ready for billing |
22
+ | `pending_payment` | Waiting for checkout |
23
+ | `trialing` | Trial access is active |
24
+ | `active` | Billing normally |
25
+ | `past_due` | Renewal failed and dunning is active |
26
+ | `paused` | Access and renewals paused until resume |
27
+ | `canceled` | Billing and subscription access ended |
29
28
 
30
29
  ## Create
31
30
 
@@ -237,6 +236,106 @@ $subscription = $commet->subscriptions->get(id: 'sub_xxx');
237
236
 
238
237
  Use `get` with a public subscription ID to retrieve any persisted status, including `pending_payment`, `past_due`, and `canceled`.
239
238
 
239
+ ## Pause and resume
240
+
241
+ A pause temporarily stops subscription access and renewals without canceling the subscription. You can pause a paid recurring subscription in `active` or `trialing` status. Free, one-time, pending-payment, past-due, and canceled subscriptions are not eligible. Resolve any scheduled cancellation, scheduled plan change, or pending plan-change checkout before creating a pause.
242
+
243
+ ### Choose when to pause
244
+
245
+ | Mode | Access and billing | What happens on resume |
246
+ | ------------ | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
247
+ | `immediate` | Access stops immediately. The unused portion of the current paid or trial period is preserved. | Restores the remaining period without a new charge. Renewal moves to the end of that remaining time. |
248
+ | `period_end` | Access continues until the current billing or trial period ends. The next renewal is skipped. | Charges a new period using the saved payment method. Access returns after successful settlement. |
249
+
250
+ For example, an immediate pause with 10 paid days remaining preserves those 10 days. Resuming after a week still leaves 10 days before renewal.
251
+
252
+ While paused, the subscription does not generate renewal invoices. A period-end pause may still produce a final invoice for pending usage, overage, or seat/quota adjustments from the period that ended. It does not charge advance capacity for the next period.
253
+
254
+ ### Set the duration
255
+
256
+ Set `durationDays` to a positive integer for an automatic resume attempt, or `null` for an indefinite pause that requires manual resume. The duration starts when the pause becomes effective, not when a future pause is scheduled.
257
+
258
+ In the Dashboard, open the subscription detail and choose **Pause**. Choose when the pause starts, then select a suggested duration or enter a number of days, weeks, or calendar months. Leave the duration empty for an indefinite pause. The dialog shows the effective date and the automatic resume attempt date before you confirm. Customers can edit an existing pause, cancel a scheduled pause, and resume a paused subscription in the [Customer Portal](/docs/customer-portal), but cannot create pauses; Commet Admin exposes them in the subscription detail. Dashboard mutations require permission to edit subscriptions.
259
+
260
+ Editing a pause derives an equivalent duration from its stored dates: weekly subscriptions prefer whole weeks; other subscriptions prefer whole calendar months, then weeks or days. Durations are always measured from the original effective date; a month ending on a shorter month uses its last day. The current pause shows its effective date and resume date. Use its actions to edit the duration, revoke a scheduled pause, or resume an effective pause.
261
+
262
+ ### Create a pause
263
+
264
+ This request schedules a seven-day pause at period end:
265
+
266
+ ```bash
267
+ curl -X POST https://commet.co/api/v1/subscriptions/sub_xxx/pause \
268
+ -H "x-api-key: $COMMET_API_KEY" \
269
+ -H "commet-version: 2026-08-27" \
270
+ -H "Content-Type: application/json" \
271
+ -d '{"mode":"period_end","durationDays":7}'
272
+ ```
273
+
274
+ Use `"mode":"immediate"` to pause now, or `"durationDays":null` to leave the resume date open.
275
+
276
+ Creation returns the updated subscription. A future pause has `pause.status: "scheduled"` while the subscription remains `active` or `trialing`. Once effective, the subscription is `paused` and `pause.status` is `"active"`. The `pause` object includes `mode`, `effectiveAt`, and `resumeAt`; it is `null` when there is no current or scheduled pause.
277
+
278
+ ### Edit or revoke a pause
279
+
280
+ Change the duration of a scheduled or effective pause:
281
+
282
+ ```bash
283
+ curl -X PATCH https://commet.co/api/v1/subscriptions/sub_xxx/pause \
284
+ -H "x-api-key: $COMMET_API_KEY" \
285
+ -H "commet-version: 2026-08-27" \
286
+ -H "Content-Type: application/json" \
287
+ -d '{"durationDays":14}'
288
+ ```
289
+
290
+ This sets the total duration to 14 days from the original effective date; it does not add 14 days from today. Send `null` to make the pause indefinite. This operation does not change its mode.
291
+
292
+ Revoke a pause before it becomes effective:
293
+
294
+ ```bash
295
+ curl -X DELETE https://commet.co/api/v1/subscriptions/sub_xxx/pause \
296
+ -H "x-api-key: $COMMET_API_KEY" \
297
+ -H "commet-version: 2026-08-27"
298
+ ```
299
+
300
+ The subscription keeps its current period and access. An effective pause must be resumed instead.
301
+
302
+ ### Resume and handle payment outcomes
303
+
304
+ Use `resume` for a paused subscription; `reactivate` is a separate operation for canceled or past-due subscriptions.
305
+
306
+ ```bash
307
+ curl -X POST https://commet.co/api/v1/subscriptions/sub_xxx/resume \
308
+ -H "x-api-key: $COMMET_API_KEY" \
309
+ -H "commet-version: 2026-08-27"
310
+ ```
311
+
312
+ The response includes `subscriptionId`, `invoiceId`, and `status`. An immediate resume has no new invoice, so `invoiceId` is `null`.
313
+
314
+ | Response | Meaning |
315
+ | ----------------------------- | ------------------------------------------------------------------------------------------------------ |
316
+ | `200`, `status: "succeeded"` | Resume completed. Access is restored. |
317
+ | `200`, `status: "processing"` | The resume payment or settlement is still pending. Do not restore access based on this response alone. |
318
+ | `402`, `charge_failed` | The payment was declined. The subscription stays paused. |
319
+ | `422`, `no_payment_method` | A period-end resume needs a saved payment method. |
320
+ | `500`, `internal_error` | An internal failure prevented completion; this is distinct from a declined payment. |
321
+
322
+ 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.
323
+
324
+ A period-end resume uses the current base price 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.
325
+
326
+ See the [Pause API reference](/docs/api-reference/subscriptions/pause-subscription) and [Resume API reference](/docs/api-reference/subscriptions/resume-subscription) for the complete schemas.
327
+
328
+ ### Keep access in sync
329
+
330
+ Use [Feature Access](/docs/api-reference/features/get-feature-access) to authorize requests against the current subscription state. Subscribe to these webhooks for asynchronous updates in your application:
331
+
332
+ - [`subscription.pause_scheduled`](/docs/webhooks/subscription-pause-scheduled): a future pause was scheduled; access has not stopped yet.
333
+ - [`subscription.pause_updated`](/docs/webhooks/subscription-pause-updated): the pause duration changed.
334
+ - [`subscription.pause_revoked`](/docs/webhooks/subscription-pause-revoked): the scheduled pause was removed.
335
+ - [`subscription.paused`](/docs/webhooks/subscription-paused): the pause became effective and subscription access stopped.
336
+ - [`subscription.resumed`](/docs/webhooks/subscription-resumed): resume completed and subscription access returned.
337
+ - [`subscription.resume_failed`](/docs/webhooks/subscription-resume-failed): resume payment failed and the subscription remains paused.
338
+
240
339
  ## Cancel
241
340
 
242
341
  **TypeScript**
@@ -300,6 +399,8 @@ $subscription = $commet->subscriptions->cancel(id: 'sub_xxx');
300
399
 
301
400
  A normal paid active subscription schedules cancellation at period end unless `immediate: true` is sent. Free, pending-payment, and past-due relationships cancel immediately. Cancellation does not erase the stored subscription balance.
302
401
 
402
+ Canceling a paused subscription is immediate and discards its preserved time. Pending usage, overage, or seat adjustments may still produce a final invoice. To cancel while a future pause is scheduled, revoke that pause first.
403
+
303
404
  ## Reverse a scheduled cancellation
304
405
 
305
406
  **TypeScript**
@@ -4,7 +4,7 @@ The add-on is already active on this subscription.
4
4
 
5
5
  - **Error type:** `conflict_error`
6
6
  - **`code`:** `addon_already_active`
7
- - **API version:** `2026-07-31`
7
+ - **API version:** `2026-08-27`
8
8
 
9
9
 
10
10
  ## What to do
@@ -4,7 +4,7 @@ The add-on cannot be deleted while subscriptions use it.
4
4
 
5
5
  - **Error type:** `conflict_error`
6
6
  - **`code`:** `addon_has_activations`
7
- - **API version:** `2026-07-31`
7
+ - **API version:** `2026-08-27`
8
8
 
9
9
 
10
10
  ## What to do
@@ -4,7 +4,7 @@ The add-on is not active on this subscription.
4
4
 
5
5
  - **Error type:** `billing_error`
6
6
  - **`code`:** `addon_not_active`
7
- - **API version:** `2026-07-31`
7
+ - **API version:** `2026-08-27`
8
8
 
9
9
 
10
10
  ## What to do
@@ -4,7 +4,7 @@ The requested add-on does not exist in this organization.
4
4
 
5
5
  - **Error type:** `not_found_error`
6
6
  - **`code`:** `addon_not_found`
7
- - **API version:** `2026-07-31`
7
+ - **API version:** `2026-08-27`
8
8
 
9
9
 
10
10
  ## What to do
@@ -4,7 +4,7 @@ The customer already has a draft, trialing, active, or past-due subscription tha
4
4
 
5
5
  - **Error type:** `conflict_error`
6
6
  - **`code`:** `already_has_active_subscription`
7
- - **API version:** `2026-07-31`
7
+ - **API version:** `2026-08-27`
8
8
 
9
9
 
10
10
  ## What to do
@@ -4,7 +4,7 @@ The requested subscription action is already scheduled.
4
4
 
5
5
  - **Error type:** `conflict_error`
6
6
  - **`code`:** `already_scheduled`
7
- - **API version:** `2026-07-31`
7
+ - **API version:** `2026-08-27`
8
8
 
9
9
 
10
10
  ## What to do
@@ -4,7 +4,7 @@ The requested API key does not exist in this organization.
4
4
 
5
5
  - **Error type:** `not_found_error`
6
6
  - **`code`:** `api_key_not_found`
7
- - **API version:** `2026-07-31`
7
+ - **API version:** `2026-08-27`
8
8
 
9
9
 
10
10
  ## What to do
@@ -4,7 +4,7 @@ Card promotions are not available for this organization.
4
4
 
5
5
  - **Error type:** `conflict_error`
6
6
  - **`code`:** `card_promotions_not_available`
7
- - **API version:** `2026-07-31`
7
+ - **API version:** `2026-08-27`
8
8
 
9
9
 
10
10
  ## What to do
@@ -4,7 +4,7 @@ The charge required by the subscription operation failed.
4
4
 
5
5
  - **Error type:** `billing_error`
6
6
  - **`code`:** `charge_failed`
7
- - **API version:** `2026-07-31`
7
+ - **API version:** `2026-08-27`
8
8
 
9
9
 
10
10
  ## What to do
@@ -4,7 +4,7 @@ A charge or payment retry is already running for the subscription.
4
4
 
5
5
  - **Error type:** `conflict_error`
6
6
  - **`code`:** `charge_in_progress`
7
- - **API version:** `2026-07-31`
7
+ - **API version:** `2026-08-27`
8
8
 
9
9
 
10
10
  ## What to do