@openmeter/client 1.0.0-beta-19a1f6bdbcd5 → 1.0.0-beta-d512c81f78a3

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.
@@ -423,17 +423,63 @@ export const creditTransactionType = z
423
423
  .enum(['funded', 'consumed', 'expired', 'voided'])
424
424
  .describe('The type of the credit transaction. - `funded`: Credit granted and available for consumption. - `consumed`: Credit consumed by usage or fees. - `expired`: Credit removed because it expired before being used. - `voided`: Credit removed because the grant was voided before being used.');
425
425
  export const chargesExpand = z
426
- .enum(['real_time_usage'])
427
- .describe("Expands for customer charges. Values: - `real_time_usage`: The charge's real-time usage.");
426
+ .enum([
427
+ 'real_time_usage',
428
+ 'customer',
429
+ 'feature',
430
+ 'subscription',
431
+ 'realization.invoice',
432
+ 'realization.totals',
433
+ 'realization.detailed_lines',
434
+ ])
435
+ .describe("Expands for customer charges. Values: - `real_time_usage`: The charge's real-time usage; it sets the `usage` and the `totals.realtime` fields, and fills the `outstanding` realization's `usage` with the not-yet-booked remainder of the live read. - `customer`: The complete customer entity of the charge. - `feature`: The complete feature entity of the charge. - `subscription`: The complete subscription of the charge, when present. - `realization.invoice`: The invoice header of each realization (the invoice entity without its `lines` and `customer` snapshot), in place of the ID reference. - `realization.totals`: The `totals` of each realization run, including credit allocations. - `realization.detailed_lines`: The `detailed_lines` of each realization run.");
428
436
  export const lifecycleController = z
429
437
  .enum(['system', 'manual'])
430
438
  .describe('Identifies whether a resource lifecycle is controlled by OpenMeter or manually overridden by the API user. Values: - `system`: The resource lifecycle is controlled by OpenMeter. - `manual`: The resource lifecycle was manually overridden by the API user.');
431
- export const chargeStatus = z
432
- .enum(['created', 'active', 'final', 'deleted'])
433
- .describe('Lifecycle status of a charge. Values: - `created`: The charge has been created but is not active yet. - `active`: The charge is active. - `final`: The charge is fully finalized and no further changes are expected. - `deleted`: The charge has been deleted.');
439
+ export const subscriptionCostBasisMode = z
440
+ .enum(['dynamic', 'pinned'])
441
+ .describe('Controls how custom-currency cost bases are selected for the subscription.');
442
+ export const rateCardProrationMode = z
443
+ .enum(['no_proration', 'prorate_prices'])
444
+ .describe('The proration mode of the rate card. Values: - `no_proration`: No proration. - `prorate_prices`: Prorate the price based on the time remaining in the billing period.');
445
+ export const subscriptionStatus = z
446
+ .enum(['active', 'inactive', 'canceled', 'scheduled'])
447
+ .describe('Subscription status.');
434
448
  export const settlementMode = z
435
449
  .enum(['credit_then_invoice', 'credit_only'])
436
450
  .describe('Settlement mode for billing. Values: - `credit_then_invoice`: Credits are applied first, then any remainder is invoiced. - `credit_only`: Usage is settled exclusively against credits.');
451
+ export const priceFree = z
452
+ .object({
453
+ type: z.literal('free').describe('The type of the price.'),
454
+ })
455
+ .describe('Free price.');
456
+ export const unitConfigOperation = z
457
+ .enum(['divide', 'multiply'])
458
+ .describe('The arithmetic operation used to convert raw metered units into billing units. - `divide`: Divide the metered quantity by the conversion factor (e.g., bytes ÷ 1e9 = GB). - `multiply`: Multiply the metered quantity by the conversion factor (e.g., cost × 1.2 = cost + 20% margin).');
459
+ export const unitConfigRoundingMode = z
460
+ .enum(['ceiling', 'floor', 'half_up', 'none'])
461
+ .describe('The rounding mode applied to the converted quantity for invoicing. Rounding is applied only to the invoiced quantity. Entitlement balance checks use the precise decimal value after conversion. - `ceiling`: Round up to the next integer (typical for package-style billing). - `floor`: Round down to the previous integer. - `half_up`: Round to the nearest integer, with 0.5 rounding up. - `none`: No rounding; the converted value is used as-is.');
462
+ export const pricePaymentTerm = z
463
+ .union([z.literal('in_advance'), z.literal('in_arrears')])
464
+ .describe('The payment term of a flat price.');
465
+ export const rateCardStaticEntitlement = z
466
+ .object({
467
+ type: z.literal('static').describe('The type of the entitlement template.'),
468
+ config: z
469
+ .unknown()
470
+ .describe('The entitlement config as a JSON object. Returned when checking entitlement access; useful for configuring fine-grained access settings implemented in your own system.'),
471
+ })
472
+ .describe('The entitlement template of a static entitlement.');
473
+ export const rateCardBooleanEntitlement = z
474
+ .object({
475
+ type: z
476
+ .literal('boolean')
477
+ .describe('The type of the entitlement template.'),
478
+ })
479
+ .describe('The entitlement template of a boolean entitlement.');
480
+ export const chargeStatus = z
481
+ .enum(['created', 'active', 'final', 'deleted'])
482
+ .describe('Lifecycle status of a charge. Values: - `created`: The charge has been created but is not active yet. - `active`: The charge is active. - `final`: The charge is fully finalized and no further changes are expected. - `deleted`: The charge has been deleted.');
437
483
  export const taxConfigStripe = z
438
484
  .object({
439
485
  code: z
@@ -450,9 +496,96 @@ export const taxConfigExternalInvoicing = z
450
496
  .describe('The tax code should be interpreted by the external invoicing provider.'),
451
497
  })
452
498
  .describe('External invoicing tax config.');
453
- export const pricePaymentTerm = z
454
- .union([z.literal('in_advance'), z.literal('in_arrears')])
455
- .describe('The payment term of a flat price.');
499
+ export const invoiceNumber = z
500
+ .string()
501
+ .min(1)
502
+ .max(256)
503
+ .describe('InvoiceNumber is a unique identifier for the invoice, generated by the invoicing app. The uniqueness depends on a lot of factors: - app setting (unique per app or unique per customer) - multiple app scenarios (multiple apps generating invoices with the same prefix)');
504
+ export const taxIdentificationCode = z
505
+ .string()
506
+ .min(1)
507
+ .max(32)
508
+ .describe('Tax identifier code is a normalized tax code shown on the original identity document.');
509
+ export const invoiceValidationIssueSeverity = z
510
+ .enum(['critical', 'warning'])
511
+ .describe('Severity level of an invoice validation issue.');
512
+ export const invoiceExternalReferences = z
513
+ .object({
514
+ invoicingId: z
515
+ .string()
516
+ .optional()
517
+ .describe('The ID assigned by the external invoicing app (e.g. Stripe invoice ID).'),
518
+ paymentId: z
519
+ .string()
520
+ .optional()
521
+ .describe('The ID assigned by the external payment app (e.g. Stripe payment intent ID).'),
522
+ })
523
+ .describe('External identifiers assigned to an invoice by third-party systems.');
524
+ export const invoiceStandardStatus = z
525
+ .enum([
526
+ 'draft',
527
+ 'issuing',
528
+ 'issued',
529
+ 'payment_processing',
530
+ 'overdue',
531
+ 'paid',
532
+ 'uncollectible',
533
+ 'voided',
534
+ ])
535
+ .describe('Lifecycle status of a standard invoice.');
536
+ export const invoiceAvailableActionDetails = z
537
+ .object({
538
+ resultingState: z
539
+ .string()
540
+ .describe('The extended status the invoice will transition to after performing this action.'),
541
+ })
542
+ .describe('Details about an available invoice action including the resulting state.');
543
+ export const invoiceWorkflowInvoicingSettings = z
544
+ .object({
545
+ autoAdvance: z
546
+ .boolean()
547
+ .optional()
548
+ .default(true)
549
+ .describe('Whether to automatically issue the invoice after the draft_period has passed.'),
550
+ draftPeriod: z
551
+ .string()
552
+ .optional()
553
+ .default('P0D')
554
+ .describe('The period for the invoice to be kept in draft status for manual reviews.'),
555
+ dueAfter: z
556
+ .string()
557
+ .optional()
558
+ .describe('The period after which the invoice is considered overdue if not paid.'),
559
+ })
560
+ .describe('Invoice-level invoicing settings. A subset of BillingWorkflowInvoicingSettings limited to fields that are meaningful per-invoice. progressive_billing is omitted as it is a gather-time / profile-level decision.');
561
+ export const workflowPaymentChargeAutomaticallySettings = z
562
+ .object({
563
+ collectionMethod: z
564
+ .literal('charge_automatically')
565
+ .describe('The collection method for the invoice.'),
566
+ })
567
+ .describe('Payment settings for a billing workflow when the collection method is charge automatically.');
568
+ export const workflowPaymentSendInvoiceSettings = z
569
+ .object({
570
+ collectionMethod: z
571
+ .literal('send_invoice')
572
+ .describe('The collection method for the invoice.'),
573
+ dueAfter: z
574
+ .string()
575
+ .optional()
576
+ .default('P30D')
577
+ .describe("The period after which the invoice is due. With some payment solutions it's only applicable for manual collection method."),
578
+ })
579
+ .describe('Payment settings for a billing workflow when the collection method is send invoice.');
580
+ export const chargeRealizationType = z
581
+ .enum(['final_realization', 'partial_invoice', 'outstanding', 'voided'])
582
+ .describe("Type of a charge realization run. Values: - `final_realization`: The run is the final realization of the charge for its service period; no further runs are expected to correct it. - `partial_invoice`: The run only realizes part of the charge, because the remainder is not yet due to be invoiced. - `outstanding`: The type an outstanding (not-yet-realized) projection would carry if it were realized now. Never returned on a booked realization run. - `voided`: The run's billing effect was undone (for example the charge's service period was extended while its invoice was still mutable); it is retained as audit history and excluded from aggregate and live calculations.");
583
+ export const chargeRealizationPaymentStatus = z
584
+ .enum(['authorized', 'settled'])
585
+ .describe("Settlement status of a charge realization's payment. Values: - `authorized`: The payment has been authorized against the customer's ledger but has not settled yet. - `settled`: The payment has settled.");
586
+ export const chargeRealizationDetailedLineCategory = z
587
+ .enum(['regular', 'commitment'])
588
+ .describe('Cost category of a charge realization detailed line. Values: - `regular`: A regular charge line, based on usage or subscription pricing. - `commitment`: A commitment-derived line, such as minimum spend.');
456
589
  export const chargeFlatFeeDiscounts = z
457
590
  .object({
458
591
  percentage: z
@@ -463,41 +596,17 @@ export const chargeFlatFeeDiscounts = z
463
596
  .describe('Percentage discount applied to the price (0–100).'),
464
597
  })
465
598
  .describe('Discounts applicable to flat fee charges. This is the same as `ProductCatalog.Discounts` but without the `usage` field, which is not applicable to flat fee charges.');
466
- export const rateCardProrationMode = z
467
- .enum(['no_proration', 'prorate_prices'])
468
- .describe('The proration mode of the rate card. Values: - `no_proration`: No proration. - `prorate_prices`: Prorate the price based on the time remaining in the billing period.');
469
- export const unitConfigOperation = z
470
- .enum(['divide', 'multiply'])
471
- .describe('The arithmetic operation used to convert raw metered units into billing units. - `divide`: Divide the metered quantity by the conversion factor (e.g., bytes ÷ 1e9 = GB). - `multiply`: Multiply the metered quantity by the conversion factor (e.g., cost × 1.2 = cost + 20% margin).');
472
- export const unitConfigRoundingMode = z
473
- .enum(['ceiling', 'floor', 'half_up', 'none'])
474
- .describe('The rounding mode applied to the converted quantity for invoicing. Rounding is applied only to the invoiced quantity. Entitlement balance checks use the precise decimal value after conversion. - `ceiling`: Round up to the next integer (typical for package-style billing). - `floor`: Round down to the previous integer. - `half_up`: Round to the nearest integer, with 0.5 rounding up. - `none`: No rounding; the converted value is used as-is.');
475
- export const subscriptionCostBasisMode = z
476
- .enum(['dynamic', 'pinned'])
477
- .describe('Controls how custom-currency cost bases are selected for the subscription.');
478
- export const subscriptionStatus = z
479
- .enum(['active', 'inactive', 'canceled', 'scheduled'])
480
- .describe('Subscription status.');
481
- export const priceFree = z
482
- .object({
483
- type: z.literal('free').describe('The type of the price.'),
484
- })
485
- .describe('Free price.');
486
- export const rateCardStaticEntitlement = z
487
- .object({
488
- type: z.literal('static').describe('The type of the entitlement template.'),
489
- config: z
490
- .unknown()
491
- .describe('The entitlement config as a JSON object. Returned when checking entitlement access; useful for configuring fine-grained access settings implemented in your own system.'),
492
- })
493
- .describe('The entitlement template of a static entitlement.');
494
- export const rateCardBooleanEntitlement = z
495
- .object({
496
- type: z
497
- .literal('boolean')
498
- .describe('The type of the entitlement template.'),
499
- })
500
- .describe('The entitlement template of a boolean entitlement.');
599
+ export const featureLlmTokenType = z
600
+ .enum([
601
+ 'input',
602
+ 'output',
603
+ 'cache_read',
604
+ 'cache_write',
605
+ 'reasoning',
606
+ 'request',
607
+ 'response',
608
+ ])
609
+ .describe('Token type for LLM cost lookup.');
501
610
  export const subscriptionEditTimingEnum = z
502
611
  .enum(['immediate', 'next_billing_cycle'])
503
612
  .describe('Subscription edit timing. When immediate, the requested changes take effect immediately. When next_billing_cycle, the requested changes take effect at the next billing cycle.');
@@ -550,11 +659,6 @@ export const installAppExternalInvoicing = z
550
659
  .describe('If true, a billing profile will be created for the app. The Stripe app will be also set as the default billing profile if the current default is a Sandbox app.'),
551
660
  })
552
661
  .describe('Base model for installing an app from the catalog.');
553
- export const taxIdentificationCode = z
554
- .string()
555
- .min(1)
556
- .max(32)
557
- .describe('Tax identifier code is a normalized tax code shown on the original identity document.');
558
662
  export const workflowCollectionAlignmentSubscription = z
559
663
  .object({
560
664
  type: z.literal('subscription').describe('The type of alignment.'),
@@ -563,82 +667,6 @@ export const workflowCollectionAlignmentSubscription = z
563
667
  export const workflowInvoicingSubscriptionEndProrationMode = z
564
668
  .enum(['bill_full_period', 'bill_actual_period'])
565
669
  .describe('Billing workflow subscription end proration mode.');
566
- export const workflowPaymentChargeAutomaticallySettings = z
567
- .object({
568
- collectionMethod: z
569
- .literal('charge_automatically')
570
- .describe('The collection method for the invoice.'),
571
- })
572
- .describe('Payment settings for a billing workflow when the collection method is charge automatically.');
573
- export const workflowPaymentSendInvoiceSettings = z
574
- .object({
575
- collectionMethod: z
576
- .literal('send_invoice')
577
- .describe('The collection method for the invoice.'),
578
- dueAfter: z
579
- .string()
580
- .optional()
581
- .default('P30D')
582
- .describe("The period after which the invoice is due. With some payment solutions it's only applicable for manual collection method."),
583
- })
584
- .describe('Payment settings for a billing workflow when the collection method is send invoice.');
585
- export const invoiceNumber = z
586
- .string()
587
- .min(1)
588
- .max(256)
589
- .describe('InvoiceNumber is a unique identifier for the invoice, generated by the invoicing app. The uniqueness depends on a lot of factors: - app setting (unique per app or unique per customer) - multiple app scenarios (multiple apps generating invoices with the same prefix)');
590
- export const invoiceValidationIssueSeverity = z
591
- .enum(['critical', 'warning'])
592
- .describe('Severity level of an invoice validation issue.');
593
- export const invoiceExternalReferences = z
594
- .object({
595
- invoicingId: z
596
- .string()
597
- .optional()
598
- .describe('The ID assigned by the external invoicing app (e.g. Stripe invoice ID).'),
599
- paymentId: z
600
- .string()
601
- .optional()
602
- .describe('The ID assigned by the external payment app (e.g. Stripe payment intent ID).'),
603
- })
604
- .describe('External identifiers assigned to an invoice by third-party systems.');
605
- export const invoiceStandardStatus = z
606
- .enum([
607
- 'draft',
608
- 'issuing',
609
- 'issued',
610
- 'payment_processing',
611
- 'overdue',
612
- 'paid',
613
- 'uncollectible',
614
- 'voided',
615
- ])
616
- .describe('Lifecycle status of a standard invoice.');
617
- export const invoiceAvailableActionDetails = z
618
- .object({
619
- resultingState: z
620
- .string()
621
- .describe('The extended status the invoice will transition to after performing this action.'),
622
- })
623
- .describe('Details about an available invoice action including the resulting state.');
624
- export const invoiceWorkflowInvoicingSettings = z
625
- .object({
626
- autoAdvance: z
627
- .boolean()
628
- .optional()
629
- .default(true)
630
- .describe('Whether to automatically issue the invoice after the draft_period has passed.'),
631
- draftPeriod: z
632
- .string()
633
- .optional()
634
- .default('P0D')
635
- .describe('The period for the invoice to be kept in draft status for manual reviews.'),
636
- dueAfter: z
637
- .string()
638
- .optional()
639
- .describe('The period after which the invoice is considered overdue if not paid.'),
640
- })
641
- .describe('Invoice-level invoicing settings. A subset of BillingWorkflowInvoicingSettings limited to fields that are meaningful per-invoice. progressive_billing is omitted as it is a gather-time / profile-level decision.');
642
670
  export const invoiceDiscountReason = z
643
671
  .enum(['maximum_spend', 'ratecard_percentage', 'ratecard_usage'])
644
672
  .describe('The reason a discount was applied to an invoice line.');
@@ -697,17 +725,6 @@ export const currencyType = z
697
725
  export const currencyExpand = z
698
726
  .enum(['cost_basis'])
699
727
  .describe("Expands for currencies. Values: - `cost_basis`: The currency's active and scheduled cost basis.");
700
- export const featureLlmTokenType = z
701
- .enum([
702
- 'input',
703
- 'output',
704
- 'cache_read',
705
- 'cache_write',
706
- 'reasoning',
707
- 'request',
708
- 'response',
709
- ])
710
- .describe('Token type for LLM cost lookup.');
711
728
  export const llmCostProvider = z
712
729
  .object({
713
730
  id: z
@@ -962,12 +979,12 @@ export const invoiceLineType = z
962
979
  export const priceType = z
963
980
  .enum(['free', 'flat', 'unit', 'graduated', 'volume'])
964
981
  .describe("The type of the price. - `free`: No charge, the rate card is included at no cost. - `flat`: A fixed amount charged once per billing period, regardless of usage. - `unit`: A fixed rate charged per billing unit consumed. - `graduated`: Tiered pricing where each tier's rate applies only to usage within that tier. - `volume`: Tiered pricing where the rate for the highest tier reached applies to all units in the period.");
965
- export const collectionAlignment = z
966
- .enum(['subscription', 'anchored'])
967
- .describe('BillingCollectionAlignment specifies when the pending line items should be collected into an invoice.');
968
982
  export const collectionMethod = z
969
983
  .enum(['charge_automatically', 'send_invoice'])
970
984
  .describe('Collection method specifies how the invoice should be collected (automatic or manual).');
985
+ export const collectionAlignment = z
986
+ .enum(['subscription', 'anchored'])
987
+ .describe('BillingCollectionAlignment specifies when the pending line items should be collected into an invoice.');
971
988
  export const featureUnitCostType = z
972
989
  .enum(['llm', 'manual'])
973
990
  .describe('The type of unit cost.');
@@ -1098,18 +1115,24 @@ export const createCurrencyCustomRequest = z
1098
1115
  code: currencyCodeCustom,
1099
1116
  })
1100
1117
  .describe('CurrencyCustom create request.');
1101
- export const currencyAmount = z
1102
- .object({
1103
- amount: numeric,
1104
- currency: currencyCode,
1105
- })
1106
- .describe('Monetary amount in a specific currency.');
1107
1118
  export const priceFlat = z
1108
1119
  .object({
1109
1120
  type: z.literal('flat').describe('The type of the price.'),
1110
1121
  amount: numeric,
1111
1122
  })
1112
1123
  .describe('Flat price.');
1124
+ export const priceUnit = z
1125
+ .object({
1126
+ type: z.literal('unit').describe('The type of the price.'),
1127
+ amount: numeric,
1128
+ })
1129
+ .describe('Unit price. Charges a fixed rate per billing unit. When UnitConfig is present on the object, billing units are the converted quantities (e.g. GB instead of bytes).');
1130
+ export const spendCommitments = z
1131
+ .object({
1132
+ minimumAmount: numeric.optional(),
1133
+ maximumAmount: numeric.optional(),
1134
+ })
1135
+ .describe('Spend commitments for a usage-based price. The customer is committed to spend at least the minimum amount and at most the maximum amount.');
1113
1136
  export const rateCardDiscounts = z
1114
1137
  .object({
1115
1138
  percentage: z
@@ -1133,18 +1156,57 @@ export const totals = z
1133
1156
  total: numeric,
1134
1157
  })
1135
1158
  .describe('Totals contains the summaries of all calculations for a billing resource.');
1136
- export const priceUnit = z
1159
+ export const chargeRealizationDetailedLineCreditApplied = z
1160
+ .object({
1161
+ amount: numeric,
1162
+ description: z
1163
+ .string()
1164
+ .optional()
1165
+ .describe('Human-readable description of the credit allocation.'),
1166
+ creditRealizationId: z
1167
+ .string()
1168
+ .describe('The ID of the credit realization (allocation) this credit was applied from.'),
1169
+ })
1170
+ .describe('A credit allocation applied to a charge realization detailed line.');
1171
+ export const chargeRealizationAmountDiscount = z
1172
+ .object({
1173
+ amount: numeric,
1174
+ reason: z
1175
+ .string()
1176
+ .describe('The reason for the discount applied to the charge.'),
1177
+ description: z
1178
+ .string()
1179
+ .optional()
1180
+ .describe('Optional human-readable description of the discount.'),
1181
+ roundingAmount: numeric.optional(),
1182
+ childUniqueReferenceId: z
1183
+ .string()
1184
+ .describe('Unique reference ID of the discount applied to the charge.'),
1185
+ })
1186
+ .describe('A discount applied to a charge realization detailed line.');
1187
+ export const featureManualUnitCost = z
1137
1188
  .object({
1138
- type: z.literal('unit').describe('The type of the price.'),
1189
+ type: z
1190
+ .literal('manual')
1191
+ .describe('The type discriminator for manual unit cost.'),
1139
1192
  amount: numeric,
1140
1193
  })
1141
- .describe('Unit price. Charges a fixed rate per billing unit. When UnitConfig is present on the object, billing units are the converted quantities (e.g. GB instead of bytes).');
1142
- export const spendCommitments = z
1194
+ .describe('A fixed per-unit cost amount.');
1195
+ export const featureLlmUnitCostPricing = z
1143
1196
  .object({
1144
- minimumAmount: numeric.optional(),
1145
- maximumAmount: numeric.optional(),
1197
+ inputPerToken: numeric,
1198
+ outputPerToken: numeric,
1199
+ cacheReadPerToken: numeric.optional(),
1200
+ reasoningPerToken: numeric.optional(),
1201
+ cacheWritePerToken: numeric.optional(),
1146
1202
  })
1147
- .describe('Spend commitments for a usage-based price. The customer is committed to spend at least the minimum amount and at most the maximum amount.');
1203
+ .describe('Resolved per-token pricing from the LLM cost database.');
1204
+ export const currencyAmount = z
1205
+ .object({
1206
+ amount: numeric,
1207
+ currency: currencyCode,
1208
+ })
1209
+ .describe('Monetary amount in a specific currency.');
1148
1210
  export const invoiceLineCreditsApplied = z
1149
1211
  .object({
1150
1212
  amount: numeric,
@@ -1187,23 +1249,6 @@ export const updateDiscounts = z
1187
1249
  usage: numeric.optional(),
1188
1250
  })
1189
1251
  .describe('Discount configuration for a rate card.');
1190
- export const featureManualUnitCost = z
1191
- .object({
1192
- type: z
1193
- .literal('manual')
1194
- .describe('The type discriminator for manual unit cost.'),
1195
- amount: numeric,
1196
- })
1197
- .describe('A fixed per-unit cost amount.');
1198
- export const featureLlmUnitCostPricing = z
1199
- .object({
1200
- inputPerToken: numeric,
1201
- outputPerToken: numeric,
1202
- cacheReadPerToken: numeric.optional(),
1203
- reasoningPerToken: numeric.optional(),
1204
- cacheWritePerToken: numeric.optional(),
1205
- })
1206
- .describe('Resolved per-token pricing from the LLM cost database.');
1207
1252
  export const llmCostModelPricing = z
1208
1253
  .object({
1209
1254
  inputPerToken: numeric,
@@ -1304,14 +1349,25 @@ export const creditGrantInvoiceReference = z
1304
1349
  .describe('Identifier of the invoice line associated with the grant.'),
1305
1350
  })
1306
1351
  .describe('Invoice references for the grant.');
1307
- export const billingCustomerReference = z
1352
+ export const subscriptionCostBasisPin = z
1353
+ .object({
1354
+ customCurrencyId: ulid,
1355
+ invoiceCurrency: currencyCode,
1356
+ costBasisId: ulid,
1357
+ })
1358
+ .describe('A cost basis pinned to a custom-currency pair for the subscription.');
1359
+ export const featureReference = z
1308
1360
  .object({
1309
1361
  id: ulid,
1310
1362
  })
1311
- .describe('Customer reference.');
1363
+ .describe('Feature reference.');
1312
1364
  export const subscriptionReference = z
1313
1365
  .object({
1314
1366
  id: ulid,
1367
+ name: z
1368
+ .string()
1369
+ .optional()
1370
+ .describe('The display name of the subscription. Only populated where the referencing endpoint documents a `subscription` expand that resolves it.'),
1315
1371
  phase: z
1316
1372
  .object({
1317
1373
  id: ulid,
@@ -1324,28 +1380,21 @@ export const subscriptionReference = z
1324
1380
  .describe('The phase of the subscription.'),
1325
1381
  })
1326
1382
  .describe('Subscription reference represents a reference to the specific subscription item this entity represents.');
1327
- export const subscriptionCostBasisPin = z
1383
+ export const appReference = z
1328
1384
  .object({
1329
- customCurrencyId: ulid,
1330
- invoiceCurrency: currencyCode,
1331
- costBasisId: ulid,
1385
+ id: ulid,
1332
1386
  })
1333
- .describe('A cost basis pinned to a custom-currency pair for the subscription.');
1334
- export const featureReference = z
1387
+ .describe('App reference.');
1388
+ export const chargeRealizationInvoiceReference = z
1335
1389
  .object({
1336
1390
  id: ulid,
1337
1391
  })
1338
- .describe('Feature reference.');
1392
+ .describe('ChargeRealizationInvoice reference.');
1339
1393
  export const addonReference = z
1340
1394
  .object({
1341
1395
  id: ulid,
1342
1396
  })
1343
1397
  .describe('Addon reference.');
1344
- export const appReference = z
1345
- .object({
1346
- id: ulid,
1347
- })
1348
- .describe('App reference.');
1349
1398
  export const chargeReference = z
1350
1399
  .object({
1351
1400
  id: ulid,
@@ -1356,6 +1405,28 @@ export const updateResourceReference = z
1356
1405
  id: ulid,
1357
1406
  })
1358
1407
  .describe('TaxCode reference.');
1408
+ export const billingCustomerReference = z
1409
+ .object({
1410
+ id: ulid,
1411
+ name: z
1412
+ .string()
1413
+ .optional()
1414
+ .describe('The display name of the customer. Only populated where the referencing endpoint documents a `customer` expand that resolves it.'),
1415
+ })
1416
+ .describe('Customer reference.');
1417
+ export const chargeFeature = z
1418
+ .object({
1419
+ id: ulid,
1420
+ key: z
1421
+ .string()
1422
+ .optional()
1423
+ .describe('The key of the feature. Requires the `feature` expand.'),
1424
+ name: z
1425
+ .string()
1426
+ .optional()
1427
+ .describe('The display name of the feature. Requires the `feature` expand.'),
1428
+ })
1429
+ .describe('The feature associated with a charge. `key` is always present and is set at charge creation time. `id` and `name` are only resolved with the `feature` expand, since resolving them requires an additional lookup against the feature catalog.');
1359
1430
  export const dateTimeFieldFilter = z
1360
1431
  .union([
1361
1432
  dateTime,
@@ -2041,11 +2112,6 @@ export const getCreditBalanceParamsFilter = z
2041
2112
  featureKey: stringFieldFilter.optional(),
2042
2113
  })
2043
2114
  .describe('Filter options for getting a credit balance.');
2044
- export const listChargesParamsFilter = z
2045
- .object({
2046
- status: stringFieldFilterExact.optional(),
2047
- })
2048
- .describe('Filter options for listing charges.');
2049
2115
  export const listPlansParamsFilter = z
2050
2116
  .object({
2051
2117
  key: stringFieldFilter.optional(),
@@ -2061,34 +2127,17 @@ export const voidCreditGrantRequest = z
2061
2127
  .default('none'),
2062
2128
  })
2063
2129
  .describe('Request body for voiding a credit grant.');
2064
- export const rateCardProrationConfiguration = z
2065
- .object({
2066
- mode: rateCardProrationMode,
2067
- })
2068
- .describe('The proration configuration of the rate card.');
2069
2130
  export const subscriptionProRatingConfig = z
2070
2131
  .object({
2071
2132
  enabled: z.boolean().describe('Whether pro-rating is enabled.'),
2072
2133
  mode: rateCardProrationMode,
2073
2134
  })
2074
2135
  .describe('The pro-rating configuration of a subscription.');
2075
- export const unitConfig = z
2136
+ export const rateCardProrationConfiguration = z
2076
2137
  .object({
2077
- operation: unitConfigOperation,
2078
- conversionFactor: numeric,
2079
- rounding: unitConfigRoundingMode.optional().default('none'),
2080
- precision: z
2081
- .number()
2082
- .int()
2083
- .optional()
2084
- .default(0)
2085
- .describe('The number of decimal places to retain after rounding. Only meaningful when rounding is not "none". Defaults to 0 (round to whole numbers).'),
2086
- displayUnit: z
2087
- .string()
2088
- .optional()
2089
- .describe('A human-readable label for the converted unit shown on invoices and in the customer portal (e.g., "GB", "hours", "M tokens"). Optional. When omitted, no unit label is rendered.'),
2138
+ mode: rateCardProrationMode,
2090
2139
  })
2091
- .describe('Unit conversion configuration. Transforms raw metered quantities into billing-ready units before pricing and entitlement evaluation. Stored with a resource\'s rating configuration so the same metered feature can be billed in different units across plans and charges. Examples: - Meter bytes, bill GB: operation=divide, conversionFactor=1e9, rounding=ceiling, displayUnit="GB" - Meter seconds, bill hours: operation=divide, conversionFactor=3600, rounding=ceiling, displayUnit="hours" - Cost + 20% margin: operation=multiply, conversionFactor=1.2 - Bill per million tokens: operation=divide, conversionFactor=1e6, rounding=ceiling, displayUnit="M" v1 equivalents: - DynamicPrice(multiplier): operation=multiply, conversionFactor=multiplier + UnitPrice(amount=1) - PackagePrice(amount, quantityPerPkg): operation=divide, conversionFactor=quantityPerPkg, rounding=ceiling + UnitPrice(amount)');
2140
+ .describe('The proration configuration of the rate card.');
2092
2141
  export const subscriptionCreate = z
2093
2142
  .object({
2094
2143
  labels: labels.optional(),
@@ -2114,6 +2163,68 @@ export const subscriptionCreate = z
2114
2163
  costBasisMode: subscriptionCostBasisMode.optional().default('dynamic'),
2115
2164
  })
2116
2165
  .describe('Subscription create request.');
2166
+ export const unitConfig = z
2167
+ .object({
2168
+ operation: unitConfigOperation,
2169
+ conversionFactor: numeric,
2170
+ rounding: unitConfigRoundingMode.optional().default('none'),
2171
+ precision: z
2172
+ .number()
2173
+ .int()
2174
+ .optional()
2175
+ .default(0)
2176
+ .describe('The number of decimal places to retain after rounding. Only meaningful when rounding is not "none". Defaults to 0 (round to whole numbers).'),
2177
+ displayUnit: z
2178
+ .string()
2179
+ .optional()
2180
+ .describe('A human-readable label for the converted unit shown on invoices and in the customer portal (e.g., "GB", "hours", "M tokens"). Optional. When omitted, no unit label is rendered.'),
2181
+ })
2182
+ .describe('Unit conversion configuration. Transforms raw metered quantities into billing-ready units before pricing and entitlement evaluation. Stored with a resource\'s rating configuration so the same metered feature can be billed in different units across plans and charges. Examples: - Meter bytes, bill GB: operation=divide, conversionFactor=1e9, rounding=ceiling, displayUnit="GB" - Meter seconds, bill hours: operation=divide, conversionFactor=3600, rounding=ceiling, displayUnit="hours" - Cost + 20% margin: operation=multiply, conversionFactor=1.2 - Bill per million tokens: operation=divide, conversionFactor=1e6, rounding=ceiling, displayUnit="M" v1 equivalents: - DynamicPrice(multiplier): operation=multiply, conversionFactor=multiplier + UnitPrice(amount=1) - PackagePrice(amount, quantityPerPkg): operation=divide, conversionFactor=quantityPerPkg, rounding=ceiling + UnitPrice(amount)');
2183
+ export const partyTaxIdentity = z
2184
+ .object({
2185
+ code: taxIdentificationCode.optional(),
2186
+ })
2187
+ .describe('Identity stores the details required to identify an entity for tax purposes in a specific country.');
2188
+ export const updateBillingPartyTaxIdentity = z
2189
+ .object({
2190
+ code: taxIdentificationCode.optional(),
2191
+ })
2192
+ .describe('Identity stores the details required to identify an entity for tax purposes in a specific country.');
2193
+ export const invoiceValidationIssue = z
2194
+ .object({
2195
+ code: z.string().describe('Machine-readable error code.'),
2196
+ message: z.string().describe('Human-readable description of the error.'),
2197
+ attributes: z
2198
+ .record(z.string(), z.unknown())
2199
+ .optional()
2200
+ .describe('Additional structured context.'),
2201
+ severity: invoiceValidationIssueSeverity,
2202
+ field: z
2203
+ .string()
2204
+ .optional()
2205
+ .describe('JSON path to the field that caused this validation issue, if applicable. For example: `lines/0/rate_card/price`.'),
2206
+ })
2207
+ .describe('A validation issue found during invoice processing. Converges on the same structure used by plan and subscription validation errors: a machine-readable `code`, a human-readable `message`, optional structured `attributes`, plus a `severity` and optional `field` path.');
2208
+ export const invoiceAvailableActions = z
2209
+ .object({
2210
+ advance: invoiceAvailableActionDetails.optional(),
2211
+ approve: invoiceAvailableActionDetails.optional(),
2212
+ delete: invoiceAvailableActionDetails.optional(),
2213
+ retry: invoiceAvailableActionDetails.optional(),
2214
+ snapshotQuantities: invoiceAvailableActionDetails.optional(),
2215
+ })
2216
+ .describe('The set of state-transition actions available for an invoice in its current status. A field is present only when that action is permitted from the current state.');
2217
+ export const workflowPaymentSettings = z
2218
+ .discriminatedUnion('collectionMethod', [
2219
+ workflowPaymentChargeAutomaticallySettings,
2220
+ workflowPaymentSendInvoiceSettings,
2221
+ ])
2222
+ .describe('Payment settings for a billing workflow.');
2223
+ export const chargeRealizationPayment = z
2224
+ .object({
2225
+ status: chargeRealizationPaymentStatus,
2226
+ })
2227
+ .describe('Payment state of a charge realization.');
2117
2228
  export const subscriptionEditTiming = z
2118
2229
  .union([subscriptionEditTimingEnum, dateTime])
2119
2230
  .describe('Subscription edit timing defined when the changes should take effect. If the provided configuration is not supported by the subscription, an error will be returned.');
@@ -2196,16 +2307,6 @@ export const installAppRequest = z
2196
2307
  installAppExternalInvoicing,
2197
2308
  ])
2198
2309
  .describe('Request to install an app from the catalog.');
2199
- export const partyTaxIdentity = z
2200
- .object({
2201
- code: taxIdentificationCode.optional(),
2202
- })
2203
- .describe('Identity stores the details required to identify an entity for tax purposes in a specific country.');
2204
- export const updateBillingPartyTaxIdentity = z
2205
- .object({
2206
- code: taxIdentificationCode.optional(),
2207
- })
2208
- .describe('Identity stores the details required to identify an entity for tax purposes in a specific country.');
2209
2310
  export const workflowInvoicingSettings = z
2210
2311
  .object({
2211
2312
  autoAdvance: z
@@ -2228,36 +2329,6 @@ export const workflowInvoicingSettings = z
2228
2329
  .default('bill_actual_period'),
2229
2330
  })
2230
2331
  .describe('Invoice settings for a billing workflow.');
2231
- export const workflowPaymentSettings = z
2232
- .discriminatedUnion('collectionMethod', [
2233
- workflowPaymentChargeAutomaticallySettings,
2234
- workflowPaymentSendInvoiceSettings,
2235
- ])
2236
- .describe('Payment settings for a billing workflow.');
2237
- export const invoiceValidationIssue = z
2238
- .object({
2239
- code: z.string().describe('Machine-readable error code.'),
2240
- message: z.string().describe('Human-readable description of the error.'),
2241
- attributes: z
2242
- .record(z.string(), z.unknown())
2243
- .optional()
2244
- .describe('Additional structured context.'),
2245
- severity: invoiceValidationIssueSeverity,
2246
- field: z
2247
- .string()
2248
- .optional()
2249
- .describe('JSON path to the field that caused this validation issue, if applicable. For example: `lines/0/rate_card/price`.'),
2250
- })
2251
- .describe('A validation issue found during invoice processing. Converges on the same structure used by plan and subscription validation errors: a machine-readable `code`, a human-readable `message`, optional structured `attributes`, plus a `severity` and optional `field` path.');
2252
- export const invoiceAvailableActions = z
2253
- .object({
2254
- advance: invoiceAvailableActionDetails.optional(),
2255
- approve: invoiceAvailableActionDetails.optional(),
2256
- delete: invoiceAvailableActionDetails.optional(),
2257
- retry: invoiceAvailableActionDetails.optional(),
2258
- snapshotQuantities: invoiceAvailableActionDetails.optional(),
2259
- })
2260
- .describe('The set of state-transition actions available for an invoice in its current status. A field is present only when that action is permitted from the current state.');
2261
2332
  export const invoiceLineAmountDiscount = z
2262
2333
  .object({
2263
2334
  id: ulid,
@@ -2426,12 +2497,6 @@ export const creditTransaction = z
2426
2497
  .describe('The available balance before and after the transaction.'),
2427
2498
  })
2428
2499
  .describe("A credit transaction represents a single credit movement on the customer's balance. Credit transactions are immutable.");
2429
- export const chargeTotals = z
2430
- .object({
2431
- booked: totals,
2432
- realtime: totals.optional(),
2433
- })
2434
- .describe('The totals of a charge. RealTime is only expanded when the `real_time_usage` expand is used.');
2435
2500
  export const priceTier = z
2436
2501
  .object({
2437
2502
  upToAmount: numeric.optional(),
@@ -2439,13 +2504,12 @@ export const priceTier = z
2439
2504
  unitPrice: priceUnit.optional(),
2440
2505
  })
2441
2506
  .describe('A price tier used in graduated and volume pricing. At least one price component (flat_price or unit_price) must be set. When UnitConfig is present on the containing resource, up_to_amount is expressed in converted billing units.');
2442
- export const updatePriceTier = z
2507
+ export const chargeTotals = z
2443
2508
  .object({
2444
- upToAmount: numeric.optional(),
2445
- flatPrice: updatePriceFlat.optional(),
2446
- unitPrice: updatePriceUnit.optional(),
2509
+ booked: totals,
2510
+ realtime: totals.optional(),
2447
2511
  })
2448
- .describe('A price tier used in graduated and volume pricing. At least one price component (flat_price or unit_price) must be set. When UnitConfig is present on the containing resource, up_to_amount is expressed in converted billing units.');
2512
+ .describe('The totals of a charge. `realtime` is only populated when the `real_time_usage` expand is used.');
2449
2513
  export const featureLlmUnitCost = z
2450
2514
  .object({
2451
2515
  type: z
@@ -2475,6 +2539,13 @@ export const featureLlmUnitCost = z
2475
2539
  pricing: featureLlmUnitCostPricing.optional(),
2476
2540
  })
2477
2541
  .describe('LLM cost lookup configuration. Each dimension (provider, model, token type) can be specified as either a static value or a meter group-by property name (mutually exclusive).');
2542
+ export const updatePriceTier = z
2543
+ .object({
2544
+ upToAmount: numeric.optional(),
2545
+ flatPrice: updatePriceFlat.optional(),
2546
+ unitPrice: updatePriceUnit.optional(),
2547
+ })
2548
+ .describe('A price tier used in graduated and volume pricing. At least one price component (flat_price or unit_price) must be set. When UnitConfig is present on the containing resource, up_to_amount is expressed in converted billing units.');
2478
2549
  export const llmCostPrice = z
2479
2550
  .object({
2480
2551
  id: ulid,
@@ -2557,6 +2628,12 @@ export const creditGrantTaxConfig = z
2557
2628
  taxCode: taxCodeReference.optional(),
2558
2629
  })
2559
2630
  .describe('Tax configuration for a credit grant. Tax configuration should be provided to ensure correct revenue recognition, including for externally funded grants.');
2631
+ export const rateCardTaxConfig = z
2632
+ .object({
2633
+ behavior: taxBehavior.optional(),
2634
+ code: taxCodeReference,
2635
+ })
2636
+ .describe('The tax config of the rate card.');
2560
2637
  export const taxConfig = z
2561
2638
  .object({
2562
2639
  behavior: taxBehavior.optional(),
@@ -2566,12 +2643,6 @@ export const taxConfig = z
2566
2643
  taxCode: taxCodeReference.optional(),
2567
2644
  })
2568
2645
  .describe('Set of provider specific tax configs.');
2569
- export const rateCardTaxConfig = z
2570
- .object({
2571
- behavior: taxBehavior.optional(),
2572
- code: taxCodeReference,
2573
- })
2574
- .describe('The tax config of the rate card.');
2575
2646
  export const organizationDefaultTaxCodes = z
2576
2647
  .object({
2577
2648
  invoicingTaxCode: taxCodeReference,
@@ -2579,13 +2650,27 @@ export const organizationDefaultTaxCodes = z
2579
2650
  createdAt: dateTime,
2580
2651
  updatedAt: dateTime,
2581
2652
  })
2582
- .describe('Organization-level default tax code references. Stores the default tax codes applied to specific billing contexts for this organization. Provisioned automatically when the organization is created.');
2583
- export const updateOrganizationDefaultTaxCodesRequest = z
2653
+ .describe('Organization-level default tax code references. Stores the default tax codes applied to specific billing contexts for this organization. Provisioned automatically when the organization is created.');
2654
+ export const updateOrganizationDefaultTaxCodesRequest = z
2655
+ .object({
2656
+ invoicingTaxCode: taxCodeReference.optional(),
2657
+ creditGrantTaxCode: taxCodeReference.optional(),
2658
+ })
2659
+ .describe('OrganizationDefaultTaxCodes update request.');
2660
+ export const invoiceWorkflowAppsReferences = z
2661
+ .object({
2662
+ tax: appReference,
2663
+ invoicing: appReference,
2664
+ payment: appReference,
2665
+ })
2666
+ .describe('BillingInvoiceWorkflowAppsReferences represents the references (id) to the apps used by a billing profile');
2667
+ export const profileAppReferences = z
2584
2668
  .object({
2585
- invoicingTaxCode: taxCodeReference.optional(),
2586
- creditGrantTaxCode: taxCodeReference.optional(),
2669
+ tax: appReference,
2670
+ invoicing: appReference,
2671
+ payment: appReference,
2587
2672
  })
2588
- .describe('OrganizationDefaultTaxCodes update request.');
2673
+ .describe('References to the applications used by a billing profile.');
2589
2674
  export const planAddon = z
2590
2675
  .object({
2591
2676
  id: ulid,
@@ -2640,20 +2725,6 @@ export const createPlanAddonRequest = z
2640
2725
  .describe('The maximum number of times the add-on can be purchased for the plan. For single-instance add-ons this field must be omitted. For multi-instance add-ons when omitted, unlimited quantity can be purchased.'),
2641
2726
  })
2642
2727
  .describe('PlanAddon create request.');
2643
- export const profileAppReferences = z
2644
- .object({
2645
- tax: appReference,
2646
- invoicing: appReference,
2647
- payment: appReference,
2648
- })
2649
- .describe('References to the applications used by a billing profile.');
2650
- export const invoiceWorkflowAppsReferences = z
2651
- .object({
2652
- tax: appReference,
2653
- invoicing: appReference,
2654
- payment: appReference,
2655
- })
2656
- .describe('BillingInvoiceWorkflowAppsReferences represents the references (id) to the apps used by a billing profile');
2657
2728
  export const updateRateCardTaxConfig = z
2658
2729
  .object({
2659
2730
  behavior: taxBehavior.optional(),
@@ -2672,6 +2743,15 @@ export const listEventsParamsFilter = z
2672
2743
  storedAt: dateTimeFieldFilter.optional(),
2673
2744
  })
2674
2745
  .describe('Filter options for listing ingested events.');
2746
+ export const listChargesParamsFilter = z
2747
+ .object({
2748
+ status: stringFieldFilterExact.optional(),
2749
+ featureId: ulidFieldFilter.optional(),
2750
+ featureKey: stringFieldFilterExact.optional(),
2751
+ servicePeriodFrom: dateTimeFieldFilter.optional(),
2752
+ servicePeriodTo: dateTimeFieldFilter.optional(),
2753
+ })
2754
+ .describe('Filter options for listing charges.');
2675
2755
  export const listInvoicesParamsFilter = z
2676
2756
  .object({
2677
2757
  status: stringFieldFilterExact.optional(),
@@ -2723,6 +2803,55 @@ export const meterQueryResult = z
2723
2803
  .describe('The usage data. If no data is available, an empty array is returned.'),
2724
2804
  })
2725
2805
  .describe('Meter query result.');
2806
+ export const chargeRealizationDetailedLineFlatFee = z
2807
+ .object({
2808
+ id: ulid,
2809
+ createdAt: dateTime,
2810
+ updatedAt: dateTime,
2811
+ deletedAt: dateTime.optional(),
2812
+ type: z
2813
+ .literal('flat_fee')
2814
+ .describe('The type of the charge the realization belongs to.'),
2815
+ servicePeriod: closedPeriod,
2816
+ totals: totals,
2817
+ category: chargeRealizationDetailedLineCategory,
2818
+ creditsApplied: z
2819
+ .array(chargeRealizationDetailedLineCreditApplied)
2820
+ .optional()
2821
+ .describe('Credits applied to this detailed line.'),
2822
+ unitPrice: numeric,
2823
+ amountDiscounts: z
2824
+ .array(chargeRealizationAmountDiscount)
2825
+ .describe('The amount discounts applied to the detailed line.'),
2826
+ })
2827
+ .describe("A detailed line produced by a flat fee charge's realization run.");
2828
+ export const chargeRealizationDetailedLineUsageBased = z
2829
+ .object({
2830
+ id: ulid,
2831
+ createdAt: dateTime,
2832
+ updatedAt: dateTime,
2833
+ deletedAt: dateTime.optional(),
2834
+ type: z
2835
+ .literal('usage_based')
2836
+ .describe('The type of the charge the realization belongs to.'),
2837
+ servicePeriod: closedPeriod,
2838
+ totals: totals,
2839
+ category: chargeRealizationDetailedLineCategory,
2840
+ creditsApplied: z
2841
+ .array(chargeRealizationDetailedLineCreditApplied)
2842
+ .optional()
2843
+ .describe('Credits applied to this detailed line.'),
2844
+ unitPrice: numeric,
2845
+ amountDiscounts: z
2846
+ .array(chargeRealizationAmountDiscount)
2847
+ .describe('The amount discounts applied to the detailed line.'),
2848
+ quantity: numeric,
2849
+ correctsRunId: z
2850
+ .string()
2851
+ .optional()
2852
+ .describe("The ID of a prior realization run this detailed line corrects. Only set if the detailed line's totals are negative."),
2853
+ })
2854
+ .describe("A detailed line produced by a usage-based charge's realization run.");
2726
2855
  export const currencyCustom = z
2727
2856
  .object({
2728
2857
  type: z.literal('custom').describe('The type of the currency.'),
@@ -2965,6 +3094,24 @@ export const chargeFlatFeeSystemIntent = z
2965
3094
  deletedAt: dateTime.optional(),
2966
3095
  })
2967
3096
  .describe('Flat fee intent fields from the system lifecycle controller shadowed by a manual override.');
3097
+ export const invoiceStatusDetails = z
3098
+ .object({
3099
+ immutable: z
3100
+ .boolean()
3101
+ .describe('Whether the invoice is immutable (i.e. cannot be modified or deleted).'),
3102
+ failed: z.boolean().describe('Whether the invoice is in a failed state.'),
3103
+ extendedStatus: z
3104
+ .string()
3105
+ .describe('Fine-grained internal status string providing additional workflow detail beyond the top-level status enum.'),
3106
+ availableActions: invoiceAvailableActions,
3107
+ })
3108
+ .describe('Detailed status information for a standard invoice.');
3109
+ export const invoiceWorkflow = z
3110
+ .object({
3111
+ invoicing: invoiceWorkflowInvoicingSettings.optional(),
3112
+ payment: workflowPaymentSettings.optional(),
3113
+ })
3114
+ .describe('Invoice-level snapshot of the workflow configuration. Contains only the settings that are meaningful for an already-created invoice: invoicing behaviour and payment settings. Collection alignment and tax policy are gather-time / profile-wide concerns and are not included.');
2968
3115
  export const subscriptionCancel = z
2969
3116
  .object({
2970
3117
  timing: subscriptionEditTiming.optional().default('immediate'),
@@ -3086,24 +3233,6 @@ export const updateAppRequest = z
3086
3233
  updateAppExternalInvoicingRequest,
3087
3234
  ])
3088
3235
  .describe('Request to update an installed app.');
3089
- export const invoiceWorkflow = z
3090
- .object({
3091
- invoicing: invoiceWorkflowInvoicingSettings.optional(),
3092
- payment: workflowPaymentSettings.optional(),
3093
- })
3094
- .describe('Invoice-level snapshot of the workflow configuration. Contains only the settings that are meaningful for an already-created invoice: invoicing behaviour and payment settings. Collection alignment and tax policy are gather-time / profile-wide concerns and are not included.');
3095
- export const invoiceStatusDetails = z
3096
- .object({
3097
- immutable: z
3098
- .boolean()
3099
- .describe('Whether the invoice is immutable (i.e. cannot be modified or deleted).'),
3100
- failed: z.boolean().describe('Whether the invoice is in a failed state.'),
3101
- extendedStatus: z
3102
- .string()
3103
- .describe('Fine-grained internal status string providing additional workflow detail beyond the top-level status enum.'),
3104
- availableActions: invoiceAvailableActions,
3105
- })
3106
- .describe('Detailed status information for a standard invoice.');
3107
3236
  export const invoiceLineDiscounts = z
3108
3237
  .object({
3109
3238
  amount: z
@@ -3172,6 +3301,9 @@ export const priceVolume = z
3172
3301
  .describe('The tiers of the volume price. At least one tier is required.'),
3173
3302
  })
3174
3303
  .describe('Volume tiered price. The maximum quantity within a period determines the per-unit price for all units in that period. When UnitConfig is present on the containing resource, tier boundaries (up_to_amount) are expressed in converted billing units.');
3304
+ export const featureUnitCost = z
3305
+ .discriminatedUnion('type', [featureManualUnitCost, featureLlmUnitCost])
3306
+ .describe('Per-unit cost configuration for a feature. Either a fixed manual amount or a dynamic LLM cost lookup.');
3175
3307
  export const updatePriceGraduated = z
3176
3308
  .object({
3177
3309
  type: z.literal('graduated').describe('The type of the price.'),
@@ -3190,9 +3322,6 @@ export const updatePriceVolume = z
3190
3322
  .describe('The tiers of the volume price. At least one tier is required.'),
3191
3323
  })
3192
3324
  .describe('Volume tiered price. The maximum quantity within a period determines the per-unit price for all units in that period. When UnitConfig is present on the containing resource, tier boundaries (up_to_amount) are expressed in converted billing units.');
3193
- export const featureUnitCost = z
3194
- .discriminatedUnion('type', [featureManualUnitCost, featureLlmUnitCost])
3195
- .describe('Per-unit cost configuration for a feature. Either a fixed manual amount or a dynamic LLM cost lookup.');
3196
3325
  export const pricePagePaginatedResponse = z
3197
3326
  .object({
3198
3327
  data: z.array(llmCostPrice),
@@ -3295,12 +3424,9 @@ export const createChargeFlatFeeRequest = z
3295
3424
  taxConfig: taxConfig.optional(),
3296
3425
  paymentTerm: pricePaymentTerm,
3297
3426
  discounts: chargeFlatFeeDiscounts.optional(),
3298
- featureId: z
3299
- .string()
3300
- .optional()
3301
- .describe('The feature ID associated with the charge.'),
3302
3427
  prorationConfiguration: rateCardProrationConfiguration,
3303
3428
  amountBeforeProration: currencyAmount,
3429
+ feature: featureReference.optional(),
3304
3430
  fullServicePeriod: closedPeriod.optional(),
3305
3431
  billingPeriod: closedPeriod.optional(),
3306
3432
  })
@@ -3332,6 +3458,12 @@ export const ingestedEventPaginatedResponse = z
3332
3458
  meta: cursorMeta,
3333
3459
  })
3334
3460
  .describe('Cursor paginated response.');
3461
+ export const chargeRealizationDetailedLine = z
3462
+ .discriminatedUnion('type', [
3463
+ chargeRealizationDetailedLineFlatFee,
3464
+ chargeRealizationDetailedLineUsageBased,
3465
+ ])
3466
+ .describe("A detailed (child) line type of a charge realization run. This is distinct from an invoice's own detailed lines: it represents the rated/priced breakdown produced by the realization run itself, before that breakdown is (or is not yet) reflected on an invoice line. Credit-then-invoice runs include credit allocations in these lines, while credits-only runs keep the gross rated detail.");
3335
3467
  export const currency = z
3336
3468
  .discriminatedUnion('type', [currencyFiat, currencyCustom])
3337
3469
  .describe('Fiat or custom currency.');
@@ -3363,29 +3495,32 @@ export const customerPagePaginatedResponse = z
3363
3495
  meta: paginatedMeta,
3364
3496
  })
3365
3497
  .describe('Page paginated response.');
3366
- export const party = z
3498
+ export const customerOrReference = z
3499
+ .union([customer, customerReference])
3500
+ .describe('Customer or reference.');
3501
+ export const supplier = z
3367
3502
  .object({
3368
- id: z.string().optional().describe('Unique identifier for the party.'),
3369
- key: externalResourceKey.optional(),
3370
3503
  name: z
3371
3504
  .string()
3372
3505
  .optional()
3373
3506
  .describe('Legal name or representation of the party.'),
3374
3507
  taxId: partyTaxIdentity.optional(),
3375
3508
  addresses: partyAddresses.optional(),
3509
+ id: z.string().optional().describe('Unique identifier for the party.'),
3376
3510
  })
3377
- .describe('Party represents a person or business entity.');
3378
- export const supplier = z
3511
+ .describe("Snapshot of the supplier's information at the time the invoice was issued. Structurally a read-only subset of `BillingParty` (the type configured on the billing profile), so the snapshot stays aligned with the source. `key` is omitted because it is not part of the snapshotted supplier data.");
3512
+ export const party = z
3379
3513
  .object({
3514
+ id: z.string().optional().describe('Unique identifier for the party.'),
3515
+ key: externalResourceKey.optional(),
3380
3516
  name: z
3381
3517
  .string()
3382
3518
  .optional()
3383
3519
  .describe('Legal name or representation of the party.'),
3384
3520
  taxId: partyTaxIdentity.optional(),
3385
3521
  addresses: partyAddresses.optional(),
3386
- id: z.string().optional().describe('Unique identifier for the party.'),
3387
3522
  })
3388
- .describe("Snapshot of the supplier's information at the time the invoice was issued. Structurally a read-only subset of `BillingParty` (the type configured on the billing profile), so the snapshot stays aligned with the source. `key` is omitted because it is not part of the snapshotted supplier data.");
3523
+ .describe('Party represents a person or business entity.');
3389
3524
  export const updateSupplier = z
3390
3525
  .object({
3391
3526
  name: z
@@ -3451,56 +3586,13 @@ export const workflowCollectionAlignment = z
3451
3586
  workflowCollectionAlignmentAnchored,
3452
3587
  ])
3453
3588
  .describe('The alignment for collecting the pending line items into an invoice. Defaults to subscription, which means that we are to create a new invoice every time the a subscription period starts (for in advance items) or ends (for in arrears items).');
3454
- export const chargeFlatFee = z
3589
+ export const invoiceWorkflowSettings = z
3455
3590
  .object({
3456
- id: ulid,
3457
- name: z
3458
- .string()
3459
- .min(1)
3460
- .max(256)
3461
- .describe('Display name of the resource. Between 1 and 256 characters.'),
3462
- description: z
3463
- .string()
3464
- .max(1024)
3465
- .optional()
3466
- .describe('Optional description of the resource. Maximum 1024 characters.'),
3467
- labels: labels.optional(),
3468
- createdAt: dateTime,
3469
- updatedAt: dateTime,
3470
- deletedAt: dateTime.optional(),
3471
- type: z.literal('flat_fee').describe('The type of the charge.'),
3472
- customer: billingCustomerReference,
3473
- lifecycleController: lifecycleController,
3474
- subscription: subscriptionReference.optional(),
3475
- currency: currencyCode,
3476
- status: chargeStatus,
3477
- invoiceAt: dateTime,
3478
- servicePeriod: closedPeriod,
3479
- fullServicePeriod: closedPeriod,
3480
- billingPeriod: closedPeriod,
3481
- advanceAfter: dateTime.optional(),
3482
- uniqueReferenceId: z
3483
- .string()
3484
- .optional()
3485
- .describe('Unique reference ID of the charge.'),
3486
- settlementMode: settlementMode,
3487
- taxConfig: taxConfig.optional(),
3488
- paymentTerm: pricePaymentTerm,
3489
- discounts: chargeFlatFeeDiscounts.optional(),
3490
- featureKey: z
3491
- .string()
3492
- .optional()
3493
- .describe('The feature associated with the charge, when applicable.'),
3494
- featureId: z
3495
- .string()
3496
- .optional()
3497
- .describe('The feature ID associated with the charge.'),
3498
- prorationConfiguration: rateCardProrationConfiguration,
3499
- amountAfterProration: currencyAmount,
3500
- price: priceFlat,
3501
- systemIntent: chargeFlatFeeSystemIntent.optional(),
3591
+ apps: invoiceWorkflowAppsReferences.optional(),
3592
+ sourceBillingProfile: profileReference,
3593
+ workflow: invoiceWorkflow,
3502
3594
  })
3503
- .describe('A flat fee charge for a customer.');
3595
+ .describe('Snapshot of the billing workflow configuration captured at invoice creation.');
3504
3596
  export const taxCodePagePaginatedResponse = z
3505
3597
  .object({
3506
3598
  data: z.array(taxCode),
@@ -3684,13 +3776,6 @@ export const installedAppExternalInvoicing = z
3684
3776
  .describe('Default capabilities of the installed app.'),
3685
3777
  })
3686
3778
  .describe('Response of an installed app.');
3687
- export const invoiceWorkflowSettings = z
3688
- .object({
3689
- apps: invoiceWorkflowAppsReferences.optional(),
3690
- sourceBillingProfile: profileReference,
3691
- workflow: invoiceWorkflow,
3692
- })
3693
- .describe('Snapshot of the billing workflow configuration captured at invoice creation.');
3694
3779
  export const invoiceDetailedLine = z
3695
3780
  .object({
3696
3781
  id: ulid,
@@ -3738,9 +3823,6 @@ export const entitlementAccessQueryResult = z
3738
3823
  updatedAt: dateTime,
3739
3824
  })
3740
3825
  .describe('Access evaluation result for a single resolved customer.');
3741
- export const priceUsageBased = z
3742
- .discriminatedUnion('type', [priceUnit, priceGraduated, priceVolume])
3743
- .describe('Usage-based price types for a rate card or charge. When UnitConfig is present on the object, these price types operate on billing units (i.e. post-conversion quantities), not raw metered units.');
3744
3826
  export const price = z
3745
3827
  .discriminatedUnion('type', [
3746
3828
  priceFree,
@@ -3750,15 +3832,9 @@ export const price = z
3750
3832
  priceVolume,
3751
3833
  ])
3752
3834
  .describe('Price.');
3753
- export const updatePrice = z
3754
- .discriminatedUnion('type', [
3755
- updatePriceFree,
3756
- updatePriceFlat,
3757
- updatePriceUnit,
3758
- updatePriceGraduated,
3759
- updatePriceVolume,
3760
- ])
3761
- .describe('Price.');
3835
+ export const priceUsageBased = z
3836
+ .discriminatedUnion('type', [priceUnit, priceGraduated, priceVolume])
3837
+ .describe('Usage-based price types for a rate card or charge. When UnitConfig is present on the object, these price types operate on billing units (i.e. post-conversion quantities), not raw metered units.');
3762
3838
  export const feature = z
3763
3839
  .object({
3764
3840
  id: ulid,
@@ -3807,6 +3883,15 @@ export const updateFeatureRequest = z
3807
3883
  .describe('Optional per-unit cost configuration. Use "manual" for a fixed per-unit cost, or "llm" to look up cost from the LLM cost database based on meter group-by properties. Set to `null` to clear the existing unit cost; omit to leave it unchanged.'),
3808
3884
  })
3809
3885
  .describe('Request body for updating a feature. Currently only the unit_cost field can be updated.');
3886
+ export const updatePrice = z
3887
+ .discriminatedUnion('type', [
3888
+ updatePriceFree,
3889
+ updatePriceFlat,
3890
+ updatePriceUnit,
3891
+ updatePriceGraduated,
3892
+ updatePriceVolume,
3893
+ ])
3894
+ .describe('Price.');
3810
3895
  export const creditGrantPagePaginatedResponse = z
3811
3896
  .object({
3812
3897
  data: z.array(creditGrant),
@@ -3866,6 +3951,42 @@ export const workflowCollectionSettings = z
3866
3951
  .describe('This grace period can be used to delay the collection of the pending line items specified in alignment. This is useful, in case of multiple subscriptions having slightly different billing periods.'),
3867
3952
  })
3868
3953
  .describe('Workflow collection specifies how to collect the pending line items for an invoice.');
3954
+ export const chargeRealizationInvoice = z
3955
+ .object({
3956
+ id: ulid,
3957
+ description: z
3958
+ .string()
3959
+ .max(1024)
3960
+ .optional()
3961
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
3962
+ labels: labels.optional(),
3963
+ createdAt: dateTime,
3964
+ updatedAt: dateTime,
3965
+ deletedAt: dateTime.optional(),
3966
+ number: invoiceNumber,
3967
+ currency: currencyCode,
3968
+ supplier: supplier,
3969
+ totals: totals,
3970
+ servicePeriod: closedPeriod,
3971
+ validationIssues: z
3972
+ .array(invoiceValidationIssue)
3973
+ .optional()
3974
+ .describe('Validation issues found during invoice processing. Present only when there are one or more validation findings. An empty list is omitted.'),
3975
+ externalReferences: invoiceExternalReferences.optional(),
3976
+ type: z
3977
+ .literal('standard')
3978
+ .describe('Discriminator field identifying this as a standard invoice.'),
3979
+ status: invoiceStandardStatus,
3980
+ statusDetails: invoiceStatusDetails,
3981
+ issuedAt: dateTime.optional(),
3982
+ draftUntil: dateTime.optional(),
3983
+ quantitySnapshottedAt: dateTime.optional(),
3984
+ collectionAt: dateTime.optional(),
3985
+ dueAt: dateTime.optional(),
3986
+ sentToCustomerAt: dateTime.optional(),
3987
+ workflow: invoiceWorkflowSettings,
3988
+ })
3989
+ .describe('The invoice a charge realization was booked to, embedded as a header. Matches the standard invoice entity, except that it carries no `customer` snapshot (the charge context already identifies the customer) and `lines` are never populated (the realization itself is the line-level breakdown). The shared invoice contract stays untouched: this model exists so the charges API can slim the embedding without loosening the invoices API.');
3869
3990
  export const app = z
3870
3991
  .discriminatedUnion('type', [appStripe, appSandbox, appExternalInvoicing])
3871
3992
  .describe('Installed application.');
@@ -3878,15 +3999,50 @@ export const billingInstallAppResponse = z
3878
3999
  .describe('Response of the app install.');
3879
4000
  export const entitlementAccessQueryResponse = z
3880
4001
  .object({
3881
- data: z
3882
- .array(entitlementAccessQueryResult)
3883
- .describe('Access evaluation results, one entry per resolved customer.'),
3884
- errors: z
3885
- .array(entitlementAccessQueryError)
3886
- .describe('Partial errors encountered while processing the request.'),
3887
- meta: cursorMeta,
4002
+ data: z
4003
+ .array(entitlementAccessQueryResult)
4004
+ .describe('Access evaluation results, one entry per resolved customer.'),
4005
+ errors: z
4006
+ .array(entitlementAccessQueryError)
4007
+ .describe('Partial errors encountered while processing the request.'),
4008
+ meta: cursorMeta,
4009
+ })
4010
+ .describe('Response of the entitlement access query.');
4011
+ export const rateCard = z
4012
+ .object({
4013
+ name: z
4014
+ .string()
4015
+ .min(1)
4016
+ .max(256)
4017
+ .describe('Display name of the resource. Between 1 and 256 characters.'),
4018
+ description: z
4019
+ .string()
4020
+ .max(1024)
4021
+ .optional()
4022
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
4023
+ labels: labels.optional(),
4024
+ key: resourceKey,
4025
+ feature: featureReference.optional(),
4026
+ currency: billingCurrencyCode.optional(),
4027
+ billingCadence: iso8601Duration.optional(),
4028
+ price: price,
4029
+ unitConfig: unitConfig.optional(),
4030
+ paymentTerm: pricePaymentTerm.optional().default('in_arrears'),
4031
+ commitments: spendCommitments.optional(),
4032
+ discounts: rateCardDiscounts.optional(),
4033
+ taxConfig: rateCardTaxConfig.optional(),
4034
+ entitlement: rateCardEntitlement.optional(),
4035
+ })
4036
+ .describe('A rate card defines the pricing and entitlement of a feature or service.');
4037
+ export const invoiceLineRateCard = z
4038
+ .object({
4039
+ price: price,
4040
+ taxConfig: rateCardTaxConfig.optional(),
4041
+ featureKey: resourceKey.optional(),
4042
+ discounts: rateCardDiscounts.optional(),
4043
+ unitConfig: unitConfig.optional(),
3888
4044
  })
3889
- .describe('Response of the entitlement access query.');
4045
+ .describe('Rate card configuration snapshot for a usage-based invoice line.');
3890
4046
  export const chargeUsageBasedSystemIntent = z
3891
4047
  .object({
3892
4048
  name: z
@@ -3935,51 +4091,23 @@ export const createChargeUsageBasedRequest = z
3935
4091
  settlementMode: settlementMode,
3936
4092
  taxConfig: taxConfig.optional(),
3937
4093
  discounts: rateCardDiscounts.optional(),
3938
- featureId: z
3939
- .string()
3940
- .describe('The feature ID associated with the charge.'),
3941
4094
  price: priceUsageBased,
3942
4095
  commitments: spendCommitments.optional(),
3943
4096
  unitConfig: unitConfig.optional(),
4097
+ feature: featureReference,
3944
4098
  fullServicePeriod: closedPeriod.optional(),
3945
4099
  billingPeriod: closedPeriod.optional(),
3946
4100
  })
3947
4101
  .describe('Usage-based charge create request.');
3948
- export const rateCard = z
3949
- .object({
3950
- name: z
3951
- .string()
3952
- .min(1)
3953
- .max(256)
3954
- .describe('Display name of the resource. Between 1 and 256 characters.'),
3955
- description: z
3956
- .string()
3957
- .max(1024)
3958
- .optional()
3959
- .describe('Optional description of the resource. Maximum 1024 characters.'),
3960
- labels: labels.optional(),
3961
- key: resourceKey,
3962
- feature: featureReference.optional(),
3963
- currency: billingCurrencyCode.optional(),
3964
- billingCadence: iso8601Duration.optional(),
3965
- price: price,
3966
- unitConfig: unitConfig.optional(),
3967
- paymentTerm: pricePaymentTerm.optional().default('in_arrears'),
3968
- commitments: spendCommitments.optional(),
3969
- discounts: rateCardDiscounts.optional(),
3970
- taxConfig: rateCardTaxConfig.optional(),
3971
- entitlement: rateCardEntitlement.optional(),
3972
- })
3973
- .describe('A rate card defines the pricing and entitlement of a feature or service.');
3974
- export const invoiceLineRateCard = z
4102
+ export const featureOrReference = z
4103
+ .union([feature, featureReference])
4104
+ .describe('Feature or reference.');
4105
+ export const featurePagePaginatedResponse = z
3975
4106
  .object({
3976
- price: price,
3977
- taxConfig: rateCardTaxConfig.optional(),
3978
- featureKey: resourceKey.optional(),
3979
- discounts: rateCardDiscounts.optional(),
3980
- unitConfig: unitConfig.optional(),
4107
+ data: z.array(feature),
4108
+ meta: paginatedMeta,
3981
4109
  })
3982
- .describe('Rate card configuration snapshot for a usage-based invoice line.');
4110
+ .describe('Page paginated response.');
3983
4111
  export const updateInvoiceLineRateCard = z
3984
4112
  .object({
3985
4113
  price: updatePrice,
@@ -3988,12 +4116,6 @@ export const updateInvoiceLineRateCard = z
3988
4116
  discounts: updateDiscounts.optional(),
3989
4117
  })
3990
4118
  .describe('Rate card configuration snapshot for a usage-based invoice line.');
3991
- export const featurePagePaginatedResponse = z
3992
- .object({
3993
- data: z.array(feature),
3994
- meta: paginatedMeta,
3995
- })
3996
- .describe('Page paginated response.');
3997
4119
  export const workflow = z
3998
4120
  .object({
3999
4121
  collection: workflowCollectionSettings.optional(),
@@ -4002,6 +4124,9 @@ export const workflow = z
4002
4124
  tax: workflowTaxSettings.optional(),
4003
4125
  })
4004
4126
  .describe('Billing workflow settings.');
4127
+ export const chargeRealizationInvoiceOrReference = z
4128
+ .union([chargeRealizationInvoice, chargeRealizationInvoiceReference])
4129
+ .describe('ChargeRealizationInvoice or reference.');
4005
4130
  export const appPagePaginatedResponse = z
4006
4131
  .object({
4007
4132
  data: z.array(app),
@@ -4015,58 +4140,6 @@ export const profileApps = z
4015
4140
  payment: app,
4016
4141
  })
4017
4142
  .describe('Applications used by a billing profile.');
4018
- export const chargeUsageBased = z
4019
- .object({
4020
- id: ulid,
4021
- name: z
4022
- .string()
4023
- .min(1)
4024
- .max(256)
4025
- .describe('Display name of the resource. Between 1 and 256 characters.'),
4026
- description: z
4027
- .string()
4028
- .max(1024)
4029
- .optional()
4030
- .describe('Optional description of the resource. Maximum 1024 characters.'),
4031
- labels: labels.optional(),
4032
- createdAt: dateTime,
4033
- updatedAt: dateTime,
4034
- deletedAt: dateTime.optional(),
4035
- type: z.literal('usage_based').describe('The type of the charge.'),
4036
- customer: billingCustomerReference,
4037
- lifecycleController: lifecycleController,
4038
- subscription: subscriptionReference.optional(),
4039
- currency: currencyCode,
4040
- status: chargeStatus,
4041
- invoiceAt: dateTime,
4042
- servicePeriod: closedPeriod,
4043
- fullServicePeriod: closedPeriod,
4044
- billingPeriod: closedPeriod,
4045
- advanceAfter: dateTime.optional(),
4046
- uniqueReferenceId: z
4047
- .string()
4048
- .optional()
4049
- .describe('Unique reference ID of the charge.'),
4050
- settlementMode: settlementMode,
4051
- taxConfig: taxConfig.optional(),
4052
- discounts: rateCardDiscounts.optional(),
4053
- featureKey: z.string().describe('The feature associated with the charge.'),
4054
- featureId: z
4055
- .string()
4056
- .describe('The feature ID associated with the charge.'),
4057
- totals: chargeTotals,
4058
- price: priceUsageBased,
4059
- commitments: spendCommitments.optional(),
4060
- unitConfig: unitConfig.optional(),
4061
- systemIntent: chargeUsageBasedSystemIntent.optional(),
4062
- })
4063
- .describe('A usage-based charge for a customer.');
4064
- export const createChargeRequest = z
4065
- .discriminatedUnion('type', [
4066
- createChargeFlatFeeRequest,
4067
- createChargeUsageBasedRequest,
4068
- ])
4069
- .describe('Customer charge.');
4070
4143
  export const subscriptionItem = z
4071
4144
  .object({
4072
4145
  id: ulid,
@@ -4211,6 +4284,12 @@ export const invoiceStandardLine = z
4211
4284
  charge: chargeReference.optional(),
4212
4285
  })
4213
4286
  .describe('A top-level line item on an invoice. Each line represents a single charge, typically associated with a rate card from a subscription. Detailed (child) lines are nested under `detailed_lines` when present.');
4287
+ export const createChargeRequest = z
4288
+ .discriminatedUnion('type', [
4289
+ createChargeFlatFeeRequest,
4290
+ createChargeUsageBasedRequest,
4291
+ ])
4292
+ .describe('Customer charge.');
4214
4293
  export const updateInvoiceStandardLine = z
4215
4294
  .object({
4216
4295
  name: z
@@ -4292,9 +4371,28 @@ export const upsertBillingProfileRequest = z
4292
4371
  default: z.boolean().describe('Whether this is the default profile.'),
4293
4372
  })
4294
4373
  .describe('BillingProfile upsert request.');
4295
- export const charge = z
4296
- .discriminatedUnion('type', [chargeFlatFee, chargeUsageBased])
4297
- .describe('Customer charge.');
4374
+ export const chargeRealization = z
4375
+ .object({
4376
+ id: z
4377
+ .string()
4378
+ .optional()
4379
+ .describe('The ID of the realization run. Not present on `outstanding` entries, which are projections rather than persisted runs.'),
4380
+ lineId: z
4381
+ .string()
4382
+ .optional()
4383
+ .describe('The ID of the invoice line this realization was booked to, when the realization has been invoiced.'),
4384
+ invoice: chargeRealizationInvoiceOrReference.optional(),
4385
+ type: chargeRealizationType,
4386
+ servicePeriod: closedPeriod,
4387
+ usage: numeric.optional(),
4388
+ payment: chargeRealizationPayment.optional(),
4389
+ totals: totals.optional(),
4390
+ detailedLines: z
4391
+ .array(chargeRealizationDetailedLine)
4392
+ .optional()
4393
+ .describe('The detailed (rated) lines produced by the realization run. Requires the `realization.detailed_lines` expand.'),
4394
+ })
4395
+ .describe("A realization run of a charge. `totals` and `detailed_lines` are only populated with the `realization.totals` and `realization.detailed_lines` expands, respectively, since computing them requires re-deriving the run's rated breakdown. `invoice` is an ID reference unless the `realization.invoice` expand is used, which resolves it to the invoice header of the run's booked line: the invoice entity without its `lines` and without the `customer` snapshot (the charge itself already identifies the customer).");
4298
4396
  export const subscriptionPhase = z
4299
4397
  .object({
4300
4398
  id: ulid,
@@ -4468,12 +4566,6 @@ export const profilePagePaginatedResponse = z
4468
4566
  meta: paginatedMeta,
4469
4567
  })
4470
4568
  .describe('Page paginated response.');
4471
- export const chargePagePaginatedResponse = z
4472
- .object({
4473
- data: z.array(charge),
4474
- meta: paginatedMeta,
4475
- })
4476
- .describe('Page paginated response.');
4477
4569
  export const subscription = z
4478
4570
  .object({
4479
4571
  id: ulid,
@@ -4585,6 +4677,9 @@ export const updateInvoiceStandardRequest = z
4585
4677
  .describe('Line items on this invoice. Always returned on single-resource GET; omitted on list endpoints unless explicitly expanded. Editable via update: existing lines are matched by `id`, lines without an `id` are created, and lines present on the invoice but omitted from the update request are deleted. Detailed (child) lines are always computed and cannot be edited directly.'),
4586
4678
  })
4587
4679
  .describe('InvoiceStandard update request.');
4680
+ export const subscriptionOrReference = z
4681
+ .union([subscription, subscriptionReference])
4682
+ .describe('Subscription or reference.');
4588
4683
  export const subscriptionPagePaginatedResponse = z
4589
4684
  .object({
4590
4685
  data: z.array(subscription),
@@ -4603,12 +4698,114 @@ export const invoice = z
4603
4698
  export const updateInvoiceRequest = z
4604
4699
  .discriminatedUnion('type', [updateInvoiceStandardRequest])
4605
4700
  .describe('UpdateInvoiceRequest update request.');
4701
+ export const chargeFlatFee = z
4702
+ .object({
4703
+ id: ulid,
4704
+ name: z
4705
+ .string()
4706
+ .min(1)
4707
+ .max(256)
4708
+ .describe('Display name of the resource. Between 1 and 256 characters.'),
4709
+ description: z
4710
+ .string()
4711
+ .max(1024)
4712
+ .optional()
4713
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
4714
+ labels: labels.optional(),
4715
+ createdAt: dateTime,
4716
+ updatedAt: dateTime,
4717
+ deletedAt: dateTime.optional(),
4718
+ type: z.literal('flat_fee').describe('The type of the charge.'),
4719
+ customer: customerOrReference,
4720
+ lifecycleController: lifecycleController,
4721
+ subscription: subscriptionOrReference.optional(),
4722
+ currency: currencyCode,
4723
+ status: chargeStatus,
4724
+ invoiceAt: dateTime,
4725
+ servicePeriod: closedPeriod,
4726
+ fullServicePeriod: closedPeriod,
4727
+ billingPeriod: closedPeriod,
4728
+ advanceAfter: dateTime.optional(),
4729
+ uniqueReferenceId: z
4730
+ .string()
4731
+ .optional()
4732
+ .describe('Unique reference ID of the charge.'),
4733
+ settlementMode: settlementMode,
4734
+ taxConfig: taxConfig.optional(),
4735
+ realizations: z
4736
+ .array(chargeRealization)
4737
+ .describe('The realization runs of the charge, sorted by `created_at`.'),
4738
+ paymentTerm: pricePaymentTerm,
4739
+ discounts: chargeFlatFeeDiscounts.optional(),
4740
+ feature: featureOrReference.optional(),
4741
+ prorationConfiguration: rateCardProrationConfiguration,
4742
+ amountAfterProration: currencyAmount,
4743
+ price: priceFlat,
4744
+ systemIntent: chargeFlatFeeSystemIntent.optional(),
4745
+ })
4746
+ .describe('A flat fee charge for a customer.');
4747
+ export const chargeUsageBased = z
4748
+ .object({
4749
+ id: ulid,
4750
+ name: z
4751
+ .string()
4752
+ .min(1)
4753
+ .max(256)
4754
+ .describe('Display name of the resource. Between 1 and 256 characters.'),
4755
+ description: z
4756
+ .string()
4757
+ .max(1024)
4758
+ .optional()
4759
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
4760
+ labels: labels.optional(),
4761
+ createdAt: dateTime,
4762
+ updatedAt: dateTime,
4763
+ deletedAt: dateTime.optional(),
4764
+ type: z.literal('usage_based').describe('The type of the charge.'),
4765
+ customer: customerOrReference,
4766
+ lifecycleController: lifecycleController,
4767
+ subscription: subscriptionOrReference.optional(),
4768
+ currency: currencyCode,
4769
+ status: chargeStatus,
4770
+ invoiceAt: dateTime,
4771
+ servicePeriod: closedPeriod,
4772
+ fullServicePeriod: closedPeriod,
4773
+ billingPeriod: closedPeriod,
4774
+ advanceAfter: dateTime.optional(),
4775
+ uniqueReferenceId: z
4776
+ .string()
4777
+ .optional()
4778
+ .describe('Unique reference ID of the charge.'),
4779
+ settlementMode: settlementMode,
4780
+ taxConfig: taxConfig.optional(),
4781
+ realizations: z
4782
+ .array(chargeRealization)
4783
+ .describe('The realization runs of the charge, sorted by `created_at`.'),
4784
+ discounts: rateCardDiscounts.optional(),
4785
+ feature: featureOrReference,
4786
+ totals: chargeTotals,
4787
+ usage: numeric.optional(),
4788
+ price: priceUsageBased,
4789
+ commitments: spendCommitments.optional(),
4790
+ unitConfig: unitConfig.optional(),
4791
+ systemIntent: chargeUsageBasedSystemIntent.optional(),
4792
+ })
4793
+ .describe('A usage-based charge for a customer.');
4606
4794
  export const invoicePagePaginatedResponse = z
4607
4795
  .object({
4608
4796
  data: z.array(invoice),
4609
4797
  meta: paginatedMeta,
4610
4798
  })
4611
4799
  .describe('Page paginated response.');
4800
+ export const charge = z
4801
+ .discriminatedUnion('type', [chargeFlatFee, chargeUsageBased])
4802
+ .describe('Customer charge.');
4803
+ export const chargePagePaginatedResponse = z
4804
+ .object({
4805
+ data: z.array(charge),
4806
+ meta: paginatedMeta,
4807
+ })
4808
+ .describe('Page paginated response.');
4612
4809
  export const listMeteringEventsQueryParams = z.object({
4613
4810
  page: cursorPaginationQueryPage.optional(),
4614
4811
  filter: listEventsParamsFilter.optional(),
@@ -4810,7 +5007,7 @@ export const listCustomerChargesQueryParams = z.object({
4810
5007
  expand: z
4811
5008
  .array(chargesExpand)
4812
5009
  .optional()
4813
- .describe("Expand full objects for referenced entities. Supported values are: - `real_time_usage`: Expand the charge's real-time usage."),
5010
+ .describe("Expand full objects for referenced entities. Supported values are: - `real_time_usage`: Expand the charge's real-time usage; it sets the `usage` and the `totals.realtime` fields. - `customer`: Expand the charge's customer to the complete entity. - `feature`: Expand the charge's feature to the complete entity. - `subscription`: Expand the charge's subscription to the complete entity. - `realization.invoice`: Expand each realization's invoice to the complete entity. - `realization.totals`: Expand each realization run's `totals`. - `realization.detailed_lines`: Expand each realization run's `detailed_lines`."),
4814
5011
  });
4815
5012
  export const listCustomerChargesResponse = z.object({
4816
5013
  data: z.array(charge),
@@ -5749,17 +5946,63 @@ export const creditTransactionTypeWire = z
5749
5946
  .enum(['funded', 'consumed', 'expired', 'voided'])
5750
5947
  .describe('The type of the credit transaction. - `funded`: Credit granted and available for consumption. - `consumed`: Credit consumed by usage or fees. - `expired`: Credit removed because it expired before being used. - `voided`: Credit removed because the grant was voided before being used.');
5751
5948
  export const chargesExpandWire = z
5752
- .enum(['real_time_usage'])
5753
- .describe("Expands for customer charges. Values: - `real_time_usage`: The charge's real-time usage.");
5949
+ .enum([
5950
+ 'real_time_usage',
5951
+ 'customer',
5952
+ 'feature',
5953
+ 'subscription',
5954
+ 'realization.invoice',
5955
+ 'realization.totals',
5956
+ 'realization.detailed_lines',
5957
+ ])
5958
+ .describe("Expands for customer charges. Values: - `real_time_usage`: The charge's real-time usage; it sets the `usage` and the `totals.realtime` fields, and fills the `outstanding` realization's `usage` with the not-yet-booked remainder of the live read. - `customer`: The complete customer entity of the charge. - `feature`: The complete feature entity of the charge. - `subscription`: The complete subscription of the charge, when present. - `realization.invoice`: The invoice header of each realization (the invoice entity without its `lines` and `customer` snapshot), in place of the ID reference. - `realization.totals`: The `totals` of each realization run, including credit allocations. - `realization.detailed_lines`: The `detailed_lines` of each realization run.");
5754
5959
  export const lifecycleControllerWire = z
5755
5960
  .enum(['system', 'manual'])
5756
5961
  .describe('Identifies whether a resource lifecycle is controlled by OpenMeter or manually overridden by the API user. Values: - `system`: The resource lifecycle is controlled by OpenMeter. - `manual`: The resource lifecycle was manually overridden by the API user.');
5962
+ export const subscriptionCostBasisModeWire = z
5963
+ .enum(['dynamic', 'pinned'])
5964
+ .describe('Controls how custom-currency cost bases are selected for the subscription.');
5965
+ export const rateCardProrationModeWire = z
5966
+ .enum(['no_proration', 'prorate_prices'])
5967
+ .describe('The proration mode of the rate card. Values: - `no_proration`: No proration. - `prorate_prices`: Prorate the price based on the time remaining in the billing period.');
5968
+ export const subscriptionStatusWire = z
5969
+ .enum(['active', 'inactive', 'canceled', 'scheduled'])
5970
+ .describe('Subscription status.');
5971
+ export const settlementModeWire = z
5972
+ .enum(['credit_then_invoice', 'credit_only'])
5973
+ .describe('Settlement mode for billing. Values: - `credit_then_invoice`: Credits are applied first, then any remainder is invoiced. - `credit_only`: Usage is settled exclusively against credits.');
5974
+ export const priceFreeWire = z
5975
+ .strictObject({
5976
+ type: z.literal('free').describe('The type of the price.'),
5977
+ })
5978
+ .describe('Free price.');
5979
+ export const unitConfigOperationWire = z
5980
+ .enum(['divide', 'multiply'])
5981
+ .describe('The arithmetic operation used to convert raw metered units into billing units. - `divide`: Divide the metered quantity by the conversion factor (e.g., bytes ÷ 1e9 = GB). - `multiply`: Multiply the metered quantity by the conversion factor (e.g., cost × 1.2 = cost + 20% margin).');
5982
+ export const unitConfigRoundingModeWire = z
5983
+ .enum(['ceiling', 'floor', 'half_up', 'none'])
5984
+ .describe('The rounding mode applied to the converted quantity for invoicing. Rounding is applied only to the invoiced quantity. Entitlement balance checks use the precise decimal value after conversion. - `ceiling`: Round up to the next integer (typical for package-style billing). - `floor`: Round down to the previous integer. - `half_up`: Round to the nearest integer, with 0.5 rounding up. - `none`: No rounding; the converted value is used as-is.');
5985
+ export const pricePaymentTermWire = z
5986
+ .union([z.literal('in_advance'), z.literal('in_arrears')])
5987
+ .describe('The payment term of a flat price.');
5988
+ export const rateCardStaticEntitlementWire = z
5989
+ .strictObject({
5990
+ type: z.literal('static').describe('The type of the entitlement template.'),
5991
+ config: z
5992
+ .unknown()
5993
+ .describe('The entitlement config as a JSON object. Returned when checking entitlement access; useful for configuring fine-grained access settings implemented in your own system.'),
5994
+ })
5995
+ .describe('The entitlement template of a static entitlement.');
5996
+ export const rateCardBooleanEntitlementWire = z
5997
+ .strictObject({
5998
+ type: z
5999
+ .literal('boolean')
6000
+ .describe('The type of the entitlement template.'),
6001
+ })
6002
+ .describe('The entitlement template of a boolean entitlement.');
5757
6003
  export const chargeStatusWire = z
5758
6004
  .enum(['created', 'active', 'final', 'deleted'])
5759
6005
  .describe('Lifecycle status of a charge. Values: - `created`: The charge has been created but is not active yet. - `active`: The charge is active. - `final`: The charge is fully finalized and no further changes are expected. - `deleted`: The charge has been deleted.');
5760
- export const settlementModeWire = z
5761
- .enum(['credit_then_invoice', 'credit_only'])
5762
- .describe('Settlement mode for billing. Values: - `credit_then_invoice`: Credits are applied first, then any remainder is invoiced. - `credit_only`: Usage is settled exclusively against credits.');
5763
6006
  export const taxConfigStripeWire = z
5764
6007
  .strictObject({
5765
6008
  code: z
@@ -5776,9 +6019,93 @@ export const taxConfigExternalInvoicingWire = z
5776
6019
  .describe('The tax code should be interpreted by the external invoicing provider.'),
5777
6020
  })
5778
6021
  .describe('External invoicing tax config.');
5779
- export const pricePaymentTermWire = z
5780
- .union([z.literal('in_advance'), z.literal('in_arrears')])
5781
- .describe('The payment term of a flat price.');
6022
+ export const invoiceNumberWire = z
6023
+ .string()
6024
+ .min(1)
6025
+ .max(256)
6026
+ .describe('InvoiceNumber is a unique identifier for the invoice, generated by the invoicing app. The uniqueness depends on a lot of factors: - app setting (unique per app or unique per customer) - multiple app scenarios (multiple apps generating invoices with the same prefix)');
6027
+ export const taxIdentificationCodeWire = z
6028
+ .string()
6029
+ .min(1)
6030
+ .max(32)
6031
+ .describe('Tax identifier code is a normalized tax code shown on the original identity document.');
6032
+ export const invoiceValidationIssueSeverityWire = z
6033
+ .enum(['critical', 'warning'])
6034
+ .describe('Severity level of an invoice validation issue.');
6035
+ export const invoiceExternalReferencesWire = z
6036
+ .strictObject({
6037
+ invoicing_id: z
6038
+ .string()
6039
+ .optional()
6040
+ .describe('The ID assigned by the external invoicing app (e.g. Stripe invoice ID).'),
6041
+ payment_id: z
6042
+ .string()
6043
+ .optional()
6044
+ .describe('The ID assigned by the external payment app (e.g. Stripe payment intent ID).'),
6045
+ })
6046
+ .describe('External identifiers assigned to an invoice by third-party systems.');
6047
+ export const invoiceStandardStatusWire = z
6048
+ .enum([
6049
+ 'draft',
6050
+ 'issuing',
6051
+ 'issued',
6052
+ 'payment_processing',
6053
+ 'overdue',
6054
+ 'paid',
6055
+ 'uncollectible',
6056
+ 'voided',
6057
+ ])
6058
+ .describe('Lifecycle status of a standard invoice.');
6059
+ export const invoiceAvailableActionDetailsWire = z
6060
+ .strictObject({
6061
+ resulting_state: z
6062
+ .string()
6063
+ .describe('The extended status the invoice will transition to after performing this action.'),
6064
+ })
6065
+ .describe('Details about an available invoice action including the resulting state.');
6066
+ export const invoiceWorkflowInvoicingSettingsWire = z
6067
+ .strictObject({
6068
+ auto_advance: z
6069
+ .boolean()
6070
+ .optional()
6071
+ .describe('Whether to automatically issue the invoice after the draft_period has passed.'),
6072
+ draft_period: z
6073
+ .string()
6074
+ .optional()
6075
+ .describe('The period for the invoice to be kept in draft status for manual reviews.'),
6076
+ due_after: z
6077
+ .string()
6078
+ .optional()
6079
+ .describe('The period after which the invoice is considered overdue if not paid.'),
6080
+ })
6081
+ .describe('Invoice-level invoicing settings. A subset of BillingWorkflowInvoicingSettings limited to fields that are meaningful per-invoice. progressive_billing is omitted as it is a gather-time / profile-level decision.');
6082
+ export const workflowPaymentChargeAutomaticallySettingsWire = z
6083
+ .strictObject({
6084
+ collection_method: z
6085
+ .literal('charge_automatically')
6086
+ .describe('The collection method for the invoice.'),
6087
+ })
6088
+ .describe('Payment settings for a billing workflow when the collection method is charge automatically.');
6089
+ export const workflowPaymentSendInvoiceSettingsWire = z
6090
+ .strictObject({
6091
+ collection_method: z
6092
+ .literal('send_invoice')
6093
+ .describe('The collection method for the invoice.'),
6094
+ due_after: z
6095
+ .string()
6096
+ .optional()
6097
+ .describe("The period after which the invoice is due. With some payment solutions it's only applicable for manual collection method."),
6098
+ })
6099
+ .describe('Payment settings for a billing workflow when the collection method is send invoice.');
6100
+ export const chargeRealizationTypeWire = z
6101
+ .enum(['final_realization', 'partial_invoice', 'outstanding', 'voided'])
6102
+ .describe("Type of a charge realization run. Values: - `final_realization`: The run is the final realization of the charge for its service period; no further runs are expected to correct it. - `partial_invoice`: The run only realizes part of the charge, because the remainder is not yet due to be invoiced. - `outstanding`: The type an outstanding (not-yet-realized) projection would carry if it were realized now. Never returned on a booked realization run. - `voided`: The run's billing effect was undone (for example the charge's service period was extended while its invoice was still mutable); it is retained as audit history and excluded from aggregate and live calculations.");
6103
+ export const chargeRealizationPaymentStatusWire = z
6104
+ .enum(['authorized', 'settled'])
6105
+ .describe("Settlement status of a charge realization's payment. Values: - `authorized`: The payment has been authorized against the customer's ledger but has not settled yet. - `settled`: The payment has settled.");
6106
+ export const chargeRealizationDetailedLineCategoryWire = z
6107
+ .enum(['regular', 'commitment'])
6108
+ .describe('Cost category of a charge realization detailed line. Values: - `regular`: A regular charge line, based on usage or subscription pricing. - `commitment`: A commitment-derived line, such as minimum spend.');
5782
6109
  export const chargeFlatFeeDiscountsWire = z
5783
6110
  .strictObject({
5784
6111
  percentage: z
@@ -5789,41 +6116,17 @@ export const chargeFlatFeeDiscountsWire = z
5789
6116
  .describe('Percentage discount applied to the price (0–100).'),
5790
6117
  })
5791
6118
  .describe('Discounts applicable to flat fee charges. This is the same as `ProductCatalog.Discounts` but without the `usage` field, which is not applicable to flat fee charges.');
5792
- export const rateCardProrationModeWire = z
5793
- .enum(['no_proration', 'prorate_prices'])
5794
- .describe('The proration mode of the rate card. Values: - `no_proration`: No proration. - `prorate_prices`: Prorate the price based on the time remaining in the billing period.');
5795
- export const unitConfigOperationWire = z
5796
- .enum(['divide', 'multiply'])
5797
- .describe('The arithmetic operation used to convert raw metered units into billing units. - `divide`: Divide the metered quantity by the conversion factor (e.g., bytes ÷ 1e9 = GB). - `multiply`: Multiply the metered quantity by the conversion factor (e.g., cost × 1.2 = cost + 20% margin).');
5798
- export const unitConfigRoundingModeWire = z
5799
- .enum(['ceiling', 'floor', 'half_up', 'none'])
5800
- .describe('The rounding mode applied to the converted quantity for invoicing. Rounding is applied only to the invoiced quantity. Entitlement balance checks use the precise decimal value after conversion. - `ceiling`: Round up to the next integer (typical for package-style billing). - `floor`: Round down to the previous integer. - `half_up`: Round to the nearest integer, with 0.5 rounding up. - `none`: No rounding; the converted value is used as-is.');
5801
- export const subscriptionCostBasisModeWire = z
5802
- .enum(['dynamic', 'pinned'])
5803
- .describe('Controls how custom-currency cost bases are selected for the subscription.');
5804
- export const subscriptionStatusWire = z
5805
- .enum(['active', 'inactive', 'canceled', 'scheduled'])
5806
- .describe('Subscription status.');
5807
- export const priceFreeWire = z
5808
- .strictObject({
5809
- type: z.literal('free').describe('The type of the price.'),
5810
- })
5811
- .describe('Free price.');
5812
- export const rateCardStaticEntitlementWire = z
5813
- .strictObject({
5814
- type: z.literal('static').describe('The type of the entitlement template.'),
5815
- config: z
5816
- .unknown()
5817
- .describe('The entitlement config as a JSON object. Returned when checking entitlement access; useful for configuring fine-grained access settings implemented in your own system.'),
5818
- })
5819
- .describe('The entitlement template of a static entitlement.');
5820
- export const rateCardBooleanEntitlementWire = z
5821
- .strictObject({
5822
- type: z
5823
- .literal('boolean')
5824
- .describe('The type of the entitlement template.'),
5825
- })
5826
- .describe('The entitlement template of a boolean entitlement.');
6119
+ export const featureLlmTokenTypeWire = z
6120
+ .enum([
6121
+ 'input',
6122
+ 'output',
6123
+ 'cache_read',
6124
+ 'cache_write',
6125
+ 'reasoning',
6126
+ 'request',
6127
+ 'response',
6128
+ ])
6129
+ .describe('Token type for LLM cost lookup.');
5827
6130
  export const subscriptionEditTimingEnumWire = z
5828
6131
  .enum(['immediate', 'next_billing_cycle'])
5829
6132
  .describe('Subscription edit timing. When immediate, the requested changes take effect immediately. When next_billing_cycle, the requested changes take effect at the next billing cycle.');
@@ -5876,11 +6179,6 @@ export const installAppExternalInvoicingWire = z
5876
6179
  .describe('If true, a billing profile will be created for the app. The Stripe app will be also set as the default billing profile if the current default is a Sandbox app.'),
5877
6180
  })
5878
6181
  .describe('Base model for installing an app from the catalog.');
5879
- export const taxIdentificationCodeWire = z
5880
- .string()
5881
- .min(1)
5882
- .max(32)
5883
- .describe('Tax identifier code is a normalized tax code shown on the original identity document.');
5884
6182
  export const workflowCollectionAlignmentSubscriptionWire = z
5885
6183
  .strictObject({
5886
6184
  type: z.literal('subscription').describe('The type of alignment.'),
@@ -5889,79 +6187,6 @@ export const workflowCollectionAlignmentSubscriptionWire = z
5889
6187
  export const workflowInvoicingSubscriptionEndProrationModeWire = z
5890
6188
  .enum(['bill_full_period', 'bill_actual_period'])
5891
6189
  .describe('Billing workflow subscription end proration mode.');
5892
- export const workflowPaymentChargeAutomaticallySettingsWire = z
5893
- .strictObject({
5894
- collection_method: z
5895
- .literal('charge_automatically')
5896
- .describe('The collection method for the invoice.'),
5897
- })
5898
- .describe('Payment settings for a billing workflow when the collection method is charge automatically.');
5899
- export const workflowPaymentSendInvoiceSettingsWire = z
5900
- .strictObject({
5901
- collection_method: z
5902
- .literal('send_invoice')
5903
- .describe('The collection method for the invoice.'),
5904
- due_after: z
5905
- .string()
5906
- .optional()
5907
- .describe("The period after which the invoice is due. With some payment solutions it's only applicable for manual collection method."),
5908
- })
5909
- .describe('Payment settings for a billing workflow when the collection method is send invoice.');
5910
- export const invoiceNumberWire = z
5911
- .string()
5912
- .min(1)
5913
- .max(256)
5914
- .describe('InvoiceNumber is a unique identifier for the invoice, generated by the invoicing app. The uniqueness depends on a lot of factors: - app setting (unique per app or unique per customer) - multiple app scenarios (multiple apps generating invoices with the same prefix)');
5915
- export const invoiceValidationIssueSeverityWire = z
5916
- .enum(['critical', 'warning'])
5917
- .describe('Severity level of an invoice validation issue.');
5918
- export const invoiceExternalReferencesWire = z
5919
- .strictObject({
5920
- invoicing_id: z
5921
- .string()
5922
- .optional()
5923
- .describe('The ID assigned by the external invoicing app (e.g. Stripe invoice ID).'),
5924
- payment_id: z
5925
- .string()
5926
- .optional()
5927
- .describe('The ID assigned by the external payment app (e.g. Stripe payment intent ID).'),
5928
- })
5929
- .describe('External identifiers assigned to an invoice by third-party systems.');
5930
- export const invoiceStandardStatusWire = z
5931
- .enum([
5932
- 'draft',
5933
- 'issuing',
5934
- 'issued',
5935
- 'payment_processing',
5936
- 'overdue',
5937
- 'paid',
5938
- 'uncollectible',
5939
- 'voided',
5940
- ])
5941
- .describe('Lifecycle status of a standard invoice.');
5942
- export const invoiceAvailableActionDetailsWire = z
5943
- .strictObject({
5944
- resulting_state: z
5945
- .string()
5946
- .describe('The extended status the invoice will transition to after performing this action.'),
5947
- })
5948
- .describe('Details about an available invoice action including the resulting state.');
5949
- export const invoiceWorkflowInvoicingSettingsWire = z
5950
- .strictObject({
5951
- auto_advance: z
5952
- .boolean()
5953
- .optional()
5954
- .describe('Whether to automatically issue the invoice after the draft_period has passed.'),
5955
- draft_period: z
5956
- .string()
5957
- .optional()
5958
- .describe('The period for the invoice to be kept in draft status for manual reviews.'),
5959
- due_after: z
5960
- .string()
5961
- .optional()
5962
- .describe('The period after which the invoice is considered overdue if not paid.'),
5963
- })
5964
- .describe('Invoice-level invoicing settings. A subset of BillingWorkflowInvoicingSettings limited to fields that are meaningful per-invoice. progressive_billing is omitted as it is a gather-time / profile-level decision.');
5965
6190
  export const invoiceDiscountReasonWire = z
5966
6191
  .enum(['maximum_spend', 'ratecard_percentage', 'ratecard_usage'])
5967
6192
  .describe('The reason a discount was applied to an invoice line.');
@@ -6017,17 +6242,6 @@ export const currencyTypeWire = z
6017
6242
  export const currencyExpandWire = z
6018
6243
  .enum(['cost_basis'])
6019
6244
  .describe("Expands for currencies. Values: - `cost_basis`: The currency's active and scheduled cost basis.");
6020
- export const featureLlmTokenTypeWire = z
6021
- .enum([
6022
- 'input',
6023
- 'output',
6024
- 'cache_read',
6025
- 'cache_write',
6026
- 'reasoning',
6027
- 'request',
6028
- 'response',
6029
- ])
6030
- .describe('Token type for LLM cost lookup.');
6031
6245
  export const llmCostProviderWire = z
6032
6246
  .strictObject({
6033
6247
  id: z
@@ -6282,12 +6496,12 @@ export const invoiceLineTypeWire = z
6282
6496
  export const priceTypeWire = z
6283
6497
  .enum(['free', 'flat', 'unit', 'graduated', 'volume'])
6284
6498
  .describe("The type of the price. - `free`: No charge, the rate card is included at no cost. - `flat`: A fixed amount charged once per billing period, regardless of usage. - `unit`: A fixed rate charged per billing unit consumed. - `graduated`: Tiered pricing where each tier's rate applies only to usage within that tier. - `volume`: Tiered pricing where the rate for the highest tier reached applies to all units in the period.");
6285
- export const collectionAlignmentWire = z
6286
- .enum(['subscription', 'anchored'])
6287
- .describe('BillingCollectionAlignment specifies when the pending line items should be collected into an invoice.');
6288
6499
  export const collectionMethodWire = z
6289
6500
  .enum(['charge_automatically', 'send_invoice'])
6290
6501
  .describe('Collection method specifies how the invoice should be collected (automatic or manual).');
6502
+ export const collectionAlignmentWire = z
6503
+ .enum(['subscription', 'anchored'])
6504
+ .describe('BillingCollectionAlignment specifies when the pending line items should be collected into an invoice.');
6291
6505
  export const featureUnitCostTypeWire = z
6292
6506
  .enum(['llm', 'manual'])
6293
6507
  .describe('The type of unit cost.');
@@ -6414,22 +6628,28 @@ export const createCurrencyCustomRequestWire = z
6414
6628
  .string()
6415
6629
  .min(1)
6416
6630
  .max(1)
6417
- .describe('The thousand separator for the currency. It should be a string that represents the thousand separator of the currency, such as "," for US Dollar or "." for Euro.'),
6418
- code: currencyCodeCustomWire,
6419
- })
6420
- .describe('CurrencyCustom create request.');
6421
- export const currencyAmountWire = z
6422
- .strictObject({
6423
- amount: numericWire,
6424
- currency: currencyCodeWire,
6631
+ .describe('The thousand separator for the currency. It should be a string that represents the thousand separator of the currency, such as "," for US Dollar or "." for Euro.'),
6632
+ code: currencyCodeCustomWire,
6425
6633
  })
6426
- .describe('Monetary amount in a specific currency.');
6634
+ .describe('CurrencyCustom create request.');
6427
6635
  export const priceFlatWire = z
6428
6636
  .strictObject({
6429
6637
  type: z.literal('flat').describe('The type of the price.'),
6430
6638
  amount: numericWire,
6431
6639
  })
6432
6640
  .describe('Flat price.');
6641
+ export const priceUnitWire = z
6642
+ .strictObject({
6643
+ type: z.literal('unit').describe('The type of the price.'),
6644
+ amount: numericWire,
6645
+ })
6646
+ .describe('Unit price. Charges a fixed rate per billing unit. When UnitConfig is present on the object, billing units are the converted quantities (e.g. GB instead of bytes).');
6647
+ export const spendCommitmentsWire = z
6648
+ .strictObject({
6649
+ minimum_amount: numericWire.optional(),
6650
+ maximum_amount: numericWire.optional(),
6651
+ })
6652
+ .describe('Spend commitments for a usage-based price. The customer is committed to spend at least the minimum amount and at most the maximum amount.');
6433
6653
  export const rateCardDiscountsWire = z
6434
6654
  .strictObject({
6435
6655
  percentage: z
@@ -6453,18 +6673,57 @@ export const totalsWire = z
6453
6673
  total: numericWire,
6454
6674
  })
6455
6675
  .describe('Totals contains the summaries of all calculations for a billing resource.');
6456
- export const priceUnitWire = z
6676
+ export const chargeRealizationDetailedLineCreditAppliedWire = z
6457
6677
  .strictObject({
6458
- type: z.literal('unit').describe('The type of the price.'),
6459
6678
  amount: numericWire,
6679
+ description: z
6680
+ .string()
6681
+ .optional()
6682
+ .describe('Human-readable description of the credit allocation.'),
6683
+ credit_realization_id: z
6684
+ .string()
6685
+ .describe('The ID of the credit realization (allocation) this credit was applied from.'),
6460
6686
  })
6461
- .describe('Unit price. Charges a fixed rate per billing unit. When UnitConfig is present on the object, billing units are the converted quantities (e.g. GB instead of bytes).');
6462
- export const spendCommitmentsWire = z
6687
+ .describe('A credit allocation applied to a charge realization detailed line.');
6688
+ export const chargeRealizationAmountDiscountWire = z
6463
6689
  .strictObject({
6464
- minimum_amount: numericWire.optional(),
6465
- maximum_amount: numericWire.optional(),
6690
+ amount: numericWire,
6691
+ reason: z
6692
+ .string()
6693
+ .describe('The reason for the discount applied to the charge.'),
6694
+ description: z
6695
+ .string()
6696
+ .optional()
6697
+ .describe('Optional human-readable description of the discount.'),
6698
+ rounding_amount: numericWire.optional(),
6699
+ child_unique_reference_id: z
6700
+ .string()
6701
+ .describe('Unique reference ID of the discount applied to the charge.'),
6466
6702
  })
6467
- .describe('Spend commitments for a usage-based price. The customer is committed to spend at least the minimum amount and at most the maximum amount.');
6703
+ .describe('A discount applied to a charge realization detailed line.');
6704
+ export const featureManualUnitCostWire = z
6705
+ .strictObject({
6706
+ type: z
6707
+ .literal('manual')
6708
+ .describe('The type discriminator for manual unit cost.'),
6709
+ amount: numericWire,
6710
+ })
6711
+ .describe('A fixed per-unit cost amount.');
6712
+ export const featureLlmUnitCostPricingWire = z
6713
+ .strictObject({
6714
+ input_per_token: numericWire,
6715
+ output_per_token: numericWire,
6716
+ cache_read_per_token: numericWire.optional(),
6717
+ reasoning_per_token: numericWire.optional(),
6718
+ cache_write_per_token: numericWire.optional(),
6719
+ })
6720
+ .describe('Resolved per-token pricing from the LLM cost database.');
6721
+ export const currencyAmountWire = z
6722
+ .strictObject({
6723
+ amount: numericWire,
6724
+ currency: currencyCodeWire,
6725
+ })
6726
+ .describe('Monetary amount in a specific currency.');
6468
6727
  export const invoiceLineCreditsAppliedWire = z
6469
6728
  .strictObject({
6470
6729
  amount: numericWire,
@@ -6507,23 +6766,6 @@ export const updateDiscountsWire = z
6507
6766
  usage: numericWire.optional(),
6508
6767
  })
6509
6768
  .describe('Discount configuration for a rate card.');
6510
- export const featureManualUnitCostWire = z
6511
- .strictObject({
6512
- type: z
6513
- .literal('manual')
6514
- .describe('The type discriminator for manual unit cost.'),
6515
- amount: numericWire,
6516
- })
6517
- .describe('A fixed per-unit cost amount.');
6518
- export const featureLlmUnitCostPricingWire = z
6519
- .strictObject({
6520
- input_per_token: numericWire,
6521
- output_per_token: numericWire,
6522
- cache_read_per_token: numericWire.optional(),
6523
- reasoning_per_token: numericWire.optional(),
6524
- cache_write_per_token: numericWire.optional(),
6525
- })
6526
- .describe('Resolved per-token pricing from the LLM cost database.');
6527
6769
  export const llmCostModelPricingWire = z
6528
6770
  .strictObject({
6529
6771
  input_per_token: numericWire,
@@ -6624,14 +6866,25 @@ export const creditGrantInvoiceReferenceWire = z
6624
6866
  .describe('Identifier of the invoice line associated with the grant.'),
6625
6867
  })
6626
6868
  .describe('Invoice references for the grant.');
6627
- export const billingCustomerReferenceWire = z
6869
+ export const subscriptionCostBasisPinWire = z
6870
+ .strictObject({
6871
+ custom_currency_id: ulidWire,
6872
+ invoice_currency: currencyCodeWire,
6873
+ cost_basis_id: ulidWire,
6874
+ })
6875
+ .describe('A cost basis pinned to a custom-currency pair for the subscription.');
6876
+ export const featureReferenceWire = z
6628
6877
  .strictObject({
6629
6878
  id: ulidWire,
6630
6879
  })
6631
- .describe('Customer reference.');
6880
+ .describe('Feature reference.');
6632
6881
  export const subscriptionReferenceWire = z
6633
6882
  .strictObject({
6634
6883
  id: ulidWire,
6884
+ name: z
6885
+ .string()
6886
+ .optional()
6887
+ .describe('The display name of the subscription. Only populated where the referencing endpoint documents a `subscription` expand that resolves it.'),
6635
6888
  phase: z
6636
6889
  .strictObject({
6637
6890
  id: ulidWire,
@@ -6644,28 +6897,21 @@ export const subscriptionReferenceWire = z
6644
6897
  .describe('The phase of the subscription.'),
6645
6898
  })
6646
6899
  .describe('Subscription reference represents a reference to the specific subscription item this entity represents.');
6647
- export const subscriptionCostBasisPinWire = z
6900
+ export const appReferenceWire = z
6648
6901
  .strictObject({
6649
- custom_currency_id: ulidWire,
6650
- invoice_currency: currencyCodeWire,
6651
- cost_basis_id: ulidWire,
6902
+ id: ulidWire,
6652
6903
  })
6653
- .describe('A cost basis pinned to a custom-currency pair for the subscription.');
6654
- export const featureReferenceWire = z
6904
+ .describe('App reference.');
6905
+ export const chargeRealizationInvoiceReferenceWire = z
6655
6906
  .strictObject({
6656
6907
  id: ulidWire,
6657
6908
  })
6658
- .describe('Feature reference.');
6909
+ .describe('ChargeRealizationInvoice reference.');
6659
6910
  export const addonReferenceWire = z
6660
6911
  .strictObject({
6661
6912
  id: ulidWire,
6662
6913
  })
6663
6914
  .describe('Addon reference.');
6664
- export const appReferenceWire = z
6665
- .strictObject({
6666
- id: ulidWire,
6667
- })
6668
- .describe('App reference.');
6669
6915
  export const chargeReferenceWire = z
6670
6916
  .strictObject({
6671
6917
  id: ulidWire,
@@ -6676,6 +6922,28 @@ export const updateResourceReferenceWire = z
6676
6922
  id: ulidWire,
6677
6923
  })
6678
6924
  .describe('TaxCode reference.');
6925
+ export const billingCustomerReferenceWire = z
6926
+ .strictObject({
6927
+ id: ulidWire,
6928
+ name: z
6929
+ .string()
6930
+ .optional()
6931
+ .describe('The display name of the customer. Only populated where the referencing endpoint documents a `customer` expand that resolves it.'),
6932
+ })
6933
+ .describe('Customer reference.');
6934
+ export const chargeFeatureWire = z
6935
+ .strictObject({
6936
+ id: ulidWire,
6937
+ key: z
6938
+ .string()
6939
+ .optional()
6940
+ .describe('The key of the feature. Requires the `feature` expand.'),
6941
+ name: z
6942
+ .string()
6943
+ .optional()
6944
+ .describe('The display name of the feature. Requires the `feature` expand.'),
6945
+ })
6946
+ .describe('The feature associated with a charge. `key` is always present and is set at charge creation time. `id` and `name` are only resolved with the `feature` expand, since resolving them requires an additional lookup against the feature catalog.');
6679
6947
  export const dateTimeFieldFilterWire = z
6680
6948
  .union([
6681
6949
  dateTimeWire,
@@ -7346,11 +7614,6 @@ export const getCreditBalanceParamsFilterWire = z
7346
7614
  feature_key: stringFieldFilterWire.optional(),
7347
7615
  })
7348
7616
  .describe('Filter options for getting a credit balance.');
7349
- export const listChargesParamsFilterWire = z
7350
- .strictObject({
7351
- status: stringFieldFilterExactWire.optional(),
7352
- })
7353
- .describe('Filter options for listing charges.');
7354
7617
  export const listPlansParamsFilterWire = z
7355
7618
  .strictObject({
7356
7619
  key: stringFieldFilterWire.optional(),
@@ -7364,33 +7627,17 @@ export const voidCreditGrantRequestWire = z
7364
7627
  payment_adjustment: creditGrantVoidPaymentAdjustmentWire.optional(),
7365
7628
  })
7366
7629
  .describe('Request body for voiding a credit grant.');
7367
- export const rateCardProrationConfigurationWire = z
7368
- .strictObject({
7369
- mode: rateCardProrationModeWire,
7370
- })
7371
- .describe('The proration configuration of the rate card.');
7372
7630
  export const subscriptionProRatingConfigWire = z
7373
7631
  .strictObject({
7374
7632
  enabled: z.boolean().describe('Whether pro-rating is enabled.'),
7375
7633
  mode: rateCardProrationModeWire,
7376
7634
  })
7377
7635
  .describe('The pro-rating configuration of a subscription.');
7378
- export const unitConfigWire = z
7636
+ export const rateCardProrationConfigurationWire = z
7379
7637
  .strictObject({
7380
- operation: unitConfigOperationWire,
7381
- conversion_factor: numericWire,
7382
- rounding: unitConfigRoundingModeWire.optional(),
7383
- precision: z
7384
- .number()
7385
- .int()
7386
- .optional()
7387
- .describe('The number of decimal places to retain after rounding. Only meaningful when rounding is not "none". Defaults to 0 (round to whole numbers).'),
7388
- display_unit: z
7389
- .string()
7390
- .optional()
7391
- .describe('A human-readable label for the converted unit shown on invoices and in the customer portal (e.g., "GB", "hours", "M tokens"). Optional. When omitted, no unit label is rendered.'),
7638
+ mode: rateCardProrationModeWire,
7392
7639
  })
7393
- .describe('Unit conversion configuration. Transforms raw metered quantities into billing-ready units before pricing and entitlement evaluation. Stored with a resource\'s rating configuration so the same metered feature can be billed in different units across plans and charges. Examples: - Meter bytes, bill GB: operation=divide, conversionFactor=1e9, rounding=ceiling, displayUnit="GB" - Meter seconds, bill hours: operation=divide, conversionFactor=3600, rounding=ceiling, displayUnit="hours" - Cost + 20% margin: operation=multiply, conversionFactor=1.2 - Bill per million tokens: operation=divide, conversionFactor=1e6, rounding=ceiling, displayUnit="M" v1 equivalents: - DynamicPrice(multiplier): operation=multiply, conversionFactor=multiplier + UnitPrice(amount=1) - PackagePrice(amount, quantityPerPkg): operation=divide, conversionFactor=quantityPerPkg, rounding=ceiling + UnitPrice(amount)');
7640
+ .describe('The proration configuration of the rate card.');
7394
7641
  export const subscriptionCreateWire = z
7395
7642
  .strictObject({
7396
7643
  labels: labelsWire.optional(),
@@ -7416,6 +7663,67 @@ export const subscriptionCreateWire = z
7416
7663
  cost_basis_mode: subscriptionCostBasisModeWire.optional(),
7417
7664
  })
7418
7665
  .describe('Subscription create request.');
7666
+ export const unitConfigWire = z
7667
+ .strictObject({
7668
+ operation: unitConfigOperationWire,
7669
+ conversion_factor: numericWire,
7670
+ rounding: unitConfigRoundingModeWire.optional(),
7671
+ precision: z
7672
+ .number()
7673
+ .int()
7674
+ .optional()
7675
+ .describe('The number of decimal places to retain after rounding. Only meaningful when rounding is not "none". Defaults to 0 (round to whole numbers).'),
7676
+ display_unit: z
7677
+ .string()
7678
+ .optional()
7679
+ .describe('A human-readable label for the converted unit shown on invoices and in the customer portal (e.g., "GB", "hours", "M tokens"). Optional. When omitted, no unit label is rendered.'),
7680
+ })
7681
+ .describe('Unit conversion configuration. Transforms raw metered quantities into billing-ready units before pricing and entitlement evaluation. Stored with a resource\'s rating configuration so the same metered feature can be billed in different units across plans and charges. Examples: - Meter bytes, bill GB: operation=divide, conversionFactor=1e9, rounding=ceiling, displayUnit="GB" - Meter seconds, bill hours: operation=divide, conversionFactor=3600, rounding=ceiling, displayUnit="hours" - Cost + 20% margin: operation=multiply, conversionFactor=1.2 - Bill per million tokens: operation=divide, conversionFactor=1e6, rounding=ceiling, displayUnit="M" v1 equivalents: - DynamicPrice(multiplier): operation=multiply, conversionFactor=multiplier + UnitPrice(amount=1) - PackagePrice(amount, quantityPerPkg): operation=divide, conversionFactor=quantityPerPkg, rounding=ceiling + UnitPrice(amount)');
7682
+ export const partyTaxIdentityWire = z
7683
+ .strictObject({
7684
+ code: taxIdentificationCodeWire.optional(),
7685
+ })
7686
+ .describe('Identity stores the details required to identify an entity for tax purposes in a specific country.');
7687
+ export const updateBillingPartyTaxIdentityWire = z
7688
+ .strictObject({
7689
+ code: taxIdentificationCodeWire.optional(),
7690
+ })
7691
+ .describe('Identity stores the details required to identify an entity for tax purposes in a specific country.');
7692
+ export const invoiceValidationIssueWire = z
7693
+ .strictObject({
7694
+ code: z.string().describe('Machine-readable error code.'),
7695
+ message: z.string().describe('Human-readable description of the error.'),
7696
+ attributes: z
7697
+ .record(z.string(), z.unknown())
7698
+ .optional()
7699
+ .describe('Additional structured context.'),
7700
+ severity: invoiceValidationIssueSeverityWire,
7701
+ field: z
7702
+ .string()
7703
+ .optional()
7704
+ .describe('JSON path to the field that caused this validation issue, if applicable. For example: `lines/0/rate_card/price`.'),
7705
+ })
7706
+ .describe('A validation issue found during invoice processing. Converges on the same structure used by plan and subscription validation errors: a machine-readable `code`, a human-readable `message`, optional structured `attributes`, plus a `severity` and optional `field` path.');
7707
+ export const invoiceAvailableActionsWire = z
7708
+ .strictObject({
7709
+ advance: invoiceAvailableActionDetailsWire.optional(),
7710
+ approve: invoiceAvailableActionDetailsWire.optional(),
7711
+ delete: invoiceAvailableActionDetailsWire.optional(),
7712
+ retry: invoiceAvailableActionDetailsWire.optional(),
7713
+ snapshot_quantities: invoiceAvailableActionDetailsWire.optional(),
7714
+ })
7715
+ .describe('The set of state-transition actions available for an invoice in its current status. A field is present only when that action is permitted from the current state.');
7716
+ export const workflowPaymentSettingsWire = z
7717
+ .discriminatedUnion('collection_method', [
7718
+ workflowPaymentChargeAutomaticallySettingsWire,
7719
+ workflowPaymentSendInvoiceSettingsWire,
7720
+ ])
7721
+ .describe('Payment settings for a billing workflow.');
7722
+ export const chargeRealizationPaymentWire = z
7723
+ .strictObject({
7724
+ status: chargeRealizationPaymentStatusWire,
7725
+ })
7726
+ .describe('Payment state of a charge realization.');
7419
7727
  export const subscriptionEditTimingWire = z
7420
7728
  .union([subscriptionEditTimingEnumWire, dateTimeWire])
7421
7729
  .describe('Subscription edit timing defined when the changes should take effect. If the provided configuration is not supported by the subscription, an error will be returned.');
@@ -7498,16 +7806,6 @@ export const installAppRequestWire = z
7498
7806
  installAppExternalInvoicingWire,
7499
7807
  ])
7500
7808
  .describe('Request to install an app from the catalog.');
7501
- export const partyTaxIdentityWire = z
7502
- .strictObject({
7503
- code: taxIdentificationCodeWire.optional(),
7504
- })
7505
- .describe('Identity stores the details required to identify an entity for tax purposes in a specific country.');
7506
- export const updateBillingPartyTaxIdentityWire = z
7507
- .strictObject({
7508
- code: taxIdentificationCodeWire.optional(),
7509
- })
7510
- .describe('Identity stores the details required to identify an entity for tax purposes in a specific country.');
7511
7809
  export const workflowInvoicingSettingsWire = z
7512
7810
  .strictObject({
7513
7811
  auto_advance: z
@@ -7525,36 +7823,6 @@ export const workflowInvoicingSettingsWire = z
7525
7823
  subscription_end_proration_mode: workflowInvoicingSubscriptionEndProrationModeWire.optional(),
7526
7824
  })
7527
7825
  .describe('Invoice settings for a billing workflow.');
7528
- export const workflowPaymentSettingsWire = z
7529
- .discriminatedUnion('collection_method', [
7530
- workflowPaymentChargeAutomaticallySettingsWire,
7531
- workflowPaymentSendInvoiceSettingsWire,
7532
- ])
7533
- .describe('Payment settings for a billing workflow.');
7534
- export const invoiceValidationIssueWire = z
7535
- .strictObject({
7536
- code: z.string().describe('Machine-readable error code.'),
7537
- message: z.string().describe('Human-readable description of the error.'),
7538
- attributes: z
7539
- .record(z.string(), z.unknown())
7540
- .optional()
7541
- .describe('Additional structured context.'),
7542
- severity: invoiceValidationIssueSeverityWire,
7543
- field: z
7544
- .string()
7545
- .optional()
7546
- .describe('JSON path to the field that caused this validation issue, if applicable. For example: `lines/0/rate_card/price`.'),
7547
- })
7548
- .describe('A validation issue found during invoice processing. Converges on the same structure used by plan and subscription validation errors: a machine-readable `code`, a human-readable `message`, optional structured `attributes`, plus a `severity` and optional `field` path.');
7549
- export const invoiceAvailableActionsWire = z
7550
- .strictObject({
7551
- advance: invoiceAvailableActionDetailsWire.optional(),
7552
- approve: invoiceAvailableActionDetailsWire.optional(),
7553
- delete: invoiceAvailableActionDetailsWire.optional(),
7554
- retry: invoiceAvailableActionDetailsWire.optional(),
7555
- snapshot_quantities: invoiceAvailableActionDetailsWire.optional(),
7556
- })
7557
- .describe('The set of state-transition actions available for an invoice in its current status. A field is present only when that action is permitted from the current state.');
7558
7826
  export const invoiceLineAmountDiscountWire = z
7559
7827
  .strictObject({
7560
7828
  id: ulidWire,
@@ -7722,12 +7990,6 @@ export const creditTransactionWire = z
7722
7990
  .describe('The available balance before and after the transaction.'),
7723
7991
  })
7724
7992
  .describe("A credit transaction represents a single credit movement on the customer's balance. Credit transactions are immutable.");
7725
- export const chargeTotalsWire = z
7726
- .strictObject({
7727
- booked: totalsWire,
7728
- realtime: totalsWire.optional(),
7729
- })
7730
- .describe('The totals of a charge. RealTime is only expanded when the `real_time_usage` expand is used.');
7731
7993
  export const priceTierWire = z
7732
7994
  .strictObject({
7733
7995
  up_to_amount: numericWire.optional(),
@@ -7735,13 +7997,12 @@ export const priceTierWire = z
7735
7997
  unit_price: priceUnitWire.optional(),
7736
7998
  })
7737
7999
  .describe('A price tier used in graduated and volume pricing. At least one price component (flat_price or unit_price) must be set. When UnitConfig is present on the containing resource, up_to_amount is expressed in converted billing units.');
7738
- export const updatePriceTierWire = z
7739
- .strictObject({
7740
- up_to_amount: numericWire.optional(),
7741
- flat_price: updatePriceFlatWire.optional(),
7742
- unit_price: updatePriceUnitWire.optional(),
8000
+ export const chargeTotalsWire = z
8001
+ .strictObject({
8002
+ booked: totalsWire,
8003
+ realtime: totalsWire.optional(),
7743
8004
  })
7744
- .describe('A price tier used in graduated and volume pricing. At least one price component (flat_price or unit_price) must be set. When UnitConfig is present on the containing resource, up_to_amount is expressed in converted billing units.');
8005
+ .describe('The totals of a charge. `realtime` is only populated when the `real_time_usage` expand is used.');
7745
8006
  export const featureLlmUnitCostWire = z
7746
8007
  .strictObject({
7747
8008
  type: z
@@ -7771,6 +8032,13 @@ export const featureLlmUnitCostWire = z
7771
8032
  pricing: featureLlmUnitCostPricingWire.optional(),
7772
8033
  })
7773
8034
  .describe('LLM cost lookup configuration. Each dimension (provider, model, token type) can be specified as either a static value or a meter group-by property name (mutually exclusive).');
8035
+ export const updatePriceTierWire = z
8036
+ .strictObject({
8037
+ up_to_amount: numericWire.optional(),
8038
+ flat_price: updatePriceFlatWire.optional(),
8039
+ unit_price: updatePriceUnitWire.optional(),
8040
+ })
8041
+ .describe('A price tier used in graduated and volume pricing. At least one price component (flat_price or unit_price) must be set. When UnitConfig is present on the containing resource, up_to_amount is expressed in converted billing units.');
7774
8042
  export const llmCostPriceWire = z
7775
8043
  .strictObject({
7776
8044
  id: ulidWire,
@@ -7853,6 +8121,12 @@ export const creditGrantTaxConfigWire = z
7853
8121
  tax_code: taxCodeReferenceWire.optional(),
7854
8122
  })
7855
8123
  .describe('Tax configuration for a credit grant. Tax configuration should be provided to ensure correct revenue recognition, including for externally funded grants.');
8124
+ export const rateCardTaxConfigWire = z
8125
+ .strictObject({
8126
+ behavior: taxBehaviorWire.optional(),
8127
+ code: taxCodeReferenceWire,
8128
+ })
8129
+ .describe('The tax config of the rate card.');
7856
8130
  export const taxConfigWire = z
7857
8131
  .strictObject({
7858
8132
  behavior: taxBehaviorWire.optional(),
@@ -7862,12 +8136,6 @@ export const taxConfigWire = z
7862
8136
  tax_code: taxCodeReferenceWire.optional(),
7863
8137
  })
7864
8138
  .describe('Set of provider specific tax configs.');
7865
- export const rateCardTaxConfigWire = z
7866
- .strictObject({
7867
- behavior: taxBehaviorWire.optional(),
7868
- code: taxCodeReferenceWire,
7869
- })
7870
- .describe('The tax config of the rate card.');
7871
8139
  export const organizationDefaultTaxCodesWire = z
7872
8140
  .strictObject({
7873
8141
  invoicing_tax_code: taxCodeReferenceWire,
@@ -7882,6 +8150,20 @@ export const updateOrganizationDefaultTaxCodesRequestWire = z
7882
8150
  credit_grant_tax_code: taxCodeReferenceWire.optional(),
7883
8151
  })
7884
8152
  .describe('OrganizationDefaultTaxCodes update request.');
8153
+ export const invoiceWorkflowAppsReferencesWire = z
8154
+ .strictObject({
8155
+ tax: appReferenceWire,
8156
+ invoicing: appReferenceWire,
8157
+ payment: appReferenceWire,
8158
+ })
8159
+ .describe('BillingInvoiceWorkflowAppsReferences represents the references (id) to the apps used by a billing profile');
8160
+ export const profileAppReferencesWire = z
8161
+ .strictObject({
8162
+ tax: appReferenceWire,
8163
+ invoicing: appReferenceWire,
8164
+ payment: appReferenceWire,
8165
+ })
8166
+ .describe('References to the applications used by a billing profile.');
7885
8167
  export const planAddonWire = z
7886
8168
  .strictObject({
7887
8169
  id: ulidWire,
@@ -7936,20 +8218,6 @@ export const createPlanAddonRequestWire = z
7936
8218
  .describe('The maximum number of times the add-on can be purchased for the plan. For single-instance add-ons this field must be omitted. For multi-instance add-ons when omitted, unlimited quantity can be purchased.'),
7937
8219
  })
7938
8220
  .describe('PlanAddon create request.');
7939
- export const profileAppReferencesWire = z
7940
- .strictObject({
7941
- tax: appReferenceWire,
7942
- invoicing: appReferenceWire,
7943
- payment: appReferenceWire,
7944
- })
7945
- .describe('References to the applications used by a billing profile.');
7946
- export const invoiceWorkflowAppsReferencesWire = z
7947
- .strictObject({
7948
- tax: appReferenceWire,
7949
- invoicing: appReferenceWire,
7950
- payment: appReferenceWire,
7951
- })
7952
- .describe('BillingInvoiceWorkflowAppsReferences represents the references (id) to the apps used by a billing profile');
7953
8221
  export const updateRateCardTaxConfigWire = z
7954
8222
  .strictObject({
7955
8223
  behavior: taxBehaviorWire.optional(),
@@ -7968,6 +8236,15 @@ export const listEventsParamsFilterWire = z
7968
8236
  stored_at: dateTimeFieldFilterWire.optional(),
7969
8237
  })
7970
8238
  .describe('Filter options for listing ingested events.');
8239
+ export const listChargesParamsFilterWire = z
8240
+ .strictObject({
8241
+ status: stringFieldFilterExactWire.optional(),
8242
+ feature_id: ulidFieldFilterWire.optional(),
8243
+ feature_key: stringFieldFilterExactWire.optional(),
8244
+ service_period_from: dateTimeFieldFilterWire.optional(),
8245
+ service_period_to: dateTimeFieldFilterWire.optional(),
8246
+ })
8247
+ .describe('Filter options for listing charges.');
7971
8248
  export const listInvoicesParamsFilterWire = z
7972
8249
  .strictObject({
7973
8250
  status: stringFieldFilterExactWire.optional(),
@@ -8019,6 +8296,55 @@ export const meterQueryResultWire = z
8019
8296
  .describe('The usage data. If no data is available, an empty array is returned.'),
8020
8297
  })
8021
8298
  .describe('Meter query result.');
8299
+ export const chargeRealizationDetailedLineFlatFeeWire = z
8300
+ .strictObject({
8301
+ id: ulidWire,
8302
+ created_at: dateTimeWire,
8303
+ updated_at: dateTimeWire,
8304
+ deleted_at: dateTimeWire.optional(),
8305
+ type: z
8306
+ .literal('flat_fee')
8307
+ .describe('The type of the charge the realization belongs to.'),
8308
+ service_period: closedPeriodWire,
8309
+ totals: totalsWire,
8310
+ category: chargeRealizationDetailedLineCategoryWire,
8311
+ credits_applied: z
8312
+ .array(chargeRealizationDetailedLineCreditAppliedWire)
8313
+ .optional()
8314
+ .describe('Credits applied to this detailed line.'),
8315
+ unit_price: numericWire,
8316
+ amount_discounts: z
8317
+ .array(chargeRealizationAmountDiscountWire)
8318
+ .describe('The amount discounts applied to the detailed line.'),
8319
+ })
8320
+ .describe("A detailed line produced by a flat fee charge's realization run.");
8321
+ export const chargeRealizationDetailedLineUsageBasedWire = z
8322
+ .strictObject({
8323
+ id: ulidWire,
8324
+ created_at: dateTimeWire,
8325
+ updated_at: dateTimeWire,
8326
+ deleted_at: dateTimeWire.optional(),
8327
+ type: z
8328
+ .literal('usage_based')
8329
+ .describe('The type of the charge the realization belongs to.'),
8330
+ service_period: closedPeriodWire,
8331
+ totals: totalsWire,
8332
+ category: chargeRealizationDetailedLineCategoryWire,
8333
+ credits_applied: z
8334
+ .array(chargeRealizationDetailedLineCreditAppliedWire)
8335
+ .optional()
8336
+ .describe('Credits applied to this detailed line.'),
8337
+ unit_price: numericWire,
8338
+ amount_discounts: z
8339
+ .array(chargeRealizationAmountDiscountWire)
8340
+ .describe('The amount discounts applied to the detailed line.'),
8341
+ quantity: numericWire,
8342
+ corrects_run_id: z
8343
+ .string()
8344
+ .optional()
8345
+ .describe("The ID of a prior realization run this detailed line corrects. Only set if the detailed line's totals are negative."),
8346
+ })
8347
+ .describe("A detailed line produced by a usage-based charge's realization run.");
8022
8348
  export const currencyCustomWire = z
8023
8349
  .strictObject({
8024
8350
  type: z.literal('custom').describe('The type of the currency.'),
@@ -8261,6 +8587,24 @@ export const chargeFlatFeeSystemIntentWire = z
8261
8587
  deleted_at: dateTimeWire.optional(),
8262
8588
  })
8263
8589
  .describe('Flat fee intent fields from the system lifecycle controller shadowed by a manual override.');
8590
+ export const invoiceStatusDetailsWire = z
8591
+ .strictObject({
8592
+ immutable: z
8593
+ .boolean()
8594
+ .describe('Whether the invoice is immutable (i.e. cannot be modified or deleted).'),
8595
+ failed: z.boolean().describe('Whether the invoice is in a failed state.'),
8596
+ extended_status: z
8597
+ .string()
8598
+ .describe('Fine-grained internal status string providing additional workflow detail beyond the top-level status enum.'),
8599
+ available_actions: invoiceAvailableActionsWire,
8600
+ })
8601
+ .describe('Detailed status information for a standard invoice.');
8602
+ export const invoiceWorkflowWire = z
8603
+ .strictObject({
8604
+ invoicing: invoiceWorkflowInvoicingSettingsWire.optional(),
8605
+ payment: workflowPaymentSettingsWire.optional(),
8606
+ })
8607
+ .describe('Invoice-level snapshot of the workflow configuration. Contains only the settings that are meaningful for an already-created invoice: invoicing behaviour and payment settings. Collection alignment and tax policy are gather-time / profile-wide concerns and are not included.');
8264
8608
  export const subscriptionCancelWire = z
8265
8609
  .strictObject({
8266
8610
  timing: subscriptionEditTimingWire.optional(),
@@ -8384,24 +8728,6 @@ export const updateAppRequestWire = z
8384
8728
  updateAppExternalInvoicingRequestWire,
8385
8729
  ])
8386
8730
  .describe('Request to update an installed app.');
8387
- export const invoiceWorkflowWire = z
8388
- .strictObject({
8389
- invoicing: invoiceWorkflowInvoicingSettingsWire.optional(),
8390
- payment: workflowPaymentSettingsWire.optional(),
8391
- })
8392
- .describe('Invoice-level snapshot of the workflow configuration. Contains only the settings that are meaningful for an already-created invoice: invoicing behaviour and payment settings. Collection alignment and tax policy are gather-time / profile-wide concerns and are not included.');
8393
- export const invoiceStatusDetailsWire = z
8394
- .strictObject({
8395
- immutable: z
8396
- .boolean()
8397
- .describe('Whether the invoice is immutable (i.e. cannot be modified or deleted).'),
8398
- failed: z.boolean().describe('Whether the invoice is in a failed state.'),
8399
- extended_status: z
8400
- .string()
8401
- .describe('Fine-grained internal status string providing additional workflow detail beyond the top-level status enum.'),
8402
- available_actions: invoiceAvailableActionsWire,
8403
- })
8404
- .describe('Detailed status information for a standard invoice.');
8405
8731
  export const invoiceLineDiscountsWire = z
8406
8732
  .strictObject({
8407
8733
  amount: z
@@ -8472,6 +8798,12 @@ export const priceVolumeWire = z
8472
8798
  .describe('The tiers of the volume price. At least one tier is required.'),
8473
8799
  })
8474
8800
  .describe('Volume tiered price. The maximum quantity within a period determines the per-unit price for all units in that period. When UnitConfig is present on the containing resource, tier boundaries (up_to_amount) are expressed in converted billing units.');
8801
+ export const featureUnitCostWire = z
8802
+ .discriminatedUnion('type', [
8803
+ featureManualUnitCostWire,
8804
+ featureLlmUnitCostWire,
8805
+ ])
8806
+ .describe('Per-unit cost configuration for a feature. Either a fixed manual amount or a dynamic LLM cost lookup.');
8475
8807
  export const updatePriceGraduatedWire = z
8476
8808
  .strictObject({
8477
8809
  type: z.literal('graduated').describe('The type of the price.'),
@@ -8490,12 +8822,6 @@ export const updatePriceVolumeWire = z
8490
8822
  .describe('The tiers of the volume price. At least one tier is required.'),
8491
8823
  })
8492
8824
  .describe('Volume tiered price. The maximum quantity within a period determines the per-unit price for all units in that period. When UnitConfig is present on the containing resource, tier boundaries (up_to_amount) are expressed in converted billing units.');
8493
- export const featureUnitCostWire = z
8494
- .discriminatedUnion('type', [
8495
- featureManualUnitCostWire,
8496
- featureLlmUnitCostWire,
8497
- ])
8498
- .describe('Per-unit cost configuration for a feature. Either a fixed manual amount or a dynamic LLM cost lookup.');
8499
8825
  export const pricePagePaginatedResponseWire = z
8500
8826
  .strictObject({
8501
8827
  data: z.array(llmCostPriceWire),
@@ -8596,12 +8922,9 @@ export const createChargeFlatFeeRequestWire = z
8596
8922
  tax_config: taxConfigWire.optional(),
8597
8923
  payment_term: pricePaymentTermWire,
8598
8924
  discounts: chargeFlatFeeDiscountsWire.optional(),
8599
- feature_id: z
8600
- .string()
8601
- .optional()
8602
- .describe('The feature ID associated with the charge.'),
8603
8925
  proration_configuration: rateCardProrationConfigurationWire,
8604
8926
  amount_before_proration: currencyAmountWire,
8927
+ feature: featureReferenceWire.optional(),
8605
8928
  full_service_period: closedPeriodWire.optional(),
8606
8929
  billing_period: closedPeriodWire.optional(),
8607
8930
  })
@@ -8631,6 +8954,12 @@ export const ingestedEventPaginatedResponseWire = z
8631
8954
  meta: cursorMetaWire,
8632
8955
  })
8633
8956
  .describe('Cursor paginated response.');
8957
+ export const chargeRealizationDetailedLineWire = z
8958
+ .discriminatedUnion('type', [
8959
+ chargeRealizationDetailedLineFlatFeeWire,
8960
+ chargeRealizationDetailedLineUsageBasedWire,
8961
+ ])
8962
+ .describe("A detailed (child) line type of a charge realization run. This is distinct from an invoice's own detailed lines: it represents the rated/priced breakdown produced by the realization run itself, before that breakdown is (or is not yet) reflected on an invoice line. Credit-then-invoice runs include credit allocations in these lines, while credits-only runs keep the gross rated detail.");
8634
8963
  export const currencyWire = z
8635
8964
  .discriminatedUnion('type', [currencyFiatWire, currencyCustomWire])
8636
8965
  .describe('Fiat or custom currency.');
@@ -8661,29 +8990,32 @@ export const customerPagePaginatedResponseWire = z
8661
8990
  meta: paginatedMetaWire,
8662
8991
  })
8663
8992
  .describe('Page paginated response.');
8664
- export const partyWire = z
8993
+ export const customerOrReferenceWire = z
8994
+ .union([customerWire, customerReferenceWire])
8995
+ .describe('Customer or reference.');
8996
+ export const supplierWire = z
8665
8997
  .strictObject({
8666
- id: z.string().optional().describe('Unique identifier for the party.'),
8667
- key: externalResourceKeyWire.optional(),
8668
8998
  name: z
8669
8999
  .string()
8670
9000
  .optional()
8671
9001
  .describe('Legal name or representation of the party.'),
8672
9002
  tax_id: partyTaxIdentityWire.optional(),
8673
9003
  addresses: partyAddressesWire.optional(),
9004
+ id: z.string().optional().describe('Unique identifier for the party.'),
8674
9005
  })
8675
- .describe('Party represents a person or business entity.');
8676
- export const supplierWire = z
9006
+ .describe("Snapshot of the supplier's information at the time the invoice was issued. Structurally a read-only subset of `BillingParty` (the type configured on the billing profile), so the snapshot stays aligned with the source. `key` is omitted because it is not part of the snapshotted supplier data.");
9007
+ export const partyWire = z
8677
9008
  .strictObject({
9009
+ id: z.string().optional().describe('Unique identifier for the party.'),
9010
+ key: externalResourceKeyWire.optional(),
8678
9011
  name: z
8679
9012
  .string()
8680
9013
  .optional()
8681
9014
  .describe('Legal name or representation of the party.'),
8682
9015
  tax_id: partyTaxIdentityWire.optional(),
8683
9016
  addresses: partyAddressesWire.optional(),
8684
- id: z.string().optional().describe('Unique identifier for the party.'),
8685
9017
  })
8686
- .describe("Snapshot of the supplier's information at the time the invoice was issued. Structurally a read-only subset of `BillingParty` (the type configured on the billing profile), so the snapshot stays aligned with the source. `key` is omitted because it is not part of the snapshotted supplier data.");
9018
+ .describe('Party represents a person or business entity.');
8687
9019
  export const updateSupplierWire = z
8688
9020
  .strictObject({
8689
9021
  name: z
@@ -8747,56 +9079,13 @@ export const workflowCollectionAlignmentWire = z
8747
9079
  workflowCollectionAlignmentAnchoredWire,
8748
9080
  ])
8749
9081
  .describe('The alignment for collecting the pending line items into an invoice. Defaults to subscription, which means that we are to create a new invoice every time the a subscription period starts (for in advance items) or ends (for in arrears items).');
8750
- export const chargeFlatFeeWire = z
9082
+ export const invoiceWorkflowSettingsWire = z
8751
9083
  .strictObject({
8752
- id: ulidWire,
8753
- name: z
8754
- .string()
8755
- .min(1)
8756
- .max(256)
8757
- .describe('Display name of the resource. Between 1 and 256 characters.'),
8758
- description: z
8759
- .string()
8760
- .max(1024)
8761
- .optional()
8762
- .describe('Optional description of the resource. Maximum 1024 characters.'),
8763
- labels: labelsWire.optional(),
8764
- created_at: dateTimeWire,
8765
- updated_at: dateTimeWire,
8766
- deleted_at: dateTimeWire.optional(),
8767
- type: z.literal('flat_fee').describe('The type of the charge.'),
8768
- customer: billingCustomerReferenceWire,
8769
- lifecycle_controller: lifecycleControllerWire,
8770
- subscription: subscriptionReferenceWire.optional(),
8771
- currency: currencyCodeWire,
8772
- status: chargeStatusWire,
8773
- invoice_at: dateTimeWire,
8774
- service_period: closedPeriodWire,
8775
- full_service_period: closedPeriodWire,
8776
- billing_period: closedPeriodWire,
8777
- advance_after: dateTimeWire.optional(),
8778
- unique_reference_id: z
8779
- .string()
8780
- .optional()
8781
- .describe('Unique reference ID of the charge.'),
8782
- settlement_mode: settlementModeWire,
8783
- tax_config: taxConfigWire.optional(),
8784
- payment_term: pricePaymentTermWire,
8785
- discounts: chargeFlatFeeDiscountsWire.optional(),
8786
- feature_key: z
8787
- .string()
8788
- .optional()
8789
- .describe('The feature associated with the charge, when applicable.'),
8790
- feature_id: z
8791
- .string()
8792
- .optional()
8793
- .describe('The feature ID associated with the charge.'),
8794
- proration_configuration: rateCardProrationConfigurationWire,
8795
- amount_after_proration: currencyAmountWire,
8796
- price: priceFlatWire,
8797
- system_intent: chargeFlatFeeSystemIntentWire.optional(),
9084
+ apps: invoiceWorkflowAppsReferencesWire.optional(),
9085
+ source_billing_profile: profileReferenceWire,
9086
+ workflow: invoiceWorkflowWire,
8798
9087
  })
8799
- .describe('A flat fee charge for a customer.');
9088
+ .describe('Snapshot of the billing workflow configuration captured at invoice creation.');
8800
9089
  export const taxCodePagePaginatedResponseWire = z
8801
9090
  .strictObject({
8802
9091
  data: z.array(taxCodeWire),
@@ -8980,13 +9269,6 @@ export const installedAppExternalInvoicingWire = z
8980
9269
  .describe('Default capabilities of the installed app.'),
8981
9270
  })
8982
9271
  .describe('Response of an installed app.');
8983
- export const invoiceWorkflowSettingsWire = z
8984
- .strictObject({
8985
- apps: invoiceWorkflowAppsReferencesWire.optional(),
8986
- source_billing_profile: profileReferenceWire,
8987
- workflow: invoiceWorkflowWire,
8988
- })
8989
- .describe('Snapshot of the billing workflow configuration captured at invoice creation.');
8990
9272
  export const invoiceDetailedLineWire = z
8991
9273
  .strictObject({
8992
9274
  id: ulidWire,
@@ -9034,13 +9316,6 @@ export const entitlementAccessQueryResultWire = z
9034
9316
  updated_at: dateTimeWire,
9035
9317
  })
9036
9318
  .describe('Access evaluation result for a single resolved customer.');
9037
- export const priceUsageBasedWire = z
9038
- .discriminatedUnion('type', [
9039
- priceUnitWire,
9040
- priceGraduatedWire,
9041
- priceVolumeWire,
9042
- ])
9043
- .describe('Usage-based price types for a rate card or charge. When UnitConfig is present on the object, these price types operate on billing units (i.e. post-conversion quantities), not raw metered units.');
9044
9319
  export const priceWire = z
9045
9320
  .discriminatedUnion('type', [
9046
9321
  priceFreeWire,
@@ -9050,15 +9325,13 @@ export const priceWire = z
9050
9325
  priceVolumeWire,
9051
9326
  ])
9052
9327
  .describe('Price.');
9053
- export const updatePriceWire = z
9328
+ export const priceUsageBasedWire = z
9054
9329
  .discriminatedUnion('type', [
9055
- updatePriceFreeWire,
9056
- updatePriceFlatWire,
9057
- updatePriceUnitWire,
9058
- updatePriceGraduatedWire,
9059
- updatePriceVolumeWire,
9330
+ priceUnitWire,
9331
+ priceGraduatedWire,
9332
+ priceVolumeWire,
9060
9333
  ])
9061
- .describe('Price.');
9334
+ .describe('Usage-based price types for a rate card or charge. When UnitConfig is present on the object, these price types operate on billing units (i.e. post-conversion quantities), not raw metered units.');
9062
9335
  export const featureWire = z
9063
9336
  .strictObject({
9064
9337
  id: ulidWire,
@@ -9107,6 +9380,15 @@ export const updateFeatureRequestWire = z
9107
9380
  .describe('Optional per-unit cost configuration. Use "manual" for a fixed per-unit cost, or "llm" to look up cost from the LLM cost database based on meter group-by properties. Set to `null` to clear the existing unit cost; omit to leave it unchanged.'),
9108
9381
  })
9109
9382
  .describe('Request body for updating a feature. Currently only the unit_cost field can be updated.');
9383
+ export const updatePriceWire = z
9384
+ .discriminatedUnion('type', [
9385
+ updatePriceFreeWire,
9386
+ updatePriceFlatWire,
9387
+ updatePriceUnitWire,
9388
+ updatePriceGraduatedWire,
9389
+ updatePriceVolumeWire,
9390
+ ])
9391
+ .describe('Price.');
9110
9392
  export const creditGrantPagePaginatedResponseWire = z
9111
9393
  .strictObject({
9112
9394
  data: z.array(creditGrantWire),
@@ -9162,7 +9444,43 @@ export const workflowCollectionSettingsWire = z
9162
9444
  .optional()
9163
9445
  .describe('This grace period can be used to delay the collection of the pending line items specified in alignment. This is useful, in case of multiple subscriptions having slightly different billing periods.'),
9164
9446
  })
9165
- .describe('Workflow collection specifies how to collect the pending line items for an invoice.');
9447
+ .describe('Workflow collection specifies how to collect the pending line items for an invoice.');
9448
+ export const chargeRealizationInvoiceWire = z
9449
+ .strictObject({
9450
+ id: ulidWire,
9451
+ description: z
9452
+ .string()
9453
+ .max(1024)
9454
+ .optional()
9455
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
9456
+ labels: labelsWire.optional(),
9457
+ created_at: dateTimeWire,
9458
+ updated_at: dateTimeWire,
9459
+ deleted_at: dateTimeWire.optional(),
9460
+ number: invoiceNumberWire,
9461
+ currency: currencyCodeWire,
9462
+ supplier: supplierWire,
9463
+ totals: totalsWire,
9464
+ service_period: closedPeriodWire,
9465
+ validation_issues: z
9466
+ .array(invoiceValidationIssueWire)
9467
+ .optional()
9468
+ .describe('Validation issues found during invoice processing. Present only when there are one or more validation findings. An empty list is omitted.'),
9469
+ external_references: invoiceExternalReferencesWire.optional(),
9470
+ type: z
9471
+ .literal('standard')
9472
+ .describe('Discriminator field identifying this as a standard invoice.'),
9473
+ status: invoiceStandardStatusWire,
9474
+ status_details: invoiceStatusDetailsWire,
9475
+ issued_at: dateTimeWire.optional(),
9476
+ draft_until: dateTimeWire.optional(),
9477
+ quantity_snapshotted_at: dateTimeWire.optional(),
9478
+ collection_at: dateTimeWire.optional(),
9479
+ due_at: dateTimeWire.optional(),
9480
+ sent_to_customer_at: dateTimeWire.optional(),
9481
+ workflow: invoiceWorkflowSettingsWire,
9482
+ })
9483
+ .describe('The invoice a charge realization was booked to, embedded as a header. Matches the standard invoice entity, except that it carries no `customer` snapshot (the charge context already identifies the customer) and `lines` are never populated (the realization itself is the line-level breakdown). The shared invoice contract stays untouched: this model exists so the charges API can slim the embedding without loosening the invoices API.');
9166
9484
  export const appWire = z
9167
9485
  .discriminatedUnion('type', [
9168
9486
  appStripeWire,
@@ -9188,6 +9506,41 @@ export const entitlementAccessQueryResponseWire = z
9188
9506
  meta: cursorMetaWire,
9189
9507
  })
9190
9508
  .describe('Response of the entitlement access query.');
9509
+ export const rateCardWire = z
9510
+ .strictObject({
9511
+ name: z
9512
+ .string()
9513
+ .min(1)
9514
+ .max(256)
9515
+ .describe('Display name of the resource. Between 1 and 256 characters.'),
9516
+ description: z
9517
+ .string()
9518
+ .max(1024)
9519
+ .optional()
9520
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
9521
+ labels: labelsWire.optional(),
9522
+ key: resourceKeyWire,
9523
+ feature: featureReferenceWire.optional(),
9524
+ currency: billingCurrencyCodeWire.optional(),
9525
+ billing_cadence: iso8601DurationWire.optional(),
9526
+ price: priceWire,
9527
+ unit_config: unitConfigWire.optional(),
9528
+ payment_term: pricePaymentTermWire.optional(),
9529
+ commitments: spendCommitmentsWire.optional(),
9530
+ discounts: rateCardDiscountsWire.optional(),
9531
+ tax_config: rateCardTaxConfigWire.optional(),
9532
+ entitlement: rateCardEntitlementWire.optional(),
9533
+ })
9534
+ .describe('A rate card defines the pricing and entitlement of a feature or service.');
9535
+ export const invoiceLineRateCardWire = z
9536
+ .strictObject({
9537
+ price: priceWire,
9538
+ tax_config: rateCardTaxConfigWire.optional(),
9539
+ feature_key: resourceKeyWire.optional(),
9540
+ discounts: rateCardDiscountsWire.optional(),
9541
+ unit_config: unitConfigWire.optional(),
9542
+ })
9543
+ .describe('Rate card configuration snapshot for a usage-based invoice line.');
9191
9544
  export const chargeUsageBasedSystemIntentWire = z
9192
9545
  .strictObject({
9193
9546
  name: z
@@ -9236,51 +9589,23 @@ export const createChargeUsageBasedRequestWire = z
9236
9589
  settlement_mode: settlementModeWire,
9237
9590
  tax_config: taxConfigWire.optional(),
9238
9591
  discounts: rateCardDiscountsWire.optional(),
9239
- feature_id: z
9240
- .string()
9241
- .describe('The feature ID associated with the charge.'),
9242
9592
  price: priceUsageBasedWire,
9243
9593
  commitments: spendCommitmentsWire.optional(),
9244
9594
  unit_config: unitConfigWire.optional(),
9595
+ feature: featureReferenceWire,
9245
9596
  full_service_period: closedPeriodWire.optional(),
9246
9597
  billing_period: closedPeriodWire.optional(),
9247
9598
  })
9248
9599
  .describe('Usage-based charge create request.');
9249
- export const rateCardWire = z
9250
- .strictObject({
9251
- name: z
9252
- .string()
9253
- .min(1)
9254
- .max(256)
9255
- .describe('Display name of the resource. Between 1 and 256 characters.'),
9256
- description: z
9257
- .string()
9258
- .max(1024)
9259
- .optional()
9260
- .describe('Optional description of the resource. Maximum 1024 characters.'),
9261
- labels: labelsWire.optional(),
9262
- key: resourceKeyWire,
9263
- feature: featureReferenceWire.optional(),
9264
- currency: billingCurrencyCodeWire.optional(),
9265
- billing_cadence: iso8601DurationWire.optional(),
9266
- price: priceWire,
9267
- unit_config: unitConfigWire.optional(),
9268
- payment_term: pricePaymentTermWire.optional(),
9269
- commitments: spendCommitmentsWire.optional(),
9270
- discounts: rateCardDiscountsWire.optional(),
9271
- tax_config: rateCardTaxConfigWire.optional(),
9272
- entitlement: rateCardEntitlementWire.optional(),
9273
- })
9274
- .describe('A rate card defines the pricing and entitlement of a feature or service.');
9275
- export const invoiceLineRateCardWire = z
9600
+ export const featureOrReferenceWire = z
9601
+ .union([featureWire, featureReferenceWire])
9602
+ .describe('Feature or reference.');
9603
+ export const featurePagePaginatedResponseWire = z
9276
9604
  .strictObject({
9277
- price: priceWire,
9278
- tax_config: rateCardTaxConfigWire.optional(),
9279
- feature_key: resourceKeyWire.optional(),
9280
- discounts: rateCardDiscountsWire.optional(),
9281
- unit_config: unitConfigWire.optional(),
9605
+ data: z.array(featureWire),
9606
+ meta: paginatedMetaWire,
9282
9607
  })
9283
- .describe('Rate card configuration snapshot for a usage-based invoice line.');
9608
+ .describe('Page paginated response.');
9284
9609
  export const updateInvoiceLineRateCardWire = z
9285
9610
  .strictObject({
9286
9611
  price: updatePriceWire,
@@ -9289,12 +9614,6 @@ export const updateInvoiceLineRateCardWire = z
9289
9614
  discounts: updateDiscountsWire.optional(),
9290
9615
  })
9291
9616
  .describe('Rate card configuration snapshot for a usage-based invoice line.');
9292
- export const featurePagePaginatedResponseWire = z
9293
- .strictObject({
9294
- data: z.array(featureWire),
9295
- meta: paginatedMetaWire,
9296
- })
9297
- .describe('Page paginated response.');
9298
9617
  export const workflowWire = z
9299
9618
  .strictObject({
9300
9619
  collection: workflowCollectionSettingsWire.optional(),
@@ -9303,6 +9622,9 @@ export const workflowWire = z
9303
9622
  tax: workflowTaxSettingsWire.optional(),
9304
9623
  })
9305
9624
  .describe('Billing workflow settings.');
9625
+ export const chargeRealizationInvoiceOrReferenceWire = z
9626
+ .union([chargeRealizationInvoiceWire, chargeRealizationInvoiceReferenceWire])
9627
+ .describe('ChargeRealizationInvoice or reference.');
9306
9628
  export const appPagePaginatedResponseWire = z
9307
9629
  .strictObject({
9308
9630
  data: z.array(appWire),
@@ -9316,58 +9638,6 @@ export const profileAppsWire = z
9316
9638
  payment: appWire,
9317
9639
  })
9318
9640
  .describe('Applications used by a billing profile.');
9319
- export const chargeUsageBasedWire = z
9320
- .strictObject({
9321
- id: ulidWire,
9322
- name: z
9323
- .string()
9324
- .min(1)
9325
- .max(256)
9326
- .describe('Display name of the resource. Between 1 and 256 characters.'),
9327
- description: z
9328
- .string()
9329
- .max(1024)
9330
- .optional()
9331
- .describe('Optional description of the resource. Maximum 1024 characters.'),
9332
- labels: labelsWire.optional(),
9333
- created_at: dateTimeWire,
9334
- updated_at: dateTimeWire,
9335
- deleted_at: dateTimeWire.optional(),
9336
- type: z.literal('usage_based').describe('The type of the charge.'),
9337
- customer: billingCustomerReferenceWire,
9338
- lifecycle_controller: lifecycleControllerWire,
9339
- subscription: subscriptionReferenceWire.optional(),
9340
- currency: currencyCodeWire,
9341
- status: chargeStatusWire,
9342
- invoice_at: dateTimeWire,
9343
- service_period: closedPeriodWire,
9344
- full_service_period: closedPeriodWire,
9345
- billing_period: closedPeriodWire,
9346
- advance_after: dateTimeWire.optional(),
9347
- unique_reference_id: z
9348
- .string()
9349
- .optional()
9350
- .describe('Unique reference ID of the charge.'),
9351
- settlement_mode: settlementModeWire,
9352
- tax_config: taxConfigWire.optional(),
9353
- discounts: rateCardDiscountsWire.optional(),
9354
- feature_key: z.string().describe('The feature associated with the charge.'),
9355
- feature_id: z
9356
- .string()
9357
- .describe('The feature ID associated with the charge.'),
9358
- totals: chargeTotalsWire,
9359
- price: priceUsageBasedWire,
9360
- commitments: spendCommitmentsWire.optional(),
9361
- unit_config: unitConfigWire.optional(),
9362
- system_intent: chargeUsageBasedSystemIntentWire.optional(),
9363
- })
9364
- .describe('A usage-based charge for a customer.');
9365
- export const createChargeRequestWire = z
9366
- .discriminatedUnion('type', [
9367
- createChargeFlatFeeRequestWire,
9368
- createChargeUsageBasedRequestWire,
9369
- ])
9370
- .describe('Customer charge.');
9371
9641
  export const subscriptionItemWire = z
9372
9642
  .strictObject({
9373
9643
  id: ulidWire,
@@ -9511,6 +9781,12 @@ export const invoiceStandardLineWire = z
9511
9781
  charge: chargeReferenceWire.optional(),
9512
9782
  })
9513
9783
  .describe('A top-level line item on an invoice. Each line represents a single charge, typically associated with a rate card from a subscription. Detailed (child) lines are nested under `detailed_lines` when present.');
9784
+ export const createChargeRequestWire = z
9785
+ .discriminatedUnion('type', [
9786
+ createChargeFlatFeeRequestWire,
9787
+ createChargeUsageBasedRequestWire,
9788
+ ])
9789
+ .describe('Customer charge.');
9514
9790
  export const updateInvoiceStandardLineWire = z
9515
9791
  .strictObject({
9516
9792
  name: z
@@ -9592,9 +9868,28 @@ export const upsertBillingProfileRequestWire = z
9592
9868
  default: z.boolean().describe('Whether this is the default profile.'),
9593
9869
  })
9594
9870
  .describe('BillingProfile upsert request.');
9595
- export const chargeWire = z
9596
- .discriminatedUnion('type', [chargeFlatFeeWire, chargeUsageBasedWire])
9597
- .describe('Customer charge.');
9871
+ export const chargeRealizationWire = z
9872
+ .strictObject({
9873
+ id: z
9874
+ .string()
9875
+ .optional()
9876
+ .describe('The ID of the realization run. Not present on `outstanding` entries, which are projections rather than persisted runs.'),
9877
+ line_id: z
9878
+ .string()
9879
+ .optional()
9880
+ .describe('The ID of the invoice line this realization was booked to, when the realization has been invoiced.'),
9881
+ invoice: chargeRealizationInvoiceOrReferenceWire.optional(),
9882
+ type: chargeRealizationTypeWire,
9883
+ service_period: closedPeriodWire,
9884
+ usage: numericWire.optional(),
9885
+ payment: chargeRealizationPaymentWire.optional(),
9886
+ totals: totalsWire.optional(),
9887
+ detailed_lines: z
9888
+ .array(chargeRealizationDetailedLineWire)
9889
+ .optional()
9890
+ .describe('The detailed (rated) lines produced by the realization run. Requires the `realization.detailed_lines` expand.'),
9891
+ })
9892
+ .describe("A realization run of a charge. `totals` and `detailed_lines` are only populated with the `realization.totals` and `realization.detailed_lines` expands, respectively, since computing them requires re-deriving the run's rated breakdown. `invoice` is an ID reference unless the `realization.invoice` expand is used, which resolves it to the invoice header of the run's booked line: the invoice entity without its `lines` and without the `customer` snapshot (the charge itself already identifies the customer).");
9598
9893
  export const subscriptionPhaseWire = z
9599
9894
  .strictObject({
9600
9895
  id: ulidWire,
@@ -9764,12 +10059,6 @@ export const profilePagePaginatedResponseWire = z
9764
10059
  meta: paginatedMetaWire,
9765
10060
  })
9766
10061
  .describe('Page paginated response.');
9767
- export const chargePagePaginatedResponseWire = z
9768
- .strictObject({
9769
- data: z.array(chargeWire),
9770
- meta: paginatedMetaWire,
9771
- })
9772
- .describe('Page paginated response.');
9773
10062
  export const subscriptionWire = z
9774
10063
  .strictObject({
9775
10064
  id: ulidWire,
@@ -9881,6 +10170,9 @@ export const updateInvoiceStandardRequestWire = z
9881
10170
  .describe('Line items on this invoice. Always returned on single-resource GET; omitted on list endpoints unless explicitly expanded. Editable via update: existing lines are matched by `id`, lines without an `id` are created, and lines present on the invoice but omitted from the update request are deleted. Detailed (child) lines are always computed and cannot be edited directly.'),
9882
10171
  })
9883
10172
  .describe('InvoiceStandard update request.');
10173
+ export const subscriptionOrReferenceWire = z
10174
+ .union([subscriptionWire, subscriptionReferenceWire])
10175
+ .describe('Subscription or reference.');
9884
10176
  export const subscriptionPagePaginatedResponseWire = z
9885
10177
  .strictObject({
9886
10178
  data: z.array(subscriptionWire),
@@ -9899,12 +10191,114 @@ export const invoiceWire = z
9899
10191
  export const updateInvoiceRequestWire = z
9900
10192
  .discriminatedUnion('type', [updateInvoiceStandardRequestWire])
9901
10193
  .describe('UpdateInvoiceRequest update request.');
10194
+ export const chargeFlatFeeWire = z
10195
+ .strictObject({
10196
+ id: ulidWire,
10197
+ name: z
10198
+ .string()
10199
+ .min(1)
10200
+ .max(256)
10201
+ .describe('Display name of the resource. Between 1 and 256 characters.'),
10202
+ description: z
10203
+ .string()
10204
+ .max(1024)
10205
+ .optional()
10206
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
10207
+ labels: labelsWire.optional(),
10208
+ created_at: dateTimeWire,
10209
+ updated_at: dateTimeWire,
10210
+ deleted_at: dateTimeWire.optional(),
10211
+ type: z.literal('flat_fee').describe('The type of the charge.'),
10212
+ customer: customerOrReferenceWire,
10213
+ lifecycle_controller: lifecycleControllerWire,
10214
+ subscription: subscriptionOrReferenceWire.optional(),
10215
+ currency: currencyCodeWire,
10216
+ status: chargeStatusWire,
10217
+ invoice_at: dateTimeWire,
10218
+ service_period: closedPeriodWire,
10219
+ full_service_period: closedPeriodWire,
10220
+ billing_period: closedPeriodWire,
10221
+ advance_after: dateTimeWire.optional(),
10222
+ unique_reference_id: z
10223
+ .string()
10224
+ .optional()
10225
+ .describe('Unique reference ID of the charge.'),
10226
+ settlement_mode: settlementModeWire,
10227
+ tax_config: taxConfigWire.optional(),
10228
+ realizations: z
10229
+ .array(chargeRealizationWire)
10230
+ .describe('The realization runs of the charge, sorted by `created_at`.'),
10231
+ payment_term: pricePaymentTermWire,
10232
+ discounts: chargeFlatFeeDiscountsWire.optional(),
10233
+ feature: featureOrReferenceWire.optional(),
10234
+ proration_configuration: rateCardProrationConfigurationWire,
10235
+ amount_after_proration: currencyAmountWire,
10236
+ price: priceFlatWire,
10237
+ system_intent: chargeFlatFeeSystemIntentWire.optional(),
10238
+ })
10239
+ .describe('A flat fee charge for a customer.');
10240
+ export const chargeUsageBasedWire = z
10241
+ .strictObject({
10242
+ id: ulidWire,
10243
+ name: z
10244
+ .string()
10245
+ .min(1)
10246
+ .max(256)
10247
+ .describe('Display name of the resource. Between 1 and 256 characters.'),
10248
+ description: z
10249
+ .string()
10250
+ .max(1024)
10251
+ .optional()
10252
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
10253
+ labels: labelsWire.optional(),
10254
+ created_at: dateTimeWire,
10255
+ updated_at: dateTimeWire,
10256
+ deleted_at: dateTimeWire.optional(),
10257
+ type: z.literal('usage_based').describe('The type of the charge.'),
10258
+ customer: customerOrReferenceWire,
10259
+ lifecycle_controller: lifecycleControllerWire,
10260
+ subscription: subscriptionOrReferenceWire.optional(),
10261
+ currency: currencyCodeWire,
10262
+ status: chargeStatusWire,
10263
+ invoice_at: dateTimeWire,
10264
+ service_period: closedPeriodWire,
10265
+ full_service_period: closedPeriodWire,
10266
+ billing_period: closedPeriodWire,
10267
+ advance_after: dateTimeWire.optional(),
10268
+ unique_reference_id: z
10269
+ .string()
10270
+ .optional()
10271
+ .describe('Unique reference ID of the charge.'),
10272
+ settlement_mode: settlementModeWire,
10273
+ tax_config: taxConfigWire.optional(),
10274
+ realizations: z
10275
+ .array(chargeRealizationWire)
10276
+ .describe('The realization runs of the charge, sorted by `created_at`.'),
10277
+ discounts: rateCardDiscountsWire.optional(),
10278
+ feature: featureOrReferenceWire,
10279
+ totals: chargeTotalsWire,
10280
+ usage: numericWire.optional(),
10281
+ price: priceUsageBasedWire,
10282
+ commitments: spendCommitmentsWire.optional(),
10283
+ unit_config: unitConfigWire.optional(),
10284
+ system_intent: chargeUsageBasedSystemIntentWire.optional(),
10285
+ })
10286
+ .describe('A usage-based charge for a customer.');
9902
10287
  export const invoicePagePaginatedResponseWire = z
9903
10288
  .strictObject({
9904
10289
  data: z.array(invoiceWire),
9905
10290
  meta: paginatedMetaWire,
9906
10291
  })
9907
10292
  .describe('Page paginated response.');
10293
+ export const chargeWire = z
10294
+ .discriminatedUnion('type', [chargeFlatFeeWire, chargeUsageBasedWire])
10295
+ .describe('Customer charge.');
10296
+ export const chargePagePaginatedResponseWire = z
10297
+ .strictObject({
10298
+ data: z.array(chargeWire),
10299
+ meta: paginatedMetaWire,
10300
+ })
10301
+ .describe('Page paginated response.');
9908
10302
  export const listMeteringEventsQueryParamsWire = z.object({
9909
10303
  page: cursorPaginationQueryPageWire.optional(),
9910
10304
  filter: listEventsParamsFilterWire.optional(),
@@ -10121,7 +10515,7 @@ export const listCustomerChargesQueryParamsWire = z.object({
10121
10515
  expand: z
10122
10516
  .array(chargesExpandWire)
10123
10517
  .optional()
10124
- .describe("Expand full objects for referenced entities. Supported values are: - `real_time_usage`: Expand the charge's real-time usage."),
10518
+ .describe("Expand full objects for referenced entities. Supported values are: - `real_time_usage`: Expand the charge's real-time usage; it sets the `usage` and the `totals.realtime` fields. - `customer`: Expand the charge's customer to the complete entity. - `feature`: Expand the charge's feature to the complete entity. - `subscription`: Expand the charge's subscription to the complete entity. - `realization.invoice`: Expand each realization's invoice to the complete entity. - `realization.totals`: Expand each realization run's `totals`. - `realization.detailed_lines`: Expand each realization run's `detailed_lines`."),
10125
10519
  });
10126
10520
  export const listCustomerChargesResponseWire = z.strictObject({
10127
10521
  data: z.array(chargeWire),