@commet/node 8.0.1 → 9.1.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.
- package/README.md +4 -4
- package/dist/index.d.mts +514 -206
- package/dist/index.d.ts +514 -206
- package/dist/index.js +202 -88
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +202 -88
- package/dist/index.mjs.map +1 -1
- package/docs/README.md +20 -0
- package/docs/ai-onboarding/ai-onboarding.md +90 -0
- package/docs/ai-onboarding/billing-best-practices-skill.md +29 -0
- package/docs/ai-onboarding/commet-skill.md +58 -0
- package/docs/ai-onboarding/mcp-server.md +207 -0
- package/docs/ai-onboarding/meta.json +17 -0
- package/docs/ai-onboarding/pricing-models-skill.md +29 -0
- package/docs/ai-onboarding/subscription-patterns-skill.md +29 -0
- package/docs/api-reference/addons.md +127 -0
- package/docs/api-reference/api-keys.md +57 -0
- package/docs/api-reference/credit-packs.md +80 -0
- package/docs/api-reference/customers.md +274 -0
- package/docs/api-reference/feature-access.md +36 -0
- package/docs/api-reference/features.md +94 -0
- package/docs/api-reference/generated-webhooks.md +120 -0
- package/docs/api-reference/index.md +31 -0
- package/docs/api-reference/invoices.md +123 -0
- package/docs/api-reference/markets.md +92 -0
- package/docs/api-reference/meta.json +7 -0
- package/docs/api-reference/offers.md +104 -0
- package/docs/api-reference/payments.md +106 -0
- package/docs/api-reference/payouts.md +66 -0
- package/docs/api-reference/plan-groups.md +157 -0
- package/docs/api-reference/plans.md +358 -0
- package/docs/api-reference/portal.md +30 -0
- package/docs/api-reference/promo-codes.md +86 -0
- package/docs/api-reference/provisioning.md +19 -0
- package/docs/api-reference/quota.md +120 -0
- package/docs/api-reference/seats.md +123 -0
- package/docs/api-reference/subscriptions.md +387 -0
- package/docs/api-reference/test-clock.md +59 -0
- package/docs/api-reference/transactions.md +78 -0
- package/docs/api-reference/usage.md +83 -0
- package/docs/documentation/api-versioning.md +100 -0
- package/docs/documentation/better-auth.md +361 -0
- package/docs/documentation/choose-a-billing-model.md +38 -0
- package/docs/documentation/cli.md +1024 -0
- package/docs/documentation/create-api-key.md +47 -0
- package/docs/documentation/customers/customer-credits.md +48 -0
- package/docs/documentation/customers/customer-portal.md +107 -0
- package/docs/documentation/customers/manage-customers.md +346 -0
- package/docs/documentation/customers/meta.json +5 -0
- package/docs/documentation/error-handling.md +239 -0
- package/docs/documentation/examples.md +37 -0
- package/docs/documentation/finance/acceptable-use.md +145 -0
- package/docs/documentation/finance/finance-overview.md +32 -0
- package/docs/documentation/finance/local-currency-taxes.md +40 -0
- package/docs/documentation/finance/merchant-of-record.md +48 -0
- package/docs/documentation/finance/meta.json +13 -0
- package/docs/documentation/finance/payouts-verification.md +186 -0
- package/docs/documentation/finance/payouts.md +41 -0
- package/docs/documentation/finance/supported-countries.md +28 -0
- package/docs/documentation/go/integrate-with-encore.md +229 -0
- package/docs/documentation/go/integrate-with-go.md +258 -0
- package/docs/documentation/go/meta.json +5 -0
- package/docs/documentation/introduction.md +58 -0
- package/docs/documentation/invoicing/handle-failed-payments.md +283 -0
- package/docs/documentation/invoicing/invoices-and-billing-cycles.md +73 -0
- package/docs/documentation/invoicing/manage-invoices.md +340 -0
- package/docs/documentation/invoicing/meta.json +9 -0
- package/docs/documentation/java/integrate-with-java.md +117 -0
- package/docs/documentation/java/meta.json +5 -0
- package/docs/documentation/meta.json +36 -0
- package/docs/documentation/nodejs/integrate-with-astro.md +129 -0
- package/docs/documentation/nodejs/integrate-with-bun.md +113 -0
- package/docs/documentation/nodejs/integrate-with-express.md +127 -0
- package/docs/documentation/nodejs/integrate-with-hono.md +141 -0
- package/docs/documentation/nodejs/integrate-with-nextjs.md +118 -0
- package/docs/documentation/nodejs/integrate-with-nuxt.md +125 -0
- package/docs/documentation/nodejs/integrate-with-remix.md +136 -0
- package/docs/documentation/nodejs/integrate-with-sveltekit.md +127 -0
- package/docs/documentation/nodejs/meta.json +14 -0
- package/docs/documentation/payments/accept-one-time-payments.md +314 -0
- package/docs/documentation/payments/meta.json +10 -0
- package/docs/documentation/payments/payment-orchestration.md +43 -0
- package/docs/documentation/payments/payment-providers.md +59 -0
- package/docs/documentation/payments/transactions-refunds-and-retries.md +199 -0
- package/docs/documentation/php/integrate-with-laravel.md +222 -0
- package/docs/documentation/php/integrate-with-php.md +103 -0
- package/docs/documentation/php/integrate-with-symfony.md +214 -0
- package/docs/documentation/php/meta.json +9 -0
- package/docs/documentation/plans/add-ons.md +257 -0
- package/docs/documentation/plans/balance-and-top-ups.md +169 -0
- package/docs/documentation/plans/configure-features.md +335 -0
- package/docs/documentation/plans/consumption-models.md +93 -0
- package/docs/documentation/plans/create-plans.md +162 -0
- package/docs/documentation/plans/credit-packs.md +89 -0
- package/docs/documentation/plans/meta.json +14 -0
- package/docs/documentation/plans/one-time-payments.md +142 -0
- package/docs/documentation/plans/plan-groups.md +31 -0
- package/docs/documentation/platform/custom-domains.md +27 -0
- package/docs/documentation/platform/dashboard-metrics-and-events.md +25 -0
- package/docs/documentation/platform/members-and-permissions.md +21 -0
- package/docs/documentation/platform/meta.json +10 -0
- package/docs/documentation/platform/organization-settings.md +29 -0
- package/docs/documentation/python/integrate-with-django.md +161 -0
- package/docs/documentation/python/integrate-with-fastapi.md +164 -0
- package/docs/documentation/python/integrate-with-flask.md +153 -0
- package/docs/documentation/python/integrate-with-python.md +90 -0
- package/docs/documentation/python/meta.json +10 -0
- package/docs/documentation/sales/card-promotions.md +41 -0
- package/docs/documentation/sales/introductory-offers.md +64 -0
- package/docs/documentation/sales/meta.json +13 -0
- package/docs/documentation/sales/offers.md +65 -0
- package/docs/documentation/sales/promo-codes.md +65 -0
- package/docs/documentation/sales/promotional-offers.md +58 -0
- package/docs/documentation/sales/regional-prices.md +100 -0
- package/docs/documentation/sales/trial-periods.md +88 -0
- package/docs/documentation/sdk-reference.md +68 -0
- package/docs/documentation/subscriptions/manage-subscriptions.md +505 -0
- package/docs/documentation/subscriptions/meta.json +9 -0
- package/docs/documentation/subscriptions/plan-grants.md +132 -0
- package/docs/documentation/subscriptions/upgrade-and-downgrade-plans.md +35 -0
- package/docs/documentation/testing-sandbox.md +251 -0
- package/docs/documentation/usage/ai-token-billing.md +294 -0
- package/docs/documentation/usage/meta.json +10 -0
- package/docs/documentation/usage/quota-management.md +341 -0
- package/docs/documentation/usage/seat-management.md +377 -0
- package/docs/documentation/usage/track-usage.md +282 -0
- package/docs/errors/addon_already_active.md +22 -0
- package/docs/errors/addon_has_activations.md +22 -0
- package/docs/errors/addon_not_active.md +22 -0
- package/docs/errors/addon_not_found.md +22 -0
- package/docs/errors/already_has_active_subscription.md +22 -0
- package/docs/errors/already_scheduled.md +22 -0
- package/docs/errors/api_key_not_found.md +22 -0
- package/docs/errors/card_promotions_not_available.md +22 -0
- package/docs/errors/charge_failed.md +22 -0
- package/docs/errors/charge_in_progress.md +22 -0
- package/docs/errors/claim_not_pending.md +22 -0
- package/docs/errors/credit_pack_not_found.md +22 -0
- package/docs/errors/customer_not_found.md +22 -0
- package/docs/errors/duplicate.md +22 -0
- package/docs/errors/endpoint_deprecated.md +22 -0
- package/docs/errors/endpoint_not_available.md +22 -0
- package/docs/errors/feature_already_exists.md +22 -0
- package/docs/errors/feature_disabled.md +22 -0
- package/docs/errors/feature_in_use.md +22 -0
- package/docs/errors/feature_not_found.md +22 -0
- package/docs/errors/feature_not_in_plan.md +22 -0
- package/docs/errors/forbidden.md +22 -0
- package/docs/errors/free_plan_change_not_supported.md +22 -0
- package/docs/errors/idempotency_in_progress.md +22 -0
- package/docs/errors/idempotency_key_mismatch.md +22 -0
- package/docs/errors/idempotency_unavailable.md +22 -0
- package/docs/errors/included_limit_reached.md +22 -0
- package/docs/errors/index.md +89 -0
- package/docs/errors/insufficient_balance.md +22 -0
- package/docs/errors/insufficient_credits.md +22 -0
- package/docs/errors/insufficient_seats.md +22 -0
- package/docs/errors/internal_error.md +22 -0
- package/docs/errors/invalid_json.md +22 -0
- package/docs/errors/invalid_subscription_status.md +22 -0
- package/docs/errors/invoice_not_found.md +22 -0
- package/docs/errors/market_group_in_use.md +22 -0
- package/docs/errors/market_group_not_found.md +22 -0
- package/docs/errors/market_in_use.md +22 -0
- package/docs/errors/market_not_found.md +22 -0
- package/docs/errors/missing_regional_price.md +22 -0
- package/docs/errors/model_not_found.md +22 -0
- package/docs/errors/no_active_subscription.md +22 -0
- package/docs/errors/no_change_requested.md +22 -0
- package/docs/errors/no_outstanding_invoice.md +22 -0
- package/docs/errors/no_payment_method.md +22 -0
- package/docs/errors/no_prices_configured.md +22 -0
- package/docs/errors/not_found.md +22 -0
- package/docs/errors/not_scheduled_for_cancellation.md +22 -0
- package/docs/errors/offer_not_applicable.md +22 -0
- package/docs/errors/offer_not_found.md +22 -0
- package/docs/errors/one_time_subscription_not_cancelable.md +22 -0
- package/docs/errors/organization_already_claimed.md +22 -0
- package/docs/errors/payment_failed.md +22 -0
- package/docs/errors/payment_method_not_found.md +22 -0
- package/docs/errors/payment_not_cancelable.md +22 -0
- package/docs/errors/payment_not_found.md +22 -0
- package/docs/errors/payouts_not_available_in_sandbox.md +22 -0
- package/docs/errors/plan_change_scheduled.md +22 -0
- package/docs/errors/plan_group_not_found.md +22 -0
- package/docs/errors/plan_not_found.md +22 -0
- package/docs/errors/plan_unavailable.md +22 -0
- package/docs/errors/plans_not_in_same_group.md +22 -0
- package/docs/errors/price_in_use.md +22 -0
- package/docs/errors/price_not_found.md +22 -0
- package/docs/errors/pricing_mode_mismatch.md +22 -0
- package/docs/errors/promo_code_expired.md +22 -0
- package/docs/errors/promo_code_not_found.md +22 -0
- package/docs/errors/provider_unsupported.md +22 -0
- package/docs/errors/rate_limited.md +22 -0
- package/docs/errors/sandbox_only.md +22 -0
- package/docs/errors/seat_limit_exceeded.md +22 -0
- package/docs/errors/subscription_activation_failed.md +22 -0
- package/docs/errors/subscription_already_canceled.md +22 -0
- package/docs/errors/subscription_cancel_failed.md +22 -0
- package/docs/errors/subscription_creation_failed.md +22 -0
- package/docs/errors/subscription_has_open_dispute.md +22 -0
- package/docs/errors/subscription_not_active.md +22 -0
- package/docs/errors/subscription_not_found.md +22 -0
- package/docs/errors/subscription_required.md +22 -0
- package/docs/errors/subscription_uncancel_failed.md +22 -0
- package/docs/errors/transaction_not_found.md +22 -0
- package/docs/errors/unauthorized.md +22 -0
- package/docs/errors/validation_error.md +22 -0
- package/docs/errors/webhook_not_found.md +22 -0
- package/docs/errors.md +34 -0
- package/docs/getting-started.md +35 -0
- package/docs/knowledge-base/how-do-balance-and-top-ups-work.md +22 -0
- package/docs/knowledge-base/how-do-credits-credit-packs-and-customer-credits-differ.md +20 -0
- package/docs/knowledge-base/how-do-discounts-work.md +65 -0
- package/docs/knowledge-base/how-do-free-plans-work-without-payment.md +88 -0
- package/docs/knowledge-base/how-do-monthly-quarterly-and-yearly-billing-work.md +77 -0
- package/docs/knowledge-base/how-do-offers-promo-codes-and-card-promotions-work-together.md +20 -0
- package/docs/knowledge-base/how-do-trial-periods-work.md +54 -0
- package/docs/knowledge-base/how-does-billing-work.md +73 -0
- package/docs/knowledge-base/how-does-payment-routing-work.md +17 -0
- package/docs/knowledge-base/how-does-quota-based-billing-work.md +106 -0
- package/docs/knowledge-base/how-does-seat-based-billing-work.md +88 -0
- package/docs/knowledge-base/how-is-proration-calculated-when-changing-plans.md +89 -0
- package/docs/knowledge-base/meta.json +29 -0
- package/docs/knowledge-base/what-happens-when-a-customer-changes-plans.md +110 -0
- package/docs/knowledge-base/what-happens-when-a-payment-fails.md +40 -0
- package/docs/knowledge-base/what-happens-when-you-change-your-prices.md +74 -0
- package/docs/knowledge-base/what-happens-when-you-refund-or-retry-a-transaction.md +21 -0
- package/docs/knowledge-base/what-invoices-do-customers-receive-and-when.md +101 -0
- package/docs/manifest.json +1677 -0
- package/docs/meta.json +11 -0
- package/docs/platform-documentation.md +175 -0
- package/docs/schemas.md +995 -0
- package/docs/webhooks/addon-activated.md +44 -0
- package/docs/webhooks/addon-deactivated.md +40 -0
- package/docs/webhooks/balance-depleted.md +37 -0
- package/docs/webhooks/balance-low.md +39 -0
- package/docs/webhooks/balance-topped-up.md +41 -0
- package/docs/webhooks/checkout-ready.md +43 -0
- package/docs/webhooks/credits-depleted.md +35 -0
- package/docs/webhooks/credits-expired.md +35 -0
- package/docs/webhooks/credits-granted.md +37 -0
- package/docs/webhooks/credits-low.md +39 -0
- package/docs/webhooks/credits-purchased.md +41 -0
- package/docs/webhooks/customer-created.md +49 -0
- package/docs/webhooks/customer-state-changed.md +134 -0
- package/docs/webhooks/customer-updated.md +49 -0
- package/docs/webhooks/introduction.md +499 -0
- package/docs/webhooks/invoice-created.md +45 -0
- package/docs/webhooks/invoice-overdue.md +53 -0
- package/docs/webhooks/invoice-upcoming.md +43 -0
- package/docs/webhooks/invoice-voided.md +53 -0
- package/docs/webhooks/meta.json +78 -0
- package/docs/webhooks/payment-dispute-resolved.md +52 -0
- package/docs/webhooks/payment-disputed.md +49 -0
- package/docs/webhooks/payment-failed.md +37 -0
- package/docs/webhooks/payment-link-canceled.md +41 -0
- package/docs/webhooks/payment-link-completed.md +47 -0
- package/docs/webhooks/payment-link-created.md +41 -0
- package/docs/webhooks/payment-link-failed.md +45 -0
- package/docs/webhooks/payment-method-attached.md +40 -0
- package/docs/webhooks/payment-method-updated.md +38 -0
- package/docs/webhooks/payment-received.md +45 -0
- package/docs/webhooks/payment-recovered.md +39 -0
- package/docs/webhooks/payment-refunded.md +47 -0
- package/docs/webhooks/payment-retry-failed.md +39 -0
- package/docs/webhooks/payout-available.md +33 -0
- package/docs/webhooks/payout-created.md +48 -0
- package/docs/webhooks/payout-failed.md +52 -0
- package/docs/webhooks/payout-paid.md +48 -0
- package/docs/webhooks/quota-exceeded.md +44 -0
- package/docs/webhooks/quota-threshold-reached.md +41 -0
- package/docs/webhooks/seats-limit-reached.md +39 -0
- package/docs/webhooks/seats-updated.md +39 -0
- package/docs/webhooks/subscription-activated.md +43 -0
- package/docs/webhooks/subscription-canceled.md +57 -0
- package/docs/webhooks/subscription-cancellation-revoked.md +37 -0
- package/docs/webhooks/subscription-cancellation-scheduled.md +45 -0
- package/docs/webhooks/subscription-created.md +35 -0
- package/docs/webhooks/subscription-past-due.md +43 -0
- package/docs/webhooks/subscription-plan-change-revoked.md +50 -0
- package/docs/webhooks/subscription-plan-change-scheduled.md +55 -0
- package/docs/webhooks/subscription-plan-changed.md +43 -0
- package/docs/webhooks/subscription-reactivated.md +53 -0
- package/docs/webhooks/subscription-updated.md +39 -0
- package/docs/webhooks/trial-checkout-ready.md +39 -0
- package/docs/webhooks/trial-converted.md +39 -0
- package/docs/webhooks/trial-expired.md +39 -0
- package/docs/webhooks/trial-started.md +46 -0
- package/docs/webhooks/trial-will-end.md +41 -0
- package/docs/webhooks/usage-recorded.md +41 -0
- package/docs/webhooks.md +782 -0
- package/package.json +2 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-08-16
|
|
3
|
+
title: Create an API Key
|
|
4
|
+
description: Create a sandbox key, keep it on your server, and rotate it without interrupting billing.
|
|
5
|
+
---
|
|
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.
|
|
8
|
+
|
|
9
|
+
## Create a sandbox key
|
|
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.
|
|
15
|
+
|
|
16
|
+
```bash title=".env.local"
|
|
17
|
+
COMMET_API_KEY=ck_sandbox_xxxxxxxxx
|
|
18
|
+
```
|
|
19
|
+
|
|
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.
|
|
21
|
+
|
|
22
|
+
## Initialize the SDK on the server
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { Commet } from "@commet/node"
|
|
26
|
+
|
|
27
|
+
export const commet = new Commet({
|
|
28
|
+
apiKey: process.env.COMMET_API_KEY,
|
|
29
|
+
})
|
|
30
|
+
```
|
|
31
|
+
|
|
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.
|
|
33
|
+
|
|
34
|
+
## Use separate keys per environment
|
|
35
|
+
|
|
36
|
+
Keep sandbox and live credentials in different deployment environments. A safe promotion flow is:
|
|
37
|
+
|
|
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.
|
|
42
|
+
|
|
43
|
+
## Rotate a key
|
|
44
|
+
|
|
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).
|
|
46
|
+
|
|
47
|
+
Use one key per workload when you need independent rotation or audit boundaries. Do not reuse a developer's local key in production.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-08-16
|
|
3
|
+
title: Customer Credits
|
|
4
|
+
description: Grant monetary invoice credit to a customer, inspect its remaining balance, and revoke unused credit.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Customer credits are monetary adjustments for a specific customer and currency. Commet applies them FIFO before tax to eligible recurring invoices.
|
|
8
|
+
|
|
9
|
+
Use customer credits for service recovery, a negotiated commercial credit, or an account adjustment. They are not plan credits and cannot be consumed by usage events.
|
|
10
|
+
|
|
11
|
+
## Grant credit
|
|
12
|
+
|
|
13
|
+
Open a customer in **Customers** to review their billing context. Grant credit through the API when the adjustment originates in your application or support workflow:
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
const credit = await commet.customers.createCredit(
|
|
17
|
+
{
|
|
18
|
+
id: 'cus_01J...',
|
|
19
|
+
amount: 2500,
|
|
20
|
+
currency: 'usd',
|
|
21
|
+
reason: 'Service recovery credit',
|
|
22
|
+
},
|
|
23
|
+
{ idempotencyKey: 'credit-acme-2026-08-16' },
|
|
24
|
+
)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`amount` uses the currency's smallest unit. A USD amount of `2500` is USD 25.00. Always send a reason; it becomes part of the credit's audit trail.
|
|
28
|
+
|
|
29
|
+
## Inspect remaining credit
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
const credits = await commet.customers.listCredits({ id: 'cus_01J...' })
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Credits only apply to invoices in the same currency. If a customer has USD and BRL subscriptions over time, each currency keeps an independent balance.
|
|
36
|
+
|
|
37
|
+
## Revoke unused credit
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
const revocation = await commet.customers.revokeCredit(
|
|
41
|
+
{ id: 'cus_01J...', creditId: 'crd_01J...' },
|
|
42
|
+
{ idempotencyKey: 'revoke-credit-acme-2026-08-16' },
|
|
43
|
+
)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Revocation removes only the unallocated remainder. It does not rewrite invoices that already consumed part of the grant.
|
|
47
|
+
|
|
48
|
+
For product allowances, use [Credits and Credit Packs](/docs/credit-packs). For access without billing, use [Plan Grants](/docs/plan-grants).
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-07-28
|
|
3
|
+
title: Customer Portal
|
|
4
|
+
description: Self-service portal for customers to manage their subscriptions.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Self-service page where customers manage their subscription, view usage, change plans, and purchase credits. Automatically created with every subscription.
|
|
8
|
+
|
|
9
|
+
## What customers can do
|
|
10
|
+
|
|
11
|
+
- View current subscription and billing cycle
|
|
12
|
+
- See usage across all features
|
|
13
|
+
- Upgrade or downgrade plans (requires a [Plan Group](/docs/plan-groups))
|
|
14
|
+
- Purchase [Credit Packs](/docs/credit-packs), balance top-ups, and [Add-ons](/docs/add-ons)
|
|
15
|
+
- Update payment method and billing details
|
|
16
|
+
- View invoice history
|
|
17
|
+
- Cancel subscription
|
|
18
|
+
|
|
19
|
+
Purchases are available on active, trialing, and free plan subscriptions. Free plan customers are prompted to add a payment method on their first purchase.
|
|
20
|
+
|
|
21
|
+
## Generate a portal URL
|
|
22
|
+
|
|
23
|
+
Portal URLs are not single-use — the customer can revisit the link while the session is alive. A session expires after **30 minutes** of inactivity, auto-refreshes while the customer is active, and is capped at **2 hours** from creation. Generate a fresh URL on each visit.
|
|
24
|
+
|
|
25
|
+
### TypeScript
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
const portal = await commet.portal.getUrl({ customerId: 'user_123' })
|
|
29
|
+
|
|
30
|
+
redirect(portal.portalUrl)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Python
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
portal = commet.portal.get_url(customer_id='user_123')
|
|
37
|
+
|
|
38
|
+
redirect(portal.portal_url)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Go
|
|
42
|
+
|
|
43
|
+
```go
|
|
44
|
+
portal, err := client.Portal.GetURL(ctx, &commet.GetPortalURLParams{
|
|
45
|
+
CustomerID: "user_123",
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
// redirect(portal.PortalURL)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Java
|
|
52
|
+
|
|
53
|
+
```java
|
|
54
|
+
var portal = commet.portal().getUrl(RequestPortalAccessParams.builder().customerId("user_123").build());
|
|
55
|
+
|
|
56
|
+
// redirect(portal.portalUrl())
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### PHP
|
|
60
|
+
|
|
61
|
+
```php
|
|
62
|
+
$portal = $commet->portal->getUrl(customerId: 'user_123');
|
|
63
|
+
|
|
64
|
+
redirect($portal->portalUrl);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### cURL
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
curl -X POST https://commet.co/api/v1/portal/request-access \
|
|
71
|
+
-H "x-api-key: $COMMET_API_KEY" \
|
|
72
|
+
-H "Content-Type: application/json" \
|
|
73
|
+
-d '{"customerId": "user_123"}'
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
You can identify customers by `customerId` (Commet ID or your external ID) or `email`.
|
|
77
|
+
|
|
78
|
+
## Next.js helper
|
|
79
|
+
|
|
80
|
+
`@commet/next` (Node.js only) provides a one-line route handler that generates portal URLs and redirects automatically.
|
|
81
|
+
|
|
82
|
+
```typescript title="app/api/commet/portal/route.ts"
|
|
83
|
+
import { CustomerPortal } from '@commet/next'
|
|
84
|
+
|
|
85
|
+
export const GET = CustomerPortal({
|
|
86
|
+
apiKey: process.env.COMMET_API_KEY!,
|
|
87
|
+
getCustomerId: async (req) => {
|
|
88
|
+
return 'user_123'
|
|
89
|
+
},
|
|
90
|
+
})
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
<a href="/api/commet/portal">Manage Billing</a>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Custom domains
|
|
98
|
+
|
|
99
|
+
Serve the portal from your own domain (e.g., `billing.acme.com`) instead of `commet.co`. Go to **Settings** → **Custom Domains**, add the domain, and point the DNS records shown — portal links use your domain once it verifies.
|
|
100
|
+
|
|
101
|
+
Each custom domain serves one surface: **portal** or **checkout**. Checkout pages support custom domains the same way.
|
|
102
|
+
|
|
103
|
+
## Related
|
|
104
|
+
|
|
105
|
+
- [Manage Subscriptions](/docs/manage-subscriptions)
|
|
106
|
+
- [Plan Groups](/docs/plan-groups)
|
|
107
|
+
- [Credit Packs](/docs/credit-packs)
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-07-28
|
|
3
|
+
title: Manage Customers
|
|
4
|
+
description: Create and manage customers using the current Commet SDKs and dashboard.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Install the Commet Skill so your coding agent can integrate customers using the current API contract.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx skills add commet-labs/skills --skill commet
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
A customer represents the business or person you bill. Each customer can have one active subscription relationship at a time.
|
|
14
|
+
|
|
15
|
+
## Dashboard
|
|
16
|
+
|
|
17
|
+
Navigate to **Customers** to search customers, inspect billing state, assign a plan, and manage the subscription.
|
|
18
|
+
|
|
19
|
+
## Create a customer
|
|
20
|
+
|
|
21
|
+
**TypeScript**
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { Commet } from "@commet/node";
|
|
25
|
+
|
|
26
|
+
const commet = new Commet({ apiKey: "ck_xxx" });
|
|
27
|
+
|
|
28
|
+
const customer = await commet.customers.create({ email: "user@example.com" });
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Python**
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from commet import Commet
|
|
35
|
+
|
|
36
|
+
commet = Commet("ck_xxx")
|
|
37
|
+
|
|
38
|
+
customer = commet.customers.create(email="user@example.com")
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Go**
|
|
42
|
+
|
|
43
|
+
```go
|
|
44
|
+
client, err := commet.New("ck_xxx")
|
|
45
|
+
if err != nil {
|
|
46
|
+
log.Fatal(err)
|
|
47
|
+
}
|
|
48
|
+
ctx := context.Background()
|
|
49
|
+
|
|
50
|
+
customer, err := client.Customers.Create(ctx, &commet.CreateCustomerParams{
|
|
51
|
+
Email: "user@example.com",
|
|
52
|
+
})
|
|
53
|
+
if err != nil {
|
|
54
|
+
log.Fatal(err)
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Java**
|
|
59
|
+
|
|
60
|
+
```java
|
|
61
|
+
import co.commet.Commet;
|
|
62
|
+
import co.commet.params.CreateCustomerParams;
|
|
63
|
+
|
|
64
|
+
var commet = Commet.builder().apiKey("ck_xxx").build();
|
|
65
|
+
|
|
66
|
+
var customer = commet.customers().create(
|
|
67
|
+
CreateCustomerParams.builder("user@example.com").build()
|
|
68
|
+
);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**PHP**
|
|
72
|
+
|
|
73
|
+
```php
|
|
74
|
+
use Commet\Commet;
|
|
75
|
+
|
|
76
|
+
$commet = new Commet('ck_xxx');
|
|
77
|
+
|
|
78
|
+
$customer = $commet->customers->create(email: 'user@example.com');
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
`create` is idempotent when you supply your own `id`: a retry with the same ID returns the existing customer.
|
|
82
|
+
|
|
83
|
+
Use:
|
|
84
|
+
|
|
85
|
+
- `id` for the stable identifier from your application.
|
|
86
|
+
- `email` for billing communication.
|
|
87
|
+
- `address` and `taxDocument` for billing and tax context.
|
|
88
|
+
- `metadata` for application-specific values that do not control billing behavior.
|
|
89
|
+
|
|
90
|
+
## Create customers in batch
|
|
91
|
+
|
|
92
|
+
**TypeScript**
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
import { Commet } from "@commet/node";
|
|
96
|
+
|
|
97
|
+
const commet = new Commet({ apiKey: "ck_xxx" });
|
|
98
|
+
|
|
99
|
+
const customerBatch = await commet.customers.createBatch({ customers: [{ email: "user@example.com" }] });
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Python**
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from commet import Commet
|
|
106
|
+
|
|
107
|
+
commet = Commet("ck_xxx")
|
|
108
|
+
|
|
109
|
+
customer_batch = commet.customers.create_batch(customers=[{"email": "user@example.com"}])
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Go**
|
|
113
|
+
|
|
114
|
+
```go
|
|
115
|
+
client, err := commet.New("ck_xxx")
|
|
116
|
+
if err != nil {
|
|
117
|
+
log.Fatal(err)
|
|
118
|
+
}
|
|
119
|
+
ctx := context.Background()
|
|
120
|
+
|
|
121
|
+
customerBatch, err := client.Customers.CreateBatch(ctx, &commet.BatchCreateCustomersParams{
|
|
122
|
+
Customers: []commet.BatchCreateCustomersParamsCustomersItem{{
|
|
123
|
+
Email: "user@example.com",
|
|
124
|
+
}},
|
|
125
|
+
})
|
|
126
|
+
if err != nil {
|
|
127
|
+
log.Fatal(err)
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Java**
|
|
132
|
+
|
|
133
|
+
```java
|
|
134
|
+
import co.commet.Commet;
|
|
135
|
+
import co.commet.models.BatchCreateCustomersParamsCustomersItem;
|
|
136
|
+
import co.commet.params.BatchCreateCustomersParams;
|
|
137
|
+
import java.util.List;
|
|
138
|
+
|
|
139
|
+
var commet = Commet.builder().apiKey("ck_xxx").build();
|
|
140
|
+
|
|
141
|
+
var customerBatch = commet.customers().createBatch(
|
|
142
|
+
BatchCreateCustomersParams.builder(List.of(new BatchCreateCustomersParamsCustomersItem("user@example.com", null, null, null, null, null, null, null))).build()
|
|
143
|
+
);
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**PHP**
|
|
147
|
+
|
|
148
|
+
```php
|
|
149
|
+
use Commet\Commet;
|
|
150
|
+
|
|
151
|
+
$commet = new Commet('ck_xxx');
|
|
152
|
+
|
|
153
|
+
$customerBatch = $commet->customers->createBatch(
|
|
154
|
+
customers: [['email' => 'user@example.com']],
|
|
155
|
+
);
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
A batch accepts up to 100 customers and returns successful and failed items independently.
|
|
159
|
+
|
|
160
|
+
## Retrieve a customer
|
|
161
|
+
|
|
162
|
+
**TypeScript**
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
import { Commet } from "@commet/node";
|
|
166
|
+
|
|
167
|
+
const commet = new Commet({ apiKey: "ck_xxx" });
|
|
168
|
+
|
|
169
|
+
const customer = await commet.customers.get({ id: "cus_xxx" });
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Python**
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
from commet import Commet
|
|
176
|
+
|
|
177
|
+
commet = Commet("ck_xxx")
|
|
178
|
+
|
|
179
|
+
customer = commet.customers.get("cus_xxx")
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**Go**
|
|
183
|
+
|
|
184
|
+
```go
|
|
185
|
+
client, err := commet.New("ck_xxx")
|
|
186
|
+
if err != nil {
|
|
187
|
+
log.Fatal(err)
|
|
188
|
+
}
|
|
189
|
+
ctx := context.Background()
|
|
190
|
+
|
|
191
|
+
customer, err := client.Customers.Get(ctx, "cus_xxx")
|
|
192
|
+
if err != nil {
|
|
193
|
+
log.Fatal(err)
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**Java**
|
|
198
|
+
|
|
199
|
+
```java
|
|
200
|
+
import co.commet.Commet;
|
|
201
|
+
|
|
202
|
+
var commet = Commet.builder().apiKey("ck_xxx").build();
|
|
203
|
+
|
|
204
|
+
var customer = commet.customers().get("cus_xxx");
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**PHP**
|
|
208
|
+
|
|
209
|
+
```php
|
|
210
|
+
use Commet\Commet;
|
|
211
|
+
|
|
212
|
+
$commet = new Commet('ck_xxx');
|
|
213
|
+
|
|
214
|
+
$customer = $commet->customers->get(id: 'cus_xxx');
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Update a customer
|
|
218
|
+
|
|
219
|
+
**TypeScript**
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
import { Commet } from "@commet/node";
|
|
223
|
+
|
|
224
|
+
const commet = new Commet({ apiKey: "ck_xxx" });
|
|
225
|
+
|
|
226
|
+
const customer = await commet.customers.update({ id: "cus_xxx" });
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
**Python**
|
|
230
|
+
|
|
231
|
+
```python
|
|
232
|
+
from commet import Commet
|
|
233
|
+
|
|
234
|
+
commet = Commet("ck_xxx")
|
|
235
|
+
|
|
236
|
+
customer = commet.customers.update("cus_xxx")
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
**Go**
|
|
240
|
+
|
|
241
|
+
```go
|
|
242
|
+
client, err := commet.New("ck_xxx")
|
|
243
|
+
if err != nil {
|
|
244
|
+
log.Fatal(err)
|
|
245
|
+
}
|
|
246
|
+
ctx := context.Background()
|
|
247
|
+
|
|
248
|
+
customer, err := client.Customers.Update(ctx, "cus_xxx", nil)
|
|
249
|
+
if err != nil {
|
|
250
|
+
log.Fatal(err)
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**Java**
|
|
255
|
+
|
|
256
|
+
```java
|
|
257
|
+
import co.commet.Commet;
|
|
258
|
+
import co.commet.params.UpdateCustomerParams;
|
|
259
|
+
|
|
260
|
+
var commet = Commet.builder().apiKey("ck_xxx").build();
|
|
261
|
+
|
|
262
|
+
var customer = commet.customers().update(
|
|
263
|
+
"cus_xxx",
|
|
264
|
+
UpdateCustomerParams.builder().build()
|
|
265
|
+
);
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
**PHP**
|
|
269
|
+
|
|
270
|
+
```php
|
|
271
|
+
use Commet\Commet;
|
|
272
|
+
|
|
273
|
+
$commet = new Commet('ck_xxx');
|
|
274
|
+
|
|
275
|
+
$customer = $commet->customers->update(id: 'cus_xxx');
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
Updates use `PATCH` semantics: send only the fields that should change.
|
|
279
|
+
|
|
280
|
+
## List customers
|
|
281
|
+
|
|
282
|
+
**TypeScript**
|
|
283
|
+
|
|
284
|
+
```typescript
|
|
285
|
+
import { Commet } from "@commet/node";
|
|
286
|
+
|
|
287
|
+
const commet = new Commet({ apiKey: "ck_xxx" });
|
|
288
|
+
|
|
289
|
+
const response = await commet.customers.list();
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
**Python**
|
|
293
|
+
|
|
294
|
+
```python
|
|
295
|
+
from commet import Commet
|
|
296
|
+
|
|
297
|
+
commet = Commet("ck_xxx")
|
|
298
|
+
|
|
299
|
+
customers_list_result = commet.customers.list()
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
**Go**
|
|
303
|
+
|
|
304
|
+
```go
|
|
305
|
+
client, err := commet.New("ck_xxx")
|
|
306
|
+
if err != nil {
|
|
307
|
+
log.Fatal(err)
|
|
308
|
+
}
|
|
309
|
+
ctx := context.Background()
|
|
310
|
+
|
|
311
|
+
customersListResult, err := client.Customers.List(ctx, nil)
|
|
312
|
+
if err != nil {
|
|
313
|
+
log.Fatal(err)
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
**Java**
|
|
318
|
+
|
|
319
|
+
```java
|
|
320
|
+
import co.commet.Commet;
|
|
321
|
+
import co.commet.params.ListCustomersParams;
|
|
322
|
+
|
|
323
|
+
var commet = Commet.builder().apiKey("ck_xxx").build();
|
|
324
|
+
|
|
325
|
+
var customersListResult = commet.customers().list(ListCustomersParams.builder().build());
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
**PHP**
|
|
329
|
+
|
|
330
|
+
```php
|
|
331
|
+
use Commet\Commet;
|
|
332
|
+
|
|
333
|
+
$commet = new Commet('ck_xxx');
|
|
334
|
+
|
|
335
|
+
$customersListResult = $commet->customers->list();
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
Lists return `{ object, data, hasMore, nextCursor }`. Pass `nextCursor` back as `cursor` to request the next page. Singular customer operations return the customer directly.
|
|
339
|
+
|
|
340
|
+
See the [Customers API reference](/docs/api-reference/customers/list-customers) for the exact generated request and response fields.
|
|
341
|
+
|
|
342
|
+
## Related
|
|
343
|
+
|
|
344
|
+
- [Customer Portal](/docs/customer-portal)
|
|
345
|
+
- [Manage Subscriptions](/docs/manage-subscriptions)
|
|
346
|
+
- [Offers & Pricing changelog and migration checklist](/changelog/offers-and-pricing)
|