@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,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-06-12
|
|
3
|
+
title: "addon.activated"
|
|
4
|
+
description: "An add-on was activated on a subscription."
|
|
5
|
+
full: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
All webhook payloads follow a consistent top-level structure with event-specific data nested within the `data` object.
|
|
9
|
+
|
|
10
|
+
- `subscriptionId` (string) — The subscription ID.
|
|
11
|
+
- `customerId` (string) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
|
|
12
|
+
- `addon` (WebhookAddonRef) — The add-on: id and name.
|
|
13
|
+
- `featureCode` (string) — The feature the add-on unlocks or extends.
|
|
14
|
+
- `proratedPrice` (number) — The prorated amount charged at activation in rate scale (10000 = $1.00). Zero when nothing was charged.
|
|
15
|
+
- `currency` (string) — The subscription currency.
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"event": "addon.activated",
|
|
20
|
+
"timestamp": "2026-06-23T14:30:00.000Z",
|
|
21
|
+
"organizationId": "8f14e45f-ceea-4e7a-9c3d-1c2b3a4d5e6f",
|
|
22
|
+
"mode": "live",
|
|
23
|
+
"apiVersion": "2026-07-31",
|
|
24
|
+
"data": {
|
|
25
|
+
"subscriptionId": "sub_1a2b3c4d",
|
|
26
|
+
"customerId": "user_123",
|
|
27
|
+
"addon": {
|
|
28
|
+
"id": "adn_5e6f7g8h",
|
|
29
|
+
"name": "Extra Storage"
|
|
30
|
+
},
|
|
31
|
+
"featureCode": "storage",
|
|
32
|
+
"proratedPrice": 25000,
|
|
33
|
+
"currency": "usd"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## When this fires
|
|
39
|
+
|
|
40
|
+
When an add-on activation completes — via `POST /subscriptions/{id}/addons` or a customer portal purchase. Any prorated activation charge has already succeeded; `proratedPrice` is the amount charged (zero when the remaining period was free).
|
|
41
|
+
|
|
42
|
+
`customer.state_changed` fires alongside it with trigger `addon_activated`, reflecting the feature the add-on unlocked.
|
|
43
|
+
|
|
44
|
+
Use it to enable the add-on's feature in your app the moment it is paid.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-06-12
|
|
3
|
+
title: "addon.deactivated"
|
|
4
|
+
description: "An add-on was deactivated from a subscription."
|
|
5
|
+
full: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
All webhook payloads follow a consistent top-level structure with event-specific data nested within the `data` object.
|
|
9
|
+
|
|
10
|
+
- `subscriptionId` (string) — The subscription ID.
|
|
11
|
+
- `customerId` (string) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
|
|
12
|
+
- `addon` (WebhookAddonRef) — The add-on: id and name.
|
|
13
|
+
- `featureCode` (string) — The feature the add-on unlocked or extended.
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"event": "addon.deactivated",
|
|
18
|
+
"timestamp": "2026-06-23T14:30:00.000Z",
|
|
19
|
+
"organizationId": "8f14e45f-ceea-4e7a-9c3d-1c2b3a4d5e6f",
|
|
20
|
+
"mode": "live",
|
|
21
|
+
"apiVersion": "2026-07-31",
|
|
22
|
+
"data": {
|
|
23
|
+
"subscriptionId": "sub_1a2b3c4d",
|
|
24
|
+
"customerId": "user_123",
|
|
25
|
+
"addon": {
|
|
26
|
+
"id": "adn_5e6f7g8h",
|
|
27
|
+
"name": "Extra Storage"
|
|
28
|
+
},
|
|
29
|
+
"featureCode": "storage"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## When this fires
|
|
35
|
+
|
|
36
|
+
When an active add-on is deactivated — via `DELETE /subscriptions/{id}/addons/{addonId}` or the customer portal. The add-on stops billing at the next renewal.
|
|
37
|
+
|
|
38
|
+
`customer.state_changed` fires alongside it with trigger `addon_deactivated`.
|
|
39
|
+
|
|
40
|
+
Use it to revoke the add-on's feature in your app.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-06-12
|
|
3
|
+
title: "balance.depleted"
|
|
4
|
+
description: "A subscription ran out of prepaid balance."
|
|
5
|
+
full: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
All webhook payloads follow a consistent top-level structure with event-specific data nested within the `data` object.
|
|
9
|
+
|
|
10
|
+
- `subscriptionId` (string) — The subscription ID.
|
|
11
|
+
- `customerId` (string) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
|
|
12
|
+
- `currentBalance` (number) — The balance after depletion in rate scale. Zero, or negative when overage is allowed.
|
|
13
|
+
- `currency` (string) — The subscription currency.
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"event": "balance.depleted",
|
|
18
|
+
"timestamp": "2026-06-23T14:30:00.000Z",
|
|
19
|
+
"organizationId": "8f14e45f-ceea-4e7a-9c3d-1c2b3a4d5e6f",
|
|
20
|
+
"mode": "live",
|
|
21
|
+
"apiVersion": "2026-07-31",
|
|
22
|
+
"data": {
|
|
23
|
+
"subscriptionId": "sub_1a2b3c4d",
|
|
24
|
+
"customerId": "user_123",
|
|
25
|
+
"currentBalance": 0,
|
|
26
|
+
"currency": "usd"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## When this fires
|
|
32
|
+
|
|
33
|
+
The async usage processor fires this once when a deduction moves the prepaid balance from positive to zero or below. On plans that block on exhaustion, further usage is rejected with `insufficient_balance`; otherwise the balance goes negative and usage continues.
|
|
34
|
+
|
|
35
|
+
`customer.state_changed` fires alongside it with trigger `balance_depleted`.
|
|
36
|
+
|
|
37
|
+
Use it to cut off gated features or push an urgent top-up flow.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-06-12
|
|
3
|
+
title: "balance.low"
|
|
4
|
+
description: "Prepaid balance dropped below 10% of the last refill."
|
|
5
|
+
full: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
All webhook payloads follow a consistent top-level structure with event-specific data nested within the `data` object.
|
|
9
|
+
|
|
10
|
+
- `subscriptionId` (string) — The subscription ID.
|
|
11
|
+
- `customerId` (string) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
|
|
12
|
+
- `currentBalance` (number) — The remaining balance in rate scale (10000 = $1.00 of the subscription currency).
|
|
13
|
+
- `thresholdBalance` (number) — The low-balance threshold that was crossed: 10% of the last refill, in rate scale.
|
|
14
|
+
- `currency` (string) — The subscription currency.
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"event": "balance.low",
|
|
19
|
+
"timestamp": "2026-06-23T14:30:00.000Z",
|
|
20
|
+
"organizationId": "8f14e45f-ceea-4e7a-9c3d-1c2b3a4d5e6f",
|
|
21
|
+
"mode": "live",
|
|
22
|
+
"apiVersion": "2026-07-31",
|
|
23
|
+
"data": {
|
|
24
|
+
"subscriptionId": "sub_1a2b3c4d",
|
|
25
|
+
"customerId": "user_123",
|
|
26
|
+
"currentBalance": 90000,
|
|
27
|
+
"thresholdBalance": 100000,
|
|
28
|
+
"currency": "usd"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## When this fires
|
|
34
|
+
|
|
35
|
+
The async usage processor watches every balance deduction. When a batch moves the prepaid balance from above to at-or-below 10% of the last refill (period reset, top-up, or manual adjustment), this event fires once per crossing. A top-up re-arms it.
|
|
36
|
+
|
|
37
|
+
Amounts are in rate scale (10000 = $1.00) in the subscription currency.
|
|
38
|
+
|
|
39
|
+
Use it to prompt the customer to top up before usage gets blocked.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-06-12
|
|
3
|
+
title: "balance.topped_up"
|
|
4
|
+
description: "A prepaid balance top-up was completed."
|
|
5
|
+
full: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
All webhook payloads follow a consistent top-level structure with event-specific data nested within the `data` object.
|
|
9
|
+
|
|
10
|
+
- `subscriptionId` (string) — The subscription ID.
|
|
11
|
+
- `customerId` (string) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
|
|
12
|
+
- `invoiceId` (string) — The invoice issued for the top-up.
|
|
13
|
+
- `invoiceNumber` (string) — The human-readable invoice number.
|
|
14
|
+
- `amount` (number) — The topped-up value in rate scale (10000 = $1.00 of the subscription currency).
|
|
15
|
+
- `currency` (string) — The subscription currency.
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"event": "balance.topped_up",
|
|
20
|
+
"timestamp": "2026-06-23T14:30:00.000Z",
|
|
21
|
+
"organizationId": "8f14e45f-ceea-4e7a-9c3d-1c2b3a4d5e6f",
|
|
22
|
+
"mode": "live",
|
|
23
|
+
"apiVersion": "2026-07-31",
|
|
24
|
+
"data": {
|
|
25
|
+
"subscriptionId": "sub_1a2b3c4d",
|
|
26
|
+
"customerId": "user_123",
|
|
27
|
+
"invoiceId": "inv_t1u2v3",
|
|
28
|
+
"invoiceNumber": "INV-0051",
|
|
29
|
+
"amount": 500000,
|
|
30
|
+
"currency": "usd"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## When this fires
|
|
36
|
+
|
|
37
|
+
When a customer on a balance plan tops up their prepaid balance through the customer portal and the payment succeeds.
|
|
38
|
+
|
|
39
|
+
`amount` is the topped-up value in rate scale (10000 = $1.00 of the subscription currency) — the same scale `balance.low` and `balance.depleted` use.
|
|
40
|
+
|
|
41
|
+
Use it to confirm the top-up in your own UI and to clear any low-balance warnings you raised on `balance.low`.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-06-12
|
|
3
|
+
title: "checkout.ready"
|
|
4
|
+
description: "A checkout link is ready to share with the customer."
|
|
5
|
+
full: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
All webhook payloads follow a consistent top-level structure with event-specific data nested within the `data` object.
|
|
9
|
+
|
|
10
|
+
- `subscriptionId` (string) — The subscription ID.
|
|
11
|
+
- `customerId` (string) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
|
|
12
|
+
- `invoiceId` (string) — The invoice this checkout collects.
|
|
13
|
+
- `invoiceNumber` (string) — The human-readable invoice number.
|
|
14
|
+
- `invoiceTotal` (number) — Invoice total in cents (100 = $1.00).
|
|
15
|
+
- `invoiceCurrency` (string) — The invoice currency code.
|
|
16
|
+
- `checkoutUrl` (string) — The hosted checkout URL to share with the customer.
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"event": "checkout.ready",
|
|
21
|
+
"timestamp": "2026-06-23T14:30:00.000Z",
|
|
22
|
+
"organizationId": "8f14e45f-ceea-4e7a-9c3d-1c2b3a4d5e6f",
|
|
23
|
+
"mode": "live",
|
|
24
|
+
"apiVersion": "2026-07-31",
|
|
25
|
+
"data": {
|
|
26
|
+
"subscriptionId": "sub_1a2b3c4d",
|
|
27
|
+
"customerId": "user_123",
|
|
28
|
+
"invoiceId": "inv_k1l2m3",
|
|
29
|
+
"invoiceNumber": "INV-0042",
|
|
30
|
+
"invoiceTotal": 9900,
|
|
31
|
+
"invoiceCurrency": "usd",
|
|
32
|
+
"checkoutUrl": "https://pay.commet.co/checkout/tok_9f8e7d6c"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## When this fires
|
|
38
|
+
|
|
39
|
+
When a subscription is created without a payment method on file, Commet generates a hosted checkout link for the first invoice and fires this event as soon as the link is ready. Commet also emails the link to the customer — this webhook lets you deliver it through your own channels (in-app banner, chat, SMS) instead of relying on email alone.
|
|
40
|
+
|
|
41
|
+
The link stays valid until the invoice is paid or voided. Trials with their own checkout flow fire `trial.checkout_ready` instead.
|
|
42
|
+
|
|
43
|
+
Use the `checkoutUrl` to put the payment link in front of the customer wherever they already are.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-06-12
|
|
3
|
+
title: "credits.depleted"
|
|
4
|
+
description: "A subscription ran out of credits."
|
|
5
|
+
full: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
All webhook payloads follow a consistent top-level structure with event-specific data nested within the `data` object.
|
|
9
|
+
|
|
10
|
+
- `subscriptionId` (string) — The subscription ID.
|
|
11
|
+
- `customerId` (string) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
|
|
12
|
+
- `remainingCredits` (number) — Credits remaining after depletion. Always 0.
|
|
13
|
+
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"event": "credits.depleted",
|
|
17
|
+
"timestamp": "2026-06-23T14:30:00.000Z",
|
|
18
|
+
"organizationId": "8f14e45f-ceea-4e7a-9c3d-1c2b3a4d5e6f",
|
|
19
|
+
"mode": "live",
|
|
20
|
+
"apiVersion": "2026-07-31",
|
|
21
|
+
"data": {
|
|
22
|
+
"subscriptionId": "sub_1a2b3c4d",
|
|
23
|
+
"customerId": "user_123",
|
|
24
|
+
"remainingCredits": 0
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## When this fires
|
|
30
|
+
|
|
31
|
+
The async usage processor fires this once when a deduction moves the credit balance from positive to zero. From this point, usage requests that need more credits than remain are rejected with `insufficient_credits`.
|
|
32
|
+
|
|
33
|
+
`customer.state_changed` fires alongside it with trigger `credits_depleted`, carrying the customer's full current entitlement state.
|
|
34
|
+
|
|
35
|
+
Use it to block gated features in your app and drive the customer to a credit pack purchase.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-06-12
|
|
3
|
+
title: "credits.expired"
|
|
4
|
+
description: "Unused plan credits expired at the period reset."
|
|
5
|
+
full: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
All webhook payloads follow a consistent top-level structure with event-specific data nested within the `data` object.
|
|
9
|
+
|
|
10
|
+
- `subscriptionId` (string) — The subscription ID.
|
|
11
|
+
- `customerId` (string) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
|
|
12
|
+
- `expiredCredits` (number) — The unused plan credits that were discarded.
|
|
13
|
+
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"event": "credits.expired",
|
|
17
|
+
"timestamp": "2026-06-23T14:30:00.000Z",
|
|
18
|
+
"organizationId": "8f14e45f-ceea-4e7a-9c3d-1c2b3a4d5e6f",
|
|
19
|
+
"mode": "live",
|
|
20
|
+
"apiVersion": "2026-07-31",
|
|
21
|
+
"data": {
|
|
22
|
+
"subscriptionId": "sub_1a2b3c4d",
|
|
23
|
+
"customerId": "user_123",
|
|
24
|
+
"expiredCredits": 120
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## When this fires
|
|
30
|
+
|
|
31
|
+
Plan credits expire at the end of each billing period: the period reset discards whatever remained and grants the new period's credits (which fires `credits.granted`). This event reports the discarded amount. Purchased credits never expire and are not affected.
|
|
32
|
+
|
|
33
|
+
It only fires when there was something to discard — a customer who used all plan credits gets no `credits.expired`.
|
|
34
|
+
|
|
35
|
+
Use it for end-of-period usage summaries ("you left 120 credits on the table").
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-06-12
|
|
3
|
+
title: "credits.granted"
|
|
4
|
+
description: "Non-purchase credits were granted to a subscription."
|
|
5
|
+
full: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
All webhook payloads follow a consistent top-level structure with event-specific data nested within the `data` object.
|
|
9
|
+
|
|
10
|
+
- `subscriptionId` (string) — The subscription ID.
|
|
11
|
+
- `customerId` (string) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
|
|
12
|
+
- `credits` (number) — The number of credits granted.
|
|
13
|
+
- `reason` (string) — Why the credits were granted: period\_reset or manual\_adjustment.
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"event": "credits.granted",
|
|
18
|
+
"timestamp": "2026-06-23T14:30:00.000Z",
|
|
19
|
+
"organizationId": "8f14e45f-ceea-4e7a-9c3d-1c2b3a4d5e6f",
|
|
20
|
+
"mode": "live",
|
|
21
|
+
"apiVersion": "2026-07-31",
|
|
22
|
+
"data": {
|
|
23
|
+
"subscriptionId": "sub_1a2b3c4d",
|
|
24
|
+
"customerId": "user_123",
|
|
25
|
+
"credits": 500,
|
|
26
|
+
"reason": "period_reset"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## When this fires
|
|
32
|
+
|
|
33
|
+
Plan-included credits are granted at the start of every billing period (`reason: "period_reset"`), and manual adjustments from the dashboard grant purchased credits (`reason: "manual_adjustment"`). Credit pack purchases are a separate flow and fire `credits.purchased` instead.
|
|
34
|
+
|
|
35
|
+
The idempotency key is derived from the billing operation that granted the credits, so engine retries never send a duplicate.
|
|
36
|
+
|
|
37
|
+
Use it to reset in-app usage meters at the start of a period or to confirm a support-driven credit grant reached the customer.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-06-12
|
|
3
|
+
title: "credits.low"
|
|
4
|
+
description: "Remaining credits dropped below 10% of the period grant."
|
|
5
|
+
full: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
All webhook payloads follow a consistent top-level structure with event-specific data nested within the `data` object.
|
|
9
|
+
|
|
10
|
+
- `subscriptionId` (string) — The subscription ID.
|
|
11
|
+
- `customerId` (string) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
|
|
12
|
+
- `remainingCredits` (number) — Total credits remaining (plan plus purchased).
|
|
13
|
+
- `thresholdCredits` (number) — The low-credit threshold that was crossed: 10% of the period's granted plan credits.
|
|
14
|
+
- `periodCredits` (number) — The plan credits granted at the last period reset.
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"event": "credits.low",
|
|
19
|
+
"timestamp": "2026-06-23T14:30:00.000Z",
|
|
20
|
+
"organizationId": "8f14e45f-ceea-4e7a-9c3d-1c2b3a4d5e6f",
|
|
21
|
+
"mode": "live",
|
|
22
|
+
"apiVersion": "2026-07-31",
|
|
23
|
+
"data": {
|
|
24
|
+
"subscriptionId": "sub_1a2b3c4d",
|
|
25
|
+
"customerId": "user_123",
|
|
26
|
+
"remainingCredits": 42,
|
|
27
|
+
"thresholdCredits": 50,
|
|
28
|
+
"periodCredits": 500
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## When this fires
|
|
34
|
+
|
|
35
|
+
The async usage processor watches every credit deduction. When a batch of usage moves the remaining credits (plan plus purchased) from above to at-or-below 10% of the credits granted at the last period reset, this event fires once. It does not re-fire while the balance stays low, and the next period reset re-arms it.
|
|
36
|
+
|
|
37
|
+
If a single burst of usage jumps straight past zero, only `credits.depleted` fires.
|
|
38
|
+
|
|
39
|
+
Use it to prompt the customer to buy a credit pack before they hit zero.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-06-12
|
|
3
|
+
title: "credits.purchased"
|
|
4
|
+
description: "A credit pack purchase was completed."
|
|
5
|
+
full: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
All webhook payloads follow a consistent top-level structure with event-specific data nested within the `data` object.
|
|
9
|
+
|
|
10
|
+
- `subscriptionId` (string) — The subscription ID.
|
|
11
|
+
- `customerId` (string) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
|
|
12
|
+
- `invoiceId` (string) — The invoice issued for the purchase.
|
|
13
|
+
- `invoiceNumber` (string) — The human-readable invoice number.
|
|
14
|
+
- `creditPackName` (string) — The purchased credit pack's name.
|
|
15
|
+
- `credits` (number) — The number of credits purchased.
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"event": "credits.purchased",
|
|
20
|
+
"timestamp": "2026-06-23T14:30:00.000Z",
|
|
21
|
+
"organizationId": "8f14e45f-ceea-4e7a-9c3d-1c2b3a4d5e6f",
|
|
22
|
+
"mode": "live",
|
|
23
|
+
"apiVersion": "2026-07-31",
|
|
24
|
+
"data": {
|
|
25
|
+
"subscriptionId": "sub_1a2b3c4d",
|
|
26
|
+
"customerId": "user_123",
|
|
27
|
+
"invoiceId": "inv_t1u2v3",
|
|
28
|
+
"invoiceNumber": "INV-0051",
|
|
29
|
+
"creditPackName": "Booster 500",
|
|
30
|
+
"credits": 500
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## When this fires
|
|
36
|
+
|
|
37
|
+
When a customer buys a credit pack through the customer portal and the payment succeeds. Purchased credits never expire — unlike plan credits, they survive period resets.
|
|
38
|
+
|
|
39
|
+
Plan-included credits granted at each period reset fire `credits.granted` instead.
|
|
40
|
+
|
|
41
|
+
Use it to confirm top-up purchases in your own UI or analytics.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-06-12
|
|
3
|
+
title: "customer.created"
|
|
4
|
+
description: "Fired when a customer is created. The payload mirrors the customer resource from GET /customers."
|
|
5
|
+
full: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
All webhook payloads follow a consistent top-level structure with event-specific data nested within the `data` object.
|
|
9
|
+
|
|
10
|
+
- `id` (string) — The Commet customer ID (cus\_...).
|
|
11
|
+
- `externalId` (string | null) — Your own identifier for this customer, if you provided one.
|
|
12
|
+
- `fullName` (string | null) — The customer's full name.
|
|
13
|
+
- `email` (string) — The customer's email.
|
|
14
|
+
- `taxDocument` (string | null) — The customer's tax identification number, if provided.
|
|
15
|
+
- `documentType` (string | null) — The local tax document type label inferred from the customer's country (e.g. CUIT, RFC, RUT), or null when no tax document was provided.
|
|
16
|
+
- `timezone` (string | null) — The customer's timezone.
|
|
17
|
+
- `metadata` (object | null) — Custom key-value metadata you attached to the customer.
|
|
18
|
+
- `createdAt` (string) — ISO 8601 datetime when the customer was created.
|
|
19
|
+
- `updatedAt` (string) — ISO 8601 datetime of the last update.
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"event": "customer.created",
|
|
24
|
+
"timestamp": "2026-06-23T14:30:00.000Z",
|
|
25
|
+
"organizationId": "8f14e45f-ceea-4e7a-9c3d-1c2b3a4d5e6f",
|
|
26
|
+
"mode": "live",
|
|
27
|
+
"apiVersion": "2026-07-31",
|
|
28
|
+
"data": {
|
|
29
|
+
"id": "cus_1a2b3c4d",
|
|
30
|
+
"externalId": "user_123",
|
|
31
|
+
"fullName": "Ada Lovelace",
|
|
32
|
+
"email": "ada@acme.com",
|
|
33
|
+
"taxDocument": "20-12345678-9",
|
|
34
|
+
"documentType": "CUIT",
|
|
35
|
+
"timezone": "UTC",
|
|
36
|
+
"metadata": {
|
|
37
|
+
"plan_intent": "pro"
|
|
38
|
+
},
|
|
39
|
+
"createdAt": "2026-03-25T14:29:00.000Z",
|
|
40
|
+
"updatedAt": "2026-03-25T14:29:00.000Z"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Resource shape and version pinning
|
|
46
|
+
|
|
47
|
+
The payload is the customer resource exactly as the REST API returns it for your pinned API version. If your endpoint is pinned to a version before `2026-06-07`, the `email` field arrives as `billingEmail` — the same downgrade applied to `GET /customers` responses.
|
|
48
|
+
|
|
49
|
+
The event fires for every creation path: `POST /customers`, batch create, the SDKs, and the dashboard. Creating a customer with an `externalId` that already exists returns the existing customer and does NOT fire this event again.
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
---
|
|
2
|
+
lastModified: 2026-08-16
|
|
3
|
+
title: "customer.state_changed"
|
|
4
|
+
description: "Aggregate entitlement event — what can this customer access right now."
|
|
5
|
+
full: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
All webhook payloads follow a consistent top-level structure with event-specific data nested within the `data` object.
|
|
9
|
+
|
|
10
|
+
- `customerId` (string) — The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId.
|
|
11
|
+
- `trigger` (string) — What caused the transition. One of: subscription\_created, subscription\_activated, subscription\_canceled, plan\_change, past\_due, trial\_started, trial\_converted, trial\_expired, cancellation\_scheduled, cancellation\_revoked, seats\_updated, addon\_activated, addon\_deactivated, credits\_depleted, balance\_depleted, quota\_exceeded, plan\_access\_granted, plan\_access\_ended.
|
|
12
|
+
- `status` (string) — The customer's current subscription status, or "none" when no live subscription exists. Access is granted while trialing, active, or past\_due — past\_due is a permissive grace window during dunning.
|
|
13
|
+
- `subscriptionId` (string | null) — The live subscription ID, or null when status is none.
|
|
14
|
+
- `plan` (WebhookPlanRef | null) — The current plan (id and name), or null when status is none.
|
|
15
|
+
- `billingInterval` (string | null) — The current billing interval.
|
|
16
|
+
- `consumptionModel` (string | null) — The plan's consumption model: metered, credits, or balance.
|
|
17
|
+
- `features` (unknown\[]) — Current feature access, discriminated by type. Boolean features expose enabled; usage features expose model-specific consumption; seats and quota expose usage allowances.
|
|
18
|
+
- `seats` (WebhookSeatSummary\[]) — Summary of seats-type features: code, current, included, remaining, unlimited.
|
|
19
|
+
- `credits` (WebhookCreditsBalance | null) — For credits plans: planCredits, purchasedCredits, totalCredits. Null otherwise.
|
|
20
|
+
- `balance` (WebhookBalance | null) — For balance plans: currentBalance in rate scale (10000 = $1.00). Null otherwise.
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"event": "customer.state_changed",
|
|
25
|
+
"timestamp": "2026-06-23T14:30:00.000Z",
|
|
26
|
+
"organizationId": "8f14e45f-ceea-4e7a-9c3d-1c2b3a4d5e6f",
|
|
27
|
+
"mode": "live",
|
|
28
|
+
"apiVersion": "2026-07-31",
|
|
29
|
+
"data": {
|
|
30
|
+
"customerId": "user_123",
|
|
31
|
+
"trigger": "subscription_activated",
|
|
32
|
+
"status": "active",
|
|
33
|
+
"subscriptionId": "sub_1a2b3c4d",
|
|
34
|
+
"plan": {
|
|
35
|
+
"id": "pln_pro_monthly",
|
|
36
|
+
"name": "Pro"
|
|
37
|
+
},
|
|
38
|
+
"billingInterval": "monthly",
|
|
39
|
+
"consumptionModel": "metered",
|
|
40
|
+
"features": [
|
|
41
|
+
{
|
|
42
|
+
"code": "api_calls",
|
|
43
|
+
"name": "API Calls",
|
|
44
|
+
"unitName": "request",
|
|
45
|
+
"type": "usage",
|
|
46
|
+
"allowed": true,
|
|
47
|
+
"consumption": {
|
|
48
|
+
"model": "metered",
|
|
49
|
+
"period": {
|
|
50
|
+
"start": "2026-07-01T00:00:00.000Z",
|
|
51
|
+
"end": "2026-08-01T00:00:00.000Z"
|
|
52
|
+
},
|
|
53
|
+
"unitsUsed": 120,
|
|
54
|
+
"includedUnits": 1000,
|
|
55
|
+
"remainingUnits": 880,
|
|
56
|
+
"unlimited": false,
|
|
57
|
+
"overage": {
|
|
58
|
+
"enabled": true,
|
|
59
|
+
"units": 0,
|
|
60
|
+
"unitPrice": {
|
|
61
|
+
"amount": 50,
|
|
62
|
+
"currency": "usd",
|
|
63
|
+
"scale": 10000
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"code": "editors",
|
|
70
|
+
"name": "Editors",
|
|
71
|
+
"unitName": "seat",
|
|
72
|
+
"type": "seats",
|
|
73
|
+
"allowed": true,
|
|
74
|
+
"usage": {
|
|
75
|
+
"period": {
|
|
76
|
+
"start": "2026-07-01T00:00:00.000Z",
|
|
77
|
+
"end": "2026-08-01T00:00:00.000Z"
|
|
78
|
+
},
|
|
79
|
+
"unitsUsed": 3,
|
|
80
|
+
"includedUnits": 5,
|
|
81
|
+
"remainingUnits": 2,
|
|
82
|
+
"unlimited": false,
|
|
83
|
+
"overage": {
|
|
84
|
+
"enabled": false,
|
|
85
|
+
"units": 0
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"seats": [
|
|
91
|
+
{
|
|
92
|
+
"code": "editors",
|
|
93
|
+
"current": 3,
|
|
94
|
+
"included": 5,
|
|
95
|
+
"remaining": 2,
|
|
96
|
+
"unlimited": false
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"credits": null,
|
|
100
|
+
"balance": null
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## One event to sync access
|
|
106
|
+
|
|
107
|
+
Instead of handling every lifecycle event (`subscription.activated`, `subscription.canceled`, `trial.expired`, ...) to keep your access flags in sync, handle this single event. Every entitlement transition fires it with the customer's **current** state, computed at delivery time:
|
|
108
|
+
|
|
109
|
+
| trigger | When |
|
|
110
|
+
| ------------------------ | ------------------------------------------------------------------------------------------------------------ |
|
|
111
|
+
| `subscription_created` | A subscription was created (status `pending_payment` — no access yet). |
|
|
112
|
+
| `subscription_activated` | A payment confirmed the subscription. |
|
|
113
|
+
| `trial_started` | A trial began. |
|
|
114
|
+
| `trial_converted` | A trialing customer converted to paid via plan change. |
|
|
115
|
+
| `trial_expired` | A trial ran out and regular billing began. |
|
|
116
|
+
| `plan_change` | A plan change executed (immediate or scheduled). |
|
|
117
|
+
| `cancellation_scheduled` | A cancellation was scheduled — access continues until period end. |
|
|
118
|
+
| `cancellation_revoked` | A scheduled cancellation was reverted. |
|
|
119
|
+
| `subscription_canceled` | The subscription terminated — `status` becomes `none`. |
|
|
120
|
+
| `past_due` | A recurring payment failed — a grace window begins: usage and seats keep working, new purchases are blocked. |
|
|
121
|
+
| `seats_updated` | A customer's seat count changed. |
|
|
122
|
+
| `addon_activated` | An add-on was activated on the subscription. |
|
|
123
|
+
| `addon_deactivated` | An add-on was deactivated from the subscription. |
|
|
124
|
+
| `credits_depleted` | The subscription ran out of credits. |
|
|
125
|
+
| `balance_depleted` | The subscription ran out of prepaid balance. |
|
|
126
|
+
| `quota_exceeded` | Usage passed a feature's included quantity. |
|
|
127
|
+
| `plan_access_granted` | A Plan Grant moved the customer from Free to a paid plan without checkout. |
|
|
128
|
+
| `plan_access_ended` | A Plan Grant expired or was revoked; the payload contains the resulting current state. |
|
|
129
|
+
|
|
130
|
+
## Handling the payload
|
|
131
|
+
|
|
132
|
+
Use `status` as the access gate (`trialing` and `active` grant access), `features` for per-feature limits, and `credits`/`balance` for consumption headroom on credits/balance plans. The payload reflects the state at delivery time — if two transitions happen back to back, the later event always carries the final state, so processing events in `timestamp` order converges to the correct result.
|
|
133
|
+
|
|
134
|
+
See [Plan Grants](/docs/plan-grants) for the checkout-free paid-access lifecycle.
|