@commet/node 9.11.0 → 9.13.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 (47) hide show
  1. package/dist/index.d.mts +329 -507
  2. package/dist/index.d.ts +329 -507
  3. package/dist/index.js +12 -12
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +12 -12
  6. package/dist/index.mjs.map +1 -1
  7. package/docs/api-reference/addons.md +8 -15
  8. package/docs/api-reference/api-keys.md +1 -1
  9. package/docs/api-reference/credit-packs.md +2 -2
  10. package/docs/api-reference/customers.md +7 -19
  11. package/docs/api-reference/features.md +1 -1
  12. package/docs/api-reference/offers.md +9 -5
  13. package/docs/api-reference/payments.md +1 -1
  14. package/docs/api-reference/plan-groups.md +2 -2
  15. package/docs/api-reference/plans.md +28 -44
  16. package/docs/api-reference/portal.md +3 -8
  17. package/docs/api-reference/promo-codes.md +3 -3
  18. package/docs/api-reference/quota.md +6 -21
  19. package/docs/api-reference/subscriptions.md +38 -52
  20. package/docs/api-reference/test-clock.md +3 -8
  21. package/docs/api-reference/usage.md +6 -11
  22. package/docs/documentation/create-api-key.md +4 -2
  23. package/docs/documentation/error-handling.md +11 -0
  24. package/docs/documentation/invoicing/handle-failed-payments.md +12 -3
  25. package/docs/documentation/plans/add-ons.md +2 -0
  26. package/docs/documentation/plans/balance-and-top-ups.md +2 -0
  27. package/docs/documentation/plans/consumption-models.md +9 -1
  28. package/docs/documentation/plans/credit-packs.md +24 -6
  29. package/docs/documentation/plans/one-time-payments.md +1 -0
  30. package/docs/documentation/sales/offers.md +21 -3
  31. package/docs/documentation/sales/promo-codes.md +2 -2
  32. package/docs/documentation/sales/promotional-offers.md +2 -2
  33. package/docs/documentation/subscriptions/manage-subscriptions.md +3 -3
  34. package/docs/documentation/subscriptions/pay-in-advance.md +6 -4
  35. package/docs/documentation/subscriptions/plan-grants.md +22 -6
  36. package/docs/errors/already_has_active_subscription.md +1 -1
  37. package/docs/errors/charge_failed.md +1 -1
  38. package/docs/errors/no_payment_method.md +1 -1
  39. package/docs/errors/payment_failed.md +1 -1
  40. package/docs/errors/subscription_not_active.md +1 -1
  41. package/docs/errors/validation_error.md +1 -1
  42. package/docs/knowledge-base/how-do-discounts-work.md +20 -2
  43. package/docs/knowledge-base/what-happens-when-a-payment-fails.md +6 -6
  44. package/docs/schemas.md +13 -5
  45. package/docs/webhooks.md +16 -14
  46. package/docs/webhooks.openapi.json +85 -41
  47. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -127,7 +127,7 @@ type BillingInterval = "weekly" | "monthly" | "quarterly" | "semiannual" | "year
127
127
  type ConsumptionModel = "metered" | "credits" | "balance";
128
128
  type FeatureType = "boolean" | "usage" | "seats" | "quota";
129
129
  type InvoiceType = "recurring" | "overage" | "plan_change" | "adjustment" | "credit_purchase" | "balance_topup" | "addon_activation" | "one_time_payment" | "reactivation" | "resume" | "prepayment";
130
- type PaymentMethod = "card" | "oxxo" | "mercado_pago" | "google_pay" | "smartpix";
130
+ type PaymentMethod = "card" | "oxxo" | "mercado_pago" | "google_pay" | "smartpix" | "apple_pay" | "link";
131
131
  type PaymentProvider = "stripe" | "commet" | "dlocal";
132
132
  type SubPaymentMethod = "credit_card" | "debit_card" | "prepaid_card" | "bank_transfer" | "account_money";
133
133
  type SubscriptionStatus = "draft" | "pending_payment" | "trialing" | "active" | "past_due" | "paused" | "canceled";
@@ -193,8 +193,10 @@ interface BalanceAdjustment {
193
193
  }
194
194
  interface BalanceTopup {
195
195
  amount: number;
196
- /** `succeeded` when the payment was confirmed and the balance was added. `processing` when the payment method confirms later: the balance is added once the payment is confirmed, and nothing is added if it is declined. */
197
- status: "succeeded" | "processing";
196
+ /** `succeeded` when the payment was confirmed and the balance was added. `processing` when the payment method confirms later: the balance is added once the payment is confirmed, and nothing is added if it is declined. `requires_checkout` when `successUrl` was sent and the subscription has no saved payment method or the saved one was declined: the balance is added once the customer pays at `checkoutUrl`. */
197
+ status: "succeeded" | "processing" | "requires_checkout";
198
+ /** Hosted checkout where the customer pays the purchase and saves the payment method. Present only when `status` is `requires_checkout`. */
199
+ checkoutUrl?: string;
198
200
  object: "balance_topup";
199
201
  livemode: boolean;
200
202
  }
@@ -315,8 +317,10 @@ interface CreatedWebhook {
315
317
  }
316
318
  interface CreditGrant {
317
319
  credits: number;
318
- /** `succeeded` when the payment was confirmed and the credits were added. `processing` when the payment method confirms later: the credits are added once the payment is confirmed, and nothing is added if it is declined. */
319
- status: "succeeded" | "processing";
320
+ /** `succeeded` when the payment was confirmed and the credits were added. `processing` when the payment method confirms later: the credits are added once the payment is confirmed, and nothing is added if it is declined. `requires_checkout` when `successUrl` was sent and the subscription has no saved payment method or the saved one was declined: the credits are added once the customer pays at `checkoutUrl`. */
321
+ status: "succeeded" | "processing" | "requires_checkout";
322
+ /** Hosted checkout where the customer pays the purchase and saves the payment method. Present only when `status` is `requires_checkout`. */
323
+ checkoutUrl?: string;
320
324
  object: "credit_grant";
321
325
  livemode: boolean;
322
326
  }
@@ -845,6 +849,10 @@ interface Offer {
845
849
  startsAt: string | null;
846
850
  endsAt: string | null;
847
851
  active: boolean;
852
+ /** Plans the offer is limited to. Empty when it applies to any plan. */
853
+ planIds: Array<string>;
854
+ /** Billing interval the offer is limited to. Null when it applies to any interval. */
855
+ billingInterval: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | "one_time" | null;
848
856
  /** Integration that manages this record, or null when the merchant does. While an integration manages it, its terms change only in that integration and edits answer 409 managed_by_integration. */
849
857
  managedBy: ManagedBy;
850
858
  /** @format date-time */
@@ -1227,6 +1235,11 @@ type PlanChange = {
1227
1235
  };
1228
1236
  object: "plan_change";
1229
1237
  livemode: boolean;
1238
+ } | {
1239
+ outcome: "processing";
1240
+ invoiceId: string;
1241
+ object: "plan_change";
1242
+ livemode: boolean;
1230
1243
  };
1231
1244
  interface PlanDraft {
1232
1245
  /** Public plan draft ID. */
@@ -2011,9 +2024,11 @@ interface Subscription {
2011
2024
  }
2012
2025
  interface SubscriptionAddon {
2013
2026
  addonId: string;
2014
- /** `active` when the add-on is active. `processing` when the payment method confirms later: the add-on is activated once the payment is confirmed, and stays inactive if it is declined. */
2015
- status: "active" | "processing";
2027
+ /** `active` when the add-on is active. `processing` when the payment method confirms later: the add-on is activated once the payment is confirmed, and stays inactive if it is declined. `requires_checkout` when `successUrl` was sent and the subscription has no saved payment method or the saved one was declined: the add-on is activated once the customer pays at `checkoutUrl`. */
2028
+ status: "active" | "processing" | "requires_checkout";
2016
2029
  proratedCharge: number;
2030
+ /** Hosted checkout where the customer pays the purchase and saves the payment method. Present only when `status` is `requires_checkout`. */
2031
+ checkoutUrl?: string;
2017
2032
  object: "subscription_addon";
2018
2033
  livemode: boolean;
2019
2034
  }
@@ -2271,7 +2286,7 @@ interface Transaction {
2271
2286
  currency: string;
2272
2287
  /** The payment provider the charge was routed to: stripe, commet, or dlocal. */
2273
2288
  provider: PaymentProvider;
2274
- /** The method used for this charge: card, oxxo, or mercado_pago. Null when unknown. */
2289
+ /** The method used for this charge: card, apple_pay, google_pay, link, smartpix, oxxo or mercado_pago. Null when unknown. */
2275
2290
  paymentMethod: PaymentMethod | null;
2276
2291
  /** The source of funds for this charge, when reported by the provider. Null when unavailable or unknown. */
2277
2292
  subPaymentMethod: SubPaymentMethod | null;
@@ -2318,7 +2333,7 @@ interface TransactionListItem {
2318
2333
  currency: string;
2319
2334
  /** The payment provider the charge was routed to: stripe, commet, or dlocal. */
2320
2335
  provider: PaymentProvider;
2321
- /** The method used for this charge: card, oxxo, or mercado_pago. Null when unknown. */
2336
+ /** The method used for this charge: card, apple_pay, google_pay, link, smartpix, oxxo or mercado_pago. Null when unknown. */
2322
2337
  paymentMethod: PaymentMethod | null;
2323
2338
  /** The source of funds for this charge, when reported by the provider. Null when unavailable or unknown. */
2324
2339
  subPaymentMethod: SubPaymentMethod | null;
@@ -2664,9 +2679,11 @@ interface UpdateAddonParams {
2664
2679
  name?: string;
2665
2680
  description?: string;
2666
2681
  basePrice?: number;
2682
+ /** Only on a metered add-on. */
2667
2683
  includedUnits?: number;
2684
+ /** Only on a metered or balance add-on. */
2668
2685
  overageRate?: number;
2669
- /** Plans that sell the add-on, replacing the current ones. Empty means every plan; omitted keeps them. Removing a plan is rejected with addon_has_activations while a subscription of that plan has the add-on active. */
2686
+ /** Plans that sell the add-on, replacing the current ones. Empty means every plan; omitted keeps them. Removing a plan is rejected with addon_has_activations while a subscription of that plan has the add-on active. Each entry is a plan ID (`pln_…`) or a plan code. */
2670
2687
  planIds?: Array<string>;
2671
2688
  }
2672
2689
  interface DeleteAddonParams {
@@ -2676,43 +2693,21 @@ interface ListAddonsParams {
2676
2693
  cursor?: string;
2677
2694
  limit?: number;
2678
2695
  }
2679
- type CreateAddonParams = {
2680
- name: string;
2681
- description?: string;
2682
- basePrice: number;
2683
- featureId: string;
2684
- /** Plans that sell the add-on. Omitted or empty, every plan sells it. Plans created later sell it too. */
2685
- planIds?: Array<string>;
2686
- consumptionModel: "boolean";
2687
- } | {
2688
- name: string;
2689
- description?: string;
2690
- basePrice: number;
2691
- featureId: string;
2692
- /** Plans that sell the add-on. Omitted or empty, every plan sells it. Plans created later sell it too. */
2693
- planIds?: Array<string>;
2694
- consumptionModel: "metered";
2695
- includedUnits: number;
2696
- overageRate: number;
2697
- } | {
2698
- name: string;
2699
- description?: string;
2700
- basePrice: number;
2701
- featureId: string;
2702
- /** Plans that sell the add-on. Omitted or empty, every plan sells it. Plans created later sell it too. */
2703
- planIds?: Array<string>;
2704
- consumptionModel: "credits";
2705
- creditCost: number;
2706
- } | {
2696
+ interface CreateAddonParams {
2697
+ consumptionModel: "boolean" | "metered" | "credits" | "balance";
2707
2698
  name: string;
2708
2699
  description?: string;
2709
2700
  basePrice: number;
2710
2701
  featureId: string;
2711
- /** Plans that sell the add-on. Omitted or empty, every plan sells it. Plans created later sell it too. */
2702
+ /** Plans that sell the add-on. Omitted or empty, every plan sells it. Plans created later sell it too. Each entry is a plan ID (`pln_…`) or a plan code. */
2712
2703
  planIds?: Array<string>;
2713
- consumptionModel: "balance";
2714
- overageRate: number;
2715
- };
2704
+ /** Required when `consumptionModel` is `metered`. Only when `consumptionModel` is `metered`. */
2705
+ includedUnits?: number;
2706
+ /** Required when `consumptionModel` is `metered` or `balance`. Only when `consumptionModel` is `metered` or `balance`. */
2707
+ overageRate?: number;
2708
+ /** Required when `consumptionModel` is `credits`. Only when `consumptionModel` is `credits`. */
2709
+ creditCost?: number;
2710
+ }
2716
2711
  declare class AddonsResource {
2717
2712
  private httpClient;
2718
2713
  constructor(httpClient: CommetHTTPClient);
@@ -2751,25 +2746,44 @@ interface CreateApiKeyParams {
2751
2746
  name: string;
2752
2747
  expiresInDays?: number;
2753
2748
  permissions?: {
2754
- customer?: Array<"read"> | ["read", "write"] | ["write", "read"];
2755
- subscription?: Array<"read"> | ["read", "write"] | ["write", "read"];
2756
- invoice?: Array<"read"> | ["read", "write"] | ["write", "read"];
2757
- usage?: Array<"read"> | ["read", "write"] | ["write", "read"];
2758
- seat?: Array<"read"> | ["read", "write"] | ["write", "read"];
2759
- plan?: Array<"read"> | ["read", "write"] | ["write", "read"];
2760
- plan_group?: Array<"read"> | ["read", "write"] | ["write", "read"];
2761
- feature?: Array<"read"> | ["read", "write"] | ["write", "read"];
2762
- addon?: Array<"read"> | ["read", "write"] | ["write", "read"];
2763
- credit_pack?: Array<"read"> | ["read", "write"] | ["write", "read"];
2764
- offer?: Array<"read"> | ["read", "write"] | ["write", "read"];
2765
- promo_code?: Array<"read"> | ["read", "write"] | ["write", "read"];
2766
- market_group?: Array<"read"> | ["read", "write"] | ["write", "read"];
2767
- payment?: Array<"read"> | ["read", "write"] | ["write", "read"];
2768
- transaction?: Array<"read"> | ["read", "write"] | ["write", "read"];
2769
- payout?: Array<"read"> | ["read", "write"] | ["write", "read"];
2770
- test_clock?: Array<"read"> | ["read", "write"] | ["write", "read"];
2771
- organization?: Array<"read"> | ["read", "write"] | ["write", "read"];
2772
- api_key?: Array<"read"> | ["read", "write"] | ["write", "read"];
2749
+ /** Empty for no access, `read` to read, or `read` and `write`, in either order, to read and write. `write` requires `read`. */
2750
+ customer?: Array<"read" | "write">;
2751
+ /** Empty for no access, `read` to read, or `read` and `write`, in either order, to read and write. `write` requires `read`. */
2752
+ subscription?: Array<"read" | "write">;
2753
+ /** Empty for no access, `read` to read, or `read` and `write`, in either order, to read and write. `write` requires `read`. */
2754
+ invoice?: Array<"read" | "write">;
2755
+ /** Empty for no access, `read` to read, or `read` and `write`, in either order, to read and write. `write` requires `read`. */
2756
+ usage?: Array<"read" | "write">;
2757
+ /** Empty for no access, `read` to read, or `read` and `write`, in either order, to read and write. `write` requires `read`. */
2758
+ seat?: Array<"read" | "write">;
2759
+ /** Empty for no access, `read` to read, or `read` and `write`, in either order, to read and write. `write` requires `read`. */
2760
+ plan?: Array<"read" | "write">;
2761
+ /** Empty for no access, `read` to read, or `read` and `write`, in either order, to read and write. `write` requires `read`. */
2762
+ plan_group?: Array<"read" | "write">;
2763
+ /** Empty for no access, `read` to read, or `read` and `write`, in either order, to read and write. `write` requires `read`. */
2764
+ feature?: Array<"read" | "write">;
2765
+ /** Empty for no access, `read` to read, or `read` and `write`, in either order, to read and write. `write` requires `read`. */
2766
+ addon?: Array<"read" | "write">;
2767
+ /** Empty for no access, `read` to read, or `read` and `write`, in either order, to read and write. `write` requires `read`. */
2768
+ credit_pack?: Array<"read" | "write">;
2769
+ /** Empty for no access, `read` to read, or `read` and `write`, in either order, to read and write. `write` requires `read`. */
2770
+ offer?: Array<"read" | "write">;
2771
+ /** Empty for no access, `read` to read, or `read` and `write`, in either order, to read and write. `write` requires `read`. */
2772
+ promo_code?: Array<"read" | "write">;
2773
+ /** Empty for no access, `read` to read, or `read` and `write`, in either order, to read and write. `write` requires `read`. */
2774
+ market_group?: Array<"read" | "write">;
2775
+ /** Empty for no access, `read` to read, or `read` and `write`, in either order, to read and write. `write` requires `read`. */
2776
+ payment?: Array<"read" | "write">;
2777
+ /** Empty for no access, `read` to read, or `read` and `write`, in either order, to read and write. `write` requires `read`. */
2778
+ transaction?: Array<"read" | "write">;
2779
+ /** Empty for no access, `read` to read, or `read` and `write`, in either order, to read and write. `write` requires `read`. */
2780
+ payout?: Array<"read" | "write">;
2781
+ /** Empty for no access, `read` to read, or `read` and `write`, in either order, to read and write. `write` requires `read`. */
2782
+ test_clock?: Array<"read" | "write">;
2783
+ /** Empty for no access, `read` to read, or `read` and `write`, in either order, to read and write. `write` requires `read`. */
2784
+ organization?: Array<"read" | "write">;
2785
+ /** Empty for no access, `read` to read, or `read` and `write`, in either order, to read and write. `write` requires `read`. */
2786
+ api_key?: Array<"read" | "write">;
2773
2787
  };
2774
2788
  }
2775
2789
  declare class ApiKeysResource {
@@ -2795,7 +2809,7 @@ interface UpdateCreditPackParams {
2795
2809
  credits?: number;
2796
2810
  price?: number;
2797
2811
  isActive?: boolean;
2798
- /** Plans that sell the credit pack, replacing the current ones. Empty means every plan; omitted keeps them. */
2812
+ /** Plans that sell the credit pack, replacing the current ones. Empty means every plan; omitted keeps them. Each entry is a plan ID (`pln_…`) or a plan code. */
2799
2813
  planIds?: Array<string>;
2800
2814
  }
2801
2815
  interface DeleteCreditPackParams {
@@ -2807,7 +2821,7 @@ interface CreateCreditPackParams {
2807
2821
  credits: number;
2808
2822
  price: number;
2809
2823
  isActive?: boolean;
2810
- /** Plans that sell the credit pack. Omitted or empty, every plan sells it. Plans created later sell it too. */
2824
+ /** Plans that sell the credit pack. Omitted or empty, every plan sells it. Plans created later sell it too. Each entry is a plan ID (`pln_…`) or a plan code. */
2811
2825
  planIds?: Array<string>;
2812
2826
  }
2813
2827
  declare class CreditPacksResource {
@@ -2848,50 +2862,37 @@ interface RevokePlanGrantParams {
2848
2862
  grantId: string;
2849
2863
  reason: string;
2850
2864
  }
2851
- type UpdatePlanGrantParams = {
2852
- id: string;
2853
- grantId: string;
2854
- reason: string;
2855
- duration: "cycles";
2856
- durationCycles: number;
2857
- } | {
2858
- id: string;
2859
- grantId: string;
2860
- reason: string;
2861
- duration: "until_date";
2862
- /** @format date-time */
2863
- expiresAt: string;
2864
- } | {
2865
+ interface UpdatePlanGrantParams {
2865
2866
  id: string;
2866
2867
  grantId: string;
2868
+ duration: "cycles" | "until_date" | "until_revoked";
2867
2869
  reason: string;
2868
- duration: "until_revoked";
2869
- };
2870
+ /** Required when `duration` is `cycles`. Ignored when `duration` is `until_date` or `until_revoked`. */
2871
+ durationCycles?: number;
2872
+ /**
2873
+ * Required when `duration` is `until_date`. Ignored when `duration` is `cycles` or `until_revoked`.
2874
+ * @format date-time
2875
+ */
2876
+ expiresAt?: string;
2877
+ }
2870
2878
  interface ListPlanGrantsParams {
2871
2879
  id: string;
2872
2880
  }
2873
- type CreatePlanGrantParams = {
2874
- id: string;
2875
- subscriptionId: string;
2876
- planId: string;
2877
- reason: string;
2878
- duration: "cycles";
2879
- durationCycles: number;
2880
- } | {
2881
- id: string;
2882
- subscriptionId: string;
2883
- planId: string;
2884
- reason: string;
2885
- duration: "until_date";
2886
- /** @format date-time */
2887
- expiresAt: string;
2888
- } | {
2881
+ interface CreatePlanGrantParams {
2889
2882
  id: string;
2883
+ duration: "cycles" | "until_date" | "until_revoked";
2890
2884
  subscriptionId: string;
2885
+ /** The plan's ID (`pln_…`) or its code. */
2891
2886
  planId: string;
2892
2887
  reason: string;
2893
- duration: "until_revoked";
2894
- };
2888
+ /** Required when `duration` is `cycles`. Ignored when `duration` is `until_date` or `until_revoked`. */
2889
+ durationCycles?: number;
2890
+ /**
2891
+ * Required when `duration` is `until_date`. Ignored when `duration` is `cycles` or `until_revoked`.
2892
+ * @format date-time
2893
+ */
2894
+ expiresAt?: string;
2895
+ }
2895
2896
  interface GetCustomerParams {
2896
2897
  id: string;
2897
2898
  }
@@ -3058,7 +3059,7 @@ declare class FeaturesResource {
3058
3059
  get(params: GetFeatureParams, options?: RequestOptions): Promise<Feature>;
3059
3060
  /** Update a feature's name, description, or unit name. At least one field must be provided. */
3060
3061
  update(params: UpdateFeatureParams, options?: RequestOptions): Promise<Feature>;
3061
- /** Delete a feature. Fails if the feature is attached to active plans or has an active add-on. */
3062
+ /** Delete a feature. Fails while a plan's current version, a running experiment or a draft includes it, or while it has an active add-on. Subscribers whose plan version includes it keep it, and its code can be used by a new feature right away. */
3062
3063
  delete(params: DeleteFeatureParams, options?: RequestOptions): Promise<DeletedObject>;
3063
3064
  /** List every feature defined in the organization. This is the organization's feature catalog (definitions), not a customer's feature access. */
3064
3065
  list(): Promise<{
@@ -3165,28 +3166,21 @@ interface UpdateOfferParams {
3165
3166
  id: string;
3166
3167
  name: string;
3167
3168
  phases: Array<{
3168
- type: "percentage";
3169
+ type: "percentage" | "amount_off" | "fixed_price";
3170
+ /** Cycles the phase lasts. `null` for a phase that never ends, which must be the last phase. */
3169
3171
  durationCycles: number | null;
3170
3172
  /** Unit the phase duration is counted in. Only a fixed-price phase may set it, because its amount is declared rather than derived from the plan. Defaults to the plan's own billing interval. */
3171
3173
  durationInterval?: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | null;
3172
- /** Discount in basis points. 5000 means 50%. */
3173
- percentage: number;
3174
- } | {
3175
- type: "amount_off";
3176
- durationCycles: number | null;
3177
- /** Unit the phase duration is counted in. Only a fixed-price phase may set it, because its amount is declared rather than derived from the plan. Defaults to the plan's own billing interval. */
3178
- durationInterval?: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | null;
3179
- amounts: Array<{
3174
+ /** Discount in basis points. 5000 means 50%. Required when `type` is `percentage`. Ignored when `type` is `amount_off` or `fixed_price`. */
3175
+ percentage?: number;
3176
+ /** Each currency at most once, including a USD value. Each amount off is greater than 0. Required when `type` is `amount_off`. Ignored when `type` is `percentage` or `fixed_price`. */
3177
+ amounts?: Array<{
3180
3178
  currency: string;
3181
3179
  /** Amount in the currency's minor unit (for example, cents for USD). */
3182
3180
  amount: number;
3183
3181
  }>;
3184
- } | {
3185
- type: "fixed_price";
3186
- durationCycles: number | null;
3187
- /** Unit the phase duration is counted in. Only a fixed-price phase may set it, because its amount is declared rather than derived from the plan. Defaults to the plan's own billing interval. */
3188
- durationInterval?: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | null;
3189
- prices: Array<{
3182
+ /** Each currency at most once, including a USD value. Each price meets its currency's minimum charge, unless every price is 0 (a gifted phase). Required when `type` is `fixed_price`. Ignored when `type` is `percentage` or `amount_off`. */
3183
+ prices?: Array<{
3190
3184
  currency: string;
3191
3185
  /** Amount in the currency's minor unit (for example, cents for USD). */
3192
3186
  amount: number;
@@ -3194,8 +3188,13 @@ interface UpdateOfferParams {
3194
3188
  }>;
3195
3189
  metadata?: Record<string, unknown>;
3196
3190
  startsAt?: string | null;
3191
+ /** After `startsAt`. */
3197
3192
  endsAt?: string | null;
3198
3193
  active?: boolean;
3194
+ /** Plans the offer is limited to: it cannot be applied to a subscription on another plan, and an applied offer ends when the subscriber changes to one. An empty list removes the limit. Omit to keep the current limit. Each entry is a plan ID (`pln_…`) or a plan code. */
3195
+ planIds?: Array<string>;
3196
+ /** Billing interval the offer is limited to: it cannot be applied to a subscription on another interval, and an applied offer ends when the subscriber changes to one. Null removes the limit. Omit to keep the current limit. */
3197
+ billingInterval?: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | "one_time" | null;
3199
3198
  }
3200
3199
  interface DeleteOfferParams {
3201
3200
  id: string;
@@ -3208,28 +3207,21 @@ interface ListOffersParams {
3208
3207
  interface CreateOfferParams {
3209
3208
  name: string;
3210
3209
  phases: Array<{
3211
- type: "percentage";
3210
+ type: "percentage" | "amount_off" | "fixed_price";
3211
+ /** Cycles the phase lasts. `null` for a phase that never ends, which must be the last phase. */
3212
3212
  durationCycles: number | null;
3213
3213
  /** Unit the phase duration is counted in. Only a fixed-price phase may set it, because its amount is declared rather than derived from the plan. Defaults to the plan's own billing interval. */
3214
3214
  durationInterval?: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | null;
3215
- /** Discount in basis points. 5000 means 50%. */
3216
- percentage: number;
3217
- } | {
3218
- type: "amount_off";
3219
- durationCycles: number | null;
3220
- /** Unit the phase duration is counted in. Only a fixed-price phase may set it, because its amount is declared rather than derived from the plan. Defaults to the plan's own billing interval. */
3221
- durationInterval?: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | null;
3222
- amounts: Array<{
3215
+ /** Discount in basis points. 5000 means 50%. Required when `type` is `percentage`. Ignored when `type` is `amount_off` or `fixed_price`. */
3216
+ percentage?: number;
3217
+ /** Each currency at most once, including a USD value. Each amount off is greater than 0. Required when `type` is `amount_off`. Ignored when `type` is `percentage` or `fixed_price`. */
3218
+ amounts?: Array<{
3223
3219
  currency: string;
3224
3220
  /** Amount in the currency's minor unit (for example, cents for USD). */
3225
3221
  amount: number;
3226
3222
  }>;
3227
- } | {
3228
- type: "fixed_price";
3229
- durationCycles: number | null;
3230
- /** Unit the phase duration is counted in. Only a fixed-price phase may set it, because its amount is declared rather than derived from the plan. Defaults to the plan's own billing interval. */
3231
- durationInterval?: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | null;
3232
- prices: Array<{
3223
+ /** Each currency at most once, including a USD value. Each price meets its currency's minimum charge, unless every price is 0 (a gifted phase). Required when `type` is `fixed_price`. Ignored when `type` is `percentage` or `amount_off`. */
3224
+ prices?: Array<{
3233
3225
  currency: string;
3234
3226
  /** Amount in the currency's minor unit (for example, cents for USD). */
3235
3227
  amount: number;
@@ -3237,8 +3229,13 @@ interface CreateOfferParams {
3237
3229
  }>;
3238
3230
  metadata?: Record<string, unknown>;
3239
3231
  startsAt?: string | null;
3232
+ /** After `startsAt`. */
3240
3233
  endsAt?: string | null;
3241
3234
  active?: boolean;
3235
+ /** Plans the offer is limited to: it cannot be applied to a subscription on another plan, and an applied offer ends when the subscriber changes to one. An empty list removes the limit. Omit to keep the current limit. Each entry is a plan ID (`pln_…`) or a plan code. */
3236
+ planIds?: Array<string>;
3237
+ /** Billing interval the offer is limited to: it cannot be applied to a subscription on another interval, and an applied offer ends when the subscriber changes to one. Null removes the limit. Omit to keep the current limit. */
3238
+ billingInterval?: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | "one_time" | null;
3242
3239
  }
3243
3240
  declare class OffersResource {
3244
3241
  private httpClient;
@@ -3256,7 +3253,7 @@ declare class OffersResource {
3256
3253
  hasMore: boolean;
3257
3254
  nextCursor?: string;
3258
3255
  }>;
3259
- /** Create reusable offer terms without assigning a plan, price, eligibility rule, or distribution channel. */
3256
+ /** Create reusable offer terms. An offer applies to any plan and billing interval unless `planIds` or `billingInterval` limit it. */
3260
3257
  create(params: CreateOfferParams, options?: RequestOptions): Promise<Offer>;
3261
3258
  }
3262
3259
 
@@ -3279,6 +3276,7 @@ interface ListPaymentsParams {
3279
3276
  customerId?: string;
3280
3277
  }
3281
3278
  interface CreatePaymentParams {
3279
+ /** In the currency's minor unit, at least the currency's minimum charge. */
3282
3280
  amount: number;
3283
3281
  currency: string;
3284
3282
  customerId?: string;
@@ -3337,10 +3335,12 @@ interface RemovePlanFromGroupParams {
3337
3335
  }
3338
3336
  interface ReorderPlansInGroupParams {
3339
3337
  id: string;
3338
+ /** Each entry is a plan ID (`pln_…`) or a plan code. */
3340
3339
  planIds: Array<string>;
3341
3340
  }
3342
3341
  interface AddPlanToGroupParams {
3343
3342
  id: string;
3343
+ /** The plan's ID (`pln_…`) or its code. */
3344
3344
  planId: string;
3345
3345
  sortOrder?: number;
3346
3346
  }
@@ -3391,14 +3391,14 @@ declare class PlanGroupsResource {
3391
3391
  create(params: CreatePlanGroupParams, options?: RequestOptions): Promise<PlanGroup>;
3392
3392
  }
3393
3393
 
3394
- type PublishPlanDraftParams = {
3394
+ interface PublishPlanDraftParams {
3395
3395
  id: string;
3396
3396
  draftId: string;
3397
- /** current sells the draft to every new buyer. */
3398
- publishAs: "current";
3399
- /** What happens to subscribers of earlier versions: keep them, move them at their next renewal, or move them now (features and balance change today, the price at renewal). Nobody moves unless every one of them fits or has a change below. */
3397
+ /** current sells the draft to every new buyer. experiment starts an experiment with experimentCode, sold with planCode plan:code. Starting an experiment moves nobody, so it takes no move or changes. experiment_version publishes the next version of the experiment the draft started from. */
3398
+ publishAs: "current" | "experiment" | "experiment_version";
3399
+ /** What happens to subscribers of earlier versions: keep them, move them at their next renewal, or move them now (features and balance change today, the price at renewal). Nobody moves unless every one of them fits or has a change below. Only when `publishAs` is `current` or `experiment_version`. Defaults to `keep` when `publishAs` is `current` or `experiment_version`. */
3400
3400
  move?: "keep" | "period_end" | "now";
3401
- /** Per-subscriber changes that make each one fit, applied at its renewal. */
3401
+ /** Per-subscriber changes that make each one fit, applied at its renewal. Only when `publishAs` is `current` or `experiment_version`. Defaults to `[]` when `publishAs` is `current` or `experiment_version`. */
3402
3402
  changes?: Array<{
3403
3403
  subscriptionId: string;
3404
3404
  /** Leave this subscriber on its version. */
@@ -3411,40 +3411,11 @@ type PublishPlanDraftParams = {
3411
3411
  /** usd to charge it in USD from its renewal when the version does not sell the currency it pays, or the USD price of its country. */
3412
3412
  currency?: string;
3413
3413
  }>;
3414
+ /** The experiment's own code, after the plan's code. Required when `publishAs` is `experiment`. Ignored when `publishAs` is `current` or `experiment_version`. */
3415
+ experimentCode?: string;
3414
3416
  /** Check everything without publishing. */
3415
3417
  preview?: boolean;
3416
- } | {
3417
- id: string;
3418
- draftId: string;
3419
- /** experiment starts an experiment with experimentCode, sold with planCode plan:code. Starting an experiment moves nobody, so it takes no move or changes. */
3420
- publishAs: "experiment";
3421
- /** The experiment's own code, after the plan's code. */
3422
- experimentCode: string;
3423
- /** Check everything without publishing. */
3424
- preview?: boolean;
3425
- } | {
3426
- id: string;
3427
- draftId: string;
3428
- /** experiment_version publishes the next version of the experiment the draft started from. */
3429
- publishAs: "experiment_version";
3430
- /** What happens to subscribers of earlier versions: keep them, move them at their next renewal, or move them now (features and balance change today, the price at renewal). Nobody moves unless every one of them fits or has a change below. */
3431
- move?: "keep" | "period_end" | "now";
3432
- /** Per-subscriber changes that make each one fit, applied at its renewal. */
3433
- changes?: Array<{
3434
- subscriptionId: string;
3435
- /** Leave this subscriber on its version. */
3436
- keepOnVersion?: true;
3437
- billingInterval?: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly";
3438
- /** Lower its seats to the version's limit at renewal. */
3439
- seatLimit?: true;
3440
- /** Add-ons it stops paying at renewal. */
3441
- removeAddonIds?: Array<string>;
3442
- /** usd to charge it in USD from its renewal when the version does not sell the currency it pays, or the USD price of its country. */
3443
- currency?: string;
3444
- }>;
3445
- /** Check everything without publishing. */
3446
- preview?: boolean;
3447
- };
3418
+ }
3448
3419
  interface GetPlanDraftParams {
3449
3420
  id: string;
3450
3421
  draftId: string;
@@ -3475,14 +3446,12 @@ interface UpdatePlanDraftParams {
3475
3446
  exchangeRate?: number | null;
3476
3447
  prices: Array<{
3477
3448
  billingInterval: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | "one_time";
3478
- /** The price set by hand, in the currency's minor unit. */
3479
- price: number;
3480
- /** The balance included each period in this country, in the currency's minor unit. Required when the plan's price includes a balance. */
3449
+ /** The price set by hand, in the currency's minor unit. Required unless `followBase` is sent. Ignored when `followBase` is true and `price` or `includedBalance` is invalid. */
3450
+ price?: number;
3451
+ /** The balance included each period in this country, in the currency's minor unit. Required when the plan's price includes a balance. Ignored when `followBase` is true and `price` or `includedBalance` is invalid. Ignored unless `price` is sent. */
3481
3452
  includedBalance?: number;
3482
- } | {
3483
- billingInterval: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | "one_time";
3484
- /** Follow the USD base at the exchange rate. */
3485
- followBase: true;
3453
+ /** Follow the USD base at the exchange rate. Required unless `price` is sent. Ignored when `price` is sent, unless it is true and `price` or `includedBalance` is invalid. */
3454
+ followBase?: true;
3486
3455
  }>;
3487
3456
  /** Smallest balance top-up in this country, in the currency's minor unit. Null follows the USD minimum at the exchange rate; left out keeps it. */
3488
3457
  topUpMinimum?: number | null;
@@ -3493,22 +3462,18 @@ interface UpdatePlanDraftParams {
3493
3462
  /** What the country pays for each add-on the draft sells. Left out keeps the country's add-on prices; sent, it replaces them, and add-ons not listed follow the USD price. */
3494
3463
  addonPrices?: Array<{
3495
3464
  addonId: string;
3496
- /** The add-on's price set by hand, in the currency's minor unit. */
3497
- price: number;
3498
- } | {
3499
- addonId: string;
3500
- /** Follow the add-on's USD price at the exchange rate. */
3501
- followBase: true;
3465
+ /** The add-on's price set by hand, in the currency's minor unit. Required unless `followBase` is sent. Ignored when `followBase` is true and `price` is invalid. */
3466
+ price?: number;
3467
+ /** Follow the add-on's USD price at the exchange rate. Required unless `price` is sent. Ignored when `price` is sent, unless it is true and `price` is invalid. */
3468
+ followBase?: true;
3502
3469
  }>;
3503
3470
  /** What the country pays for each credit pack the draft sells. Left out keeps the country's pack prices; sent, it replaces them, and packs not listed follow the USD price. */
3504
3471
  creditPackPrices?: Array<{
3505
3472
  creditPackId: string;
3506
- /** The pack's price set by hand, in the currency's minor unit. */
3507
- price: number;
3508
- } | {
3509
- creditPackId: string;
3510
- /** Follow the pack's USD price at the exchange rate. */
3511
- followBase: true;
3473
+ /** The pack's price set by hand, in the currency's minor unit. Required unless `followBase` is sent. Ignored when `followBase` is true and `price` is invalid. */
3474
+ price?: number;
3475
+ /** Follow the pack's USD price at the exchange rate. Required unless `price` is sent. Ignored when `price` is sent, unless it is true and `price` is invalid. */
3476
+ followBase?: true;
3512
3477
  }>;
3513
3478
  }>;
3514
3479
  /** Credit or balance rules; fields left out stay as they are. */
@@ -3641,7 +3606,9 @@ interface UpdatePlanFeatureParams {
3641
3606
  id: string;
3642
3607
  featureId: string;
3643
3608
  enabled?: boolean;
3609
+ /** Must be 0 when `unlimited` is true, sent or already set on the plan feature. */
3644
3610
  includedAmount?: number;
3611
+ /** When true, `includedAmount` must be 0, sent or already set on the plan feature. */
3645
3612
  unlimited?: boolean;
3646
3613
  overage?: {
3647
3614
  enabled?: boolean;
@@ -3655,16 +3622,22 @@ interface RemovePlanFeatureParams {
3655
3622
  }
3656
3623
  interface AddPlanFeatureParams {
3657
3624
  id: string;
3625
+ /** The feature's ID (`ftr_…`) or its code. */
3658
3626
  featureId: string;
3659
3627
  enabled?: boolean;
3628
+ /** Must be 0 when `unlimited` is true. */
3660
3629
  includedAmount?: number;
3630
+ /** When true, `includedAmount` must be 0. */
3661
3631
  unlimited?: boolean;
3662
3632
  overage?: {
3663
3633
  enabled?: boolean;
3634
+ /** Must be above 0 when `enabled` is true, `pricingMode` is `fixed` and the plan is metered or balance. */
3664
3635
  unitPrice?: number;
3665
3636
  };
3637
+ /** Above 0 only on a credits plan. */
3666
3638
  creditsPerUnit?: number | null;
3667
3639
  pricingMode?: "fixed" | "ai_model";
3640
+ /** Required when `overage.enabled` is true, `pricingMode` is `ai_model` and the plan is metered or balance. */
3668
3641
  margin?: number | null;
3669
3642
  }
3670
3643
  interface CancelPlanMoveParams {
@@ -3683,33 +3656,12 @@ interface CancelPlanMoveSubscriptionParams {
3683
3656
  interface ListPlanMovesParams {
3684
3657
  id: string;
3685
3658
  }
3686
- type CreatePlanMoveParams = {
3687
- id: string;
3688
- /** Public IDs of the subscriptions to move. */
3689
- subscriptionIds: Array<string>;
3690
- /** The version subscribers move to. */
3691
- toVersionId: string;
3692
- /** now changes features and the included amount today and the price at renewal; period_end moves each subscriber at its next renewal. */
3693
- effective: "now" | "period_end";
3694
- /** Per-subscriber changes that make each one fit, applied at its renewal. */
3695
- changes?: Array<{
3696
- subscriptionId: string;
3697
- /** Leave this subscriber on its version. */
3698
- keepOnVersion?: true;
3699
- billingInterval?: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly";
3700
- /** Lower its seats to the version's limit at renewal. */
3701
- seatLimit?: true;
3702
- /** Add-ons it stops paying at renewal. */
3703
- removeAddonIds?: Array<string>;
3704
- /** usd to charge it in USD from its renewal when the version does not sell the currency it pays, or the USD price of its country. */
3705
- currency?: string;
3706
- }>;
3707
- /** Check every subscriber without moving anyone. */
3708
- preview?: boolean;
3709
- } | {
3659
+ interface CreatePlanMoveParams {
3710
3660
  id: string;
3711
- /** Move every active, trialing and past due subscription on this version of the plan. */
3712
- fromVersionId: string;
3661
+ /** Public IDs of the subscriptions to move. Required unless `fromVersionId` is sent. Cannot be combined with `fromVersionId`. */
3662
+ subscriptionIds?: Array<string>;
3663
+ /** Move every active, trialing and past due subscription on this version of the plan. Another version than `toVersionId`. Required unless `subscriptionIds` is sent. Cannot be combined with `subscriptionIds`. */
3664
+ fromVersionId?: string;
3713
3665
  /** The version subscribers move to. */
3714
3666
  toVersionId: string;
3715
3667
  /** now changes features and the included amount today and the price at renewal; period_end moves each subscriber at its next renewal. */
@@ -3729,7 +3681,7 @@ type CreatePlanMoveParams = {
3729
3681
  }>;
3730
3682
  /** Check every subscriber without moving anyone. */
3731
3683
  preview?: boolean;
3732
- };
3684
+ }
3733
3685
  interface KeepPlanSubscriberOnVersionParams {
3734
3686
  id: string;
3735
3687
  subscriptionId: string;
@@ -3776,17 +3728,23 @@ interface DeletePlanPriceParams {
3776
3728
  id: string;
3777
3729
  priceId: string;
3778
3730
  }
3779
- type AddPlanPriceParams = {
3731
+ interface AddPlanPriceParams {
3780
3732
  id: string;
3781
3733
  billingInterval: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | "one_time";
3782
3734
  metadata?: Record<string, unknown>;
3783
- price: number;
3735
+ /** The base price, in the currency's minor unit. Required unless `inheritsFromPriceId` is sent. Cannot be combined with `inheritsFromPriceId`. */
3736
+ price?: number;
3737
+ /** Cannot be combined with `inheritsFromPriceId`. */
3784
3738
  trialDays?: number;
3785
- /** Set to false so the price's free trial starts without a payment method. Requires trialDays on the price. */
3739
+ /** Set to false so the price's free trial starts without a payment method. Requires trialDays on the price. Cannot be combined with `inheritsFromPriceId`. */
3786
3740
  trialRequiresPaymentMethod?: boolean;
3741
+ /** Cannot be combined with `inheritsFromPriceId`. */
3787
3742
  isDefault?: boolean;
3743
+ /** Only on a balance plan. Cannot be combined with `inheritsFromPriceId`. */
3788
3744
  includedBalance?: number | null;
3745
+ /** Only on a credits plan. Cannot be combined with `inheritsFromPriceId`. */
3789
3746
  includedCredits?: number | null;
3747
+ /** Market price overrides. Optional on a base price, where currency pricing remains the fallback elsewhere. Required when `inheritsFromPriceId` is sent. */
3790
3748
  marketPrices?: Array<{
3791
3749
  /** Public ID of a reusable pricing market group. */
3792
3750
  marketGroupId: string;
@@ -3795,20 +3753,9 @@ type AddPlanPriceParams = {
3795
3753
  /** Market price in the currency's minor unit. */
3796
3754
  price: number;
3797
3755
  }>;
3798
- } | {
3799
- id: string;
3800
- billingInterval: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | "one_time";
3801
- metadata?: Record<string, unknown>;
3802
- inheritsFromPriceId: string;
3803
- marketPrices: Array<{
3804
- /** Public ID of a reusable pricing market group. */
3805
- marketGroupId: string;
3806
- /** Presentment currency configured for this plan and market. */
3807
- currency: "usd" | "ars" | "brl" | "clp" | "cop" | "pen" | "uyu" | "pyg" | "bob" | "mxn" | "cad" | "eur" | "gbp" | "jpy" | "cny" | "krw" | "hkd" | "sgd" | "twd" | "inr" | "thb";
3808
- /** Market price in the currency's minor unit. */
3809
- price: number;
3810
- }>;
3811
- };
3756
+ /** Makes the price a selectable market price variant of this base price. It inherits the base terms and must override at least one market already configured on the base price. Required unless `price` is sent. Cannot be combined with `price`. Cannot be combined with `trialDays`. Cannot be combined with `trialRequiresPaymentMethod`. Cannot be combined with `isDefault`. Cannot be combined with `includedBalance`. Cannot be combined with `includedCredits`. */
3757
+ inheritsFromPriceId?: string;
3758
+ }
3812
3759
  interface SetPlanRegionalPricingParams {
3813
3760
  id: string;
3814
3761
  currency: "usd" | "ars" | "brl" | "clp" | "cop" | "pen" | "uyu" | "pyg" | "bob" | "mxn" | "cad" | "eur" | "gbp" | "jpy" | "cny" | "krw" | "hkd" | "sgd" | "twd" | "inr" | "thb";
@@ -3819,6 +3766,7 @@ interface SetPlanRegionalPricingParams {
3819
3766
  includedBalance?: number;
3820
3767
  }>;
3821
3768
  features?: Array<{
3769
+ /** The feature's ID (`ftr_…`) or its code. */
3822
3770
  featureId: string;
3823
3771
  overageUnitPrice: number;
3824
3772
  }>;
@@ -3834,11 +3782,10 @@ interface UpdatePlanParams {
3834
3782
  isPublic?: boolean;
3835
3783
  /** Credits plans only. What happens to unused plan credits at each reset. Changing it publishes a new version of the plan; each subscription stays on its version until moved. */
3836
3784
  unusedPlanCredits?: {
3837
- type: "expire";
3838
- } | {
3839
- type: "roll_over";
3840
- /** The most plan credits a subscription holds after a reset, including the credits that reset grants; credits above it expire. At least the included credits of every price. null means no limit other than the largest storable balance, 2,147,483,647 plan credits. */
3841
- maxPlanCredits: number | null;
3785
+ /** `expire`: each reset replaces unused plan credits with the price's included credits. `roll_over`: unused plan credits roll over: each reset adds the price's included credits to them. */
3786
+ type: "expire" | "roll_over";
3787
+ /** The most plan credits a subscription holds after a reset, including the credits that reset grants; credits above it expire. At least the included credits of every price. null means no limit other than the largest storable balance, 2,147,483,647 plan credits. Required when `type` is `roll_over`. Ignored when `type` is `expire`. */
3788
+ maxPlanCredits?: number | null;
3842
3789
  };
3843
3790
  /** Credits plans only. true makes the plan credits unlimited: usage never spends them, only planCreditLimit caps it, and every price includes 0 credits. Changing it publishes a new version of the plan; each subscription stays on its version until moved. */
3844
3791
  unlimitedPlanCredits?: boolean;
@@ -3851,11 +3798,10 @@ interface UpdatePlanParams {
3851
3798
  } | null;
3852
3799
  /** Balance plans only. What happens to unused plan balance at each reset. Changing it publishes a new version of the plan; each subscription stays on its version until moved. */
3853
3800
  unusedPlanBalance?: {
3854
- type: "expire";
3855
- } | {
3856
- type: "roll_over";
3857
- /** The most plan balance a subscription holds after a reset, in USD cents, including the balance that reset grants; balance above it expires. At least the included balance of every price. Other currencies convert it with the plan's exchange rate unless the dashboard sets a custom amount for that currency. null means no limit other than the largest storable amount, 2,147,483,647 cents. */
3858
- maxPlanBalance: number | null;
3801
+ /** `expire`: each reset replaces unused plan balance with the price's included balance. `roll_over`: unused plan balance rolls over: each reset adds the price's included balance to it. */
3802
+ type: "expire" | "roll_over";
3803
+ /** The most plan balance a subscription holds after a reset, in USD cents, including the balance that reset grants; balance above it expires. At least the included balance of every price. Other currencies convert it with the plan's exchange rate unless the dashboard sets a custom amount for that currency. null means no limit other than the largest storable amount, 2,147,483,647 cents. Required when `type` is `roll_over`. Ignored when `type` is `expire`. */
3804
+ maxPlanBalance?: number | null;
3859
3805
  };
3860
3806
  /** Balance plans only. true makes the plan balance unlimited: usage never spends it, only planBalanceLimit caps it, and every price and country includes no balance. Changing it publishes a new version of the plan; each subscription stays on its version until moved. */
3861
3807
  unlimitedPlanBalance?: boolean;
@@ -3868,7 +3814,7 @@ interface UpdatePlanParams {
3868
3814
  } | null;
3869
3815
  /** Credits and balance plans only. false lets usage continue past the plan and purchased amounts and bills the missing amount as overage at the next renewal; a credits plan bills it at the price per credit and needs one. Trials and free plans always stop, so free plans accept only true. Changing it publishes a new version of the plan; each subscription stays on its version until moved. */
3870
3816
  blockOnExhaustion?: boolean;
3871
- /** Make this plan the default plan of its plan group: customers created with that planGroupId start on it, and a paid plan of the group that ends from the customer portal, a revoked payment authorization or exhausted dunning moves to it instead of canceling. Requires a free plan in a plan group; replaces the group's previous default plan. false unmarks it. */
3817
+ /** Make this plan the default plan of its plan group: customers created with that planGroupId start on it, and a paid plan of the group that ends (a cancellation from the API, dashboard or customer portal, a lost dispute, exhausted dunning or a card-less trial end) moves to it instead of canceling. Requires a free plan in a plan group; replaces the group's previous default plan. false unmarks it. */
3872
3818
  isDefault?: boolean;
3873
3819
  }
3874
3820
  interface DeletePlanParams {
@@ -3932,11 +3878,10 @@ interface CreatePlanParams {
3932
3878
  blockOnExhaustion?: boolean;
3933
3879
  /** Credits plans only. What happens to unused plan credits at each reset; omitted means they expire. */
3934
3880
  unusedPlanCredits?: {
3935
- type: "expire";
3936
- } | {
3937
- type: "roll_over";
3938
- /** The most plan credits a subscription holds after a reset, including the credits that reset grants; credits above it expire. At least the included credits of every price. null means no limit other than the largest storable balance, 2,147,483,647 plan credits. */
3939
- maxPlanCredits: number | null;
3881
+ /** `expire`: each reset replaces unused plan credits with the price's included credits. `roll_over`: unused plan credits roll over: each reset adds the price's included credits to them. */
3882
+ type: "expire" | "roll_over";
3883
+ /** The most plan credits a subscription holds after a reset, including the credits that reset grants; credits above it expire. At least the included credits of every price. null means no limit other than the largest storable balance, 2,147,483,647 plan credits. Required when `type` is `roll_over`. Ignored when `type` is `expire`. */
3884
+ maxPlanCredits?: number | null;
3940
3885
  };
3941
3886
  /** Credits plans only. true makes the plan credits unlimited: usage never spends them, only planCreditLimit caps it, and every price includes 0 credits. Omitted means false. */
3942
3887
  unlimitedPlanCredits?: boolean;
@@ -3949,11 +3894,10 @@ interface CreatePlanParams {
3949
3894
  } | null;
3950
3895
  /** Balance plans only. What happens to unused plan balance at each reset; omitted means it expires. */
3951
3896
  unusedPlanBalance?: {
3952
- type: "expire";
3953
- } | {
3954
- type: "roll_over";
3955
- /** The most plan balance a subscription holds after a reset, in USD cents, including the balance that reset grants; balance above it expires. At least the included balance of every price. Other currencies convert it with the plan's exchange rate unless the dashboard sets a custom amount for that currency. null means no limit other than the largest storable amount, 2,147,483,647 cents. */
3956
- maxPlanBalance: number | null;
3897
+ /** `expire`: each reset replaces unused plan balance with the price's included balance. `roll_over`: unused plan balance rolls over: each reset adds the price's included balance to it. */
3898
+ type: "expire" | "roll_over";
3899
+ /** The most plan balance a subscription holds after a reset, in USD cents, including the balance that reset grants; balance above it expires. At least the included balance of every price. Other currencies convert it with the plan's exchange rate unless the dashboard sets a custom amount for that currency. null means no limit other than the largest storable amount, 2,147,483,647 cents. Required when `type` is `roll_over`. Ignored when `type` is `expire`. */
3900
+ maxPlanBalance?: number | null;
3957
3901
  };
3958
3902
  /** Balance plans only. true makes the plan balance unlimited: usage never spends it, only planBalanceLimit caps it, and every price and country includes no balance. Omitted means false. */
3959
3903
  unlimitedPlanBalance?: boolean;
@@ -3965,7 +3909,7 @@ interface CreatePlanParams {
3965
3909
  interval: "day" | "week";
3966
3910
  } | null;
3967
3911
  planGroupId?: string;
3968
- /** Make this plan the default plan of its plan group: customers created with that planGroupId start on it, and a paid plan of the group that ends from the customer portal, a revoked payment authorization or exhausted dunning moves to it instead of canceling. Requires a free plan with a planGroupId; replaces the group's previous default plan. */
3912
+ /** Make this plan the default plan of its plan group: customers created with that planGroupId start on it, and a paid plan of the group that ends (a cancellation from the API, dashboard or customer portal, a lost dispute, exhausted dunning or a card-less trial end) moves to it instead of canceling. Requires a free plan with a planGroupId; replaces the group's previous default plan. */
3969
3913
  isDefault?: boolean;
3970
3914
  metadata?: Record<string, unknown>;
3971
3915
  }
@@ -4082,18 +4026,18 @@ declare class PlansResource {
4082
4026
  create(params: CreatePlanParams, options?: RequestOptions): Promise<Plan>;
4083
4027
  }
4084
4028
 
4085
- type RequestPortalAccessParams = {
4086
- email: string;
4087
- returnUrl?: string;
4088
- } | {
4089
- customerId: string;
4029
+ interface RequestPortalAccessParams {
4030
+ /** Required unless `customerId` is sent. Cannot be combined with `customerId`. */
4031
+ email?: string;
4032
+ /** Required unless `email` is sent. Cannot be combined with `email`. */
4033
+ customerId?: string;
4090
4034
  returnUrl?: string;
4091
- };
4035
+ }
4092
4036
  declare class PortalResource {
4093
4037
  private httpClient;
4094
4038
  constructor(httpClient: CommetHTTPClient);
4095
4039
  /** Generate a customer portal URL. Exactly one identifier (email or customerId) is required. */
4096
- getUrl(params: RequestPortalAccessParams, options?: RequestOptions): Promise<PortalAccess>;
4040
+ getUrl(params?: RequestPortalAccessParams, options?: RequestOptions): Promise<PortalAccess>;
4097
4041
  }
4098
4042
 
4099
4043
  interface GetPromoCodeParams {
@@ -4105,6 +4049,7 @@ interface UpdatePromoCodeParams {
4105
4049
  maxRedemptions?: number | null;
4106
4050
  expiresAt?: string | null;
4107
4051
  active?: boolean;
4052
+ /** Each entry is a plan ID (`pln_…`) or a plan code. */
4108
4053
  planIds?: Array<string>;
4109
4054
  /** Whether the code only applies to a customer's first purchase: one with no paid invoice above zero and no paid subscription. */
4110
4055
  firstPurchaseOnly?: boolean;
@@ -4120,6 +4065,7 @@ interface CreatePromoCodeParams {
4120
4065
  maxRedemptions?: number;
4121
4066
  /** @format date-time */
4122
4067
  expiresAt?: string;
4068
+ /** Each entry is a plan ID (`pln_…`) or a plan code. */
4123
4069
  planIds?: Array<string>;
4124
4070
  /** Whether the code only applies to a customer's first purchase: one with no paid invoice above zero and no paid subscription. Defaults to false. */
4125
4071
  firstPurchaseOnly?: boolean;
@@ -4127,7 +4073,7 @@ interface CreatePromoCodeParams {
4127
4073
  declare class PromoCodesResource {
4128
4074
  private httpClient;
4129
4075
  constructor(httpClient: CommetHTTPClient);
4130
- /** Retrieve a promo code by its public ID. */
4076
+ /** Retrieve a promo code by its public ID or by the code customers enter, in any letter case. */
4131
4077
  get(params: GetPromoCodeParams, options?: RequestOptions): Promise<PromoCode>;
4132
4078
  /** Update a promo code's billing interval, redemption limits, expiration, active status, or plan restrictions. */
4133
4079
  update(params: UpdatePromoCodeParams, options?: RequestOptions): Promise<PromoCode>;
@@ -4152,37 +4098,34 @@ declare class ProvisioningResource {
4152
4098
  interface GetAllQuotaAllowancesParams {
4153
4099
  customerId: string;
4154
4100
  }
4155
- type RemoveQuotaParams = {
4101
+ interface RemoveQuotaParams {
4156
4102
  featureCode: string;
4157
4103
  count?: number;
4158
- customerId: string;
4159
- } | {
4160
- featureCode: string;
4161
- count?: number;
4162
- externalId: string;
4163
- };
4104
+ /** Required unless `externalId` is sent. Cannot be combined with `externalId`. */
4105
+ customerId?: string;
4106
+ /** Required unless `customerId` is sent. Cannot be combined with `customerId`. */
4107
+ externalId?: string;
4108
+ }
4164
4109
  interface GetQuotaAllowanceParams {
4165
4110
  customerId: string;
4166
4111
  featureCode: string;
4167
4112
  }
4168
- type AddQuotaParams = {
4169
- featureCode: string;
4170
- count?: number;
4171
- customerId: string;
4172
- } | {
4113
+ interface AddQuotaParams {
4173
4114
  featureCode: string;
4174
4115
  count?: number;
4175
- externalId: string;
4176
- };
4177
- type SetQuotaParams = {
4178
- featureCode: string;
4179
- count: number;
4180
- customerId: string;
4181
- } | {
4116
+ /** Required unless `externalId` is sent. Cannot be combined with `externalId`. */
4117
+ customerId?: string;
4118
+ /** Required unless `customerId` is sent. Cannot be combined with `customerId`. */
4119
+ externalId?: string;
4120
+ }
4121
+ interface SetQuotaParams {
4182
4122
  featureCode: string;
4183
4123
  count: number;
4184
- externalId: string;
4185
- };
4124
+ /** Required unless `externalId` is sent. Cannot be combined with `externalId`. */
4125
+ customerId?: string;
4126
+ /** Required unless `customerId` is sent. Cannot be combined with `customerId`. */
4127
+ externalId?: string;
4128
+ }
4186
4129
  declare class QuotaResource {
4187
4130
  private httpClient;
4188
4131
  constructor(httpClient: CommetHTTPClient);
@@ -4258,6 +4201,8 @@ interface DeactivateAddonParams {
4258
4201
  interface ActivateAddonParams {
4259
4202
  id: string;
4260
4203
  addonId: string;
4204
+ /** Where the customer returns after paying. When it is set and the subscription has no saved payment method, or the saved method is declined or asks for authentication, the response has status `requires_checkout` and a `checkoutUrl` where the customer pays this purchase and saves the method in one step. Without it, the request is rejected in both cases. A saved method is always charged directly first, and a payment that fails for any other reason is rejected either way. */
4205
+ successUrl?: string;
4261
4206
  }
4262
4207
  interface GetSubscriptionAutoTopUpParams {
4263
4208
  id: string;
@@ -4282,28 +4227,29 @@ interface TopupBalanceParams {
4282
4227
  id: string;
4283
4228
  /** The amount to add, in minor units of the subscription currency (cents; whole units for zero-decimal currencies). */
4284
4229
  amount: number;
4230
+ /** Where the customer returns after paying. When it is set and the subscription has no saved payment method, or the saved method is declined or asks for authentication, the response has status `requires_checkout` and a `checkoutUrl` where the customer pays this purchase and saves the method in one step. Without it, the request is rejected in both cases. A saved method is always charged directly first, and a payment that fails for any other reason is rejected either way. */
4231
+ successUrl?: string;
4285
4232
  }
4286
4233
  interface CancelSubscriptionParams {
4287
4234
  id: string;
4288
4235
  reason?: string;
4289
4236
  immediate?: boolean;
4290
4237
  }
4291
- type ChangePlanParams = {
4238
+ interface ChangePlanParams {
4292
4239
  id: string;
4293
- newPlanId?: string;
4294
4240
  newBillingInterval?: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly";
4295
4241
  successUrl?: string;
4242
+ /** Cannot be combined with `promoCode`. */
4296
4243
  offerId?: string;
4297
- promoCode?: never;
4298
- } | {
4299
- id: string;
4244
+ /** Promo code whose Offer prices the change, validated with the checkout's rules: a code the checkout would refuse returns 400 validation_error with the checkout's reason in details.reason. Cannot be combined with `offerId`. */
4245
+ promoCode?: string;
4246
+ /** The plan's ID (`pln_…`) or its code. Cannot be combined with `planCode`. */
4300
4247
  newPlanId?: string;
4301
- newBillingInterval?: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly";
4302
- successUrl?: string;
4303
- offerId?: never;
4304
- /** Promo code whose Offer prices the change, validated with the checkout's rules: a code the checkout would refuse returns 400 validation_error with the checkout's reason in details.reason. Cannot be combined with offerId. */
4305
- promoCode: string;
4306
- };
4248
+ /** Code of the destination plan, or `<plan code>:<experiment code>` to change to the experiment's latest version while it runs (the plan's current version once the experiment is won or archived). Same rules as planCode on subscription creation. Cannot be combined with `newPlanId`. */
4249
+ planCode?: string;
4250
+ /** Public ID of a published version of the destination plan, current or not, including a running experiment's versions. The change is priced, checked out and activated on that version. Only for an immediate change to another paid plan, and not with an experiment code. When omitted, the change lands on the plan's current version, or the version its experiment code sells. Requires `newPlanId` or `planCode`. */
4251
+ planVersionId?: string;
4252
+ }
4307
4253
  interface ChangeSubscriptionVersionParams {
4308
4254
  id: string;
4309
4255
  /** A published version of the subscription's plan. */
@@ -4313,18 +4259,22 @@ interface ChangeSubscriptionVersionParams {
4313
4259
  /** usd to charge the subscription in USD from its next renewal when the version does not sell the currency it pays, or the USD price of its country: it pays the version's USD price for its country, or the USD base price. The whole move then happens at that renewal, even with effective now. Rejected with missing_regional_price when the version still sells what the subscription pays or for another currency, and with a currency_held_by code naming what keeps it in its currency: currency_held_by_payment_method (it pays through dLocal), currency_held_by_customer_credit, currency_held_by_balance_plan, currency_held_by_fixed_amount_discount, currency_held_by_prepaid_period or currency_held_by_scheduled_pause. */
4314
4260
  currency?: string;
4315
4261
  }
4316
- type PurchaseCreditsParams = {
4317
- id: string;
4318
- creditPackId: string;
4319
- quantity?: never;
4320
- } | {
4262
+ interface PurchaseCreditsParams {
4321
4263
  id: string;
4322
- quantity: number;
4323
- };
4264
+ /** Required unless `quantity` is sent. Cannot be combined with `quantity`. */
4265
+ creditPackId?: string;
4266
+ /** Required unless `creditPackId` is sent. Cannot be combined with `creditPackId`. */
4267
+ quantity?: number;
4268
+ /** Where the customer returns after paying. When it is set and the subscription has no saved payment method, or the saved method is declined or asks for authentication, the response has status `requires_checkout` and a `checkoutUrl` where the customer pays this purchase and saves the method in one step. Without it, the request is rejected in both cases. A saved method is always charged directly first, and a payment that fails for any other reason is rejected either way. */
4269
+ successUrl?: string;
4270
+ }
4324
4271
  interface ApplySubscriptionOfferParams {
4325
4272
  id: string;
4326
4273
  offerId: string;
4327
- /** @format date-time */
4274
+ /**
4275
+ * Only for a pending payment checkout, and later than the current time.
4276
+ * @format date-time
4277
+ */
4328
4278
  expiresAt?: string;
4329
4279
  }
4330
4280
  interface RemoveSubscriptionOfferParams {
@@ -4354,20 +4304,20 @@ interface CreatePrepaidPeriodsCheckoutParams {
4354
4304
  offerId?: string;
4355
4305
  successUrl?: string;
4356
4306
  }
4357
- type PreviewChangePlanParams = {
4307
+ interface PreviewChangePlanParams {
4358
4308
  id: string;
4359
- planId: string;
4360
4309
  billingInterval?: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | "one_time";
4310
+ /** Cannot be combined with `promoCode`. */
4361
4311
  offerId?: string;
4362
- promoCode?: never;
4363
- } | {
4364
- id: string;
4365
- planId: string;
4366
- billingInterval?: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | "one_time";
4367
- offerId?: never;
4368
- /** Promo code whose Offer prices the change, validated with the checkout's rules: a code the checkout would refuse returns 400 validation_error with the checkout's reason in details.reason. Cannot be combined with offerId. */
4369
- promoCode: string;
4370
- };
4312
+ /** Promo code whose Offer prices the change, validated with the checkout's rules: a code the checkout would refuse returns 400 validation_error with the checkout's reason in details.reason. Cannot be combined with `offerId`. */
4313
+ promoCode?: string;
4314
+ /** The plan's ID (`pln_…`) or its code. Required unless `planCode` is sent. Cannot be combined with `planCode`. */
4315
+ planId?: string;
4316
+ /** Code of the destination plan, or `<plan code>:<experiment code>` to change to the experiment's latest version while it runs (the plan's current version once the experiment is won or archived). Same rules as planCode on subscription creation. Required unless `planId` is sent. Cannot be combined with `planId`. */
4317
+ planCode?: string;
4318
+ /** Public ID of a published version of the destination plan, current or not, including a running experiment's versions. The change is priced, checked out and activated on that version. Only for an immediate change to another paid plan, and not with an experiment code. When omitted, the change lands on the plan's current version, or the version its experiment code sells. */
4319
+ planVersionId?: string;
4320
+ }
4371
4321
  interface ReactivateSubscriptionParams {
4372
4322
  id: string;
4373
4323
  offerId?: string;
@@ -4394,178 +4344,53 @@ interface GetActiveSubscriptionParams {
4394
4344
  customerId: string;
4395
4345
  }
4396
4346
  interface ListSubscriptionsParams {
4347
+ cursor?: string;
4348
+ limit?: number;
4397
4349
  customerId?: string;
4398
4350
  status?: SubscriptionStatus;
4399
4351
  planVersionId?: string;
4400
4352
  }
4401
- type CreateSubscriptionParams = {
4402
- customerId: string;
4403
- billingInterval?: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | "one_time" | null;
4404
- /** Public price ID. When omitted, Commet selects the default price for the billing interval and still applies its market pricing. */
4405
- priceId?: string;
4406
- initialSeats?: Record<string, number>;
4407
- /** Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present. */
4408
- provider?: "stripe" | "commet" | "dlocal" | string;
4409
- /** Payment methods the initial checkout may offer. Restricts what the checkout already offers for the buyer's country, currency and payment connection; it never enables a method the connection does not have and never changes routing. When none of them is available to the buyer, the checkout shows that it cannot accept payments. */
4410
- paymentMethodTypes?: Array<"card" | "oxxo" | "mercado_pago" | "google_pay" | "smartpix">;
4411
- name?: string;
4412
- /** @format date-time */
4413
- startDate?: string;
4414
- successUrl?: string;
4415
- /** Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true. */
4416
- prepaidPeriods?: number;
4417
- /** Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method. */
4418
- cancelAtPeriodEnd?: boolean;
4419
- /** Public ID of a published version of the plan, current or not, including an experiment's versions. The subscription is created on that version and stays on it: checkout charges its price and activation grants its credits, add-ons and credit packs. When omitted, the subscription gets the current version, or the version an experiment code (planCode `<plan code>:<experiment code>`) sells. */
4420
- planVersionId?: string;
4421
- offerId?: never;
4422
- promoCode?: string;
4423
- /** Trial length in days, replacing the price's trial. A customer who already had this plan, in a trial or paying, gets no trial and goes through the regular checkout. */
4424
- customTrialDays?: number;
4425
- skipTrial?: boolean;
4426
- planId: string;
4427
- } | {
4353
+ interface CreateSubscriptionParams {
4428
4354
  customerId: string;
4429
4355
  billingInterval?: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | "one_time" | null;
4430
4356
  /** Public price ID. When omitted, Commet selects the default price for the billing interval and still applies its market pricing. */
4431
4357
  priceId?: string;
4432
4358
  initialSeats?: Record<string, number>;
4433
- /** Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present. */
4359
+ /** Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present. Not available on free plans or with a free trial that requires no payment method. */
4434
4360
  provider?: "stripe" | "commet" | "dlocal" | string;
4435
- /** Payment methods the initial checkout may offer. Restricts what the checkout already offers for the buyer's country, currency and payment connection; it never enables a method the connection does not have and never changes routing. When none of them is available to the buyer, the checkout shows that it cannot accept payments. */
4436
- paymentMethodTypes?: Array<"card" | "oxxo" | "mercado_pago" | "google_pay" | "smartpix">;
4361
+ /** Payment methods the initial checkout may offer. Restricts what the checkout already offers for the buyer's country, currency and payment connection; it never enables a method the connection does not have and never changes routing. When none of them is available to the buyer, the checkout shows that it cannot accept payments. Not available on free plans or with a free trial that requires no payment method. */
4362
+ paymentMethodTypes?: Array<"card" | "mercado_pago" | "oxxo" | "google_pay" | "smartpix" | "apple_pay" | "link">;
4437
4363
  name?: string;
4438
4364
  /** @format date-time */
4439
4365
  startDate?: string;
4440
4366
  successUrl?: string;
4441
- /** Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true. */
4367
+ /** Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true. Above 1, needs a paid recurring price, cannot take an Offer whose phases bill on another interval and cannot be combined with `customTrialDays` above 0. */
4442
4368
  prepaidPeriods?: number;
4443
- /** Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method. */
4369
+ /** Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method. When the plan's group has a default free plan, it moves to that plan then instead of ending. When true, needs a paid recurring price and cannot be combined with `customTrialDays` above 0. */
4444
4370
  cancelAtPeriodEnd?: boolean;
4445
- /** Public ID of a published version of the plan, current or not, including an experiment's versions. The subscription is created on that version and stays on it: checkout charges its price and activation grants its credits, add-ons and credit packs. When omitted, the subscription gets the current version, or the version an experiment code (planCode `<plan code>:<experiment code>`) sells. */
4371
+ /** Public ID of a published version of the plan, current or not, including an experiment's versions. The subscription is created on that version and stays on it: checkout charges its price and activation grants its credits, add-ons and credit packs. When omitted, the subscription gets the current version, or the version an experiment code (planCode `<plan code>:<experiment code>`) sells. Cannot be combined with an experiment code in `planCode`. */
4446
4372
  planVersionId?: string;
4447
- offerId?: never;
4373
+ /** Cannot be combined with `promoCode`. Cannot be combined with `cardPromotionId`. */
4374
+ offerId?: string;
4375
+ /** Cannot be combined with `offerId`. Cannot be combined with `cardPromotionId`. */
4448
4376
  promoCode?: string;
4449
- /** Trial length in days, replacing the price's trial. A customer who already had this plan, in a trial or paying, gets no trial and goes through the regular checkout. */
4450
- customTrialDays?: number;
4451
- skipTrial?: boolean;
4452
- /** The plan code, or an experiment code as `<plan code>:<experiment code>` to sell the version the experiment sells. */
4453
- planCode: string;
4454
- } | {
4455
- customerId: string;
4456
- billingInterval?: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | "one_time" | null;
4457
- /** Public price ID. When omitted, Commet selects the default price for the billing interval and still applies its market pricing. */
4458
- priceId?: string;
4459
- initialSeats?: Record<string, number>;
4460
- /** Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present. */
4461
- provider?: "stripe" | "commet" | "dlocal" | string;
4462
- /** Payment methods the initial checkout may offer. Restricts what the checkout already offers for the buyer's country, currency and payment connection; it never enables a method the connection does not have and never changes routing. When none of them is available to the buyer, the checkout shows that it cannot accept payments. */
4463
- paymentMethodTypes?: Array<"card" | "oxxo" | "mercado_pago" | "google_pay" | "smartpix">;
4464
- name?: string;
4465
- /** @format date-time */
4466
- startDate?: string;
4467
- successUrl?: string;
4468
- /** Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true. */
4469
- prepaidPeriods?: number;
4470
- /** Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method. */
4471
- cancelAtPeriodEnd?: boolean;
4472
- /** Public ID of a published version of the plan, current or not, including an experiment's versions. The subscription is created on that version and stays on it: checkout charges its price and activation grants its credits, add-ons and credit packs. When omitted, the subscription gets the current version, or the version an experiment code (planCode `<plan code>:<experiment code>`) sells. */
4473
- planVersionId?: string;
4474
- offerId: string;
4475
- promoCode?: never;
4476
- /** Trial length in days, replacing the price's trial. A customer who already had this plan, in a trial or paying, gets no trial and goes through the regular checkout. */
4377
+ /** Trial length in days, replacing the price's trial. A customer who already had this plan, in a trial or paying, gets no trial and goes through the regular checkout. Above 0, cannot be combined with `prepaidPeriods` above 1 or with `cancelAtPeriodEnd` true. Cannot be combined with `cardPromotionId`. */
4477
4378
  customTrialDays?: number;
4379
+ /** Cannot be `true` with `cardPromotionId`. */
4478
4380
  skipTrial?: boolean;
4479
- planId: string;
4480
- } | {
4481
- customerId: string;
4482
- billingInterval?: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | "one_time" | null;
4483
- /** Public price ID. When omitted, Commet selects the default price for the billing interval and still applies its market pricing. */
4484
- priceId?: string;
4485
- initialSeats?: Record<string, number>;
4486
- /** Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present. */
4487
- provider?: "stripe" | "commet" | "dlocal" | string;
4488
- /** Payment methods the initial checkout may offer. Restricts what the checkout already offers for the buyer's country, currency and payment connection; it never enables a method the connection does not have and never changes routing. When none of them is available to the buyer, the checkout shows that it cannot accept payments. */
4489
- paymentMethodTypes?: Array<"card" | "oxxo" | "mercado_pago" | "google_pay" | "smartpix">;
4490
- name?: string;
4491
- /** @format date-time */
4492
- startDate?: string;
4493
- successUrl?: string;
4494
- /** Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true. */
4495
- prepaidPeriods?: number;
4496
- /** Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method. */
4497
- cancelAtPeriodEnd?: boolean;
4498
- /** Public ID of a published version of the plan, current or not, including an experiment's versions. The subscription is created on that version and stays on it: checkout charges its price and activation grants its credits, add-ons and credit packs. When omitted, the subscription gets the current version, or the version an experiment code (planCode `<plan code>:<experiment code>`) sells. */
4499
- planVersionId?: string;
4500
- offerId: string;
4501
- promoCode?: never;
4502
- /** Trial length in days, replacing the price's trial. A customer who already had this plan, in a trial or paying, gets no trial and goes through the regular checkout. */
4503
- customTrialDays?: number;
4504
- skipTrial?: boolean;
4505
- /** The plan code, or an experiment code as `<plan code>:<experiment code>` to sell the version the experiment sells. */
4506
- planCode: string;
4507
- } | {
4508
- customerId: string;
4509
- billingInterval?: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | "one_time" | null;
4510
- /** Public price ID. When omitted, Commet selects the default price for the billing interval and still applies its market pricing. */
4511
- priceId?: string;
4512
- initialSeats?: Record<string, number>;
4513
- /** Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present. */
4514
- provider?: "stripe" | "commet" | "dlocal" | string;
4515
- /** Payment methods the initial checkout may offer. Restricts what the checkout already offers for the buyer's country, currency and payment connection; it never enables a method the connection does not have and never changes routing. When none of them is available to the buyer, the checkout shows that it cannot accept payments. */
4516
- paymentMethodTypes?: Array<"card" | "oxxo" | "mercado_pago" | "google_pay" | "smartpix">;
4517
- name?: string;
4518
- /** @format date-time */
4519
- startDate?: string;
4520
- successUrl?: string;
4521
- /** Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true. */
4522
- prepaidPeriods?: number;
4523
- /** Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method. */
4524
- cancelAtPeriodEnd?: boolean;
4525
- /** Public ID of a published version of the plan, current or not, including an experiment's versions. The subscription is created on that version and stays on it: checkout charges its price and activation grants its credits, add-ons and credit packs. When omitted, the subscription gets the current version, or the version an experiment code (planCode `<plan code>:<experiment code>`) sells. */
4526
- planVersionId?: string;
4527
- offerId?: never;
4528
- /** Public card promotion ID. The offer is shown immediately and remains conditional on card eligibility until checkout confirmation. */
4529
- cardPromotionId: string;
4530
- promoCode?: never;
4531
- customTrialDays?: never;
4532
- skipTrial?: false;
4533
- planId: string;
4534
- } | {
4535
- customerId: string;
4536
- billingInterval?: "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly" | "one_time" | null;
4537
- /** Public price ID. When omitted, Commet selects the default price for the billing interval and still applies its market pricing. */
4538
- priceId?: string;
4539
- initialSeats?: Record<string, number>;
4540
- /** Payment provider name or exact public payment connection ID for the initial checkout. Overrides country routing when present. */
4541
- provider?: "stripe" | "commet" | "dlocal" | string;
4542
- /** Payment methods the initial checkout may offer. Restricts what the checkout already offers for the buyer's country, currency and payment connection; it never enables a method the connection does not have and never changes routing. When none of them is available to the buyer, the checkout shows that it cannot accept payments. */
4543
- paymentMethodTypes?: Array<"card" | "oxxo" | "mercado_pago" | "google_pay" | "smartpix">;
4544
- name?: string;
4545
- /** @format date-time */
4546
- startDate?: string;
4547
- successUrl?: string;
4548
- /** Billing periods of the subscription's interval paid with the first payment, including the current one. Defaults to 1. The interval does not change: each paid period renews at zero and the subscription renews normally after the last one unless `cancelAtPeriodEnd` is true. */
4549
- prepaidPeriods?: number;
4550
- /** Schedules the cancellation from creation so the subscription ends after its last paid period and never renews with any payment method. */
4551
- cancelAtPeriodEnd?: boolean;
4552
- /** Public ID of a published version of the plan, current or not, including an experiment's versions. The subscription is created on that version and stays on it: checkout charges its price and activation grants its credits, add-ons and credit packs. When omitted, the subscription gets the current version, or the version an experiment code (planCode `<plan code>:<experiment code>`) sells. */
4553
- planVersionId?: string;
4554
- offerId?: never;
4555
- /** Public card promotion ID. The offer is shown immediately and remains conditional on card eligibility until checkout confirmation. */
4556
- cardPromotionId: string;
4557
- promoCode?: never;
4558
- customTrialDays?: never;
4559
- skipTrial?: false;
4560
- /** The plan code, or an experiment code as `<plan code>:<experiment code>` to sell the version the experiment sells. */
4561
- planCode: string;
4562
- };
4381
+ /** Public card promotion ID. The offer is shown immediately and remains conditional on card eligibility until checkout confirmation. Cannot be combined with `offerId`. Cannot be combined with `promoCode`. Cannot be combined with `customTrialDays`. Cannot be used when `skipTrial` is `true`. */
4382
+ cardPromotionId?: string;
4383
+ /** Required unless `planCode` is sent. Cannot be combined with `planCode`. */
4384
+ planId?: string;
4385
+ /** The plan code, or an experiment code as `<plan code>:<experiment code>` to sell the version the experiment sells. Required unless `planId` is sent. Cannot be combined with `planId`. */
4386
+ planCode?: string;
4387
+ }
4563
4388
  declare class SubscriptionsResource {
4564
4389
  private httpClient;
4565
4390
  constructor(httpClient: CommetHTTPClient);
4566
4391
  /** Deactivate an add-on from a subscription. */
4567
4392
  deactivateAddon(params: DeactivateAddonParams, options?: RequestOptions): Promise<DeletedSubscriptionAddon>;
4568
- /** Activate an add-on on a subscription. Creates the activation invoice and charges a prorated amount for the current billing period; the add-on is active once the payment is confirmed. Rejected with 409 while the add-on is active or an activation of it is still processing. An add-on that the subscription's plan version does not sell is rejected with addon_unavailable. */
4393
+ /** Activate an add-on on a subscription. Creates the activation invoice and charges a prorated amount for the current billing period; the add-on is active once the payment is confirmed. Send successUrl to receive, when there is no saved payment method or it is declined, a checkout that charges the activation and saves the method. Rejected with 409 while the add-on is active or an activation of it is still processing. An add-on that the subscription's plan version does not sell is rejected with addon_unavailable. */
4569
4394
  activateAddon(params: ActivateAddonParams, options?: RequestOptions): Promise<SubscriptionAddon>;
4570
4395
  /** Read whether the subscription tops up automatically with its saved payment method when its available credits or balance reach a threshold, with the top-ups used this period and the last failure. */
4571
4396
  getAutoTopUp(params: GetSubscriptionAutoTopUpParams, options?: RequestOptions): Promise<SubscriptionAutoTopUp>;
@@ -4573,15 +4398,15 @@ declare class SubscriptionsResource {
4573
4398
  updateAutoTopUp(params: UpdateSubscriptionAutoTopUpParams, options?: RequestOptions): Promise<SubscriptionAutoTopUp>;
4574
4399
  /** Adjust a subscription's balance or credits by a signed amount. Positive adds, negative subtracts. */
4575
4400
  adjustBalance(params: AdjustBalanceParams, options?: RequestOptions): Promise<BalanceAdjustment>;
4576
- /** Top up a balance subscription. Creates the top-up invoice and charges the customer's payment method for the amount plus tax. Once the payment is confirmed, adds the amount to the subscription's purchased balance (after paying back any overage owed on the plan balance), marks the invoice paid and emits `balance.topped_up`. Purchased balance is spent after the plan balance and is kept until the subscription ends. Rejected with 400 when the subscription is not on a balance plan, its plan has top-ups turned off, or the amount is below the effective minimum: the plan's minimum top-up in the subscription currency, raised to the currency's minimum charge. */
4401
+ /** Top up a balance subscription. Creates the top-up invoice and charges the customer's payment method for the amount plus tax. Once the payment is confirmed, adds the amount to the subscription's purchased balance (after paying back any overage owed on the plan balance), marks the invoice paid and emits `balance.topped_up`. Purchased balance is spent after the plan balance and is kept until the subscription ends. Send successUrl to receive, when there is no saved payment method or it is declined, a checkout that charges the top-up and saves the method. Rejected with 400 when the subscription is not on a balance plan, its plan has top-ups turned off, or the amount is below the effective minimum: the plan's minimum top-up in the subscription currency, raised to the currency's minimum charge. */
4577
4402
  topupBalance(params: TopupBalanceParams, options?: RequestOptions): Promise<BalanceTopup>;
4578
- /** Cancel immediately or at period end and return the updated subscription. */
4403
+ /** Cancel immediately or at period end and return the updated subscription. When the plan's group has a default free plan, a paid subscription moves to that plan instead of ending: now when `immediate` is true, otherwise at the end of the period or trial as a scheduled plan change that `POST /subscriptions/{id}/uncancel` undoes. The move sends `subscription.plan_change_scheduled` and `subscription.plan_changed` with the `reason` as `cancelReason`, never `subscription.canceled`. Cancelling the default plan itself ends the subscription. */
4579
4404
  cancel(params: CancelSubscriptionParams, options?: RequestOptions): Promise<Subscription>;
4580
4405
  /** Upgrade or change billing interval immediately, optionally applying an Offer by offerId or the Offer of a promoCode. Scheduled changes accept neither offerId nor promoCode. From a free plan, a promoCode opens the checkout with the code applied and counts its use when the checkout is paid; without offerId or promoCode, a destination price whose free trial requires no payment method starts that trial right away without checkout. During a trial without a payment method, an immediate change returns 409 no_payment_method; scheduled changes still apply. */
4581
4406
  changePlan(params: ChangePlanParams, options?: RequestOptions): Promise<PlanChange>;
4582
4407
  /** Move a subscription to a newer published version of its plan, now or at the end of the period, without proration; an older version is rejected with version_not_newer, and a subscription on a running experiment moves only to a later version of that experiment. The subscription keeps its currency and its price: a destination that does not sell its currency is rejected with missing_regional_price unless currency asks to charge it in USD from its renewal, and one that does not sell the price it pays with price_not_found. A free version moves only to a free version and a paid one only to a paid one (validation_error). A subscription whose usage does not fit the destination, or with an active add-on the destination does not sell, is not moved either, and the error says why. Each change is recorded as a move of this one subscription in the plan's moves. Repeating the same request changes nothing; a new one replaces the pending move. */
4583
4408
  changeVersion(params: ChangeSubscriptionVersionParams, options?: RequestOptions): Promise<Subscription>;
4584
- /** Purchase a fixed credit pack or choose a whole credit quantity at the subscription plan price and minimum. Creates the purchase invoice, charges the saved payment method and adds the purchased credits once the payment is confirmed. A credit pack that the subscription's plan version does not sell is rejected with credit_pack_unavailable. */
4409
+ /** Purchase a fixed credit pack or choose a whole credit quantity at the subscription plan price and minimum. Creates the purchase invoice, charges the saved payment method and adds the purchased credits once the payment is confirmed. Send successUrl to receive, when there is no saved payment method or it is declined, a checkout that charges the purchase and saves the method. A credit pack that the subscription's plan version does not sell is rejected with credit_pack_unavailable. */
4585
4410
  purchaseCredits(params: PurchaseCreditsParams, options?: RequestOptions): Promise<CreditGrant>;
4586
4411
  /** Apply a direct Offer to a subscription. On a pending checkout it quotes or replaces the checkout discount, which starts after the plan price trial when there is one, and the existing checkout URL remains unchanged. On an active subscription it applies the Offer immediately with its discount phases starting at the next billing cycle; the call is rejected while another applied Offer still has active or upcoming discount phases. */
4587
4412
  applyOffer(params: ApplySubscriptionOfferParams, options?: RequestOptions): Promise<Subscription>;
@@ -4599,7 +4424,7 @@ declare class SubscriptionsResource {
4599
4424
  createPrepaidPeriodsCheckout(params: CreatePrepaidPeriodsCheckoutParams, options?: RequestOptions): Promise<PrepaidPeriodsCheckout>;
4600
4425
  /** Preview proration details for an immediate plan change without applying it. Free-to-paid changes are never scheduled and the change-plan endpoint returns hosted checkout for them, except a change without offerId or promoCode to a price whose free trial needs no payment method, for a customer who never had that plan: it starts the trial at once, so the preview reports nothing due today. For paid plans, interval direction takes precedence: a longer interval is immediate and a shorter interval is scheduled. When the interval is unchanged, a higher-sort-order plan is immediate and a lower-sort-order plan is scheduled. A paid-to-free change is always scheduled. Returns credit, charge, and net amount. The target plan must belong to the same plan group as the current plan, otherwise a 400 with code `plans_not_in_same_group` is returned. A change between two free plans has nothing to prorate and returns a zero-amount estimate. Scheduled changes return a 400 with code `plan_change_scheduled`; apply those via the change-plan endpoint. Pass offerId to quote the destination plan with an Offer, or promoCode to quote it with the Offer of a promo code validated with the checkout's rules. */
4601
4426
  previewChange(params: PreviewChangePlanParams, options?: RequestOptions): Promise<PreviewChange>;
4602
- /** Reactivates a subscription. A past_due subscription retries its outstanding renewal charge (recovering to active on success). A canceled subscription generates a fresh invoice, charges the saved card, and resets the billing period. On a successful charge the subscription becomes active; a declined charge returns an error with a recoveryUrl in the error details that can be sent to the customer to update their card. A canceled subscription may apply an Offer by offerId; past-due recovery cannot. */
4427
+ /** Reactivates a subscription. A past_due subscription retries its outstanding renewal charge (recovering to active on success). A canceled subscription generates a fresh invoice, charges the saved card, and resets the billing period; when that invoice totals zero, for example under an Offer, it is marked paid without a charge and the subscription becomes active at once, still requiring a saved payment method. On a successful charge the subscription becomes active; a declined charge returns an error with a recoveryUrl in the error details that can be sent to the customer to update their card. A past_due subscription without a payment method returns no_payment_method with the same recoveryUrl. A canceled subscription may apply an Offer by offerId; past-due recovery cannot. */
4603
4428
  reactivate(params: ReactivateSubscriptionParams, options?: RequestOptions): Promise<ReactivatedSubscription>;
4604
4429
  /** Generates a hosted, signed recovery link that lets the customer pay the outstanding renewal charge for a past_due subscription. Unlike reactivate, which charges server-to-server, this returns a link the merchant can deliver through their own email, SMS, or dashboard. The link carries a self-contained signed token and stays valid until the charge is paid or the subscription is no longer past due. */
4605
4430
  createRecoveryLink(params: CreateSubscriptionRecoveryLinkParams, options?: RequestOptions): Promise<RecoveryLink>;
@@ -4611,27 +4436,30 @@ declare class SubscriptionsResource {
4611
4436
  revokeScheduledPlanChange(params: RevokeScheduledPlanChangeParams, options?: RequestOptions): Promise<Subscription>;
4612
4437
  /** Cancel the move to another plan version pending for the next renewal, so the subscription stays on its version, and send subscription.version_change_canceled with reason canceled_by_merchant. A move made now has nothing pending to revoke. With nothing pending it changes nothing. Returns the subscription. */
4613
4438
  revokeScheduledVersionChange(params: RevokeScheduledVersionChangeParams, options?: RequestOptions): Promise<Subscription>;
4614
- /** Revert a scheduled cancellation and return the updated subscription. Only works before cancellation takes effect. */
4439
+ /** Revert a scheduled cancellation and return the updated subscription. Only works before cancellation takes effect. When the cancellation scheduled a move to the group's default plan instead, it reverts that move: the subscription keeps its plan and renews normally. */
4615
4440
  uncancel(params: UncancelSubscriptionParams, options?: RequestOptions): Promise<Subscription>;
4616
4441
  /** Get the active subscription for a customer. Returns null if none. */
4617
4442
  getActive(params: GetActiveSubscriptionParams, options?: RequestOptions): Promise<Subscription | null>;
4618
- /** List all subscriptions. Filter by customer ID or status. */
4443
+ /** List subscriptions, newest first. Filter by customer ID, status or plan version. Send `limit` or `cursor` to receive them in pages and follow `nextCursor` while `hasMore` is true; without them the response holds every matching subscription, up to 80,000. */
4619
4444
  list(params?: ListSubscriptionsParams, options?: RequestOptions): Promise<{
4620
4445
  object: "list";
4621
4446
  data: Array<SubscriptionSummary>;
4622
4447
  hasMore: boolean;
4623
4448
  nextCursor?: string;
4624
4449
  }>;
4625
- /** Create a subscription for a customer. Commet selects the default price when priceId is omitted. The subscription starts at the base USD price; market and currency are resolved from the buyer's request country when the checkout opens. Without an offer override, Commet applies the price's automatic introductory Offer. Pass offerId to apply an active compatible Offer directly, or cardPromotionId to preselect a card-eligible Promotional Offer for the initial checkout when card promotions are enabled for the organization. For the initial checkout, provider accepts either a processor name or an exact payment connection ID. When the price's free trial requires no payment method, the subscription starts trialing right away with no checkout (checkoutUrl null, hasPaymentMethod false); it cannot be combined with offerId, promoCode, cardPromotionId or provider, and an organization that cannot charge yet receives 403. */
4450
+ /** Create a subscription for a customer. Commet selects the default price when priceId is omitted. The subscription starts at the base USD price; market and currency are resolved from the buyer's request country when the checkout opens. Without an offer override, Commet applies the price's automatic introductory Offer. Pass offerId to apply an active compatible Offer directly, or cardPromotionId to preselect a card-eligible Promotional Offer for the initial checkout when card promotions are enabled for the organization. For the initial checkout, provider accepts either a processor name or an exact payment connection ID. When the price's free trial requires no payment method, the subscription starts trialing right away with no checkout (checkoutUrl null, hasPaymentMethod false); it cannot be combined with offerId, promoCode, cardPromotionId, provider or paymentMethodTypes, and an organization that cannot charge yet receives 403. When the customer already has a past_due subscription, the 409 error details carry its subscriptionId, its status and, while its renewal is unpaid, a recoveryUrl where the customer can pay it. */
4626
4451
  create(params: CreateSubscriptionParams, options?: RequestOptions): Promise<CreatedSubscription>;
4627
4452
  }
4628
4453
 
4629
- type AdvanceTestClockParams = {
4630
- advanceDays: number;
4631
- } | {
4632
- /** @format date-time */
4633
- frozenTime: string;
4634
- };
4454
+ interface AdvanceTestClockParams {
4455
+ /** Required unless `frozenTime` is sent. Cannot be combined with `frozenTime`. */
4456
+ advanceDays?: number;
4457
+ /**
4458
+ * Required unless `advanceDays` is sent. Cannot be combined with `advanceDays`.
4459
+ * @format date-time
4460
+ */
4461
+ frozenTime?: string;
4462
+ }
4635
4463
  declare class TestClockResource {
4636
4464
  private httpClient;
4637
4465
  constructor(httpClient: CommetHTTPClient);
@@ -4643,7 +4471,7 @@ declare class TestClockResource {
4643
4471
  /** Returns the organization's current test clock state and latest durable run. Sandbox only. */
4644
4472
  get(): Promise<TestClock>;
4645
4473
  /** Starts a durable run that moves the test clock forward and processes every billing deadline due before the target time. Poll GET /test-clock for progress and terminal results. Sandbox only. */
4646
- advance(params: AdvanceTestClockParams, options?: RequestOptions): Promise<TestClockRun>;
4474
+ advance(params?: AdvanceTestClockParams, options?: RequestOptions): Promise<TestClockRun>;
4647
4475
  }
4648
4476
 
4649
4477
  interface RefundTransactionParams {
@@ -4686,7 +4514,7 @@ interface CheckUsageAvailabilityParams {
4686
4514
  featureCode: string;
4687
4515
  quantity?: number;
4688
4516
  }
4689
- type TrackUsageParams = {
4517
+ interface TrackUsageParams {
4690
4518
  featureCode: string;
4691
4519
  customerId: string;
4692
4520
  eventId?: string;
@@ -4696,29 +4524,19 @@ type TrackUsageParams = {
4696
4524
  property: string;
4697
4525
  value: string;
4698
4526
  }>;
4699
- model: string;
4700
- inputTokens: number;
4701
- outputTokens: number;
4702
- value?: never;
4527
+ /** Required when `inputTokens`, `outputTokens`, `cacheReadTokens` or `cacheWriteTokens` is sent. Cannot be combined with `value`. */
4528
+ model?: string;
4529
+ /** Required when `model`, `outputTokens`, `cacheReadTokens` or `cacheWriteTokens` is sent. Cannot be combined with `value`. */
4530
+ inputTokens?: number;
4531
+ /** Required when `model`, `inputTokens`, `cacheReadTokens` or `cacheWriteTokens` is sent. Cannot be combined with `value`. */
4532
+ outputTokens?: number;
4533
+ /** Defaults to `1` unless `model` is sent. Cannot be combined with `model`, `inputTokens`, `outputTokens`, `cacheReadTokens` or `cacheWriteTokens`. */
4534
+ value?: number;
4535
+ /** Requires `model`, `inputTokens` and `outputTokens`. Cannot be combined with `value`. */
4703
4536
  cacheReadTokens?: number;
4537
+ /** Requires `model`, `inputTokens` and `outputTokens`. Cannot be combined with `value`. */
4704
4538
  cacheWriteTokens?: number;
4705
- } | {
4706
- featureCode: string;
4707
- customerId: string;
4708
- eventId?: string;
4709
- /** @format date-time */
4710
- timestamp?: string;
4711
- properties?: Array<{
4712
- property: string;
4713
- value: string;
4714
- }>;
4715
- value?: number;
4716
- model?: never;
4717
- inputTokens?: never;
4718
- outputTokens?: never;
4719
- cacheReadTokens?: never;
4720
- cacheWriteTokens?: never;
4721
- };
4539
+ }
4722
4540
  interface SetUsageParams {
4723
4541
  customerId: string;
4724
4542
  featureCode: string;
@@ -4805,7 +4623,7 @@ interface SubscriptionActivatedData {
4805
4623
  /** The payment provider that processed the activating charge: stripe, commet, or dlocal. Null when the subscription activated without a charge (zero-total or setup-based activation). */
4806
4624
  provider: "stripe" | "commet" | "dlocal" | null;
4807
4625
  }
4808
- /** Fired when a canceled subscription is reactivated and its reactivation charge succeeds. The subscription returns to active with a fresh invoice and a billing period anchored to the reactivation date. Distinct from subscription.activated (first activation) and payment.recovered (past_due recovery, which keeps the original anchor). */
4626
+ /** Fired when a canceled subscription is reactivated: its reactivation charge succeeds, or its reactivation invoice totals zero and is paid without a charge. The subscription returns to active with a fresh invoice and a billing period anchored to the reactivation date. Distinct from subscription.activated (first activation) and payment.recovered (past_due recovery, which keeps the original anchor). */
4809
4627
  interface SubscriptionReactivatedData {
4810
4628
  /** The subscription ID. */
4811
4629
  subscriptionId: string;
@@ -4827,7 +4645,7 @@ interface SubscriptionReactivatedData {
4827
4645
  invoiceTotal: number;
4828
4646
  /** The invoice currency code. */
4829
4647
  invoiceCurrency: string;
4830
- /** The payment provider that processed the reactivation charge: stripe, commet, or dlocal. */
4648
+ /** The subscription's payment provider, which processed the reactivation charge: stripe, commet, or dlocal. A reactivation whose invoice totals zero runs no charge and still carries the subscription's provider. */
4831
4649
  provider: "stripe" | "commet" | "dlocal";
4832
4650
  }
4833
4651
  /** Fired when a period-end pause is scheduled. Access and billing continue until effectiveAt. */
@@ -4973,6 +4791,8 @@ interface SubscriptionPlanChangedData {
4973
4791
  charge: number;
4974
4792
  /** Total amount charged in cents. */
4975
4793
  totalCharged: number;
4794
+ /** The cancellation reason when a cancellation moved the subscription to its group's default plan instead of ending it. Null for any other plan change. */
4795
+ cancelReason: string | null;
4976
4796
  }
4977
4797
  /** Fired when a cancellation is scheduled for the end of the billing period. The subscription stays active until effectiveAt — do NOT revoke access here. subscription.updated also fires for backward compatibility. */
4978
4798
  interface SubscriptionCancellationScheduledData {
@@ -5018,6 +4838,8 @@ interface SubscriptionPlanChangeScheduledData {
5018
4838
  scheduledBillingInterval: string | null;
5019
4839
  /** ISO 8601 datetime when the change executes (the billing period end). */
5020
4840
  effectiveAt: string;
4841
+ /** The cancellation reason when a cancellation scheduled the move to the group's default plan instead of ending the subscription. Null for any other scheduled change. */
4842
+ cancelReason: string | null;
5021
4843
  }
5022
4844
  /** Fired when a scheduled plan change will no longer take effect: it was revoked through the API, the dashboard or the customer portal, an immediate plan change or an immediate cancellation voided it, or a different change replaced it. A replacement also fires subscription.plan_change_scheduled with the new target plan. */
5023
4845
  interface SubscriptionPlanChangeRevokedData {
@@ -5118,7 +4940,7 @@ interface TrialExpiredData {
5118
4940
  /** ISO 8601 datetime when the trial ended. */
5119
4941
  trialEndsAt: string;
5120
4942
  }
5121
- /** Predictive event fired once, 3 days before a trial ends. Use it to remind the customer that billing starts soon. Emitted by a daily scan with a deterministic idempotency key, so it never fires twice for the same trial end date. */
4943
+ /** Predictive event fired once, 3 days before a trial ends. Use it to remind the customer that billing starts soon. Emitted by a recurring scan with a deterministic idempotency key, so it never fires twice for the same trial end date. */
5122
4944
  interface TrialWillEndData {
5123
4945
  /** The subscription ID. */
5124
4946
  subscriptionId: string;
@@ -5195,7 +5017,7 @@ interface PaymentReceivedData {
5195
5017
  paymentTransactionId: string | null;
5196
5018
  /** The payment provider the charge was routed to: stripe, commet, or dlocal. Null for billing-only charges with no Commet ledger row. */
5197
5019
  provider: "stripe" | "commet" | "dlocal" | null;
5198
- /** The payment method: card, oxxo, or mercado_pago. Null when unknown. */
5020
+ /** The payment method: card, apple_pay, google_pay, link, smartpix, oxxo or mercado_pago. Null when unknown. */
5199
5021
  paymentMethod: PaymentMethod | null;
5200
5022
  /** The source of funds for this charge, when reported by the provider. Null when unavailable or unknown. */
5201
5023
  subPaymentMethod: SubPaymentMethod | null;
@@ -5238,7 +5060,7 @@ interface PaymentFailedData {
5238
5060
  subscriptionId: string | null;
5239
5061
  /** The payment provider the charge was routed to: stripe, commet, or dlocal. */
5240
5062
  provider: "stripe" | "commet" | "dlocal";
5241
- /** The payment method: card, oxxo, or mercado_pago. Null when unknown. */
5063
+ /** The payment method: card, apple_pay, google_pay, link, smartpix, oxxo or mercado_pago. Null when unknown. */
5242
5064
  paymentMethod: PaymentMethod | null;
5243
5065
  /** The source of funds for this charge, when reported by the provider. Null when unavailable or unknown. */
5244
5066
  subPaymentMethod: SubPaymentMethod | null;
@@ -5263,7 +5085,7 @@ interface PaymentRecoveredData {
5263
5085
  subscriptionId: string | null;
5264
5086
  /** The payment provider that recovered the payment, or null when the invoice was recovered without a processor charge. */
5265
5087
  provider: "stripe" | "commet" | "dlocal" | null;
5266
- /** The payment method: card, oxxo, or mercado_pago. Null when unknown. */
5088
+ /** The payment method: card, apple_pay, google_pay, link, smartpix, oxxo or mercado_pago. Null when unknown. */
5267
5089
  paymentMethod: PaymentMethod | null;
5268
5090
  /** The source of funds for this charge, when reported by the provider. Null when unavailable or unknown. */
5269
5091
  subPaymentMethod: SubPaymentMethod | null;
@@ -5405,7 +5227,7 @@ interface PaymentLinkCompletedData {
5405
5227
  invoiceNumber: string;
5406
5228
  /** The payment transaction ID for the settled charge. */
5407
5229
  paymentTransactionId: string | null;
5408
- /** The payment method: card, oxxo, or mercado_pago. Null when unknown. */
5230
+ /** The payment method: card, apple_pay, google_pay, link, smartpix, oxxo or mercado_pago. Null when unknown. */
5409
5231
  paymentMethod: PaymentMethod | null;
5410
5232
  /** The source of funds for this charge, when reported by the provider. Null when unavailable or unknown. */
5411
5233
  subPaymentMethod: SubPaymentMethod | null;
@@ -5444,7 +5266,7 @@ interface PaymentLinkFailedData {
5444
5266
  failureCode: string;
5445
5267
  /** A human-readable failure message. */
5446
5268
  failureMessage: string;
5447
- /** The payment method: card, oxxo, or mercado_pago. Null when unknown. */
5269
+ /** The payment method: card, apple_pay, google_pay, link, smartpix, oxxo or mercado_pago. Null when unknown. */
5448
5270
  paymentMethod: PaymentMethod | null;
5449
5271
  /** The source of funds for this charge, when reported by the provider. Null when unavailable or unknown. */
5450
5272
  subPaymentMethod: SubPaymentMethod | null;
@@ -5518,7 +5340,7 @@ interface InvoiceVoidedData {
5518
5340
  /** The subscription ID, if the invoice is linked to a subscription. */
5519
5341
  subscriptionId: string | null;
5520
5342
  }
5521
- /** Fired once when an outstanding invoice passes its due date without payment. The invoice keeps its outstanding status — overdue is a fact about the due date, not a new status. Use it to start your own dunning flow. */
5343
+ /** Fired once when an invoice is still outstanding 24 hours after its due date. The invoice keeps its outstanding status — overdue is a fact about the due date, not a new status. Use it to start your own dunning flow. */
5522
5344
  interface InvoiceOverdueData {
5523
5345
  /** The invoice ID. */
5524
5346
  invoiceId: string;
@@ -5545,7 +5367,7 @@ interface InvoiceOverdueData {
5545
5367
  /** The subscription ID, if the invoice is linked to a subscription. */
5546
5368
  subscriptionId: string | null;
5547
5369
  }
5548
- /** Predictive event fired once, 3 days before an active subscription renews. Use it to notify the customer before they are charged. Carries no amount — usage-based charges are only final at renewal, when invoice.created delivers the actual invoice. */
5370
+ /** Predictive event fired once, 3 days before an active subscription renews. A subscription on a free plan issues no renewal invoice and does not fire it. Use it to notify the customer before they are charged. Carries no amount — usage-based charges are only final at renewal, when invoice.created delivers the actual invoice. */
5549
5371
  interface InvoiceUpcomingData {
5550
5372
  /** The subscription ID. */
5551
5373
  subscriptionId: string;
@@ -5568,7 +5390,7 @@ interface PaymentMethodAttachedData {
5568
5390
  subscriptionId: string;
5569
5391
  /** The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId. */
5570
5392
  customerId: string;
5571
- /** The payment method: card, oxxo, or mercado_pago. Null when unknown. */
5393
+ /** The payment method: card, apple_pay, google_pay, link, smartpix, oxxo or mercado_pago. Null when unknown. */
5572
5394
  paymentMethod: PaymentMethod | null;
5573
5395
  /** Card display metadata: brand, last4, expMonth, expYear. Null when the method is not a card or its details cannot be retrieved. */
5574
5396
  card: WebhookCardInfo | null;
@@ -5577,7 +5399,7 @@ interface PaymentMethodAttachedData {
5577
5399
  interface PaymentMethodUpdatedData {
5578
5400
  /** The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId. */
5579
5401
  customerId: string;
5580
- /** The payment method: card, oxxo, or mercado_pago. Null when unknown. */
5402
+ /** The payment method: card, apple_pay, google_pay, link, smartpix, oxxo or mercado_pago. Null when unknown. */
5581
5403
  paymentMethod: PaymentMethod | null;
5582
5404
  /** Card display metadata for the new method: brand, last4, expMonth, expYear. Null when the method is not a card or its details cannot be retrieved. */
5583
5405
  card: WebhookCardInfo | null;
@@ -5586,7 +5408,7 @@ interface PaymentMethodUpdatedData {
5586
5408
  interface PaymentMethodDetachedData {
5587
5409
  /** The customer ID. Returns your externalId if you provided one when creating the customer, otherwise returns the Commet publicId. */
5588
5410
  customerId: string;
5589
- /** The payment method: card, oxxo, or mercado_pago. Null when unknown. */
5411
+ /** The payment method: card, apple_pay, google_pay, link, smartpix, oxxo or mercado_pago. Null when unknown. */
5590
5412
  paymentMethod: PaymentMethod | null;
5591
5413
  /** Card display metadata of the removed method: brand, last4, expMonth, expYear. Null when the method is not a card or its details cannot be retrieved. */
5592
5414
  card: WebhookCardInfo | null;
@@ -6138,7 +5960,7 @@ interface CreditsDepletedData {
6138
5960
  /** Credits remaining after depletion. Always 0. */
6139
5961
  remainingCredits: number;
6140
5962
  }
6141
- /** Fired at a reset when unused plan credits are discarded. On a plan whose unused plan credits expire, every unused plan credit expires at each reset. On a plan that rolls them over, a reset keeps them, up to the plan's maxPlanCredits when it has one, and only the excess expires. A change to another credits plan applies the new plan's terms the same way. Purchased credits never expire and are not affected. */
5963
+ /** Fired at a reset when unused plan credits are discarded. On a plan whose unused plan credits expire, every unused plan credit expires at each reset. On a plan that rolls them over, a reset keeps them, up to the plan's maxPlanCredits when it has one, and only the excess expires. A change to another credits plan applies the new plan's terms the same way, and an immediate change also discards the credits the previous plan gave for the period it cuts short. Purchased credits never expire and are not affected. */
6142
5964
  interface CreditsExpiredData {
6143
5965
  /** The subscription ID. */
6144
5966
  subscriptionId: string;