@openmeter/client 1.0.0-beta.236 → 1.0.0-beta.238

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.
@@ -6,8 +6,11 @@
6
6
  * "mesh", "kic", or "\_".
7
7
  */
8
8
  export type Labels = Record<string, string>;
9
- /** Determines which page of the collection to retrieve. */
10
- export interface CursorPaginationQueryPage {
9
+ /**
10
+ * Determines which page of the metering event list to retrieve. A page holds at
11
+ * most 100 events.
12
+ */
13
+ export interface ListEventsPage {
11
14
  /** The number of items to include per page. */
12
15
  size?: number;
13
16
  /** Request the next page of data, starting with the item after this parameter. */
@@ -169,6 +172,15 @@ export interface VersionFilter {
169
172
  /** Match this version and earlier versions. */
170
173
  lte?: number;
171
174
  }
175
+ /** Determines which page of the collection to retrieve. */
176
+ export interface CursorPaginationQueryPage {
177
+ /** The number of items to include per page. */
178
+ size?: number;
179
+ /** Request the next page of data, starting with the item after this parameter. */
180
+ after?: string;
181
+ /** Request the previous page of data, starting with the item before this parameter. */
182
+ before?: string;
183
+ }
172
184
  /** Free price. */
173
185
  export interface PriceFree {
174
186
  /** The type of the price. */
@@ -258,6 +270,11 @@ export interface ChargeFlatFeeDiscounts {
258
270
  /** Percentage discount applied to the price (0–100). */
259
271
  percentage?: number;
260
272
  }
273
+ /** External identifiers for an invoice line item assigned by third-party systems. */
274
+ export interface InvoiceLineExternalReferences {
275
+ /** The ID assigned by the external invoicing app. */
276
+ invoicingId?: string;
277
+ }
261
278
  /** Remove a rate card from a phase. */
262
279
  export interface SubscriptionEditRemoveItem {
263
280
  /** Discriminator for the remove-item operation. */
@@ -337,11 +354,6 @@ export interface WorkflowCollectionAlignmentSubscription {
337
354
  /** The type of alignment. */
338
355
  type: 'subscription';
339
356
  }
340
- /** External identifiers for an invoice line item assigned by third-party systems. */
341
- export interface InvoiceLineExternalReferences {
342
- /** The ID assigned by the external invoicing app. */
343
- invoicingId?: string;
344
- }
345
357
  /**
346
358
  * Invoice-level invoicing settings.
347
359
  *
@@ -406,6 +418,18 @@ export interface ProductCatalogValidationError {
406
418
  /** The path to the field. */
407
419
  field: string;
408
420
  }
421
+ /**
422
+ * Determines which page of the entitlement access query to retrieve. A page holds
423
+ * at most 100 customers.
424
+ */
425
+ export interface EntitlementAccessQueryPage {
426
+ /** The number of items to include per page. */
427
+ size?: number;
428
+ /** Request the next page of data, starting with the item after this parameter. */
429
+ after?: string;
430
+ /** Request the previous page of data, starting with the item before this parameter. */
431
+ before?: string;
432
+ }
409
433
  /** List of customer identifiers to evaluate access for. */
410
434
  export interface EntitlementAccessQueryRequestCustomers {
411
435
  /**
@@ -441,6 +465,255 @@ export interface NotificationEventDeliveryAttemptResponse {
441
465
  /** The URL the event was delivered to. Only set for webhook channels. */
442
466
  url?: string;
443
467
  }
468
+ /**
469
+ * Set of key-value pairs. Metadata can be used to store additional information
470
+ * about a resource.
471
+ */
472
+ export type NotificationEventV1Metadata = Record<string, string>;
473
+ /** Set of key-value pairs managed by the system. Cannot be modified by user. */
474
+ export type NotificationEventV1Annotations = Record<string, unknown>;
475
+ /** A period with a start and end time. */
476
+ export interface NotificationEventV1Period {
477
+ /** Period start time. */
478
+ from: Date;
479
+ /** Period end time. */
480
+ to: Date;
481
+ }
482
+ /** A filter for a string field. */
483
+ export interface NotificationEventV1FilterString {
484
+ /** The field must be equal to the provided value. */
485
+ $eq?: string | null;
486
+ /** The field must not be equal to the provided value. */
487
+ $ne?: string | null;
488
+ /** The field must be in the provided list of values. */
489
+ $in?: string[] | null;
490
+ /** The field must not be in the provided list of values. */
491
+ $nin?: string[] | null;
492
+ /** The field must match the provided value. */
493
+ $like?: string | null;
494
+ /** The field must not match the provided value. */
495
+ $nlike?: string | null;
496
+ /** The field must match the provided value, ignoring case. */
497
+ $ilike?: string | null;
498
+ /** The field must not match the provided value, ignoring case. */
499
+ $nilike?: string | null;
500
+ /** The field must be greater than the provided value. */
501
+ $gt?: string | null;
502
+ /** The field must be greater than or equal to the provided value. */
503
+ $gte?: string | null;
504
+ /** The field must be less than the provided value. */
505
+ $lt?: string | null;
506
+ /** The field must be less than or equal to the provided value. */
507
+ $lte?: string | null;
508
+ /** Provide a list of filters to be combined with a logical AND. */
509
+ $and?: NotificationEventV1FilterString[] | null;
510
+ /** Provide a list of filters to be combined with a logical OR. */
511
+ $or?: NotificationEventV1FilterString[] | null;
512
+ }
513
+ /**
514
+ * A subject is a unique identifier for a usage attribution by its key. Subjects
515
+ * only exist in the concept of metering. Subjects are optional to create and work
516
+ * as an enrichment for the subject key like displayName, metadata, etc. Subjects
517
+ * are useful when you are reporting usage events with your own database ID but
518
+ * want to enrich the subject with a human-readable name or metadata. For most use
519
+ * cases, a subject is equivalent to a customer.
520
+ *
521
+ * ⚠️ **Deprecated**: Subjects as managable entities are being depracated, use
522
+ * customers with subject key usage attribution instead.
523
+ */
524
+ export interface NotificationEventV1Subject {
525
+ /** Timestamp of when the resource was created. */
526
+ createdAt: Date;
527
+ /** Timestamp of when the resource was last updated. */
528
+ updatedAt: Date;
529
+ /** Timestamp of when the resource was permanently deleted. */
530
+ deletedAt?: Date;
531
+ /** A unique identifier for the subject. */
532
+ id: string;
533
+ /**
534
+ * A unique, human-readable identifier for the subject. This is typically a
535
+ * database ID or a customer key.
536
+ */
537
+ key: string;
538
+ /** A human-readable display name for the subject. */
539
+ displayName?: string | null;
540
+ /** Metadata for the subject. */
541
+ metadata?: Record<string, unknown> | null;
542
+ /** The start of the current period for the subject. */
543
+ currentPeriodStart?: Date;
544
+ /** The end of the current period for the subject. */
545
+ currentPeriodEnd?: Date;
546
+ /** The Stripe customer ID for the subject. */
547
+ stripeCustomerId?: string | null;
548
+ }
549
+ /**
550
+ * Entitlements are the core of OpenMeter access management. They define access to
551
+ * features for subjects. Entitlements can be metered, boolean, or static.
552
+ */
553
+ export interface NotificationEventV1EntitlementValue {
554
+ /**
555
+ * Whether the subject has access to the feature. Shared accross all entitlement
556
+ * types.
557
+ */
558
+ hasAccess: boolean;
559
+ /**
560
+ * Only available for metered entitlements. Metered entitlements are built around a
561
+ * balance calculation where feature usage is deducted from the issued grants.
562
+ * Balance represents the remaining balance of the entitlement, it's value never
563
+ * turns negative.
564
+ */
565
+ balance?: number;
566
+ /**
567
+ * Only available for metered entitlements. Returns the total feature usage in the
568
+ * current period.
569
+ */
570
+ usage?: number;
571
+ /**
572
+ * Only available for metered entitlements. Overage represents the usage that
573
+ * wasn't covered by grants, e.g. if the subject had a total feature usage of 100
574
+ * in the period but they were only granted 80, there would be 20 overage.
575
+ */
576
+ overage?: number;
577
+ /**
578
+ * Only available for metered entitlements. The summed amount of all grant active
579
+ * at query time PLUS the used amount of since inactive grants.
580
+ */
581
+ totalAvailableGrantAmount?: number;
582
+ /**
583
+ * Only available for static entitlements. The JSON parsable config of the
584
+ * entitlement.
585
+ */
586
+ config?: string;
587
+ }
588
+ /**
589
+ * Mapping to attribute metered usage to the customer. One customer can have zero
590
+ * or more subjects, but one subject can only belong to one customer.
591
+ */
592
+ export interface NotificationEventV1CustomerUsageAttribution {
593
+ /**
594
+ * The subjects that are attributed to the customer. Can be empty when no subjects
595
+ * are associated with the customer.
596
+ */
597
+ subjectKeys: string[] | null;
598
+ }
599
+ /** Alignment configuration for a plan or subscription. */
600
+ export interface NotificationEventV1Alignment {
601
+ /**
602
+ * Whether all Billable items and RateCards must align. Alignment means the Price's
603
+ * BillingCadence must align for both duration and anchor time.
604
+ */
605
+ billablesMustAlign?: boolean;
606
+ }
607
+ /** References an exact plan. */
608
+ export interface NotificationEventV1PlanReference {
609
+ /** The plan ID. */
610
+ id: string;
611
+ /** The plan key. */
612
+ key: string;
613
+ /** The plan version. */
614
+ version: number;
615
+ }
616
+ /**
617
+ * InvoiceAvailableActionInvoiceDetails represents the details of the invoice
618
+ * action for non-gathering invoices.
619
+ */
620
+ export interface NotificationEventV1InvoiceAvailableActionDetails {
621
+ /**
622
+ * The state the invoice will reach if the action is activated and all intermediate
623
+ * steps are successful.
624
+ *
625
+ * For example advancing a draft_created invoice will result in a
626
+ * draft_manual_approval_needed invoice.
627
+ */
628
+ resultingState: string;
629
+ }
630
+ /**
631
+ * InvoiceAvailableActionInvoiceDetails represents the details of the invoice
632
+ * action for gathering invoices.
633
+ */
634
+ export type NotificationEventV1InvoiceAvailableActionInvoiceDetails = Record<string, never>;
635
+ /**
636
+ * BillingWorkflowCollectionAlignmentSubscription specifies the alignment for
637
+ * collecting the pending line items into an invoice.
638
+ */
639
+ export interface NotificationEventV1BillingWorkflowCollectionAlignmentSubscription {
640
+ /** The type of alignment. */
641
+ type: 'subscription';
642
+ }
643
+ /** The tax config for Stripe. */
644
+ export interface NotificationEventV1StripeTaxConfig {
645
+ /**
646
+ * Product tax code.
647
+ *
648
+ * See: https://docs.stripe.com/tax/tax-codes
649
+ */
650
+ code: string;
651
+ }
652
+ /** Custom invoicing tax config. */
653
+ export interface NotificationEventV1CustomInvoicingTaxConfig {
654
+ /**
655
+ * Tax code.
656
+ *
657
+ * The tax code should be interpreted by the custom invoicing provider.
658
+ */
659
+ code: string;
660
+ }
661
+ /** BillingWorkflowTaxSettings represents the tax settings for a billing workflow */
662
+ export interface NotificationEventV1BillingWorkflowTaxSettings {
663
+ /**
664
+ * Enable automatic tax calculation when tax is supported by the app. For example,
665
+ * with Stripe Invoicing when enabled, tax is calculated via Stripe Tax.
666
+ */
667
+ enabled?: boolean;
668
+ /**
669
+ * Enforce tax calculation when tax is supported by the app. When enabled,
670
+ * OpenMeter will not allow to create an invoice without tax calculation.
671
+ * Enforcement is different per apps, for example, Stripe app requires customer to
672
+ * have a tax location when starting a paid subscription.
673
+ */
674
+ enforced?: boolean;
675
+ }
676
+ /** The reason for the discount is a maximum spend. */
677
+ export interface NotificationEventV1DiscountReasonMaximumSpend {
678
+ /** type. */
679
+ type: 'maximum_spend';
680
+ }
681
+ /**
682
+ * InvoiceLineAppExternalIds contains the external IDs of the invoice in other apps
683
+ * such as Stripe.
684
+ */
685
+ export interface NotificationEventV1InvoiceLineAppExternalIds {
686
+ /** The external ID of the invoice in the invoicing app if available. */
687
+ invoicing?: string;
688
+ /** The external ID of the invoice in the tax app if available. */
689
+ tax?: string;
690
+ }
691
+ /** IDResource is a resouce with an ID. */
692
+ export interface NotificationEventV1IdResource {
693
+ /** A unique identifier for the resource. */
694
+ id: string;
695
+ }
696
+ /** PaymentTermInstant defines the terms for payment on receipt of invoice. */
697
+ export interface NotificationEventV1PaymentTermInstant {
698
+ /** Type of terms to be applied. */
699
+ type: 'instant';
700
+ /** Text detail of the chosen payment terms. */
701
+ detail?: string;
702
+ /** Description of the conditions for payment. */
703
+ notes?: string;
704
+ }
705
+ /**
706
+ * InvoiceAppExternalIds contains the external IDs of the invoice in other apps
707
+ * such as Stripe.
708
+ */
709
+ export interface NotificationEventV1InvoiceAppExternalIds {
710
+ /** The external ID of the invoice in the invoicing app if available. */
711
+ invoicing?: string;
712
+ /** The external ID of the invoice in the tax app if available. */
713
+ tax?: string;
714
+ /** The external ID of the invoice in the payment app if available. */
715
+ payment?: string;
716
+ }
444
717
  /**
445
718
  * A query filter for an integer attribute. Operators are mutually exclusive, only
446
719
  * one operator is allowed at a time.
@@ -506,6 +779,16 @@ export interface PagePaginationQuery {
506
779
  * list of objects.
507
780
  */
508
781
  export type PublicLabels = Record<string, string>;
782
+ /**
783
+ * Rule configuration of `v1.billing.invoice.created`. Invoice Rules have no
784
+ * type-specific settings.
785
+ */
786
+ export type InvoiceCreatedV1RuleConfig = Record<string, never>;
787
+ /**
788
+ * Rule configuration of `v1.billing.invoice.updated`. Invoice Rules have no
789
+ * type-specific settings.
790
+ */
791
+ export type InvoiceUpdatedV1RuleConfig = Record<string, never>;
509
792
  /**
510
793
  * The system account access token is meant for automations and integrations that
511
794
  * are not directly associated with a human identity.
@@ -917,9 +1200,13 @@ export interface QueryFilterNumeric {
917
1200
  /** Combines the provided filters with a logical OR. */
918
1201
  or?: QueryFilterNumeric[];
919
1202
  }
920
- /** Cursor page query. */
921
- export interface CursorPaginationQuery {
922
- page?: CursorPaginationQueryPage;
1203
+ /**
1204
+ * Cursor pagination for the metering event list, with a smaller page size limit
1205
+ * than the common one.
1206
+ */
1207
+ export interface ListEventsPagination {
1208
+ /** Determines which page of the collection to retrieve. */
1209
+ page?: ListEventsPage;
923
1210
  }
924
1211
  /** Filter options for listing meters. */
925
1212
  export interface ListMetersParamsFilter {
@@ -983,6 +1270,10 @@ export interface CreateChargeCostBasisPinned {
983
1270
  export interface CreateResourceReference {
984
1271
  id: string;
985
1272
  }
1273
+ /** CurrencyCustom reference. */
1274
+ export interface CurrencyCustomReference {
1275
+ id: string;
1276
+ }
986
1277
  /** Cost basis pinned to a specific cost basis resource of the custom currency. */
987
1278
  export interface ChargeCostBasisPinned {
988
1279
  /** Discriminator selecting the cost basis mode. */
@@ -1005,10 +1296,6 @@ export interface CreditGrantInvoiceReference {
1005
1296
  id: string;
1006
1297
  };
1007
1298
  }
1008
- /** CurrencyCustom reference. */
1009
- export interface CurrencyCustomReference {
1010
- id: string;
1011
- }
1012
1299
  /** A cost basis pinned to a custom-currency pair for the subscription. */
1013
1300
  export interface SubscriptionCostBasisPin {
1014
1301
  /** The managed custom currency ID. */
@@ -1049,15 +1336,15 @@ export interface AppReference {
1049
1336
  export interface ChargeRealizationInvoiceReference {
1050
1337
  id: string;
1051
1338
  }
1052
- /** Addon reference. */
1053
- export interface AddonReference {
1054
- id: string;
1055
- }
1056
1339
  /** Reference to a charge associated with an invoice line. */
1057
1340
  export interface ChargeReference {
1058
1341
  /** Unique identifier for the charge. */
1059
1342
  id: string;
1060
1343
  }
1344
+ /** Addon reference. */
1345
+ export interface AddonReference {
1346
+ id: string;
1347
+ }
1061
1348
  /** TaxCode reference. */
1062
1349
  export interface UpdateResourceReference {
1063
1350
  id: string;
@@ -1066,29 +1353,6 @@ export interface UpdateResourceReference {
1066
1353
  export interface NotificationChannelReference {
1067
1354
  id: string;
1068
1355
  }
1069
- /** A reference to the feature of an entitlement notification event. */
1070
- export interface NotificationEventFeatureReference {
1071
- /** The unique identifier of the feature. */
1072
- id: string;
1073
- /** The immutable key of the feature. */
1074
- key: string;
1075
- }
1076
- /** A reference to the invoice of an invoice notification event. */
1077
- export interface NotificationEventInvoiceReference {
1078
- /** The unique identifier of the invoice. */
1079
- id: string;
1080
- /** The human-readable invoice number. */
1081
- number: string;
1082
- }
1083
- /** Request body for resending a notification event. */
1084
- export interface ResendBillingNotificationEventRequest {
1085
- /**
1086
- * The channels to resend the event to. When omitted or empty, the event is resent
1087
- * to every enabled channel of the rule. Channels not targeted by the rule or
1088
- * disabled are rejected.
1089
- */
1090
- channels?: string[];
1091
- }
1092
1356
  /** Customer reference. */
1093
1357
  export interface BillingCustomerReference {
1094
1358
  /** The ID of the customer. */
@@ -1281,6 +1545,16 @@ export interface ChargeResolvedCostBasis {
1281
1545
  /** When the rate was resolved. */
1282
1546
  resolvedAt: Date;
1283
1547
  }
1548
+ /** Options for manually collecting a customer's pending lines into invoices. */
1549
+ export interface InvoiceCustomerChargesInput {
1550
+ /** Collection cutoff. Defaults to the current time and cannot be in the future. */
1551
+ asOf?: Date;
1552
+ /**
1553
+ * Override the customer's progressive billing setting for this collection. When
1554
+ * enabled, eligible usage-based lines can be collected for a partial period.
1555
+ */
1556
+ progressiveBillingOverride?: boolean;
1557
+ }
1284
1558
  /** A subscription add-on event. */
1285
1559
  export interface SubscriptionAddonTimelineSegment {
1286
1560
  /** An ISO-8601 timestamp representation of the cadence start of the resource. */
@@ -2031,15 +2305,6 @@ export interface CreditGrantPlanFilter {
2031
2305
  /** Omission matches all versions, including future versions. */
2032
2306
  version?: VersionFilter;
2033
2307
  }
2034
- /** Filter options for listing credit grants. */
2035
- export interface ListCreditGrantsParamsFilter {
2036
- /** Filter credit grants by status. */
2037
- status?: 'pending' | 'active' | 'expired' | 'voided';
2038
- /** Filter credit grants by currency. */
2039
- currency?: string;
2040
- /** Filter credit grants by key. */
2041
- key?: StringFieldFilter;
2042
- }
2043
2308
  /** A validation issue found while processing a billing resource. */
2044
2309
  export interface ValidationIssue {
2045
2310
  /** Machine-readable error code. */
@@ -2066,6 +2331,10 @@ export interface VoidCreditGrantRequest {
2066
2331
  */
2067
2332
  paymentAdjustment: 'none';
2068
2333
  }
2334
+ /** Cursor page query. */
2335
+ export interface CursorPaginationQuery {
2336
+ page?: CursorPaginationQueryPage;
2337
+ }
2069
2338
  /** The pro-rating configuration of a subscription. */
2070
2339
  export interface SubscriptionProRatingConfig {
2071
2340
  /** Whether pro-rating is enabled. */
@@ -2175,6 +2444,43 @@ export interface ChargeRealizationPayment {
2175
2444
  /** The settlement status of the payment. */
2176
2445
  status: 'authorized' | 'settled';
2177
2446
  }
2447
+ /** A monetary amount discount applied to an invoice line item. */
2448
+ export interface InvoiceLineAmountDiscount {
2449
+ /** Unique identifier for the discount. */
2450
+ id: string;
2451
+ /** The reason this discount was applied. */
2452
+ reason: 'maximum_spend' | 'ratecard_percentage' | 'ratecard_usage';
2453
+ /** Optional human-readable description of the discount. */
2454
+ description?: string;
2455
+ /** External identifiers for this discount. */
2456
+ externalReferences?: InvoiceLineExternalReferences;
2457
+ /** The monetary amount deducted. */
2458
+ amount: string;
2459
+ }
2460
+ /** A usage quantity discount applied to an invoice line item. */
2461
+ export interface InvoiceLineUsageDiscount {
2462
+ /** Unique identifier for the discount. */
2463
+ id: string;
2464
+ /** The reason this discount was applied. */
2465
+ reason: 'maximum_spend' | 'ratecard_percentage' | 'ratecard_usage';
2466
+ /** Optional human-readable description of the discount. */
2467
+ description?: string;
2468
+ /** External identifiers for this discount. */
2469
+ externalReferences?: InvoiceLineExternalReferences;
2470
+ /** The usage quantity deducted (in billing units). */
2471
+ quantity: string;
2472
+ }
2473
+ /** Base fields shared by all invoice line item discounts. */
2474
+ export interface InvoiceLineBaseDiscount {
2475
+ /** Unique identifier for the discount. */
2476
+ id: string;
2477
+ /** The reason this discount was applied. */
2478
+ reason: 'maximum_spend' | 'ratecard_percentage' | 'ratecard_usage';
2479
+ /** Optional human-readable description of the discount. */
2480
+ description?: string;
2481
+ /** External identifiers for this discount. */
2482
+ externalReferences?: InvoiceLineExternalReferences;
2483
+ }
2178
2484
  /** Remove a phase from the subscription. */
2179
2485
  export interface SubscriptionEditRemovePhase {
2180
2486
  /** Discriminator for the remove-phase operation. */
@@ -2299,48 +2605,24 @@ export interface WorkflowInvoicingSettings {
2299
2605
  progressiveBilling: boolean;
2300
2606
  /** Controls how subscription-ending shortened service periods are billed. */
2301
2607
  subscriptionEndProrationMode: 'bill_full_period' | 'bill_actual_period';
2608
+ /**
2609
+ * Controls whether empty invoices are created in the invoicing app. An invoice is
2610
+ * empty when it has no line items or its total is zero.
2611
+ */
2612
+ emptyInvoiceMode: 'create' | 'omit';
2302
2613
  }
2303
- /** A monetary amount discount applied to an invoice line item. */
2304
- export interface InvoiceLineAmountDiscount {
2305
- /** Unique identifier for the discount. */
2306
- id: string;
2307
- /** The reason this discount was applied. */
2308
- reason: 'maximum_spend' | 'ratecard_percentage' | 'ratecard_usage';
2309
- /** Optional human-readable description of the discount. */
2310
- description?: string;
2311
- /** External identifiers for this discount. */
2312
- externalReferences?: InvoiceLineExternalReferences;
2313
- /** The monetary amount deducted. */
2314
- amount: string;
2614
+ /** Filter options for listing currencies. */
2615
+ export interface ListCurrenciesParamsFilter {
2616
+ type?: 'fiat' | 'custom';
2617
+ code?: StringFieldFilter;
2315
2618
  }
2316
- /** A usage quantity discount applied to an invoice line item. */
2317
- export interface InvoiceLineUsageDiscount {
2318
- /** Unique identifier for the discount. */
2319
- id: string;
2320
- /** The reason this discount was applied. */
2321
- reason: 'maximum_spend' | 'ratecard_percentage' | 'ratecard_usage';
2322
- /** Optional human-readable description of the discount. */
2323
- description?: string;
2324
- /** External identifiers for this discount. */
2325
- externalReferences?: InvoiceLineExternalReferences;
2326
- /** The usage quantity deducted (in billing units). */
2327
- quantity: string;
2328
- }
2329
- /** Base fields shared by all invoice line item discounts. */
2330
- export interface InvoiceLineBaseDiscount {
2331
- /** Unique identifier for the discount. */
2332
- id: string;
2333
- /** The reason this discount was applied. */
2334
- reason: 'maximum_spend' | 'ratecard_percentage' | 'ratecard_usage';
2335
- /** Optional human-readable description of the discount. */
2336
- description?: string;
2337
- /** External identifiers for this discount. */
2338
- externalReferences?: InvoiceLineExternalReferences;
2339
- }
2340
- /** Filter options for listing currencies. */
2341
- export interface ListCurrenciesParamsFilter {
2342
- type?: 'fiat' | 'custom';
2343
- code?: StringFieldFilter;
2619
+ /**
2620
+ * Cursor pagination for the entitlement access query, with a smaller page size
2621
+ * limit than the common one.
2622
+ */
2623
+ export interface EntitlementAccessQueryPagination {
2624
+ /** Determines which page of the collection to retrieve. */
2625
+ page?: EntitlementAccessQueryPage;
2344
2626
  }
2345
2627
  /** Query to evaluate feature access for a list of customers. */
2346
2628
  export interface EntitlementAccessQueryRequest {
@@ -2516,6 +2798,416 @@ export interface NotificationEventDeliveryAttempt {
2516
2798
  /** When the attempt was made. */
2517
2799
  timestamp: Date;
2518
2800
  }
2801
+ /** A fixed per-unit cost amount. */
2802
+ export interface NotificationEventV1FeatureManualUnitCost {
2803
+ /** type. */
2804
+ type: 'manual';
2805
+ /** Fixed per-unit cost amount in USD. */
2806
+ amount: string;
2807
+ }
2808
+ /** Resolved per-token pricing from the LLM cost database. */
2809
+ export interface NotificationEventV1FeatureLlmUnitCostPricing {
2810
+ /** Cost per input token in USD. */
2811
+ inputPerToken: string;
2812
+ /** Cost per output token in USD. */
2813
+ outputPerToken: string;
2814
+ /** Cost per cache read token in USD. */
2815
+ cacheReadPerToken?: string;
2816
+ /** Cost per reasoning token in USD. */
2817
+ reasoningPerToken?: string;
2818
+ /** Cost per cache write token in USD. */
2819
+ cacheWritePerToken?: string;
2820
+ }
2821
+ /** Totals contains the summaries of all calculations for the invoice. */
2822
+ export interface NotificationEventV1InvoiceTotals {
2823
+ /** The total value of the line before taxes, discounts and commitments. */
2824
+ amount: string;
2825
+ /** The amount of value of the line that are due to additional charges. */
2826
+ chargesTotal: string;
2827
+ /** The amount of value of the line that are due to discounts. */
2828
+ discountsTotal: string;
2829
+ /** The amount of value of the line that are due to credits. */
2830
+ creditsTotal: string;
2831
+ /** The total amount of taxes that are included in the line. */
2832
+ taxesInclusiveTotal: string;
2833
+ /** The total amount of taxes that are added on top of amount from the line. */
2834
+ taxesExclusiveTotal: string;
2835
+ /** The total amount of taxes for this line. */
2836
+ taxesTotal: string;
2837
+ /** The total amount value of the line after taxes, discounts and commitments. */
2838
+ total: string;
2839
+ }
2840
+ /** The reason for the discount is a ratecard usage. */
2841
+ export interface NotificationEventV1DiscountReasonRatecardUsage {
2842
+ /** type. */
2843
+ type: 'ratecard_usage';
2844
+ /**
2845
+ * The quantity of the usage discount.
2846
+ *
2847
+ * Must be positive.
2848
+ */
2849
+ quantity: string;
2850
+ /**
2851
+ * Correlation ID for the discount.
2852
+ *
2853
+ * This is used to link discounts across different invoices (progressive billing
2854
+ * use case).
2855
+ *
2856
+ * If not provided, the invoicing engine will auto-generate one. When editing an
2857
+ * invoice line, please make sure to keep the same correlation ID of the discount
2858
+ * or in progressive billing setups the discount amounts might be incorrect.
2859
+ */
2860
+ correlationId?: string;
2861
+ }
2862
+ /**
2863
+ * InvoiceLineCreditAllocation represents a credit amount allocated to the line
2864
+ * before taxes are applied.
2865
+ */
2866
+ export interface NotificationEventV1InvoiceLineCreditAllocation {
2867
+ /** Amount allocated from credits. */
2868
+ amount: string;
2869
+ /** Text description as to why the credit was allocated. */
2870
+ description?: string;
2871
+ }
2872
+ /** Unit price with spend commitments. */
2873
+ export interface NotificationEventV1UnitPriceWithCommitments {
2874
+ /** The type of the price. */
2875
+ type: 'unit';
2876
+ /** The amount of the unit price. */
2877
+ amount: string;
2878
+ /** The customer is committed to spend at least the amount. */
2879
+ minimumAmount?: string;
2880
+ /** The customer is limited to spend at most the amount. */
2881
+ maximumAmount?: string;
2882
+ }
2883
+ /** Flat price. */
2884
+ export interface NotificationEventV1FlatPrice {
2885
+ /** The type of the price. */
2886
+ type: 'flat';
2887
+ /** The amount of the flat price. */
2888
+ amount: string;
2889
+ }
2890
+ /** Unit price. */
2891
+ export interface NotificationEventV1UnitPrice {
2892
+ /** The type of the price. */
2893
+ type: 'unit';
2894
+ /** The amount of the unit price. */
2895
+ amount: string;
2896
+ }
2897
+ /** Dynamic price with spend commitments. */
2898
+ export interface NotificationEventV1DynamicPriceWithCommitments {
2899
+ /** The type of the price. */
2900
+ type: 'dynamic';
2901
+ /**
2902
+ * The multiplier to apply to the base price to get the dynamic price.
2903
+ *
2904
+ * Examples:
2905
+ *
2906
+ * - 0.0: the price is zero
2907
+ * - 0.5: the price is 50% of the base price
2908
+ * - 1.0: the price is the same as the base price
2909
+ * - 1.5: the price is 150% of the base price
2910
+ */
2911
+ multiplier?: string;
2912
+ /** The customer is committed to spend at least the amount. */
2913
+ minimumAmount?: string;
2914
+ /** The customer is limited to spend at most the amount. */
2915
+ maximumAmount?: string;
2916
+ }
2917
+ /** Package price with spend commitments. */
2918
+ export interface NotificationEventV1PackagePriceWithCommitments {
2919
+ /** The type of the price. */
2920
+ type: 'package';
2921
+ /** The price of one package. */
2922
+ amount: string;
2923
+ /** The quantity per package. */
2924
+ quantityPerPackage: string;
2925
+ /** The customer is committed to spend at least the amount. */
2926
+ minimumAmount?: string;
2927
+ /** The customer is limited to spend at most the amount. */
2928
+ maximumAmount?: string;
2929
+ }
2930
+ /** A usage discount. */
2931
+ export interface NotificationEventV1BillingDiscountUsage {
2932
+ /**
2933
+ * The quantity of the usage discount.
2934
+ *
2935
+ * Must be positive.
2936
+ */
2937
+ quantity: string;
2938
+ /**
2939
+ * Correlation ID for the discount.
2940
+ *
2941
+ * This is used to link discounts across different invoices (progressive billing
2942
+ * use case).
2943
+ *
2944
+ * If not provided, the invoicing engine will auto-generate one. When editing an
2945
+ * invoice line, please make sure to keep the same correlation ID of the discount
2946
+ * or in progressive billing setups the discount amounts might be incorrect.
2947
+ */
2948
+ correlationId?: string;
2949
+ }
2950
+ /** A cost basis pinned to a custom-currency pair for the subscription. */
2951
+ export interface NotificationEventV1SubscriptionCostBasisPin {
2952
+ /** The managed custom currency ID. */
2953
+ customCurrencyId: string;
2954
+ /** The fiat currency in which the subscription is invoiced. */
2955
+ invoiceCurrency: string;
2956
+ /** The pinned cost basis resource ID. */
2957
+ costBasisId: string;
2958
+ }
2959
+ /** Address */
2960
+ export interface NotificationEventV1Address {
2961
+ /**
2962
+ * Country code in [ISO 3166-1](https://www.iso.org/iso-3166-country-codes.html)
2963
+ * alpha-2 format.
2964
+ */
2965
+ country?: string;
2966
+ /** Postal code. */
2967
+ postalCode?: string;
2968
+ /** State or province. */
2969
+ state?: string;
2970
+ /** City. */
2971
+ city?: string;
2972
+ /** First line of the address. */
2973
+ line1?: string;
2974
+ /** Second line of the address. */
2975
+ line2?: string;
2976
+ /** Phone number. */
2977
+ phoneNumber?: string;
2978
+ }
2979
+ /** Configuration for pro-rating behavior. */
2980
+ export interface NotificationEventV1ProRatingConfig {
2981
+ /** Whether pro-rating is enabled for this plan. */
2982
+ enabled: boolean;
2983
+ /** How to handle pro-rating for billing period changes. */
2984
+ mode: 'prorate_prices';
2985
+ }
2986
+ /** Threshold value with multiple supported types. */
2987
+ export interface NotificationEventV1RuleBalanceThresholdValue {
2988
+ /** Value of the threshold. */
2989
+ value: number;
2990
+ /** Type of the threshold. */
2991
+ type: 'PERCENT' | 'NUMBER' | 'balance_value' | 'usage_percentage' | 'usage_value';
2992
+ }
2993
+ /**
2994
+ * Identity stores the details required to identify an entity for tax purposes in a
2995
+ * specific country.
2996
+ */
2997
+ export interface NotificationEventV1BillingPartyTaxIdentity {
2998
+ /** Normalized tax code shown on the original identity document. */
2999
+ code?: string;
3000
+ }
3001
+ /** Reference to an invoice. */
3002
+ export interface NotificationEventV1InvoiceReference {
3003
+ /** The ID of the invoice. */
3004
+ id: string;
3005
+ /** The number of the invoice. */
3006
+ number?: string;
3007
+ }
3008
+ /**
3009
+ * InvoiceDocumentRef is used to describe a reference to an existing document
3010
+ * (invoice).
3011
+ *
3012
+ * The v1 schema describes credit note references with issued_at, number and url,
3013
+ * but the v1 API only ever sends the generic fields below.
3014
+ */
3015
+ export interface NotificationEventV1InvoiceDocumentRef {
3016
+ /** Type of the document referenced. */
3017
+ type: 'credit_note_original_invoice';
3018
+ /** Human readable description on why this reference is here or needs to be used. */
3019
+ reason?: string;
3020
+ /** Additional details about the document. */
3021
+ description?: string;
3022
+ }
3023
+ /**
3024
+ * Omitted fields: period: Tax period in which the referred document had an effect
3025
+ * required by some tax regimes and formats. stamps: Seals of approval from other
3026
+ * organisations that may need to be listed. ext: Extensions for additional codes
3027
+ * that may be required.
3028
+ */
3029
+ export interface NotificationEventV1InvoiceGenericDocumentRef {
3030
+ /** Type of the document referenced. */
3031
+ type: 'credit_note_original_invoice';
3032
+ /** Human readable description on why this reference is here or needs to be used. */
3033
+ reason?: string;
3034
+ /** Additional details about the document. */
3035
+ description?: string;
3036
+ }
3037
+ /**
3038
+ * InvoiceAvailableActions represents the actions that can be performed on the
3039
+ * invoice.
3040
+ */
3041
+ export interface NotificationEventV1InvoiceAvailableActions {
3042
+ /** Advance the invoice to the next status. */
3043
+ advance?: NotificationEventV1InvoiceAvailableActionDetails;
3044
+ /** Approve an invoice that requires manual approval. */
3045
+ approve?: NotificationEventV1InvoiceAvailableActionDetails;
3046
+ /** Delete the invoice (only non-issued invoices can be deleted). */
3047
+ delete?: NotificationEventV1InvoiceAvailableActionDetails;
3048
+ /** Retry an invoice issuing step that failed. */
3049
+ retry?: NotificationEventV1InvoiceAvailableActionDetails;
3050
+ /** Snapshot quantities for usage based line items. */
3051
+ snapshotQuantities?: NotificationEventV1InvoiceAvailableActionDetails;
3052
+ /** Void an already issued invoice. */
3053
+ void?: NotificationEventV1InvoiceAvailableActionDetails;
3054
+ /** Invoice a gathering invoice */
3055
+ invoice?: NotificationEventV1InvoiceAvailableActionInvoiceDetails;
3056
+ }
3057
+ /**
3058
+ * App capability.
3059
+ *
3060
+ * Capabilities only exist in config so they don't extend the Resource model.
3061
+ */
3062
+ export interface NotificationEventV1AppCapability {
3063
+ /** The capability type. */
3064
+ type: 'reportUsage' | 'reportEvents' | 'calculateTax' | 'invoiceCustomers' | 'collectPayments';
3065
+ /** Key */
3066
+ key: string;
3067
+ /** The capability name. */
3068
+ name: string;
3069
+ /** The capability description. */
3070
+ description: string;
3071
+ }
3072
+ /** Set of provider specific tax configs. */
3073
+ export interface NotificationEventV1TaxConfig {
3074
+ /**
3075
+ * Tax behavior.
3076
+ *
3077
+ * If not specified the billing profile is used to determine the tax behavior. If
3078
+ * not specified in the billing profile, the provider's default behavior is used.
3079
+ */
3080
+ behavior?: 'inclusive' | 'exclusive';
3081
+ /** Stripe tax config. */
3082
+ stripe?: NotificationEventV1StripeTaxConfig;
3083
+ /** Custom invoicing tax config. */
3084
+ customInvoicing?: NotificationEventV1CustomInvoicingTaxConfig;
3085
+ /**
3086
+ * Tax code reference.
3087
+ *
3088
+ * When both `taxCodeId` and `stripe.code` are provided, `taxCodeId` takes
3089
+ * precedence: the referenced tax code entity is used and `stripe.code` is ignored.
3090
+ */
3091
+ taxCodeId?: string;
3092
+ }
3093
+ /**
3094
+ * BillingWorkflowPaymentSettings represents the payment settings for a billing
3095
+ * workflow
3096
+ */
3097
+ export interface NotificationEventV1BillingWorkflowPaymentSettings {
3098
+ /** The payment method for the invoice. */
3099
+ collectionMethod?: 'charge_automatically' | 'send_invoice';
3100
+ }
3101
+ /** The reason for the discount is a ratecard percentage. */
3102
+ export interface NotificationEventV1DiscountReasonRatecardPercentage {
3103
+ /** type. */
3104
+ type: 'ratecard_percentage';
3105
+ /** The percentage of the discount. */
3106
+ percentage: number;
3107
+ /**
3108
+ * Correlation ID for the discount.
3109
+ *
3110
+ * This is used to link discounts across different invoices (progressive billing
3111
+ * use case).
3112
+ *
3113
+ * If not provided, the invoicing engine will auto-generate one. When editing an
3114
+ * invoice line, please make sure to keep the same correlation ID of the discount
3115
+ * or in progressive billing setups the discount amounts might be incorrect.
3116
+ */
3117
+ correlationId?: string;
3118
+ }
3119
+ /** A percentage discount. */
3120
+ export interface NotificationEventV1BillingDiscountPercentage {
3121
+ /** The percentage of the discount. */
3122
+ percentage: number;
3123
+ /**
3124
+ * Correlation ID for the discount.
3125
+ *
3126
+ * This is used to link discounts across different invoices (progressive billing
3127
+ * use case).
3128
+ *
3129
+ * If not provided, the invoicing engine will auto-generate one. When editing an
3130
+ * invoice line, please make sure to keep the same correlation ID of the discount
3131
+ * or in progressive billing setups the discount amounts might be incorrect.
3132
+ */
3133
+ correlationId?: string;
3134
+ }
3135
+ /** PaymentDueDate contains an amount that should be paid by the given date. */
3136
+ export interface NotificationEventV1PaymentDueDate {
3137
+ /** When the payment is due. */
3138
+ dueAt: Date;
3139
+ /** Other details to take into account for the due date. */
3140
+ notes?: string;
3141
+ /** How much needs to be paid by the date. */
3142
+ amount: string;
3143
+ /** Percentage of the total that should be paid by the date. */
3144
+ percent?: number;
3145
+ /** If different from the parent document's base currency. */
3146
+ currency?: string;
3147
+ }
3148
+ /**
3149
+ * InvoiceLineSubscriptionReference contains the references to the subscription
3150
+ * that this line is related to.
3151
+ */
3152
+ export interface NotificationEventV1InvoiceLineSubscriptionReference {
3153
+ /** The subscription. */
3154
+ subscription: NotificationEventV1IdResource;
3155
+ /** The phase of the subscription. */
3156
+ phase: NotificationEventV1IdResource;
3157
+ /** The item this line is related to. */
3158
+ item: NotificationEventV1IdResource;
3159
+ /**
3160
+ * The billing period of the subscription. In case the subscription item's billing
3161
+ * period is different from the subscription's billing period, this field will
3162
+ * contain the billing period of the subscription itself.
3163
+ *
3164
+ * For example, in case of:
3165
+ *
3166
+ * - A monthly billed subscription anchored to 2025-01-01
3167
+ * - A subscription item billed daily
3168
+ *
3169
+ * An example line would have the period of 2025-01-02 to 2025-01-03 as the item is
3170
+ * billed daily, but the subscription's billing period will be 2025-01-01 to
3171
+ * 2025-01-31.
3172
+ */
3173
+ billingPeriod: NotificationEventV1Period;
3174
+ }
3175
+ /** Flat price with payment term. */
3176
+ export interface NotificationEventV1FlatPriceWithPaymentTerm {
3177
+ /** The type of the price. */
3178
+ type: 'flat';
3179
+ /** The amount of the flat price. */
3180
+ amount: string;
3181
+ /** The payment term of the flat price. Defaults to in advance. */
3182
+ paymentTerm?: 'in_advance' | 'in_arrears';
3183
+ }
3184
+ /**
3185
+ * ValidationIssue captures any validation issues related to the invoice.
3186
+ *
3187
+ * Issues with severity "critical" will prevent the invoice from being issued.
3188
+ */
3189
+ export interface NotificationEventV1ValidationIssue {
3190
+ /** Timestamp of when the resource was created. */
3191
+ createdAt: Date;
3192
+ /** Timestamp of when the resource was last updated. */
3193
+ updatedAt: Date;
3194
+ /** Timestamp of when the resource was permanently deleted. */
3195
+ deletedAt?: Date;
3196
+ /** ID of the charge or discount. */
3197
+ id: string;
3198
+ /** The severity of the issue. */
3199
+ severity: 'critical' | 'warning';
3200
+ /** The field that the issue is related to, if available in JSON path format. */
3201
+ field?: string;
3202
+ /** Machine indentifiable code for the issue, if available. */
3203
+ code?: string;
3204
+ /** Component reporting the issue. */
3205
+ component: string;
3206
+ /** A human-readable description of the issue. */
3207
+ message: string;
3208
+ /** Additional context for the issue. */
3209
+ metadata?: NotificationEventV1Metadata;
3210
+ }
2519
3211
  /** App customer data. */
2520
3212
  export interface AppCustomerData {
2521
3213
  /**
@@ -2573,6 +3265,22 @@ export interface CreditAdjustment {
2573
3265
  description?: string;
2574
3266
  labels?: Labels;
2575
3267
  }
3268
+ /** Filter options for listing credit grants. */
3269
+ export interface ListCreditGrantsParamsFilter {
3270
+ /** Filter credit grants by status. */
3271
+ status?: 'pending' | 'active' | 'expired' | 'voided';
3272
+ /** Filter credit grants by fiat or custom currency code. */
3273
+ currency?: BillingCurrencyCode;
3274
+ /** Filter credit grants by key. */
3275
+ key?: StringFieldFilter;
3276
+ /**
3277
+ * Select grants spendable on any requested feature, including grants without
3278
+ * feature restrictions. Keys are case-sensitive. Supports `eq` (or shorthand) and
3279
+ * `oeq` with comma-separated keys. Omit to include all features; use
3280
+ * `exists=false` for grants without feature restrictions.
3281
+ */
3282
+ featureKey?: StringFieldFilter;
3283
+ }
2576
3284
  /** CreditAdjustment create request. */
2577
3285
  export interface CreateCreditAdjustmentRequest {
2578
3286
  /**
@@ -2596,7 +3304,7 @@ export interface CreateCreditAdjustmentRequest {
2596
3304
  /** Filter options for listing credit transactions. */
2597
3305
  export interface ListCreditTransactionsParamsFilter {
2598
3306
  /** Filter credit transactions by type. */
2599
- type?: 'funded' | 'consumed' | 'expired' | 'voided';
3307
+ type?: 'funded' | 'consumed' | 'correction' | 'expired' | 'voided';
2600
3308
  /**
2601
3309
  * Filter credit transactions by currency code. Custom-currency rows retain their
2602
3310
  * managed currency identifier.
@@ -2894,6 +3602,47 @@ export interface ListPlanAddonsParamsFilter {
2894
3602
  addonName?: StringFieldFilter;
2895
3603
  planCurrency?: StringFieldFilter;
2896
3604
  }
3605
+ /** CustomerBillingProfile upsert request. */
3606
+ export interface UpsertCustomerBillingProfileRequest {
3607
+ /**
3608
+ * The billing profile explicitly selected for the customer.
3609
+ *
3610
+ * Unpinned customers use the current namespace default. Selecting the current
3611
+ * default explicitly pins the customer to that profile.
3612
+ */
3613
+ billingProfile?: ProfileReference | null;
3614
+ }
3615
+ /** Customer billing profile selection. */
3616
+ export interface CustomerProfile {
3617
+ /**
3618
+ * The billing profile explicitly selected for the customer.
3619
+ *
3620
+ * Unpinned customers use the current namespace default. Selecting the current
3621
+ * default explicitly pins the customer to that profile.
3622
+ */
3623
+ billingProfile?: ProfileReference | null;
3624
+ /**
3625
+ * The effective billing profile for the customer. Uses the explicitly selected
3626
+ * billing profile when pinned, otherwise the current default billing profile.
3627
+ */
3628
+ effectiveBillingProfile: ProfileReference;
3629
+ }
3630
+ /** The feature filter shared by the entitlement Rule configurations. */
3631
+ export interface EntitlementFeaturesRuleConfig {
3632
+ /**
3633
+ * The features the rule applies to. When omitted, the rule applies to every
3634
+ * feature.
3635
+ */
3636
+ features?: FeatureReference[];
3637
+ }
3638
+ /** Rule configuration of `v1.entitlement.usage_period.reset`. */
3639
+ export interface EntitlementUsagePeriodResetV1RuleConfig {
3640
+ /**
3641
+ * The features the rule applies to. When omitted, the rule applies to every
3642
+ * feature.
3643
+ */
3644
+ features?: FeatureReference[];
3645
+ }
2897
3646
  /**
2898
3647
  * Tax configuration for a billable resource.
2899
3648
  *
@@ -2903,16 +3652,94 @@ export interface ListPlanAddonsParamsFilter {
2903
3652
  */
2904
3653
  export interface CreateTaxCodeConfig {
2905
3654
  /**
2906
- * Tax behavior.
2907
- *
2908
- * This enum is used to specify whether tax is included in the price or excluded
2909
- * from the price. If not specified, the billing profile is used to determine the
2910
- * tax behavior. If not specified in the billing profile, the provider's default
2911
- * behavior is used.
3655
+ * Tax behavior.
3656
+ *
3657
+ * This enum is used to specify whether tax is included in the price or excluded
3658
+ * from the price. If not specified, the billing profile is used to determine the
3659
+ * tax behavior. If not specified in the billing profile, the provider's default
3660
+ * behavior is used.
3661
+ */
3662
+ behavior?: 'inclusive' | 'exclusive';
3663
+ /** Tax code applied to the invoice line item. */
3664
+ code?: CreateResourceReference;
3665
+ }
3666
+ /** The credit balance by currency. */
3667
+ export interface CreditBalance {
3668
+ currency: BillingCurrencyCode;
3669
+ /** Managed currency reference. Present only for custom currencies. */
3670
+ customCurrency?: CurrencyCustomReference;
3671
+ /**
3672
+ * Spendable balance after applying currently live, unbooked charge impacts. Can be
3673
+ * negative when usage exceeds available credit.
3674
+ *
3675
+ * Always zero for historical balance queries using the `timestamp` parameter
3676
+ * because live charge impacts cannot be reconstructed historically.
3677
+ */
3678
+ live: string;
3679
+ /**
3680
+ * Credits that have been booked on the ledger as of the balance timestamp,
3681
+ * including credit-only advance debt. Can be negative.
3682
+ */
3683
+ booked: string;
3684
+ /** Deprecated alias for `booked`. Always returns the same value. */
3685
+ settled: string;
3686
+ /**
3687
+ * Spendable credit at the balance timestamp, including any credit-only advance
3688
+ * debt. Preserves credit already committed to later usage. Future grants cannot be
3689
+ * spent early; scheduled expiry reduces availability when it takes effect. Can be
3690
+ * negative when advance debt exceeds spendable credit.
3691
+ */
3692
+ spendable: string;
3693
+ /**
3694
+ * Credits that have been granted but are not yet written to the ledger, or are
3695
+ * written to the ledger with a future booked time.
3696
+ */
3697
+ pending: string;
3698
+ }
3699
+ /**
3700
+ * A credit transaction represents a single credit movement on the customer's
3701
+ * balance.
3702
+ *
3703
+ * Credit transactions are immutable.
3704
+ */
3705
+ export interface CreditTransaction {
3706
+ id: string;
3707
+ /**
3708
+ * Display name of the resource.
3709
+ *
3710
+ * Between 1 and 256 characters.
3711
+ */
3712
+ name: string;
3713
+ /**
3714
+ * Optional description of the resource.
3715
+ *
3716
+ * Maximum 1024 characters.
3717
+ */
3718
+ description?: string;
3719
+ labels?: Labels;
3720
+ /** An ISO-8601 timestamp representation of entity creation date. */
3721
+ createdAt: Date;
3722
+ /** The date and time the transaction was booked. */
3723
+ bookedAt: Date;
3724
+ /** The type of credit transaction. */
3725
+ type: 'funded' | 'consumed' | 'correction' | 'expired' | 'voided';
3726
+ /** Currency of the balance affected by the transaction. */
3727
+ currency: BillingCurrencyCode;
3728
+ /** Managed currency reference. Present only for custom currencies. */
3729
+ customCurrency?: CurrencyCustomReference;
3730
+ /**
3731
+ * Signed amount of the credit movement. Positive values add balance, negative
3732
+ * values reduce balance.
2912
3733
  */
2913
- behavior?: 'inclusive' | 'exclusive';
2914
- /** Tax code applied to the invoice line item. */
2915
- code?: CreateResourceReference;
3734
+ amount: string;
3735
+ /**
3736
+ * The booked credit balance before and after the transaction, including
3737
+ * credit-only advance debt.
3738
+ */
3739
+ availableBalance: {
3740
+ before: string;
3741
+ after: string;
3742
+ };
2916
3743
  }
2917
3744
  /**
2918
3745
  * Tax configuration for a billable resource.
@@ -2981,68 +3808,6 @@ export interface UpdateOrganizationDefaultTaxCodesRequest {
2981
3808
  /** Default tax code for credit grants. */
2982
3809
  creditGrantTaxCode?: TaxCodeReference;
2983
3810
  }
2984
- /** The credit balance by currency. */
2985
- export interface CreditBalance {
2986
- currency: BillingCurrencyCode;
2987
- /** Managed currency reference. Present only for custom currencies. */
2988
- customCurrency?: CurrencyCustomReference;
2989
- /**
2990
- * Credits available after applying currently live charge impacts.
2991
- *
2992
- * Always zero for historical balance queries using the `timestamp` parameter
2993
- * because live charge impacts cannot be reconstructed historically.
2994
- */
2995
- live: string;
2996
- /** Credits that have been booked on the ledger as of the balance timestamp. */
2997
- settled: string;
2998
- /**
2999
- * Credits that have been granted but are not yet written to the ledger, or are
3000
- * written to the ledger with a future booked time.
3001
- */
3002
- pending: string;
3003
- }
3004
- /**
3005
- * A credit transaction represents a single credit movement on the customer's
3006
- * balance.
3007
- *
3008
- * Credit transactions are immutable.
3009
- */
3010
- export interface CreditTransaction {
3011
- id: string;
3012
- /**
3013
- * Display name of the resource.
3014
- *
3015
- * Between 1 and 256 characters.
3016
- */
3017
- name: string;
3018
- /**
3019
- * Optional description of the resource.
3020
- *
3021
- * Maximum 1024 characters.
3022
- */
3023
- description?: string;
3024
- labels?: Labels;
3025
- /** An ISO-8601 timestamp representation of entity creation date. */
3026
- createdAt: Date;
3027
- /** The date and time the transaction was booked. */
3028
- bookedAt: Date;
3029
- /** The type of credit transaction. */
3030
- type: 'funded' | 'consumed' | 'expired' | 'voided';
3031
- /** Currency of the balance affected by the transaction. */
3032
- currency: BillingCurrencyCode;
3033
- /** Managed currency reference. Present only for custom currencies. */
3034
- customCurrency?: CurrencyCustomReference;
3035
- /**
3036
- * Signed amount of the credit movement. Positive values add balance, negative
3037
- * values reduce balance.
3038
- */
3039
- amount: string;
3040
- /** The available balance before and after the transaction. */
3041
- availableBalance: {
3042
- before: string;
3043
- after: string;
3044
- };
3045
- }
3046
3811
  /**
3047
3812
  * BillingInvoiceWorkflowAppsReferences represents the references (id) to the apps
3048
3813
  * used by a billing profile
@@ -3299,18 +4064,14 @@ export interface NotificationRuleInvoiceUpdatedRequest {
3299
4064
  */
3300
4065
  channels: NotificationChannelReference[];
3301
4066
  }
3302
- /** The invoice an invoice notification event refers to. */
3303
- export interface NotificationEventInvoiceData {
3304
- /** The invoice the event was generated for. */
3305
- invoice: NotificationEventInvoiceReference;
3306
- /** The identifier of the customer the invoice was issued to. */
3307
- customerId?: string;
3308
- /** The currency the invoice is denominated in. */
3309
- currency: string;
3310
- /** The status of the invoice at the time the event was generated. */
3311
- status: string;
3312
- /** The invoice total, including taxes, at the time the event was generated. */
3313
- total: string;
4067
+ /** Request body for resending a notification event. */
4068
+ export interface ResendBillingNotificationEventRequest {
4069
+ /**
4070
+ * The channels to resend the event to. When omitted or empty, the event is resent
4071
+ * to every enabled channel of the rule. Channels not targeted by the rule or
4072
+ * disabled are rejected.
4073
+ */
4074
+ channels?: NotificationChannelReference[];
3314
4075
  }
3315
4076
  /** Filter options for listing ingested events. */
3316
4077
  export interface ListEventsParamsFilter {
@@ -3393,6 +4154,11 @@ export interface ListChargesParamsFilter {
3393
4154
  servicePeriodTo?: DateTimeFieldFilter;
3394
4155
  /** Filter charges by the ID of their customer. */
3395
4156
  customerId?: UlidFieldFilter;
4157
+ /**
4158
+ * Filter charges by the ID of their subscription. Only charges linked to a
4159
+ * subscription can match, including when using `neq`.
4160
+ */
4161
+ subscriptionId?: UlidFieldFilter;
3396
4162
  }
3397
4163
  /** Filter options for listing notification channels. */
3398
4164
  export interface ListNotificationChannelsParamsFilter {
@@ -4177,6 +4943,21 @@ export interface SubscriptionBase {
4177
4943
  * - Custom date (customer-specified day)
4178
4944
  */
4179
4945
  billingAnchor: Date;
4946
+ /**
4947
+ * When billing starts for the subscription. Nothing is billed for service before
4948
+ * this time, while access, entitlements and metering start with the subscription.
4949
+ * Use it when the time before was already billed elsewhere, for example when
4950
+ * importing a subscription from another billing system.
4951
+ *
4952
+ * It cannot be before the start of the subscription and cannot be changed later.
4953
+ * On subscriptions billed through invoice lines it must be the start of a billing
4954
+ * period. If not provided, billing starts with the subscription.
4955
+ *
4956
+ * When billing starts inside a billing period, we recommend enabling price
4957
+ * pro-rating (`prorate_prices`) on the plan. Without it that billing period's flat
4958
+ * fees are billed in full.
4959
+ */
4960
+ billingStartsAt?: Date;
4180
4961
  /** The status of the subscription. */
4181
4962
  status: 'active' | 'inactive' | 'canceled' | 'scheduled';
4182
4963
  /**
@@ -4217,6 +4998,13 @@ export interface InvoiceWorkflow {
4217
4998
  /** Payment settings for this invoice. */
4218
4999
  payment?: WorkflowPaymentSettings;
4219
5000
  }
5001
+ /** Discounts applied to an invoice line item. */
5002
+ export interface InvoiceLineDiscounts {
5003
+ /** Monetary amount discounts (e.g. from maximum spend commitments). */
5004
+ amount?: InvoiceLineAmountDiscount[];
5005
+ /** Usage quantity discounts (e.g. free tier usage allowances). */
5006
+ usage?: InvoiceLineUsageDiscount[];
5007
+ }
4220
5008
  /** Request for canceling a subscription. */
4221
5009
  export interface SubscriptionCancel {
4222
5010
  /** If not provided the subscription is canceled immediately. */
@@ -4356,13 +5144,6 @@ export interface AppCatalogItem {
4356
5144
  /** Available install methods of the app. */
4357
5145
  installMethods: ('with_oauth2' | 'with_api_key' | 'no_credentials_required')[];
4358
5146
  }
4359
- /** Discounts applied to an invoice line item. */
4360
- export interface InvoiceLineDiscounts {
4361
- /** Monetary amount discounts (e.g. from maximum spend commitments). */
4362
- amount?: InvoiceLineAmountDiscount[];
4363
- /** Usage quantity discounts (e.g. free tier usage allowances). */
4364
- usage?: InvoiceLineUsageDiscount[];
4365
- }
4366
5147
  /**
4367
5148
  * Invoice-level snapshot of the workflow configuration.
4368
5149
  *
@@ -4462,6 +5243,16 @@ export interface NotificationRuleBalanceThresholdRequest {
4462
5243
  */
4463
5244
  features?: FeatureReference[];
4464
5245
  }
5246
+ /** Rule configuration of `v1.entitlement.balance_threshold.triggered`. */
5247
+ export interface EntitlementBalanceThresholdTriggeredV1RuleConfig {
5248
+ /** The thresholds that generate an event when crossed. */
5249
+ thresholds: NotificationBalanceThreshold[];
5250
+ /**
5251
+ * The features the rule applies to. When omitted, the rule applies to every
5252
+ * feature.
5253
+ */
5254
+ features?: FeatureReference[];
5255
+ }
4465
5256
  /**
4466
5257
  * The delivery status of a notification event for one channel of the generating
4467
5258
  * rule.
@@ -4479,29 +5270,316 @@ export interface NotificationEventDeliveryStatus {
4479
5270
  * When the next delivery attempt is scheduled. Absent when no further attempts
4480
5271
  * will be made.
4481
5272
  */
4482
- nextAttempt?: Date;
4483
- /** The delivery attempts made so far, most recent first. */
4484
- attempts: NotificationEventDeliveryAttempt[];
5273
+ nextAttempt?: Date;
5274
+ /** The delivery attempts made so far, most recent first. */
5275
+ attempts: NotificationEventDeliveryAttempt[];
5276
+ }
5277
+ /** Recurring period with an interval and an anchor. */
5278
+ export interface NotificationEventV1RecurringPeriod {
5279
+ /**
5280
+ * The unit of time for the interval. Heuristically maps ISO duraitons to enum
5281
+ * values or returns the ISO duration.
5282
+ */
5283
+ interval: NotificationEventV1RecurringPeriodInterval;
5284
+ /** A date-time anchor to base the recurring period on. */
5285
+ anchor: Date;
5286
+ /** The unit of time for the interval in ISO8601 format. */
5287
+ intervalIso: string;
5288
+ }
5289
+ /** Recurring period with an interval and an anchor. */
5290
+ export interface NotificationEventV1RecurringPeriodV2 {
5291
+ /**
5292
+ * The unit of time for the interval. Heuristically maps ISO duraitons to enum
5293
+ * values or returns the ISO duration.
5294
+ */
5295
+ interval: NotificationEventV1RecurringPeriodInterval;
5296
+ /** A date-time anchor to base the recurring period on. */
5297
+ anchor: Date;
5298
+ }
5299
+ /**
5300
+ * LLM cost lookup configuration. Maps meter group-by dimensions to LLM cost
5301
+ * database fields.
5302
+ */
5303
+ export interface NotificationEventV1FeatureLlmUnitCost {
5304
+ /** type. */
5305
+ type: 'llm';
5306
+ /**
5307
+ * Meter group-by property that holds the LLM provider. Use this when the meter has
5308
+ * a group-by dimension for provider. Mutually exclusive with `provider`.
5309
+ */
5310
+ providerProperty?: string;
5311
+ /**
5312
+ * Static LLM provider value (e.g., "openai", "anthropic"). Use this when the
5313
+ * feature tracks a single provider. Mutually exclusive with `providerProperty`.
5314
+ */
5315
+ provider?: string;
5316
+ /**
5317
+ * Meter group-by property that holds the model ID. Use this when the meter has a
5318
+ * group-by dimension for model. Mutually exclusive with `model`.
5319
+ */
5320
+ modelProperty?: string;
5321
+ /**
5322
+ * Static model ID value (e.g., "gpt-4", "claude-3-5-sonnet"). Use this when the
5323
+ * feature tracks a single model. Mutually exclusive with `modelProperty`.
5324
+ */
5325
+ model?: string;
5326
+ /**
5327
+ * Meter group-by property that holds the token type. Use this when the meter has a
5328
+ * group-by dimension for token type. Mutually exclusive with `tokenType`.
5329
+ */
5330
+ tokenTypeProperty?: string;
5331
+ /**
5332
+ * Static token type value. Use this when the feature tracks a single token type
5333
+ * (e.g., only input tokens). Expected values: input, output, cache_read,
5334
+ * reasoning, cache_write, request, response. `request` is an alias for `input`,
5335
+ * `response` is an alias for `output`. Mutually exclusive with
5336
+ * `tokenTypeProperty`.
5337
+ */
5338
+ tokenType?: string;
5339
+ /**
5340
+ * Resolved per-token pricing from the LLM cost database. Only populated in
5341
+ * responses when the feature's meter group-by filters specify exact provider and
5342
+ * model values.
5343
+ */
5344
+ pricing?: NotificationEventV1FeatureLlmUnitCostPricing;
5345
+ }
5346
+ /** A price tier. At least one price component is required in each tier. */
5347
+ export interface NotificationEventV1PriceTier {
5348
+ /**
5349
+ * Up to and including to this quantity will be contained in the tier. If null, the
5350
+ * tier is open-ended.
5351
+ */
5352
+ upToAmount?: string;
5353
+ /** The flat price component of the tier. */
5354
+ flatPrice: NotificationEventV1FlatPrice | null;
5355
+ /** The unit price component of the tier. */
5356
+ unitPrice: NotificationEventV1UnitPrice | null;
5357
+ }
5358
+ /** Subscription is an exact subscription instance. */
5359
+ export interface NotificationEventV1Subscription {
5360
+ /** A unique identifier for the resource. */
5361
+ id: string;
5362
+ /** Human-readable name for the resource. Between 1 and 256 characters. */
5363
+ name: string;
5364
+ /** Optional description of the resource. Maximum 1024 characters. */
5365
+ description?: string;
5366
+ /** Additional metadata for the resource. */
5367
+ metadata?: NotificationEventV1Metadata | null;
5368
+ /** Timestamp of when the resource was created. */
5369
+ createdAt: Date;
5370
+ /** Timestamp of when the resource was last updated. */
5371
+ updatedAt: Date;
5372
+ /** Timestamp of when the resource was permanently deleted. */
5373
+ deletedAt?: Date;
5374
+ /** The cadence start of the resource. */
5375
+ activeFrom: Date;
5376
+ /** The cadence end of the resource. */
5377
+ activeTo?: Date;
5378
+ /** Set of key-value pairs managed by the system. Cannot be modified by user. */
5379
+ annotations?: NotificationEventV1Annotations;
5380
+ /** Alignment configuration for the plan. */
5381
+ alignment?: NotificationEventV1Alignment;
5382
+ /** The status of the subscription. */
5383
+ status: 'active' | 'inactive' | 'canceled' | 'scheduled';
5384
+ /** The customer ID of the subscription. */
5385
+ customerId: string;
5386
+ /** The plan of the subscription. */
5387
+ plan?: NotificationEventV1PlanReference;
5388
+ /** The fiat currency in which the subscription is invoiced. */
5389
+ currency: string;
5390
+ /**
5391
+ * Controls whether custom-currency cost bases are resolved dynamically or pinned
5392
+ * when their currency pair is introduced to the subscription.
5393
+ */
5394
+ costBasisMode: 'dynamic' | 'pinned';
5395
+ /** Cost bases pinned to custom-currency pairs for this subscription. */
5396
+ costBasisPins: NotificationEventV1SubscriptionCostBasisPin[];
5397
+ /**
5398
+ * The billing cadence for the subscriptions. Defines how often customers are
5399
+ * billed using ISO8601 duration format. Examples: "P1M" (monthly), "P3M"
5400
+ * (quarterly), "P1Y" (annually).
5401
+ */
5402
+ billingCadence: string;
5403
+ /** The pro-rating configuration for the subscriptions. */
5404
+ proRatingConfig?: NotificationEventV1ProRatingConfig;
5405
+ /** The normalizedbilling anchor of the subscription. */
5406
+ billingAnchor: Date;
5407
+ /**
5408
+ * The settlement mode of the subscription.
5409
+ *
5410
+ * - credit_then_invoice: credits from the previous billing period are applied
5411
+ * first, then the remaining balance is invoiced.
5412
+ * - credit_only: only credits from the previous billing period are generated and
5413
+ * applied. No invoices are generated for the subscription. This is the default
5414
+ * and most common settlement mode.
5415
+ */
5416
+ settlementMode: 'credit_then_invoice' | 'credit_only';
5417
+ }
5418
+ /** Party represents a person or business entity. */
5419
+ export interface NotificationEventV1BillingParty {
5420
+ /** Unique identifier for the party (if available) */
5421
+ id?: string;
5422
+ /** An optional unique key of the party (if available) */
5423
+ key?: string;
5424
+ /** Legal name or representation of the organization. */
5425
+ name?: string;
5426
+ /**
5427
+ * The entity's legal ID code used for tax purposes. They may have other numbers,
5428
+ * but we're only interested in those valid for tax purposes.
5429
+ */
5430
+ taxId?: NotificationEventV1BillingPartyTaxIdentity;
5431
+ /** Regular post addresses for where information should be sent if needed. */
5432
+ addresses?: NotificationEventV1Address[];
5433
+ }
5434
+ /**
5435
+ * BillingInvoiceCustomerExtendedDetails is a collection of fields that are used to
5436
+ * extend the billing party details for invoices.
5437
+ *
5438
+ * These fields contain the OpenMeter specific details for the customer, that are
5439
+ * not strictly required for the invoice itself.
5440
+ */
5441
+ export interface NotificationEventV1BillingInvoiceCustomerExtendedDetails {
5442
+ /** Unique identifier for the party (if available) */
5443
+ id?: string;
5444
+ /** An optional unique key of the party (if available) */
5445
+ key?: string;
5446
+ /** Legal name or representation of the organization. */
5447
+ name?: string;
5448
+ /**
5449
+ * The entity's legal ID code used for tax purposes. They may have other numbers,
5450
+ * but we're only interested in those valid for tax purposes.
5451
+ */
5452
+ taxId?: NotificationEventV1BillingPartyTaxIdentity;
5453
+ /** Regular post addresses for where information should be sent if needed. */
5454
+ addresses?: NotificationEventV1Address[];
5455
+ /** Mapping to attribute metered usage to the customer */
5456
+ usageAttribution: NotificationEventV1CustomerUsageAttribution;
5457
+ }
5458
+ /**
5459
+ * InvoiceStatusDetails represents the details of the invoice status.
5460
+ *
5461
+ * API users are encouraged to rely on the immutable/failed/avaliableActions fields
5462
+ * to determine the next steps of the invoice instead of the extendedStatus field.
5463
+ */
5464
+ export interface NotificationEventV1InvoiceStatusDetails {
5465
+ /** Is the invoice editable? */
5466
+ immutable: boolean;
5467
+ /** Is the invoice in a failed state? */
5468
+ failed: boolean;
5469
+ /** Extended status information for the invoice. */
5470
+ extendedStatus: string;
5471
+ /** The actions that can be performed on the invoice. */
5472
+ availableActions: NotificationEventV1InvoiceAvailableActions;
5473
+ }
5474
+ /**
5475
+ * A marketplace listing. Represent an available app in the app marketplace that
5476
+ * can be installed to the organization.
5477
+ *
5478
+ * Marketplace apps only exist in config so they don't extend the Resource model.
5479
+ */
5480
+ export interface NotificationEventV1MarketplaceListing {
5481
+ /** The app's type */
5482
+ type: 'stripe' | 'sandbox' | 'custom_invoicing';
5483
+ /** The app's name. */
5484
+ name: string;
5485
+ /** The app's description. */
5486
+ description: string;
5487
+ /** The app's capabilities. */
5488
+ capabilities: NotificationEventV1AppCapability[];
5489
+ /**
5490
+ * Install methods.
5491
+ *
5492
+ * List of methods to install the app.
5493
+ */
5494
+ installMethods: ('with_oauth2' | 'with_api_key' | 'no_credentials_required')[];
5495
+ }
5496
+ /**
5497
+ * BillingWorkflowInvoicingSettings represents the invoice settings for a billing
5498
+ * workflow
5499
+ */
5500
+ export interface NotificationEventV1BillingWorkflowInvoicingSettings {
5501
+ /** Whether to automatically issue the invoice after the draftPeriod has passed. */
5502
+ autoAdvance?: boolean;
5503
+ /** The period for the invoice to be kept in draft status for manual reviews. */
5504
+ draftPeriod?: string;
5505
+ /**
5506
+ * The period after which the invoice is due. With some payment solutions it's only
5507
+ * applicable for manual collection method.
5508
+ */
5509
+ dueAfter?: string;
5510
+ /** Should progressive billing be allowed for this workflow? */
5511
+ progressiveBilling?: boolean;
5512
+ /** Controls how subscription-ending shortened service periods are billed. */
5513
+ subscriptionEndProrationMode?: 'bill_full_period' | 'bill_actual_period';
5514
+ /**
5515
+ * Default tax configuration to apply to the invoices.
5516
+ *
5517
+ * Setting a tax code (`stripe.code` / `taxCodeId`) on a profile's default tax
5518
+ * config is deprecated and can no longer be added or changed: the organization
5519
+ * default tax code is used instead. Existing tax-code values may still be removed,
5520
+ * and `behavior` remains fully supported.
5521
+ */
5522
+ defaultTaxConfig?: NotificationEventV1TaxConfig;
5523
+ }
5524
+ /** TaxConfig stores the configuration for a tax line relative to an invoice line. */
5525
+ export interface NotificationEventV1InvoiceLineTaxItem {
5526
+ /** Tax provider configuration. */
5527
+ config?: NotificationEventV1TaxConfig;
5528
+ /**
5529
+ * Percent defines the percentage set manually or determined from the rate key
5530
+ * (calculated if rate present). A nil percent implies that this tax combo is
5531
+ * **exempt** from tax.")
5532
+ */
5533
+ percent?: number;
5534
+ /** Some countries require an additional surcharge (calculated if rate present). */
5535
+ surcharge?: string;
5536
+ /** Is the tax item inclusive or exclusive of the base amount. */
5537
+ behavior?: 'inclusive' | 'exclusive';
5538
+ }
5539
+ /** A discount by type. */
5540
+ export interface NotificationEventV1BillingDiscounts {
5541
+ /** The percentage discount. */
5542
+ percentage?: NotificationEventV1BillingDiscountPercentage;
5543
+ /** The usage discount. */
5544
+ usage?: NotificationEventV1BillingDiscountUsage;
5545
+ }
5546
+ /** PaymentTermDueDate defines the terms for payment on a specific date. */
5547
+ export interface NotificationEventV1PaymentTermDueDate {
5548
+ /** Type of terms to be applied. */
5549
+ type: 'due_date';
5550
+ /** Text detail of the chosen payment terms. */
5551
+ detail?: string;
5552
+ /** Description of the conditions for payment. */
5553
+ notes?: string;
5554
+ /** When the payment is due. */
5555
+ dueAt: NotificationEventV1PaymentDueDate[];
4485
5556
  }
4486
5557
  /** Billing customer data. */
4487
5558
  export interface CustomerData {
4488
5559
  /**
4489
- * The billing profile for the customer.
5560
+ * The billing profile explicitly selected for the customer.
4490
5561
  *
4491
- * If not provided, the default billing profile will be used.
5562
+ * Unpinned customers use the current namespace default. Selecting the current
5563
+ * default explicitly pins the customer to that profile.
5564
+ */
5565
+ billingProfile?: ProfileReference | null;
5566
+ /**
5567
+ * The effective billing profile for the customer. Uses the explicitly selected
5568
+ * billing profile when pinned, otherwise the current default billing profile.
4492
5569
  */
4493
- billingProfile?: ProfileReference;
5570
+ effectiveBillingProfile: ProfileReference;
4494
5571
  /** App customer data. */
4495
5572
  appData?: AppCustomerData;
4496
5573
  }
4497
5574
  /** CustomerBillingData upsert request. */
4498
5575
  export interface UpsertCustomerBillingDataRequest {
4499
5576
  /**
4500
- * The billing profile for the customer.
5577
+ * The billing profile explicitly selected for the customer.
4501
5578
  *
4502
- * If not provided, the default billing profile will be used.
5579
+ * Unpinned customers use the current namespace default. Selecting the current
5580
+ * default explicitly pins the customer to that profile.
4503
5581
  */
4504
- billingProfile?: ProfileReference;
5582
+ billingProfile?: ProfileReference | null;
4505
5583
  /** App customer data. */
4506
5584
  appData?: AppCustomerData;
4507
5585
  }
@@ -4550,37 +5628,6 @@ export interface ListCustomerEntitlementAccessResponseData {
4550
5628
  /** The list of entitlement access results. */
4551
5629
  data: EntitlementValueResult[];
4552
5630
  }
4553
- /** The entities and threshold a balance threshold event refers to. */
4554
- export interface NotificationEventBalanceThresholdData {
4555
- /** The identifier of the entitlement that triggered the event. */
4556
- entitlementId: string;
4557
- /** The feature the entitlement grants access to. */
4558
- feature: NotificationEventFeatureReference;
4559
- /** The key of the subject the entitlement belongs to. */
4560
- subjectKey: string;
4561
- /** The identifier of the customer the subject belongs to, if any. */
4562
- customerId?: string;
4563
- /** The entitlement value at the time the event was generated. */
4564
- value: EntitlementValueResult;
4565
- /** The threshold the balance crossed. */
4566
- threshold: NotificationBalanceThreshold;
4567
- }
4568
- /**
4569
- * The entitlement, feature, and subject an entitlement notification event refers
4570
- * to.
4571
- */
4572
- export interface NotificationEventEntitlementData {
4573
- /** The identifier of the entitlement that triggered the event. */
4574
- entitlementId: string;
4575
- /** The feature the entitlement grants access to. */
4576
- feature: NotificationEventFeatureReference;
4577
- /** The key of the subject the entitlement belongs to. */
4578
- subjectKey: string;
4579
- /** The identifier of the customer the subject belongs to, if any. */
4580
- customerId?: string;
4581
- /** The entitlement value at the time the event was generated. */
4582
- value: EntitlementValueResult;
4583
- }
4584
5631
  /**
4585
5632
  * Graduated tiered price.
4586
5633
  *
@@ -4686,6 +5733,18 @@ export interface CreateCreditGrantPurchase {
4686
5733
  */
4687
5734
  availabilityPolicy: 'on_creation';
4688
5735
  }
5736
+ /** The balances of the credits of a customer. */
5737
+ export interface CreditBalances {
5738
+ /** The timestamp of the balance retrieval. */
5739
+ retrievedAt: Date;
5740
+ /** The balances by currencies. */
5741
+ balances: CreditBalance[];
5742
+ }
5743
+ /** Cursor paginated response. */
5744
+ export interface CreditTransactionPaginatedResponse {
5745
+ data: CreditTransaction[];
5746
+ meta: CursorMeta;
5747
+ }
4689
5748
  /** Purchase and payment terms of the grant. */
4690
5749
  export interface CreditGrantPurchase {
4691
5750
  /**
@@ -4801,45 +5860,11 @@ export interface WorkflowTaxSettings {
4801
5860
  */
4802
5861
  defaultTaxConfig?: TaxConfig;
4803
5862
  }
4804
- /** The balances of the credits of a customer. */
4805
- export interface CreditBalances {
4806
- /** The timestamp of the balance retrieval. */
4807
- retrievedAt: Date;
4808
- /** The balances by currencies. */
4809
- balances: CreditBalance[];
4810
- }
4811
- /** Cursor paginated response. */
4812
- export interface CreditTransactionPaginatedResponse {
4813
- data: CreditTransaction[];
4814
- meta: CursorMeta;
4815
- }
4816
5863
  /** Page paginated response. */
4817
5864
  export interface PlanAddonPagePaginatedResponse {
4818
5865
  data: PlanAddon[];
4819
5866
  meta: PaginatedMeta;
4820
5867
  }
4821
- /** An invoice created notification event payload. */
4822
- export interface NotificationEventInvoiceCreatedPayload {
4823
- /** The identifier of the event the payload belongs to. */
4824
- id: string;
4825
- /** The type of the event. */
4826
- type: 'invoice.created';
4827
- /** When the event was generated. */
4828
- timestamp: Date;
4829
- /** The invoice the event refers to. */
4830
- data: NotificationEventInvoiceData;
4831
- }
4832
- /** An invoice updated notification event payload. */
4833
- export interface NotificationEventInvoiceUpdatedPayload {
4834
- /** The identifier of the event the payload belongs to. */
4835
- id: string;
4836
- /** The type of the event. */
4837
- type: 'invoice.updated';
4838
- /** When the event was generated. */
4839
- timestamp: Date;
4840
- /** The invoice the event refers to. */
4841
- data: NotificationEventInvoiceData;
4842
- }
4843
5868
  /** Cursor paginated response. */
4844
5869
  export interface IngestedEventPaginatedResponse {
4845
5870
  data: IngestedEvent[];
@@ -5091,6 +6116,50 @@ export interface InvoiceWorkflowSettings {
5091
6116
  */
5092
6117
  workflow: InvoiceWorkflow;
5093
6118
  }
6119
+ /**
6120
+ * A detailed (child) sub-line belonging to a parent invoice line.
6121
+ *
6122
+ * Detailed lines represent the individual flat-fee components that make up a
6123
+ * usage-based parent line after quantity snapshotting.
6124
+ */
6125
+ export interface InvoiceDetailedLine {
6126
+ id: string;
6127
+ /**
6128
+ * Display name of the resource.
6129
+ *
6130
+ * Between 1 and 256 characters.
6131
+ */
6132
+ name: string;
6133
+ /**
6134
+ * Optional description of the resource.
6135
+ *
6136
+ * Maximum 1024 characters.
6137
+ */
6138
+ description?: string;
6139
+ labels?: Labels;
6140
+ /** An ISO-8601 timestamp representation of entity creation date. */
6141
+ createdAt: Date;
6142
+ /** An ISO-8601 timestamp representation of entity last update date. */
6143
+ updatedAt: Date;
6144
+ /** An ISO-8601 timestamp representation of entity deletion date. */
6145
+ deletedAt?: Date;
6146
+ /** The service period covered by this detailed line. */
6147
+ servicePeriod: ClosedPeriod;
6148
+ /** Aggregated financial totals for the detailed line. */
6149
+ totals: Totals;
6150
+ /** The cost category of this detailed line. */
6151
+ category: 'regular' | 'commitment';
6152
+ /** Discounts applied to this detailed line. */
6153
+ discounts?: InvoiceLineDiscounts;
6154
+ /** Credit applied to this detailed line. */
6155
+ creditsApplied?: InvoiceLineCreditsApplied[];
6156
+ /** External identifiers for this detailed line. */
6157
+ externalReferences?: InvoiceLineExternalReferences;
6158
+ /** The quantity of the detailed line. */
6159
+ quantity: string;
6160
+ /** The unit price of the detailed line. */
6161
+ unitPrice: string;
6162
+ }
5094
6163
  /** Page paginated response. */
5095
6164
  export interface TaxCodePagePaginatedResponse {
5096
6165
  data: TaxCode[];
@@ -5389,109 +6458,362 @@ export interface InstalledAppExternalInvoicing {
5389
6458
  /** Default capabilities of the installed app. */
5390
6459
  defaultForCapabilityTypes: ('report_usage' | 'report_events' | 'calculate_tax' | 'invoice_customers' | 'collect_payments')[];
5391
6460
  }
6461
+ /** Snapshot of the billing workflow configuration captured at invoice creation. */
6462
+ export interface UpdateInvoiceWorkflowSettings {
6463
+ /**
6464
+ * The workflow configuration that was active when the invoice was created.
6465
+ *
6466
+ * Only the fields that are meaningful at the per-invoice level are included:
6467
+ * invoicing behaviour (auto-advance, draft period) and payment settings
6468
+ * (collection method, due date). Profile-wide settings such as collection
6469
+ * alignment, progressive billing, and tax policy are omitted.
6470
+ */
6471
+ workflow: UpdateBillingInvoiceWorkflow;
6472
+ }
6473
+ /** Access evaluation result for a single resolved customer. */
6474
+ export interface EntitlementAccessQueryResult {
6475
+ /**
6476
+ * The list of identifiers from the request that resolved to this customer. Each
6477
+ * entry is either the customer `key` or one of its usage-attribution subject
6478
+ * `key`s.
6479
+ *
6480
+ * Duplicate or aliased identifiers that resolve to the same customer collapse to a
6481
+ * single result entry, with every requested identifier listed here.
6482
+ */
6483
+ matched: string[];
6484
+ /** The customer the matched identifiers resolved to. */
6485
+ customer: Customer;
6486
+ /**
6487
+ * Map of features with their access status.
6488
+ *
6489
+ * Map keys are the feature keys requested in `feature.keys`, or every feature
6490
+ * `key` available in the organization when the feature filter was omitted.
6491
+ */
6492
+ features: Record<string, EntitlementFeatureAccess>;
6493
+ /**
6494
+ * Timestamp of the most recent change to the customer's access state reflected in
6495
+ * this result.
6496
+ */
6497
+ updatedAt: Date;
6498
+ }
5392
6499
  /**
5393
- * A detailed (child) sub-line belonging to a parent invoice line.
5394
- *
5395
- * Detailed lines represent the individual flat-fee components that make up a
5396
- * usage-based parent line after quantity snapshotting.
6500
+ * Metered entitlements are useful for many different use cases, from setting up
6501
+ * usage based access to implementing complex credit systems. Access is determined
6502
+ * based on feature usage using a balance calculation (the "usage allowance"
6503
+ * provided by the issued grants is "burnt down" by the usage).
5397
6504
  */
5398
- export interface InvoiceDetailedLine {
6505
+ export interface NotificationEventV1EntitlementMetered {
6506
+ /** type. */
6507
+ type: 'metered';
6508
+ /**
6509
+ * If softLimit=true the subject can use the feature even if the entitlement is
6510
+ * exhausted, hasAccess will always be true.
6511
+ */
6512
+ isSoftLimit?: boolean;
6513
+ /**
6514
+ * Deprecated, ignored by the backend. Please use isSoftLimit instead; this field
6515
+ * will be removed in the future.
6516
+ */
6517
+ isUnlimited?: boolean;
6518
+ /**
6519
+ * You can grant usage automatically alongside the entitlement, the example
6520
+ * scenario would be creating a starting balance. If an amount is specified here, a
6521
+ * grant will be created alongside the entitlement with the specified amount. That
6522
+ * grant will have it's rollover settings configured in a way that after each reset
6523
+ * operation, the balance will return the original amount specified here. Manually
6524
+ * creating such a grant would mean having the "amount", "minRolloverAmount", and
6525
+ * "maxRolloverAmount" fields all be the same.
6526
+ */
6527
+ issueAfterReset?: number;
6528
+ /** Defines the grant priority for the default grant. */
6529
+ issueAfterResetPriority?: number;
6530
+ /** If true, the overage is preserved at reset. If false, the usage is reset to 0. */
6531
+ preserveOverageAtReset?: boolean;
6532
+ /** Timestamp of when the resource was created. */
6533
+ createdAt: Date;
6534
+ /** Timestamp of when the resource was last updated. */
6535
+ updatedAt: Date;
6536
+ /** Timestamp of when the resource was permanently deleted. */
6537
+ deletedAt?: Date;
6538
+ /** Additional metadata for the feature. */
6539
+ metadata?: NotificationEventV1Metadata;
6540
+ /** The cadence start of the resource. */
6541
+ activeFrom: Date;
6542
+ /** The cadence end of the resource. */
6543
+ activeTo?: Date;
6544
+ /** The annotations of the entitlement. */
6545
+ annotations?: NotificationEventV1Annotations;
6546
+ /** Readonly unique ULID identifier. */
5399
6547
  id: string;
5400
6548
  /**
5401
- * Display name of the resource.
6549
+ * The identifier key unique to the subject. NOTE: Subjects are being deprecated,
6550
+ * please use the new customer APIs.
6551
+ */
6552
+ subjectKey: string;
6553
+ /** The feature the subject is entitled to use. */
6554
+ featureKey: string;
6555
+ /** The feature the subject is entitled to use. */
6556
+ featureId: string;
6557
+ /** The time the last reset happened. */
6558
+ lastReset: Date;
6559
+ /** The current usage period. */
6560
+ currentUsagePeriod: NotificationEventV1Period;
6561
+ /**
6562
+ * The time from which usage is measured. If not specified on creation, defaults to
6563
+ * entitlement creation time.
6564
+ */
6565
+ measureUsageFrom: Date;
6566
+ /** THe usage period of the entitlement. */
6567
+ usagePeriod: NotificationEventV1RecurringPeriod;
6568
+ }
6569
+ /**
6570
+ * BillingWorkflowCollectionAlignmentAnchored specifies the alignment for
6571
+ * collecting the pending line items into an invoice.
6572
+ */
6573
+ export interface NotificationEventV1BillingWorkflowCollectionAlignmentAnchored {
6574
+ /** The type of alignment. */
6575
+ type: 'anchored';
6576
+ /** The recurring period for the alignment. */
6577
+ recurringPeriod: NotificationEventV1RecurringPeriodV2;
6578
+ }
6579
+ /** Tiered price with spend commitments. */
6580
+ export interface NotificationEventV1TieredPriceWithCommitments {
6581
+ /**
6582
+ * The type of the price.
5402
6583
  *
5403
- * Between 1 and 256 characters.
6584
+ * One of: flat, unit, or tiered.
6585
+ */
6586
+ type: 'tiered';
6587
+ /**
6588
+ * Defines if the tiering mode is volume-based or graduated:
6589
+ *
6590
+ * - In `volume`-based tiering, the maximum quantity within a period determines the
6591
+ * per unit price.
6592
+ * - In `graduated` tiering, pricing can change as the quantity grows.
6593
+ */
6594
+ mode: 'volume' | 'graduated';
6595
+ /**
6596
+ * The tiers of the tiered price. At least one price component is required in each
6597
+ * tier.
6598
+ */
6599
+ tiers: NotificationEventV1PriceTier[];
6600
+ /** The customer is committed to spend at least the amount. */
6601
+ minimumAmount?: string;
6602
+ /** The customer is limited to spend at most the amount. */
6603
+ maximumAmount?: string;
6604
+ }
6605
+ /** A customer object. */
6606
+ export interface NotificationEventV1Customer {
6607
+ /** A unique identifier for the resource. */
6608
+ id: string;
6609
+ /** Human-readable name for the resource. Between 1 and 256 characters. */
6610
+ name: string;
6611
+ /** Optional description of the resource. Maximum 1024 characters. */
6612
+ description?: string;
6613
+ /** Additional metadata for the resource. */
6614
+ metadata?: NotificationEventV1Metadata | null;
6615
+ /** Timestamp of when the resource was created. */
6616
+ createdAt: Date;
6617
+ /** Timestamp of when the resource was last updated. */
6618
+ updatedAt: Date;
6619
+ /** Timestamp of when the resource was permanently deleted. */
6620
+ deletedAt?: Date;
6621
+ /**
6622
+ * An optional unique key of the customer. Either key or
6623
+ * usageAttribution.subjectKeys must be provided. Useful to reference the customer
6624
+ * in external systems. For example, your database ID.
6625
+ */
6626
+ key?: string;
6627
+ /**
6628
+ * Mapping to attribute metered usage to the customer Either key or
6629
+ * usageAttribution.subjectKeys must be provided.
5404
6630
  */
6631
+ usageAttribution?: NotificationEventV1CustomerUsageAttribution;
6632
+ /** The primary email address of the customer. */
6633
+ primaryEmail?: string;
6634
+ /** Currency of the customer. Used for billing, tax and invoicing. */
6635
+ currency?: string;
6636
+ /** The billing address of the customer. Used for tax and invoicing. */
6637
+ billingAddress?: NotificationEventV1Address;
6638
+ /** The ID of the Subscription if the customer has one. */
6639
+ currentSubscriptionId?: string;
6640
+ /** The subscriptions of the customer. Only with the `subscriptions` expand option. */
6641
+ subscriptions?: NotificationEventV1Subscription[];
6642
+ /** Set of key-value pairs managed by the system. Cannot be modified by user. */
6643
+ annotations?: NotificationEventV1Annotations;
6644
+ }
6645
+ /** A installed Stripe app object. */
6646
+ export interface NotificationEventV1StripeApp {
6647
+ /** A unique identifier for the resource. */
6648
+ id: string;
6649
+ /** Human-readable name for the resource. Between 1 and 256 characters. */
6650
+ name: string;
6651
+ /** Optional description of the resource. Maximum 1024 characters. */
6652
+ description?: string;
6653
+ /** Additional metadata for the resource. */
6654
+ metadata?: NotificationEventV1Metadata | null;
6655
+ /** Timestamp of when the resource was created. */
6656
+ createdAt: Date;
6657
+ /** Timestamp of when the resource was last updated. */
6658
+ updatedAt: Date;
6659
+ /** Timestamp of when the resource was permanently deleted. */
6660
+ deletedAt?: Date;
6661
+ /** The marketplace listing that this installed app is based on. */
6662
+ listing: NotificationEventV1MarketplaceListing;
6663
+ /** Status of the app connection. */
6664
+ status: 'ready' | 'unauthorized';
6665
+ /** The app's type is Stripe. */
6666
+ type: 'stripe';
6667
+ /** The Stripe account ID. */
6668
+ stripeAccountId: string;
6669
+ /** Livemode, true if the app is in production mode. */
6670
+ livemode: boolean;
6671
+ /** The masked API key. Only shows the first 8 and last 3 characters. */
6672
+ maskedApiKey: string;
6673
+ }
6674
+ /**
6675
+ * Sandbox app can be used for testing OpenMeter features.
6676
+ *
6677
+ * The app is not creating anything in external systems, thus it is safe to use for
6678
+ * verifying OpenMeter features.
6679
+ */
6680
+ export interface NotificationEventV1SandboxApp {
6681
+ /** A unique identifier for the resource. */
6682
+ id: string;
6683
+ /** Human-readable name for the resource. Between 1 and 256 characters. */
6684
+ name: string;
6685
+ /** Optional description of the resource. Maximum 1024 characters. */
6686
+ description?: string;
6687
+ /** Additional metadata for the resource. */
6688
+ metadata?: NotificationEventV1Metadata | null;
6689
+ /** Timestamp of when the resource was created. */
6690
+ createdAt: Date;
6691
+ /** Timestamp of when the resource was last updated. */
6692
+ updatedAt: Date;
6693
+ /** Timestamp of when the resource was permanently deleted. */
6694
+ deletedAt?: Date;
6695
+ /** The marketplace listing that this installed app is based on. */
6696
+ listing: NotificationEventV1MarketplaceListing;
6697
+ /** Status of the app connection. */
6698
+ status: 'ready' | 'unauthorized';
6699
+ /** The app's type is Sandbox. */
6700
+ type: 'sandbox';
6701
+ }
6702
+ /**
6703
+ * Custom Invoicing app can be used for interface with any invoicing or payment
6704
+ * system.
6705
+ *
6706
+ * This app provides ways to manipulate invoices and payments, however the
6707
+ * integration must rely on Notifications API to get notified about invoice
6708
+ * changes.
6709
+ */
6710
+ export interface NotificationEventV1CustomInvoicingApp {
6711
+ /** A unique identifier for the resource. */
6712
+ id: string;
6713
+ /** Human-readable name for the resource. Between 1 and 256 characters. */
5405
6714
  name: string;
6715
+ /** Optional description of the resource. Maximum 1024 characters. */
6716
+ description?: string;
6717
+ /** Additional metadata for the resource. */
6718
+ metadata?: NotificationEventV1Metadata | null;
6719
+ /** Timestamp of when the resource was created. */
6720
+ createdAt: Date;
6721
+ /** Timestamp of when the resource was last updated. */
6722
+ updatedAt: Date;
6723
+ /** Timestamp of when the resource was permanently deleted. */
6724
+ deletedAt?: Date;
6725
+ /** The marketplace listing that this installed app is based on. */
6726
+ listing: NotificationEventV1MarketplaceListing;
6727
+ /** Status of the app connection. */
6728
+ status: 'ready' | 'unauthorized';
6729
+ /** The app's type is CustomInvoicing. */
6730
+ type: 'custom_invoicing';
5406
6731
  /**
5407
- * Optional description of the resource.
6732
+ * Enable draft.sync hook.
5408
6733
  *
5409
- * Maximum 1024 characters.
6734
+ * If the hook is not enabled, the invoice will be progressed to the next state
6735
+ * automatically.
5410
6736
  */
6737
+ enableDraftSyncHook: boolean;
6738
+ /**
6739
+ * Enable issuing.sync hook.
6740
+ *
6741
+ * If the hook is not enabled, the invoice will be progressed to the next state
6742
+ * automatically.
6743
+ */
6744
+ enableIssuingSyncHook: boolean;
6745
+ }
6746
+ /**
6747
+ * InvoiceLineAmountDiscount represents an amount deducted from the line, and will
6748
+ * be applied before taxes.
6749
+ */
6750
+ export interface NotificationEventV1InvoiceLineAmountDiscount {
6751
+ /** Timestamp of when the resource was created. */
6752
+ createdAt: Date;
6753
+ /** Timestamp of when the resource was last updated. */
6754
+ updatedAt: Date;
6755
+ /** Timestamp of when the resource was permanently deleted. */
6756
+ deletedAt?: Date;
6757
+ /** ID of the charge or discount. */
6758
+ id: string;
6759
+ /** Reason code. */
6760
+ reason: NotificationEventV1BillingDiscountReason;
6761
+ /** Text description as to why the discount was applied. */
5411
6762
  description?: string;
5412
- labels?: Labels;
5413
- /** An ISO-8601 timestamp representation of entity creation date. */
6763
+ /** External IDs of the invoice in other apps such as Stripe. */
6764
+ externalIds?: NotificationEventV1InvoiceLineAppExternalIds;
6765
+ /** Fixed discount amount to apply (calculated if percent present). */
6766
+ amount: string;
6767
+ }
6768
+ /**
6769
+ * InvoiceLineUsageDiscount represents an usage-based discount applied to the line.
6770
+ *
6771
+ * The deduction is done before the pricing algorithm is applied.
6772
+ */
6773
+ export interface NotificationEventV1InvoiceLineUsageDiscount {
6774
+ /** Timestamp of when the resource was created. */
5414
6775
  createdAt: Date;
5415
- /** An ISO-8601 timestamp representation of entity last update date. */
6776
+ /** Timestamp of when the resource was last updated. */
5416
6777
  updatedAt: Date;
5417
- /** An ISO-8601 timestamp representation of entity deletion date. */
6778
+ /** Timestamp of when the resource was permanently deleted. */
5418
6779
  deletedAt?: Date;
5419
- /** The service period covered by this detailed line. */
5420
- servicePeriod: ClosedPeriod;
5421
- /** Aggregated financial totals for the detailed line. */
5422
- totals: Totals;
5423
- /** The cost category of this detailed line. */
5424
- category: 'regular' | 'commitment';
5425
- /** Discounts applied to this detailed line. */
5426
- discounts?: InvoiceLineDiscounts;
5427
- /** Credit applied to this detailed line. */
5428
- creditsApplied?: InvoiceLineCreditsApplied[];
5429
- /** External identifiers for this detailed line. */
5430
- externalReferences?: InvoiceLineExternalReferences;
5431
- /** The quantity of the detailed line. */
6780
+ /** ID of the charge or discount. */
6781
+ id: string;
6782
+ /** Reason code. */
6783
+ reason: NotificationEventV1BillingDiscountReason;
6784
+ /** Text description as to why the discount was applied. */
6785
+ description?: string;
6786
+ /** External IDs of the invoice in other apps such as Stripe. */
6787
+ externalIds?: NotificationEventV1InvoiceLineAppExternalIds;
6788
+ /** The usage to apply. */
5432
6789
  quantity: string;
5433
- /** The unit price of the detailed line. */
5434
- unitPrice: string;
5435
- }
5436
- /** Snapshot of the billing workflow configuration captured at invoice creation. */
5437
- export interface UpdateInvoiceWorkflowSettings {
5438
6790
  /**
5439
- * The workflow configuration that was active when the invoice was created.
6791
+ * The usage discount already applied to the previous split lines.
5440
6792
  *
5441
- * Only the fields that are meaningful at the per-invoice level are included:
5442
- * invoicing behaviour (auto-advance, draft period) and payment settings
5443
- * (collection method, due date). Profile-wide settings such as collection
5444
- * alignment, progressive billing, and tax policy are omitted.
6793
+ * Only set if progressive billing is enabled and the line is a split line.
5445
6794
  */
5446
- workflow: UpdateBillingInvoiceWorkflow;
6795
+ preLinePeriodQuantity?: string;
5447
6796
  }
5448
- /** Access evaluation result for a single resolved customer. */
5449
- export interface EntitlementAccessQueryResult {
6797
+ /**
6798
+ * InvoiceDetailedLineRateCard represents the rate card (intent) for a flat fee
6799
+ * line.
6800
+ */
6801
+ export interface NotificationEventV1InvoiceDetailedLineRateCard {
5450
6802
  /**
5451
- * The list of identifiers from the request that resolved to this customer. Each
5452
- * entry is either the customer `key` or one of its usage-attribution subject
5453
- * `key`s.
5454
- *
5455
- * Duplicate or aliased identifiers that resolve to the same customer collapse to a
5456
- * single result entry, with every requested identifier listed here.
6803
+ * The tax config of the rate card. When undefined, the tax config of the feature
6804
+ * or the default tax config of the plan is used.
5457
6805
  */
5458
- matched: string[];
5459
- /** The customer the matched identifiers resolved to. */
5460
- customer: Customer;
6806
+ taxConfig?: NotificationEventV1TaxConfig;
6807
+ /** The price of the rate card. When null, the feature or service is free. */
6808
+ price: NotificationEventV1FlatPriceWithPaymentTerm | null;
5461
6809
  /**
5462
- * Map of features with their access status.
6810
+ * Quantity of the item being sold.
5463
6811
  *
5464
- * Map keys are the feature keys requested in `feature.keys`, or every feature
5465
- * `key` available in the organization when the feature filter was omitted.
5466
- */
5467
- features: Record<string, EntitlementFeatureAccess>;
5468
- /**
5469
- * Timestamp of the most recent change to the customer's access state reflected in
5470
- * this result.
6812
+ * Default: 1
5471
6813
  */
5472
- updatedAt: Date;
5473
- }
5474
- /** A balance threshold notification event payload. */
5475
- export interface NotificationEventBalanceThresholdPayload {
5476
- /** The identifier of the event the payload belongs to. */
5477
- id: string;
5478
- /** The type of the event. */
5479
- type: 'entitlements.balance.threshold';
5480
- /** When the event was generated. */
5481
- timestamp: Date;
5482
- /** The entities and threshold the event refers to. */
5483
- data: NotificationEventBalanceThresholdData;
5484
- }
5485
- /** An entitlement reset notification event payload. */
5486
- export interface NotificationEventResetPayload {
5487
- /** The identifier of the event the payload belongs to. */
5488
- id: string;
5489
- /** The type of the event. */
5490
- type: 'entitlements.reset';
5491
- /** When the event was generated. */
5492
- timestamp: Date;
5493
- /** The entities the event refers to. */
5494
- data: NotificationEventEntitlementData;
6814
+ quantity?: string;
6815
+ /** The discounts that are applied to the line. */
6816
+ discounts?: NotificationEventV1BillingDiscounts;
5495
6817
  }
5496
6818
  /** A capability or billable dimension offered by a provider. */
5497
6819
  export interface Feature {
@@ -5666,6 +6988,8 @@ export interface CreditGrant {
5666
6988
  * fiat currency.
5667
6989
  */
5668
6990
  currency: BillingCurrencyCode;
6991
+ /** Managed currency reference. Present only for custom currencies. */
6992
+ customCurrency?: CurrencyCustomReference;
5669
6993
  /** Granted credit amount. */
5670
6994
  amount: string;
5671
6995
  /** Present when a funding workflow applies (funding_method is not `none`). */
@@ -5908,6 +7232,73 @@ export interface NotificationRulePagePaginatedResponse {
5908
7232
  data: NotificationRule[];
5909
7233
  meta: PaginatedMeta;
5910
7234
  }
7235
+ /**
7236
+ * Represents a feature that can be enabled or disabled for a plan. Used both for
7237
+ * product catalog and entitlements.
7238
+ */
7239
+ export interface NotificationEventV1Feature {
7240
+ /** Timestamp of when the resource was created. */
7241
+ createdAt: Date;
7242
+ /** Timestamp of when the resource was last updated. */
7243
+ updatedAt: Date;
7244
+ /** Timestamp of when the resource was permanently deleted. */
7245
+ deletedAt?: Date;
7246
+ /** Timestamp of when the resource was archived. */
7247
+ archivedAt?: Date;
7248
+ /** A key is a unique string that is used to identify a resource. */
7249
+ key: string;
7250
+ /** The human-readable name of the feature. */
7251
+ name: string;
7252
+ /** Optional metadata. */
7253
+ metadata?: NotificationEventV1Metadata;
7254
+ /** A key is a unique string that is used to identify a resource. */
7255
+ meterSlug?: string;
7256
+ /**
7257
+ * Optional meter group by filters. Useful if the meter scope is broader than what
7258
+ * feature tracks. Example scenario would be a meter tracking all token use with
7259
+ * groupBy fields for the model, then the feature could filter for model=gpt-4.
7260
+ *
7261
+ * ⚠️ **Deprecated**: Use advancedMeterGroupByFilters instead
7262
+ */
7263
+ meterGroupByFilters?: Record<string, string>;
7264
+ /**
7265
+ * Optional advanced meter group by filters. You can use this to filter for values
7266
+ * of the meter groupBy fields.
7267
+ */
7268
+ advancedMeterGroupByFilters?: Record<string, NotificationEventV1FilterString>;
7269
+ /**
7270
+ * Optional per-unit cost configuration. Use "manual" for a fixed per-unit cost, or
7271
+ * "llm" to look up cost from the LLM cost database based on meter group-by
7272
+ * properties.
7273
+ */
7274
+ unitCost?: NotificationEventV1FeatureUnitCost;
7275
+ /** Readonly unique ULID identifier. */
7276
+ id: string;
7277
+ }
7278
+ /**
7279
+ * InvoiceLineDiscounts represents the discounts applied to the invoice line by
7280
+ * type.
7281
+ */
7282
+ export interface NotificationEventV1InvoiceLineDiscounts {
7283
+ /**
7284
+ * Amount based discounts applied to the line.
7285
+ *
7286
+ * Amount based discounts are deduced from the total price of the line.
7287
+ */
7288
+ amount?: NotificationEventV1InvoiceLineAmountDiscount[];
7289
+ /**
7290
+ * Usage based discounts applied to the line.
7291
+ *
7292
+ * Usage based discounts are deduced from the usage of the line before price
7293
+ * calculations are applied.
7294
+ */
7295
+ usage?: NotificationEventV1InvoiceLineUsageDiscount[];
7296
+ }
7297
+ /** Payment contains details as to how the invoice should be paid. */
7298
+ export interface NotificationEventV1InvoicePaymentTerms {
7299
+ /** The terms of payment for the invoice. */
7300
+ terms?: NotificationEventV1PaymentTerms;
7301
+ }
5911
7302
  /** A rate card defines the pricing and entitlement of a feature or service. */
5912
7303
  export interface RateCard {
5913
7304
  /**
@@ -6151,23 +7542,193 @@ export interface ProfileApps {
6151
7542
  payment: App;
6152
7543
  }
6153
7544
  /**
6154
- * A notification event records that a notification rule fired and tracks the
6155
- * delivery of its payload to each channel of the rule. Events are created by the
6156
- * system and cannot be modified.
7545
+ * Workflow collection specifies how to collect the pending line items for an
7546
+ * invoice
6157
7547
  */
6158
- export interface NotificationEvent {
6159
- /** The unique identifier of the event. */
6160
- id: string;
6161
- /** The type of the event. */
6162
- type: 'entitlements.balance.threshold' | 'entitlements.reset' | 'invoice.created' | 'invoice.updated';
6163
- /** When the event was generated. */
7548
+ export interface NotificationEventV1BillingWorkflowCollectionSettings {
7549
+ /** The alignment for collecting the pending line items into an invoice. */
7550
+ alignment?: NotificationEventV1BillingWorkflowCollectionAlignment;
7551
+ /**
7552
+ * This grace period can be used to delay the collection of the pending line items
7553
+ * specified in alignment.
7554
+ *
7555
+ * This is useful, in case of multiple subscriptions having slightly different
7556
+ * billing periods.
7557
+ */
7558
+ interval?: string;
7559
+ }
7560
+ /**
7561
+ * Payload of `v1.entitlement.balance_threshold.triggered`, the legacy
7562
+ * `entitlements.balance.threshold` Event type.
7563
+ */
7564
+ export interface EntitlementBalanceThresholdTriggeredV1Payload {
7565
+ /** Entitlement. */
7566
+ entitlement: NotificationEventV1EntitlementMetered;
7567
+ /** Feature. */
7568
+ feature: NotificationEventV1Feature;
7569
+ /** Subject. */
7570
+ subject: NotificationEventV1Subject;
7571
+ /** Entitlement Value. */
7572
+ value: NotificationEventV1EntitlementValue;
7573
+ /** Customer. */
7574
+ customer?: NotificationEventV1Customer;
7575
+ /** Threshold. */
7576
+ threshold: NotificationEventV1RuleBalanceThresholdValue;
7577
+ }
7578
+ /**
7579
+ * Payload of `v1.entitlement.usage_period.reset`, the legacy `entitlements.reset`
7580
+ * Event type.
7581
+ */
7582
+ export interface EntitlementUsagePeriodResetV1Payload {
7583
+ /** Entitlement. */
7584
+ entitlement: NotificationEventV1EntitlementMetered;
7585
+ /** Feature. */
7586
+ feature: NotificationEventV1Feature;
7587
+ /** Subject. */
7588
+ subject: NotificationEventV1Subject;
7589
+ /** Entitlement Value. */
7590
+ value: NotificationEventV1EntitlementValue;
7591
+ /** Customer. */
7592
+ customer?: NotificationEventV1Customer;
7593
+ }
7594
+ /**
7595
+ * Data of the payload for notification event with `entitlements.balance.threshold`
7596
+ * type.
7597
+ */
7598
+ export interface NotificationEventV1BalanceThresholdPayloadData {
7599
+ /** Entitlement. */
7600
+ entitlement: NotificationEventV1EntitlementMetered;
7601
+ /** Feature. */
7602
+ feature: NotificationEventV1Feature;
7603
+ /** Subject. */
7604
+ subject: NotificationEventV1Subject;
7605
+ /** Entitlement Value. */
7606
+ value: NotificationEventV1EntitlementValue;
7607
+ /** Customer. */
7608
+ customer?: NotificationEventV1Customer;
7609
+ /** Threshold. */
7610
+ threshold: NotificationEventV1RuleBalanceThresholdValue;
7611
+ }
7612
+ /** Base data for any payload with entitlement entitlement value. */
7613
+ export interface NotificationEventV1EntitlementValuePayloadBase {
7614
+ /** Entitlement. */
7615
+ entitlement: NotificationEventV1EntitlementMetered;
7616
+ /** Feature. */
7617
+ feature: NotificationEventV1Feature;
7618
+ /** Subject. */
7619
+ subject: NotificationEventV1Subject;
7620
+ /** Entitlement Value. */
7621
+ value: NotificationEventV1EntitlementValue;
7622
+ /** Customer. */
7623
+ customer?: NotificationEventV1Customer;
7624
+ }
7625
+ /**
7626
+ * InvoiceUsageBasedRateCard represents the rate card (intent) for an usage-based
7627
+ * line.
7628
+ */
7629
+ export interface NotificationEventV1InvoiceUsageBasedRateCard {
7630
+ /** The feature the customer is entitled to use. */
7631
+ featureKey?: string;
7632
+ /**
7633
+ * The tax config of the rate card. When undefined, the tax config of the feature
7634
+ * or the default tax config of the plan is used.
7635
+ */
7636
+ taxConfig?: NotificationEventV1TaxConfig;
7637
+ /** The price of the rate card. When null, the feature or service is free. */
7638
+ price: NotificationEventV1RateCardUsageBasedPrice | null;
7639
+ /** The discounts that are applied to the line. */
7640
+ discounts?: NotificationEventV1BillingDiscounts;
7641
+ }
7642
+ /** BillingProfileApps represents the applications used by a billing profile */
7643
+ export interface NotificationEventV1BillingProfileApps {
7644
+ /** The tax app used for this workflow */
7645
+ tax: NotificationEventV1App | null;
7646
+ /** The invoicing app used for this workflow */
7647
+ invoicing: NotificationEventV1App | null;
7648
+ /** The payment app used for this workflow */
7649
+ payment: NotificationEventV1App | null;
7650
+ }
7651
+ /**
7652
+ * InvoiceDetailedLine represents a line item that is sold to the customer as a
7653
+ * manually added fee.
7654
+ */
7655
+ export interface NotificationEventV1InvoiceDetailedLine {
7656
+ /** Human-readable name for the resource. Between 1 and 256 characters. */
7657
+ name: string;
7658
+ /** Optional description of the resource. Maximum 1024 characters. */
7659
+ description?: string;
7660
+ /** Additional metadata for the resource. */
7661
+ metadata?: NotificationEventV1Metadata | null;
7662
+ /** Timestamp of when the resource was created. */
6164
7663
  createdAt: Date;
6165
- /** The rule that generated the event. */
6166
- rule: NotificationRuleReference;
6167
- /** The delivery status of the event, one entry per channel of the rule. */
6168
- deliveryStatus: NotificationEventDeliveryStatus[];
6169
- /** The payload delivered to the channels. */
6170
- payload: NotificationEventPayload;
7664
+ /** Timestamp of when the resource was last updated. */
7665
+ updatedAt: Date;
7666
+ /** Timestamp of when the resource was permanently deleted. */
7667
+ deletedAt?: Date;
7668
+ /** ID of the line. */
7669
+ id: string;
7670
+ /**
7671
+ * managedBy specifies if the line is manually added via the api or managed by
7672
+ * OpenMeter.
7673
+ */
7674
+ managedBy: 'subscription' | 'system' | 'manual';
7675
+ /**
7676
+ * Status of the line.
7677
+ *
7678
+ * External calls always create valid lines, other line types are managed by the
7679
+ * billing engine of OpenMeter.
7680
+ */
7681
+ status: 'valid' | 'detailed' | 'split';
7682
+ /**
7683
+ * Discounts detailes applied to this line.
7684
+ *
7685
+ * New discounts can be added via the invoice's discounts API, to facilitate
7686
+ * discounts that are affecting multiple lines.
7687
+ */
7688
+ discounts?: NotificationEventV1InvoiceLineDiscounts;
7689
+ /**
7690
+ * Credit allocations applied to this line.
7691
+ *
7692
+ * Credits are deducted from the line total before taxes are applied.
7693
+ */
7694
+ creditAllocations?: NotificationEventV1InvoiceLineCreditAllocation[];
7695
+ /** The invoice this item belongs to. */
7696
+ invoice?: NotificationEventV1InvoiceReference;
7697
+ /** The currency of this line. */
7698
+ currency: string;
7699
+ /** Taxes applied to the invoice totals. */
7700
+ taxes?: NotificationEventV1InvoiceLineTaxItem[];
7701
+ /** Tax config specify the tax configuration for this line. */
7702
+ taxConfig?: NotificationEventV1TaxConfig;
7703
+ /** Totals for this line. */
7704
+ totals: NotificationEventV1InvoiceTotals;
7705
+ /**
7706
+ * Period of the line item applies to for revenue recognition pruposes.
7707
+ *
7708
+ * Billing always treats periods as start being inclusive and end being exclusive.
7709
+ */
7710
+ period: NotificationEventV1Period;
7711
+ /** External IDs of the invoice in other apps such as Stripe. */
7712
+ externalIds?: NotificationEventV1InvoiceLineAppExternalIds;
7713
+ /**
7714
+ * Subscription are the references to the subscritpions that this line is related
7715
+ * to.
7716
+ */
7717
+ subscription?: NotificationEventV1InvoiceLineSubscriptionReference;
7718
+ /** The time this line item should be invoiced. */
7719
+ invoiceAt: Date;
7720
+ /** Type of the line. */
7721
+ type: 'flat_fee';
7722
+ /** Price of the item being sold. */
7723
+ perUnitAmount?: string;
7724
+ /** Payment term of the line. */
7725
+ paymentTerm?: 'in_advance' | 'in_arrears';
7726
+ /** Quantity of the item being sold. */
7727
+ quantity?: string;
7728
+ /** The rate card that is used for this line. */
7729
+ rateCard?: NotificationEventV1InvoiceDetailedLineRateCard;
7730
+ /** Category of the flat fee. */
7731
+ category?: 'regular' | 'commitment';
6171
7732
  }
6172
7733
  /** A subscription item pins a rate card to a cadence within a subscription phase. */
6173
7734
  export interface SubscriptionItem {
@@ -6575,41 +8136,182 @@ export interface ChargeRealization {
6575
8136
  /** The service period covered by this realization run. */
6576
8137
  servicePeriod: ClosedPeriod;
6577
8138
  /**
6578
- * The metered usage quantity this realization run accounts for. Only present on
6579
- * usage-based charges; flat fees are not metered, so their realizations carry no
6580
- * usage.
8139
+ * The metered usage quantity this realization run accounts for. Only present on
8140
+ * usage-based charges; flat fees are not metered, so their realizations carry no
8141
+ * usage.
8142
+ *
8143
+ * Booked entries report a signed delta: a negative value states a downward usage
8144
+ * correction (or a voided run that snapshotted behind its live neighbors) instead
8145
+ * of masking it as zero.
8146
+ *
8147
+ * On an `outstanding` entry, usage is omitted unless `real_time_usage` supplies a
8148
+ * live reading. When present, it is the unbooked remainder of that reading,
8149
+ * floored at zero.
8150
+ */
8151
+ usage?: string;
8152
+ /**
8153
+ * The payment state of the realization, when the charge requires a fiat
8154
+ * transaction to settle.
8155
+ */
8156
+ payment?: ChargeRealizationPayment;
8157
+ /**
8158
+ * Financial totals for the realization run, including credit allocations.
8159
+ *
8160
+ * Requires the `realization.totals` expand.
8161
+ */
8162
+ totals?: Totals;
8163
+ /**
8164
+ * The detailed (rated) lines produced by the realization run.
8165
+ *
8166
+ * Requires the `realization.detailed_lines` expand.
8167
+ */
8168
+ detailedLines?: ChargeRealizationDetailedLine[];
8169
+ }
8170
+ /** BillingWorkflow represents the settings for a billing workflow. */
8171
+ export interface NotificationEventV1BillingWorkflow {
8172
+ /** The collection settings for this workflow */
8173
+ collection?: NotificationEventV1BillingWorkflowCollectionSettings;
8174
+ /** The invoicing settings for this workflow */
8175
+ invoicing?: NotificationEventV1BillingWorkflowInvoicingSettings;
8176
+ /** The payment settings for this workflow */
8177
+ payment?: NotificationEventV1BillingWorkflowPaymentSettings;
8178
+ /** The tax settings for this workflow */
8179
+ tax?: NotificationEventV1BillingWorkflowTaxSettings;
8180
+ }
8181
+ /** A balance threshold notification event payload. */
8182
+ export interface NotificationEventBalanceThresholdPayload {
8183
+ /** The identifier of the event the payload belongs to. */
8184
+ id: string;
8185
+ /** The type of the event. */
8186
+ type: 'entitlements.balance.threshold';
8187
+ /** When the event was generated. */
8188
+ timestamp: Date;
8189
+ /** The entities and threshold the event refers to. */
8190
+ data: EntitlementBalanceThresholdTriggeredV1Payload;
8191
+ }
8192
+ /** An entitlement reset notification event payload. */
8193
+ export interface NotificationEventResetPayload {
8194
+ /** The identifier of the event the payload belongs to. */
8195
+ id: string;
8196
+ /** The type of the event. */
8197
+ type: 'entitlements.reset';
8198
+ /** When the event was generated. */
8199
+ timestamp: Date;
8200
+ /** The entities the event refers to. */
8201
+ data: EntitlementUsagePeriodResetV1Payload;
8202
+ }
8203
+ /**
8204
+ * InvoiceUsageBasedLine represents a line item that is sold to the customer based
8205
+ * on usage.
8206
+ */
8207
+ export interface NotificationEventV1InvoiceLine {
8208
+ /** Human-readable name for the resource. Between 1 and 256 characters. */
8209
+ name: string;
8210
+ /** Optional description of the resource. Maximum 1024 characters. */
8211
+ description?: string;
8212
+ /** Additional metadata for the resource. */
8213
+ metadata?: NotificationEventV1Metadata | null;
8214
+ /** Timestamp of when the resource was created. */
8215
+ createdAt: Date;
8216
+ /** Timestamp of when the resource was last updated. */
8217
+ updatedAt: Date;
8218
+ /** Timestamp of when the resource was permanently deleted. */
8219
+ deletedAt?: Date;
8220
+ /** ID of the line. */
8221
+ id: string;
8222
+ /**
8223
+ * managedBy specifies if the line is manually added via the api or managed by
8224
+ * OpenMeter.
8225
+ */
8226
+ managedBy: 'subscription' | 'system' | 'manual';
8227
+ /**
8228
+ * Status of the line.
8229
+ *
8230
+ * External calls always create valid lines, other line types are managed by the
8231
+ * billing engine of OpenMeter.
8232
+ */
8233
+ status: 'valid' | 'detailed' | 'split';
8234
+ /**
8235
+ * Discounts detailes applied to this line.
8236
+ *
8237
+ * New discounts can be added via the invoice's discounts API, to facilitate
8238
+ * discounts that are affecting multiple lines.
8239
+ */
8240
+ discounts?: NotificationEventV1InvoiceLineDiscounts;
8241
+ /**
8242
+ * Credit allocations applied to this line.
8243
+ *
8244
+ * Credits are deducted from the line total before taxes are applied.
8245
+ */
8246
+ creditAllocations?: NotificationEventV1InvoiceLineCreditAllocation[];
8247
+ /** The invoice this item belongs to. */
8248
+ invoice?: NotificationEventV1InvoiceReference;
8249
+ /** The currency of this line. */
8250
+ currency: string;
8251
+ /** Taxes applied to the invoice totals. */
8252
+ taxes?: NotificationEventV1InvoiceLineTaxItem[];
8253
+ /** Tax config specify the tax configuration for this line. */
8254
+ taxConfig?: NotificationEventV1TaxConfig;
8255
+ /** Totals for this line. */
8256
+ totals: NotificationEventV1InvoiceTotals;
8257
+ /**
8258
+ * Period of the line item applies to for revenue recognition pruposes.
8259
+ *
8260
+ * Billing always treats periods as start being inclusive and end being exclusive.
8261
+ */
8262
+ period: NotificationEventV1Period;
8263
+ /** The time this line item should be invoiced. */
8264
+ invoiceAt: Date;
8265
+ /** External IDs of the invoice in other apps such as Stripe. */
8266
+ externalIds?: NotificationEventV1InvoiceLineAppExternalIds;
8267
+ /**
8268
+ * Subscription are the references to the subscritpions that this line is related
8269
+ * to.
8270
+ */
8271
+ subscription?: NotificationEventV1InvoiceLineSubscriptionReference;
8272
+ /** Type of the line. */
8273
+ type: 'usage_based';
8274
+ /** Price of the usage-based item being sold. */
8275
+ price?: NotificationEventV1RateCardUsageBasedPrice;
8276
+ /** The feature that the usage is based on. */
8277
+ featureKey?: string;
8278
+ /** The lines detailing the item or service sold. */
8279
+ children?: NotificationEventV1InvoiceDetailedLine[];
8280
+ /**
8281
+ * The rate card that is used for this line.
6581
8282
  *
6582
- * Booked entries report a signed delta: a negative value states a downward usage
6583
- * correction (or a voided run that snapshotted behind its live neighbors) instead
6584
- * of masking it as zero.
8283
+ * The rate card captures the intent of the price and discounts for the usage-based
8284
+ * item.
8285
+ */
8286
+ rateCard?: NotificationEventV1InvoiceUsageBasedRateCard;
8287
+ /**
8288
+ * The quantity of the item being sold.
6585
8289
  *
6586
- * On an `outstanding` entry this is `0` unless the `real_time_usage` expand is
6587
- * applied, in which case it is the not-yet-booked remainder of the live metering
6588
- * read (never negative).
8290
+ * Any usage discounts applied previously are deducted from this quantity.
6589
8291
  */
6590
- usage?: string;
8292
+ quantity?: string;
6591
8293
  /**
6592
- * The payment state of the realization, when the charge requires a fiat
6593
- * transaction to settle.
8294
+ * The quantity of the item that has been metered for the period before any
8295
+ * discounts were applied.
6594
8296
  */
6595
- payment?: ChargeRealizationPayment;
8297
+ meteredQuantity?: string;
6596
8298
  /**
6597
- * Financial totals for the realization run, including credit allocations.
8299
+ * The quantity of the item used before this line's period.
6598
8300
  *
6599
- * Requires the `realization.totals` expand.
8301
+ * It is non-zero in case of progressive billing, when this shows how much of the
8302
+ * usage was already billed.
8303
+ *
8304
+ * Any usage discounts applied previously are deducted from this quantity.
6600
8305
  */
6601
- totals?: Totals;
8306
+ preLinePeriodQuantity?: string;
6602
8307
  /**
6603
- * The detailed (rated) lines produced by the realization run.
8308
+ * The metered quantity of the item used in before this line's period without any
8309
+ * discounts applied.
6604
8310
  *
6605
- * Requires the `realization.detailed_lines` expand.
8311
+ * It is non-zero in case of progressive billing, when this shows how much of the
8312
+ * usage was already billed.
6606
8313
  */
6607
- detailedLines?: ChargeRealizationDetailedLine[];
6608
- }
6609
- /** Page paginated response. */
6610
- export interface NotificationEventPagePaginatedResponse {
6611
- data: NotificationEvent[];
6612
- meta: PaginatedMeta;
8314
+ meteredPreLinePeriodQuantity?: string;
6613
8315
  }
6614
8316
  /**
6615
8317
  * A subscription phase groups the rate cards in effect for a segment of the
@@ -6886,6 +8588,31 @@ export interface ProfilePagePaginatedResponse {
6886
8588
  data: Profile[];
6887
8589
  meta: PaginatedMeta;
6888
8590
  }
8591
+ /**
8592
+ * InvoiceWorkflowSettings represents the workflow settings used by the invoice.
8593
+ *
8594
+ * This is a clone of the billing profile's workflow settings at the time of
8595
+ * invoice creation with customer overrides considered.
8596
+ */
8597
+ export interface NotificationEventV1InvoiceWorkflowSettings {
8598
+ /**
8599
+ * The apps that will be used to orchestrate the invoice's workflow.
8600
+ *
8601
+ * The v1 schema allows app references here too, but the v1 Event payloads always
8602
+ * carry the full apps.
8603
+ */
8604
+ apps?: NotificationEventV1BillingProfileApps;
8605
+ /**
8606
+ * sourceBillingProfileID is the billing profile on which the workflow was based
8607
+ * on.
8608
+ *
8609
+ * The profile is snapshotted on invoice creation, after which it can be altered
8610
+ * independently of the profile itself.
8611
+ */
8612
+ sourceBillingProfileId: string;
8613
+ /** The workflow details used by this invoice. */
8614
+ workflow: NotificationEventV1BillingWorkflow;
8615
+ }
6889
8616
  /** Subscription. */
6890
8617
  export interface Subscription {
6891
8618
  id: string;
@@ -6949,6 +8676,21 @@ export interface Subscription {
6949
8676
  * - Custom date (customer-specified day)
6950
8677
  */
6951
8678
  billingAnchor: Date;
8679
+ /**
8680
+ * When billing starts for the subscription. Nothing is billed for service before
8681
+ * this time, while access, entitlements and metering start with the subscription.
8682
+ * Use it when the time before was already billed elsewhere, for example when
8683
+ * importing a subscription from another billing system.
8684
+ *
8685
+ * It cannot be before the start of the subscription and cannot be changed later.
8686
+ * On subscriptions billed through invoice lines it must be the start of a billing
8687
+ * period. If not provided, billing starts with the subscription.
8688
+ *
8689
+ * When billing starts inside a billing period, we recommend enabling price
8690
+ * pro-rating (`prorate_prices`) on the plan. Without it that billing period's flat
8691
+ * fees are billed in full.
8692
+ */
8693
+ billingStartsAt?: Date;
6952
8694
  /** The status of the subscription. */
6953
8695
  status: 'active' | 'inactive' | 'canceled' | 'scheduled';
6954
8696
  /**
@@ -6974,6 +8716,21 @@ export interface Subscription {
6974
8716
  }
6975
8717
  export interface SubscriptionCreate {
6976
8718
  labels?: Labels;
8719
+ /**
8720
+ * When billing starts for the subscription. Nothing is billed for service before
8721
+ * this time, while access, entitlements and metering start with the subscription.
8722
+ * Use it when the time before was already billed elsewhere, for example when
8723
+ * importing a subscription from another billing system.
8724
+ *
8725
+ * It cannot be before the start of the subscription and cannot be changed later.
8726
+ * On subscriptions billed through invoice lines it must be the start of a billing
8727
+ * period. If not provided, billing starts with the subscription.
8728
+ *
8729
+ * When billing starts inside a billing period, we recommend enabling price
8730
+ * pro-rating (`prorate_prices`) on the plan. Without it that billing period's flat
8731
+ * fees are billed in full.
8732
+ */
8733
+ billingStartsAt?: Date;
6977
8734
  /**
6978
8735
  * Settlement mode for billing.
6979
8736
  *
@@ -7241,6 +8998,366 @@ export interface UpdateInvoiceStandardRequest {
7241
8998
  */
7242
8999
  lines?: UpdateInvoiceLine[];
7243
9000
  }
9001
+ /**
9002
+ * Payload of `v1.billing.invoice.created`, the legacy `invoice.created` Event
9003
+ * type: the invoice as it was created.
9004
+ */
9005
+ export interface InvoiceCreatedV1Payload {
9006
+ /** A unique identifier for the resource. */
9007
+ id: string;
9008
+ /** Optional description of the resource. Maximum 1024 characters. */
9009
+ description?: string;
9010
+ /** Additional metadata for the resource. */
9011
+ metadata?: NotificationEventV1Metadata | null;
9012
+ /** Timestamp of when the resource was created. */
9013
+ createdAt: Date;
9014
+ /** Timestamp of when the resource was last updated. */
9015
+ updatedAt: Date;
9016
+ /** Timestamp of when the resource was permanently deleted. */
9017
+ deletedAt?: Date;
9018
+ /**
9019
+ * Type of the invoice.
9020
+ *
9021
+ * The type of invoice determines the purpose of the invoice and how it should be
9022
+ * handled.
9023
+ *
9024
+ * Supported types:
9025
+ *
9026
+ * - standard: A regular commercial invoice document between a supplier and
9027
+ * customer.
9028
+ * - credit_note: Reflects a refund either partial or complete of the preceding
9029
+ * document. A credit note effectively _extends_ the previous document.
9030
+ */
9031
+ type: 'standard' | 'credit_note';
9032
+ /** The taxable entity supplying the goods or services. */
9033
+ supplier: NotificationEventV1BillingParty;
9034
+ /** Legal entity receiving the goods or services. */
9035
+ customer: NotificationEventV1BillingInvoiceCustomerExtendedDetails;
9036
+ /**
9037
+ * Number specifies the human readable key used to reference this Invoice.
9038
+ *
9039
+ * The invoice number can change in the draft phases, as we are allocating
9040
+ * temporary draft invoice numbers, but it's final as soon as the invoice gets
9041
+ * finalized (issued state).
9042
+ *
9043
+ * Please note that the number is (depending on the upstream settings) either
9044
+ * unique for the whole organization or unique for the customer, or in multi
9045
+ * (stripe) account setups unique for the account.
9046
+ */
9047
+ number: string;
9048
+ /**
9049
+ * Currency for all invoice line items.
9050
+ *
9051
+ * Multi currency invoices are not supported yet.
9052
+ */
9053
+ currency: string;
9054
+ /**
9055
+ * Key information regarding previous invoices and potentially details as to why
9056
+ * they were corrected.
9057
+ */
9058
+ preceding?: NotificationEventV1InvoiceDocumentRef[];
9059
+ /** Summary of all the invoice totals, including taxes (calculated). */
9060
+ totals: NotificationEventV1InvoiceTotals;
9061
+ /**
9062
+ * The status of the invoice.
9063
+ *
9064
+ * This field only conatins a simplified status, for more detailed information use
9065
+ * the statusDetails field.
9066
+ */
9067
+ status: 'gathering' | 'draft' | 'issuing' | 'issued' | 'payment_processing' | 'overdue' | 'paid' | 'uncollectible' | 'voided';
9068
+ /** The details of the current invoice status. */
9069
+ statusDetails: NotificationEventV1InvoiceStatusDetails;
9070
+ /**
9071
+ * The time the invoice was issued.
9072
+ *
9073
+ * Depending on the status of the invoice this can mean multiple things:
9074
+ *
9075
+ * - draft, gathering: The time the invoice will be issued based on the workflow
9076
+ * settings.
9077
+ * - issued: The time the invoice was issued.
9078
+ */
9079
+ issuedAt?: Date;
9080
+ /**
9081
+ * The time until the invoice is in draft status.
9082
+ *
9083
+ * On draft invoice creation it is calculated from the workflow settings.
9084
+ *
9085
+ * If manual approval is required, the draftUntil time is set.
9086
+ */
9087
+ draftUntil?: Date;
9088
+ /** The time when the quantity snapshots on the invoice lines were taken. */
9089
+ quantitySnapshotedAt?: Date;
9090
+ /** The time when the invoice will be/has been collected. */
9091
+ collectionAt?: Date;
9092
+ /** Due time of the fulfillment of the invoice (if available). */
9093
+ dueAt?: Date;
9094
+ /** The period the invoice covers. If the invoice has no line items, it's not set. */
9095
+ period?: NotificationEventV1Period;
9096
+ /**
9097
+ * The time the invoice was voided.
9098
+ *
9099
+ * If the invoice was voided, this field will be set to the time the invoice was
9100
+ * voided.
9101
+ */
9102
+ voidedAt?: Date;
9103
+ /** The time the invoice was sent to customer. */
9104
+ sentToCustomerAt?: Date;
9105
+ /**
9106
+ * The workflow associated with the invoice.
9107
+ *
9108
+ * It is always a snapshot of the workflow settings at the time of invoice
9109
+ * creation. The field is optional as it should be explicitly requested with expand
9110
+ * options.
9111
+ */
9112
+ workflow: NotificationEventV1InvoiceWorkflowSettings;
9113
+ /** List of invoice lines representing each of the items sold to the customer. */
9114
+ lines?: NotificationEventV1InvoiceLine[];
9115
+ /** Information on when, how, and to whom the invoice should be paid. */
9116
+ payment?: NotificationEventV1InvoicePaymentTerms;
9117
+ /** Validation issues reported by the invoice workflow. */
9118
+ validationIssues?: NotificationEventV1ValidationIssue[];
9119
+ /** External IDs of the invoice in other apps such as Stripe. */
9120
+ externalIds?: NotificationEventV1InvoiceAppExternalIds;
9121
+ }
9122
+ /**
9123
+ * Payload of `v1.billing.invoice.updated`, the legacy `invoice.updated` Event
9124
+ * type: the invoice after the update.
9125
+ */
9126
+ export interface InvoiceUpdatedV1Payload {
9127
+ /** A unique identifier for the resource. */
9128
+ id: string;
9129
+ /** Optional description of the resource. Maximum 1024 characters. */
9130
+ description?: string;
9131
+ /** Additional metadata for the resource. */
9132
+ metadata?: NotificationEventV1Metadata | null;
9133
+ /** Timestamp of when the resource was created. */
9134
+ createdAt: Date;
9135
+ /** Timestamp of when the resource was last updated. */
9136
+ updatedAt: Date;
9137
+ /** Timestamp of when the resource was permanently deleted. */
9138
+ deletedAt?: Date;
9139
+ /**
9140
+ * Type of the invoice.
9141
+ *
9142
+ * The type of invoice determines the purpose of the invoice and how it should be
9143
+ * handled.
9144
+ *
9145
+ * Supported types:
9146
+ *
9147
+ * - standard: A regular commercial invoice document between a supplier and
9148
+ * customer.
9149
+ * - credit_note: Reflects a refund either partial or complete of the preceding
9150
+ * document. A credit note effectively _extends_ the previous document.
9151
+ */
9152
+ type: 'standard' | 'credit_note';
9153
+ /** The taxable entity supplying the goods or services. */
9154
+ supplier: NotificationEventV1BillingParty;
9155
+ /** Legal entity receiving the goods or services. */
9156
+ customer: NotificationEventV1BillingInvoiceCustomerExtendedDetails;
9157
+ /**
9158
+ * Number specifies the human readable key used to reference this Invoice.
9159
+ *
9160
+ * The invoice number can change in the draft phases, as we are allocating
9161
+ * temporary draft invoice numbers, but it's final as soon as the invoice gets
9162
+ * finalized (issued state).
9163
+ *
9164
+ * Please note that the number is (depending on the upstream settings) either
9165
+ * unique for the whole organization or unique for the customer, or in multi
9166
+ * (stripe) account setups unique for the account.
9167
+ */
9168
+ number: string;
9169
+ /**
9170
+ * Currency for all invoice line items.
9171
+ *
9172
+ * Multi currency invoices are not supported yet.
9173
+ */
9174
+ currency: string;
9175
+ /**
9176
+ * Key information regarding previous invoices and potentially details as to why
9177
+ * they were corrected.
9178
+ */
9179
+ preceding?: NotificationEventV1InvoiceDocumentRef[];
9180
+ /** Summary of all the invoice totals, including taxes (calculated). */
9181
+ totals: NotificationEventV1InvoiceTotals;
9182
+ /**
9183
+ * The status of the invoice.
9184
+ *
9185
+ * This field only conatins a simplified status, for more detailed information use
9186
+ * the statusDetails field.
9187
+ */
9188
+ status: 'gathering' | 'draft' | 'issuing' | 'issued' | 'payment_processing' | 'overdue' | 'paid' | 'uncollectible' | 'voided';
9189
+ /** The details of the current invoice status. */
9190
+ statusDetails: NotificationEventV1InvoiceStatusDetails;
9191
+ /**
9192
+ * The time the invoice was issued.
9193
+ *
9194
+ * Depending on the status of the invoice this can mean multiple things:
9195
+ *
9196
+ * - draft, gathering: The time the invoice will be issued based on the workflow
9197
+ * settings.
9198
+ * - issued: The time the invoice was issued.
9199
+ */
9200
+ issuedAt?: Date;
9201
+ /**
9202
+ * The time until the invoice is in draft status.
9203
+ *
9204
+ * On draft invoice creation it is calculated from the workflow settings.
9205
+ *
9206
+ * If manual approval is required, the draftUntil time is set.
9207
+ */
9208
+ draftUntil?: Date;
9209
+ /** The time when the quantity snapshots on the invoice lines were taken. */
9210
+ quantitySnapshotedAt?: Date;
9211
+ /** The time when the invoice will be/has been collected. */
9212
+ collectionAt?: Date;
9213
+ /** Due time of the fulfillment of the invoice (if available). */
9214
+ dueAt?: Date;
9215
+ /** The period the invoice covers. If the invoice has no line items, it's not set. */
9216
+ period?: NotificationEventV1Period;
9217
+ /**
9218
+ * The time the invoice was voided.
9219
+ *
9220
+ * If the invoice was voided, this field will be set to the time the invoice was
9221
+ * voided.
9222
+ */
9223
+ voidedAt?: Date;
9224
+ /** The time the invoice was sent to customer. */
9225
+ sentToCustomerAt?: Date;
9226
+ /**
9227
+ * The workflow associated with the invoice.
9228
+ *
9229
+ * It is always a snapshot of the workflow settings at the time of invoice
9230
+ * creation. The field is optional as it should be explicitly requested with expand
9231
+ * options.
9232
+ */
9233
+ workflow: NotificationEventV1InvoiceWorkflowSettings;
9234
+ /** List of invoice lines representing each of the items sold to the customer. */
9235
+ lines?: NotificationEventV1InvoiceLine[];
9236
+ /** Information on when, how, and to whom the invoice should be paid. */
9237
+ payment?: NotificationEventV1InvoicePaymentTerms;
9238
+ /** Validation issues reported by the invoice workflow. */
9239
+ validationIssues?: NotificationEventV1ValidationIssue[];
9240
+ /** External IDs of the invoice in other apps such as Stripe. */
9241
+ externalIds?: NotificationEventV1InvoiceAppExternalIds;
9242
+ }
9243
+ /** Invoice represents an invoice in the system. */
9244
+ export interface NotificationEventV1Invoice {
9245
+ /** A unique identifier for the resource. */
9246
+ id: string;
9247
+ /** Optional description of the resource. Maximum 1024 characters. */
9248
+ description?: string;
9249
+ /** Additional metadata for the resource. */
9250
+ metadata?: NotificationEventV1Metadata | null;
9251
+ /** Timestamp of when the resource was created. */
9252
+ createdAt: Date;
9253
+ /** Timestamp of when the resource was last updated. */
9254
+ updatedAt: Date;
9255
+ /** Timestamp of when the resource was permanently deleted. */
9256
+ deletedAt?: Date;
9257
+ /**
9258
+ * Type of the invoice.
9259
+ *
9260
+ * The type of invoice determines the purpose of the invoice and how it should be
9261
+ * handled.
9262
+ *
9263
+ * Supported types:
9264
+ *
9265
+ * - standard: A regular commercial invoice document between a supplier and
9266
+ * customer.
9267
+ * - credit_note: Reflects a refund either partial or complete of the preceding
9268
+ * document. A credit note effectively _extends_ the previous document.
9269
+ */
9270
+ type: 'standard' | 'credit_note';
9271
+ /** The taxable entity supplying the goods or services. */
9272
+ supplier: NotificationEventV1BillingParty;
9273
+ /** Legal entity receiving the goods or services. */
9274
+ customer: NotificationEventV1BillingInvoiceCustomerExtendedDetails;
9275
+ /**
9276
+ * Number specifies the human readable key used to reference this Invoice.
9277
+ *
9278
+ * The invoice number can change in the draft phases, as we are allocating
9279
+ * temporary draft invoice numbers, but it's final as soon as the invoice gets
9280
+ * finalized (issued state).
9281
+ *
9282
+ * Please note that the number is (depending on the upstream settings) either
9283
+ * unique for the whole organization or unique for the customer, or in multi
9284
+ * (stripe) account setups unique for the account.
9285
+ */
9286
+ number: string;
9287
+ /**
9288
+ * Currency for all invoice line items.
9289
+ *
9290
+ * Multi currency invoices are not supported yet.
9291
+ */
9292
+ currency: string;
9293
+ /**
9294
+ * Key information regarding previous invoices and potentially details as to why
9295
+ * they were corrected.
9296
+ */
9297
+ preceding?: NotificationEventV1InvoiceDocumentRef[];
9298
+ /** Summary of all the invoice totals, including taxes (calculated). */
9299
+ totals: NotificationEventV1InvoiceTotals;
9300
+ /**
9301
+ * The status of the invoice.
9302
+ *
9303
+ * This field only conatins a simplified status, for more detailed information use
9304
+ * the statusDetails field.
9305
+ */
9306
+ status: 'gathering' | 'draft' | 'issuing' | 'issued' | 'payment_processing' | 'overdue' | 'paid' | 'uncollectible' | 'voided';
9307
+ /** The details of the current invoice status. */
9308
+ statusDetails: NotificationEventV1InvoiceStatusDetails;
9309
+ /**
9310
+ * The time the invoice was issued.
9311
+ *
9312
+ * Depending on the status of the invoice this can mean multiple things:
9313
+ *
9314
+ * - draft, gathering: The time the invoice will be issued based on the workflow
9315
+ * settings.
9316
+ * - issued: The time the invoice was issued.
9317
+ */
9318
+ issuedAt?: Date;
9319
+ /**
9320
+ * The time until the invoice is in draft status.
9321
+ *
9322
+ * On draft invoice creation it is calculated from the workflow settings.
9323
+ *
9324
+ * If manual approval is required, the draftUntil time is set.
9325
+ */
9326
+ draftUntil?: Date;
9327
+ /** The time when the quantity snapshots on the invoice lines were taken. */
9328
+ quantitySnapshotedAt?: Date;
9329
+ /** The time when the invoice will be/has been collected. */
9330
+ collectionAt?: Date;
9331
+ /** Due time of the fulfillment of the invoice (if available). */
9332
+ dueAt?: Date;
9333
+ /** The period the invoice covers. If the invoice has no line items, it's not set. */
9334
+ period?: NotificationEventV1Period;
9335
+ /**
9336
+ * The time the invoice was voided.
9337
+ *
9338
+ * If the invoice was voided, this field will be set to the time the invoice was
9339
+ * voided.
9340
+ */
9341
+ voidedAt?: Date;
9342
+ /** The time the invoice was sent to customer. */
9343
+ sentToCustomerAt?: Date;
9344
+ /**
9345
+ * The workflow associated with the invoice.
9346
+ *
9347
+ * It is always a snapshot of the workflow settings at the time of invoice
9348
+ * creation. The field is optional as it should be explicitly requested with expand
9349
+ * options.
9350
+ */
9351
+ workflow: NotificationEventV1InvoiceWorkflowSettings;
9352
+ /** List of invoice lines representing each of the items sold to the customer. */
9353
+ lines?: NotificationEventV1InvoiceLine[];
9354
+ /** Information on when, how, and to whom the invoice should be paid. */
9355
+ payment?: NotificationEventV1InvoicePaymentTerms;
9356
+ /** Validation issues reported by the invoice workflow. */
9357
+ validationIssues?: NotificationEventV1ValidationIssue[];
9358
+ /** External IDs of the invoice in other apps such as Stripe. */
9359
+ externalIds?: NotificationEventV1InvoiceAppExternalIds;
9360
+ }
7244
9361
  /** Page paginated response. */
7245
9362
  export interface SubscriptionPagePaginatedResponse {
7246
9363
  data: Subscription[];
@@ -7264,6 +9381,28 @@ export interface SubscriptionMigrateResponse {
7264
9381
  /** The resulting subscription, including its phases and items. */
7265
9382
  next: Subscription;
7266
9383
  }
9384
+ /** An invoice created notification event payload. */
9385
+ export interface NotificationEventInvoiceCreatedPayload {
9386
+ /** The identifier of the event the payload belongs to. */
9387
+ id: string;
9388
+ /** The type of the event. */
9389
+ type: 'invoice.created';
9390
+ /** When the event was generated. */
9391
+ timestamp: Date;
9392
+ /** The invoice the event refers to. */
9393
+ data: InvoiceCreatedV1Payload;
9394
+ }
9395
+ /** An invoice updated notification event payload. */
9396
+ export interface NotificationEventInvoiceUpdatedPayload {
9397
+ /** The identifier of the event the payload belongs to. */
9398
+ id: string;
9399
+ /** The type of the event. */
9400
+ type: 'invoice.updated';
9401
+ /** When the event was generated. */
9402
+ timestamp: Date;
9403
+ /** The invoice the event refers to. */
9404
+ data: InvoiceUpdatedV1Payload;
9405
+ }
7267
9406
  /** A flat fee charge for a customer. */
7268
9407
  export interface ChargeFlatFee {
7269
9408
  id: string;
@@ -7487,16 +9626,45 @@ export interface ChargeUsageBased {
7487
9626
  */
7488
9627
  systemIntent?: ChargeUsageBasedSystemIntent;
7489
9628
  }
9629
+ /** Result of manually collecting a customer's pending lines into invoices. */
9630
+ export interface InvoiceCustomerChargesResult {
9631
+ /** Created standard invoices, one per collected currency. */
9632
+ invoices: Invoice[];
9633
+ }
7490
9634
  /** Page paginated response. */
7491
9635
  export interface InvoicePagePaginatedResponse {
7492
9636
  data: Invoice[];
7493
9637
  meta: PaginatedMeta;
7494
9638
  }
9639
+ /**
9640
+ * A notification event records that a notification rule fired and tracks the
9641
+ * delivery of its payload to each channel of the rule. Events are created by the
9642
+ * system and cannot be modified.
9643
+ */
9644
+ export interface NotificationEvent {
9645
+ /** The unique identifier of the event. */
9646
+ id: string;
9647
+ /** The type of the event. */
9648
+ type: 'entitlements.balance.threshold' | 'entitlements.reset' | 'invoice.created' | 'invoice.updated';
9649
+ /** When the event was generated. */
9650
+ createdAt: Date;
9651
+ /** The rule that generated the event. */
9652
+ rule: NotificationRuleReference;
9653
+ /** The delivery status of the event, one entry per channel of the rule. */
9654
+ deliveryStatus: NotificationEventDeliveryStatus[];
9655
+ /** The payload delivered to the channels. */
9656
+ payload: NotificationEventPayload;
9657
+ }
7495
9658
  /** Page paginated response. */
7496
9659
  export interface ChargePagePaginatedResponse {
7497
9660
  data: Charge[];
7498
9661
  meta: PaginatedMeta;
7499
9662
  }
9663
+ /** Page paginated response. */
9664
+ export interface NotificationEventPagePaginatedResponse {
9665
+ data: NotificationEvent[];
9666
+ meta: PaginatedMeta;
9667
+ }
7500
9668
  /**
7501
9669
  * Filters on the given string field value by either exact or fuzzy match. All
7502
9670
  * properties are optional; provide exactly one to specify the comparison.
@@ -7585,6 +9753,8 @@ export type AppActionRequest = AppReconcileWebhookEventsActionRequest;
7585
9753
  export type InstallAppRequest = InstallAppStripeWithApiKey | InstallAppSandbox | InstallAppExternalInvoicing;
7586
9754
  /** Payment settings for a billing workflow. */
7587
9755
  export type UpdateBillingWorkflowPaymentSettings = UpdateBillingWorkflowPaymentChargeAutomaticallySettings | UpdateBillingWorkflowPaymentSendInvoiceSettings;
9756
+ /** Period duration for the recurrence */
9757
+ export type NotificationEventV1RecurringPeriodInterval = string | 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';
7588
9758
  /**
7589
9759
  * Cost basis selection for a custom-currency charge. The variant chosen fixes when
7590
9760
  * and how the conversion rate is determined.
@@ -7604,6 +9774,8 @@ export type InvalidParameter = InvalidParameterStandard | InvalidParameterMinimu
7604
9774
  export type RateCardEntitlement = RateCardMeteredEntitlement | RateCardStaticEntitlement | RateCardBooleanEntitlement;
7605
9775
  /** Request to update an installed app. */
7606
9776
  export type UpdateAppRequest = UpdateAppStripeRequest | UpdateAppSandboxRequest | UpdateAppExternalInvoicingRequest;
9777
+ /** The reason for the discount. */
9778
+ export type NotificationEventV1BillingDiscountReason = NotificationEventV1DiscountReasonMaximumSpend | NotificationEventV1DiscountReasonRatecardPercentage | NotificationEventV1DiscountReasonRatecardUsage;
7607
9779
  /**
7608
9780
  * Per-unit cost configuration for a feature. Either a fixed manual amount or a
7609
9781
  * dynamic LLM cost lookup.
@@ -7644,6 +9816,13 @@ export type NotificationRule = NotificationRuleBalanceThreshold | NotificationRu
7644
9816
  * to their defaults. The `type` must match the existing rule on update.
7645
9817
  */
7646
9818
  export type NotificationRuleRequest = NotificationRuleBalanceThresholdRequest | NotificationRuleEntitlementResetRequest | NotificationRuleInvoiceCreatedRequest | NotificationRuleInvoiceUpdatedRequest;
9819
+ /**
9820
+ * Per-unit cost configuration for a feature. Either a fixed manual amount or a
9821
+ * dynamic LLM cost lookup.
9822
+ */
9823
+ export type NotificationEventV1FeatureUnitCost = NotificationEventV1FeatureManualUnitCost | NotificationEventV1FeatureLlmUnitCost;
9824
+ /** PaymentTerms defines the terms for payment. */
9825
+ export type NotificationEventV1PaymentTerms = NotificationEventV1PaymentTermInstant | NotificationEventV1PaymentTermDueDate;
7647
9826
  /** Price. */
7648
9827
  export type Price = PriceFree | PriceFlat | PriceUnit | PriceGraduated | PriceVolume;
7649
9828
  /**
@@ -7661,8 +9840,18 @@ export type CreateEntitlementRequest = CreateEntitlementMeteredRequest | CreateE
7661
9840
  export type App = AppStripe | AppSandbox | AppExternalInvoicing;
7662
9841
  /** Response of the app install. */
7663
9842
  export type BillingInstallAppResponse = InstalledAppStripe | InstalledAppSandbox | InstalledAppExternalInvoicing;
7664
- /** The payload delivered to the channels, discriminated by the event type. */
7665
- export type NotificationEventPayload = NotificationEventBalanceThresholdPayload | NotificationEventResetPayload | NotificationEventInvoiceCreatedPayload | NotificationEventInvoiceUpdatedPayload;
9843
+ /**
9844
+ * The alignment for collecting the pending line items into an invoice.
9845
+ *
9846
+ * Defaults to subscription, which means that we are to create a new invoice every
9847
+ * time the a subscription period starts (for in advance items) or ends (for in
9848
+ * arrears items).
9849
+ */
9850
+ export type NotificationEventV1BillingWorkflowCollectionAlignment = NotificationEventV1BillingWorkflowCollectionAlignmentSubscription | NotificationEventV1BillingWorkflowCollectionAlignmentAnchored;
9851
+ /** The price of the usage based rate card. */
9852
+ export type NotificationEventV1RateCardUsageBasedPrice = NotificationEventV1FlatPriceWithPaymentTerm | NotificationEventV1UnitPriceWithCommitments | NotificationEventV1TieredPriceWithCommitments | NotificationEventV1DynamicPriceWithCommitments | NotificationEventV1PackagePriceWithCommitments;
9853
+ /** App. One of: stripe */
9854
+ export type NotificationEventV1App = NotificationEventV1StripeApp | NotificationEventV1SandboxApp | NotificationEventV1CustomInvoicingApp;
7666
9855
  /** Feature or reference. */
7667
9856
  export type FeatureOrReference = Feature | FeatureReference;
7668
9857
  /** ChargeRealizationInvoice or reference. */
@@ -7702,6 +9891,8 @@ export type SubscriptionOrReference = Subscription | SubscriptionReference;
7702
9891
  export type Invoice = InvoiceStandard;
7703
9892
  /** UpdateInvoiceRequest update request. */
7704
9893
  export type UpdateInvoiceRequest = UpdateInvoiceStandardRequest;
9894
+ /** The payload delivered to the channels, discriminated by the event type. */
9895
+ export type NotificationEventPayload = NotificationEventBalanceThresholdPayload | NotificationEventResetPayload | NotificationEventInvoiceCreatedPayload | NotificationEventInvoiceUpdatedPayload;
7705
9896
  /** Customer charge. */
7706
9897
  export type Charge = ChargeFlatFee | ChargeUsageBased;
7707
9898
  /**
@@ -8021,6 +10212,11 @@ export interface WorkflowInvoicingSettingsInput {
8021
10212
  progressiveBilling?: boolean;
8022
10213
  /** Controls how subscription-ending shortened service periods are billed. */
8023
10214
  subscriptionEndProrationMode?: 'bill_full_period' | 'bill_actual_period';
10215
+ /**
10216
+ * Controls whether empty invoices are created in the invoicing app. An invoice is
10217
+ * empty when it has no line items or its total is zero.
10218
+ */
10219
+ emptyInvoiceMode?: 'create' | 'omit';
8024
10220
  }
8025
10221
  /** Query to evaluate feature access for a list of customers. */
8026
10222
  export interface EntitlementAccessQueryRequestInput {
@@ -8427,6 +10623,21 @@ export interface SubscriptionBaseInput {
8427
10623
  * - Custom date (customer-specified day)
8428
10624
  */
8429
10625
  billingAnchor: Date;
10626
+ /**
10627
+ * When billing starts for the subscription. Nothing is billed for service before
10628
+ * this time, while access, entitlements and metering start with the subscription.
10629
+ * Use it when the time before was already billed elsewhere, for example when
10630
+ * importing a subscription from another billing system.
10631
+ *
10632
+ * It cannot be before the start of the subscription and cannot be changed later.
10633
+ * On subscriptions billed through invoice lines it must be the start of a billing
10634
+ * period. If not provided, billing starts with the subscription.
10635
+ *
10636
+ * When billing starts inside a billing period, we recommend enabling price
10637
+ * pro-rating (`prorate_prices`) on the plan. Without it that billing period's flat
10638
+ * fees are billed in full.
10639
+ */
10640
+ billingStartsAt?: Date;
8430
10641
  /** The status of the subscription. */
8431
10642
  status: 'active' | 'inactive' | 'canceled' | 'scheduled';
8432
10643
  /**
@@ -8990,6 +11201,8 @@ export interface CreditGrantInput {
8990
11201
  * fiat currency.
8991
11202
  */
8992
11203
  currency: BillingCurrencyCode;
11204
+ /** Managed currency reference. Present only for custom currencies. */
11205
+ customCurrency?: CurrencyCustomReference;
8993
11206
  /** Granted credit amount. */
8994
11207
  amount: string;
8995
11208
  /** Present when a funding workflow applies (funding_method is not `none`). */
@@ -9748,9 +11961,9 @@ export interface ChargeRealizationInput {
9748
11961
  * correction (or a voided run that snapshotted behind its live neighbors) instead
9749
11962
  * of masking it as zero.
9750
11963
  *
9751
- * On an `outstanding` entry this is `0` unless the `real_time_usage` expand is
9752
- * applied, in which case it is the not-yet-booked remainder of the live metering
9753
- * read (never negative).
11964
+ * On an `outstanding` entry, usage is omitted unless `real_time_usage` supplies a
11965
+ * live reading. When present, it is the unbooked remainder of that reading,
11966
+ * floored at zero.
9754
11967
  */
9755
11968
  usage?: string;
9756
11969
  /**
@@ -10109,6 +12322,21 @@ export interface SubscriptionInput {
10109
12322
  * - Custom date (customer-specified day)
10110
12323
  */
10111
12324
  billingAnchor: Date;
12325
+ /**
12326
+ * When billing starts for the subscription. Nothing is billed for service before
12327
+ * this time, while access, entitlements and metering start with the subscription.
12328
+ * Use it when the time before was already billed elsewhere, for example when
12329
+ * importing a subscription from another billing system.
12330
+ *
12331
+ * It cannot be before the start of the subscription and cannot be changed later.
12332
+ * On subscriptions billed through invoice lines it must be the start of a billing
12333
+ * period. If not provided, billing starts with the subscription.
12334
+ *
12335
+ * When billing starts inside a billing period, we recommend enabling price
12336
+ * pro-rating (`prorate_prices`) on the plan. Without it that billing period's flat
12337
+ * fees are billed in full.
12338
+ */
12339
+ billingStartsAt?: Date;
10112
12340
  /** The status of the subscription. */
10113
12341
  status: 'active' | 'inactive' | 'canceled' | 'scheduled';
10114
12342
  /**
@@ -10134,6 +12362,21 @@ export interface SubscriptionInput {
10134
12362
  }
10135
12363
  export interface SubscriptionCreateInput {
10136
12364
  labels?: Labels;
12365
+ /**
12366
+ * When billing starts for the subscription. Nothing is billed for service before
12367
+ * this time, while access, entitlements and metering start with the subscription.
12368
+ * Use it when the time before was already billed elsewhere, for example when
12369
+ * importing a subscription from another billing system.
12370
+ *
12371
+ * It cannot be before the start of the subscription and cannot be changed later.
12372
+ * On subscriptions billed through invoice lines it must be the start of a billing
12373
+ * period. If not provided, billing starts with the subscription.
12374
+ *
12375
+ * When billing starts inside a billing period, we recommend enabling price
12376
+ * pro-rating (`prorate_prices`) on the plan. Without it that billing period's flat
12377
+ * fees are billed in full.
12378
+ */
12379
+ billingStartsAt?: Date;
10137
12380
  /**
10138
12381
  * Settlement mode for billing.
10139
12382
  *
@@ -10647,6 +12890,11 @@ export interface ChargeUsageBasedInput {
10647
12890
  */
10648
12891
  systemIntent?: ChargeUsageBasedSystemIntentInput;
10649
12892
  }
12893
+ /** Result of manually collecting a customer's pending lines into invoices. */
12894
+ export interface InvoiceCustomerChargesResultInput {
12895
+ /** Created standard invoices, one per collected currency. */
12896
+ invoices: InvoiceInput[];
12897
+ }
10650
12898
  /** Page paginated response. */
10651
12899
  export interface InvoicePagePaginatedResponseInput {
10652
12900
  data: InvoiceInput[];