@openmeter/client 1.0.0-beta-32aecbad2ac6 → 1.0.0-beta-8b2581c1dca5

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.
@@ -956,6 +956,409 @@ export const notificationEventDeliveryAttemptResponse = z
956
956
  .describe('The URL the event was delivered to. Only set for webhook channels.'),
957
957
  })
958
958
  .describe('The response the recipient returned for a delivery attempt. For webhook channels this is the HTTP response.');
959
+ export const notificationEventV1Metadata = z
960
+ .record(z.string(), z.string())
961
+ .describe('Set of key-value pairs. Metadata can be used to store additional information about a resource.');
962
+ export const notificationEventV1Annotations = z
963
+ .record(z.string(), z.unknown())
964
+ .describe('Set of key-value pairs managed by the system. Cannot be modified by user.');
965
+ export const notificationEventV1Period = z
966
+ .object({
967
+ from: z.date().describe('Period start time.'),
968
+ to: z.date().describe('Period end time.'),
969
+ })
970
+ .describe('A period with a start and end time.');
971
+ export const notificationEventV1RecurringPeriodIntervalEnum = z
972
+ .enum(['DAY', 'WEEK', 'MONTH', 'YEAR'])
973
+ .describe('The unit of time for the interval. One of: `day`, `week`, `month`, or `year`.');
974
+ export const notificationEventV1FilterString = z
975
+ .object({
976
+ $eq: z
977
+ .string()
978
+ .nullable()
979
+ .optional()
980
+ .describe('The field must be equal to the provided value.'),
981
+ $ne: z
982
+ .string()
983
+ .nullable()
984
+ .optional()
985
+ .describe('The field must not be equal to the provided value.'),
986
+ $in: z
987
+ .array(z.string())
988
+ .nullable()
989
+ .optional()
990
+ .describe('The field must be in the provided list of values.'),
991
+ $nin: z
992
+ .array(z.string())
993
+ .nullable()
994
+ .optional()
995
+ .describe('The field must not be in the provided list of values.'),
996
+ $like: z
997
+ .string()
998
+ .nullable()
999
+ .optional()
1000
+ .describe('The field must match the provided value.'),
1001
+ $nlike: z
1002
+ .string()
1003
+ .nullable()
1004
+ .optional()
1005
+ .describe('The field must not match the provided value.'),
1006
+ $ilike: z
1007
+ .string()
1008
+ .nullable()
1009
+ .optional()
1010
+ .describe('The field must match the provided value, ignoring case.'),
1011
+ $nilike: z
1012
+ .string()
1013
+ .nullable()
1014
+ .optional()
1015
+ .describe('The field must not match the provided value, ignoring case.'),
1016
+ $gt: z
1017
+ .string()
1018
+ .nullable()
1019
+ .optional()
1020
+ .describe('The field must be greater than the provided value.'),
1021
+ $gte: z
1022
+ .string()
1023
+ .nullable()
1024
+ .optional()
1025
+ .describe('The field must be greater than or equal to the provided value.'),
1026
+ $lt: z
1027
+ .string()
1028
+ .nullable()
1029
+ .optional()
1030
+ .describe('The field must be less than the provided value.'),
1031
+ $lte: z
1032
+ .string()
1033
+ .nullable()
1034
+ .optional()
1035
+ .describe('The field must be less than or equal to the provided value.'),
1036
+ get $and() {
1037
+ return z
1038
+ .array(notificationEventV1FilterString)
1039
+ .nullable()
1040
+ .optional()
1041
+ .describe('Provide a list of filters to be combined with a logical AND.');
1042
+ },
1043
+ get $or() {
1044
+ return z
1045
+ .array(notificationEventV1FilterString)
1046
+ .nullable()
1047
+ .optional()
1048
+ .describe('Provide a list of filters to be combined with a logical OR.');
1049
+ },
1050
+ })
1051
+ .describe('A filter for a string field.');
1052
+ export const notificationEventV1Numeric = z
1053
+ .string()
1054
+ .regex(new RegExp('^\\-?[0-9]+(\\.[0-9]+)?$'))
1055
+ .describe('Numeric represents an arbitrary precision number.');
1056
+ export const notificationEventV1Subject = z
1057
+ .object({
1058
+ createdAt: z.date().describe('Timestamp of when the resource was created.'),
1059
+ updatedAt: z
1060
+ .date()
1061
+ .describe('Timestamp of when the resource was last updated.'),
1062
+ deletedAt: z
1063
+ .date()
1064
+ .optional()
1065
+ .describe('Timestamp of when the resource was permanently deleted.'),
1066
+ id: z.string().describe('A unique identifier for the subject.'),
1067
+ key: z
1068
+ .string()
1069
+ .describe('A unique, human-readable identifier for the subject. This is typically a database ID or a customer key.'),
1070
+ displayName: z
1071
+ .string()
1072
+ .nullable()
1073
+ .optional()
1074
+ .describe('A human-readable display name for the subject.'),
1075
+ metadata: z
1076
+ .record(z.string(), z.unknown())
1077
+ .nullable()
1078
+ .optional()
1079
+ .describe('Metadata for the subject.'),
1080
+ currentPeriodStart: z
1081
+ .date()
1082
+ .optional()
1083
+ .describe('The start of the current period for the subject.'),
1084
+ currentPeriodEnd: z
1085
+ .date()
1086
+ .optional()
1087
+ .describe('The end of the current period for the subject.'),
1088
+ stripeCustomerId: z
1089
+ .string()
1090
+ .nullable()
1091
+ .optional()
1092
+ .describe('The Stripe customer ID for the subject.'),
1093
+ })
1094
+ .describe('A subject is a unique identifier for a usage attribution by its key. Subjects only exist in the concept of metering. Subjects are optional to create and work as an enrichment for the subject key like displayName, metadata, etc. Subjects are useful when you are reporting usage events with your own database ID but want to enrich the subject with a human-readable name or metadata. For most use cases, a subject is equivalent to a customer. ⚠️ **Deprecated**: Subjects as managable entities are being depracated, use customers with subject key usage attribution instead.');
1095
+ export const notificationEventV1EntitlementValue = z
1096
+ .object({
1097
+ hasAccess: z
1098
+ .boolean()
1099
+ .describe('Whether the subject has access to the feature. Shared accross all entitlement types.'),
1100
+ balance: z
1101
+ .number()
1102
+ .optional()
1103
+ .describe("Only available for metered entitlements. Metered entitlements are built around a balance calculation where feature usage is deducted from the issued grants. Balance represents the remaining balance of the entitlement, it's value never turns negative."),
1104
+ usage: z
1105
+ .number()
1106
+ .optional()
1107
+ .describe('Only available for metered entitlements. Returns the total feature usage in the current period.'),
1108
+ overage: z
1109
+ .number()
1110
+ .optional()
1111
+ .describe("Only available for metered entitlements. Overage represents the usage that wasn't covered by grants, e.g. if the subject had a total feature usage of 100 in the period but they were only granted 80, there would be 20 overage."),
1112
+ totalAvailableGrantAmount: z
1113
+ .number()
1114
+ .optional()
1115
+ .describe('Only available for metered entitlements. The summed amount of all grant active at query time PLUS the used amount of since inactive grants.'),
1116
+ config: z
1117
+ .string()
1118
+ .optional()
1119
+ .describe('Only available for static entitlements. The JSON parsable config of the entitlement.'),
1120
+ })
1121
+ .describe('Entitlements are the core of OpenMeter access management. They define access to features for subjects. Entitlements can be metered, boolean, or static.');
1122
+ export const notificationEventV1CustomerUsageAttribution = z
1123
+ .object({
1124
+ subjectKeys: z
1125
+ .array(z.string())
1126
+ .nullable()
1127
+ .describe('The subjects that are attributed to the customer. Can be empty when no subjects are associated with the customer.'),
1128
+ })
1129
+ .describe('Mapping to attribute metered usage to the customer. One customer can have zero or more subjects, but one subject can only belong to one customer.');
1130
+ export const notificationEventV1CurrencyCode = z
1131
+ .string()
1132
+ .min(3)
1133
+ .max(3)
1134
+ .regex(new RegExp('^[A-Z]{3}$'))
1135
+ .describe('Three-letter [ISO4217](https://www.iso.org/iso-4217-currency-codes.html) currency code. Custom three-letter currency codes are also supported for convenience.');
1136
+ export const notificationEventV1CountryCode = z
1137
+ .string()
1138
+ .min(2)
1139
+ .max(2)
1140
+ .regex(new RegExp('^[A-Z]{2}$'))
1141
+ .describe('[ISO 3166-1](https://www.iso.org/iso-3166-country-codes.html) alpha-2 country code. Custom two-letter country codes are also supported for convenience.');
1142
+ export const notificationEventV1Alignment = z
1143
+ .object({
1144
+ billablesMustAlign: z
1145
+ .boolean()
1146
+ .optional()
1147
+ .describe("Whether all Billable items and RateCards must align. Alignment means the Price's BillingCadence must align for both duration and anchor time."),
1148
+ })
1149
+ .describe('Alignment configuration for a plan or subscription.');
1150
+ export const notificationEventV1SubscriptionStatus = z
1151
+ .enum(['active', 'inactive', 'canceled', 'scheduled'])
1152
+ .describe('Subscription status.');
1153
+ export const notificationEventV1PlanReference = z
1154
+ .object({
1155
+ id: z
1156
+ .string()
1157
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
1158
+ .describe('The plan ID.'),
1159
+ key: z
1160
+ .string()
1161
+ .min(1)
1162
+ .max(64)
1163
+ .regex(new RegExp('^[a-z0-9]+(?:_[a-z0-9]+)*$'))
1164
+ .describe('The plan key.'),
1165
+ version: z.number().int().describe('The plan version.'),
1166
+ })
1167
+ .describe('References an exact plan.');
1168
+ export const notificationEventV1SubscriptionCostBasisMode = z
1169
+ .enum(['dynamic', 'pinned'])
1170
+ .describe('Controls how custom-currency cost bases are selected for the subscription.');
1171
+ export const notificationEventV1ProRatingMode = z
1172
+ .enum(['prorate_prices'])
1173
+ .describe('Pro-rating mode options for handling billing period changes.');
1174
+ export const notificationEventV1BillingSettlementMode = z
1175
+ .enum(['credit_then_invoice', 'credit_only'])
1176
+ .describe('The settlement mode of a plan. It determines how the billing system generates invoices and credits for the subscriptions using this plan. - credit_then_invoice: credits from the previous billing period are applied first, then the remaining balance is invoiced. This is the default and most common settlement mode. - credit_only: only credits from the previous billing period are generated and applied. No invoices are generated for the subscription.');
1177
+ export const notificationEventV1RuleBalanceThresholdValueType = z
1178
+ .enum([
1179
+ 'PERCENT',
1180
+ 'NUMBER',
1181
+ 'balance_value',
1182
+ 'usage_percentage',
1183
+ 'usage_value',
1184
+ ])
1185
+ .describe('Type of the rule in the balance threshold specification: - `balance_value`: threshold defined by the remaining balance value based on usage and the total of grants in the current usage period - `usage_percentage`: threshold defined by the usage percentage compared to the total of grants in the current usage period - `usage_value`: threshold defined by the usage value in the current usage period - `NUMBER` (**deprecated**): see `usage_value` - `PERCENT` (**deprecated**): see `usage_percentage`');
1186
+ export const notificationEventV1InvoiceType = z
1187
+ .enum(['standard', 'credit_note'])
1188
+ .describe('InvoiceType represents the type of invoice. The type of invoice determines the purpose of the invoice and how it should be handled.');
1189
+ export const notificationEventV1BillingTaxIdentificationCode = z
1190
+ .string()
1191
+ .min(1)
1192
+ .max(32)
1193
+ .describe('TaxIdentificationCode is a normalized tax code shown on the original identity document.');
1194
+ export const notificationEventV1InvoiceNumber = z
1195
+ .string()
1196
+ .min(1)
1197
+ .max(256)
1198
+ .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)');
1199
+ export const notificationEventV1InvoiceDocumentRefType = z
1200
+ .enum(['credit_note_original_invoice'])
1201
+ .describe('InvoiceDocumentRefType defines the type of document that is being referenced.');
1202
+ export const notificationEventV1InvoiceStatus = z
1203
+ .enum([
1204
+ 'gathering',
1205
+ 'draft',
1206
+ 'issuing',
1207
+ 'issued',
1208
+ 'payment_processing',
1209
+ 'overdue',
1210
+ 'paid',
1211
+ 'uncollectible',
1212
+ 'voided',
1213
+ ])
1214
+ .describe('InvoiceStatus describes the status of an invoice.');
1215
+ export const notificationEventV1InvoiceAvailableActionDetails = z
1216
+ .object({
1217
+ resultingState: z
1218
+ .string()
1219
+ .describe('The state the invoice will reach if the action is activated and all intermediate steps are successful. For example advancing a draft_created invoice will result in a draft_manual_approval_needed invoice.'),
1220
+ })
1221
+ .describe('InvoiceAvailableActionInvoiceDetails represents the details of the invoice action for non-gathering invoices.');
1222
+ export const notificationEventV1InvoiceAvailableActionInvoiceDetails = z
1223
+ .object({})
1224
+ .describe('InvoiceAvailableActionInvoiceDetails represents the details of the invoice action for gathering invoices.');
1225
+ export const notificationEventV1AppType = z
1226
+ .enum(['stripe', 'sandbox', 'custom_invoicing'])
1227
+ .describe('Type of the app.');
1228
+ export const notificationEventV1AppCapabilityType = z
1229
+ .enum([
1230
+ 'reportUsage',
1231
+ 'reportEvents',
1232
+ 'calculateTax',
1233
+ 'invoiceCustomers',
1234
+ 'collectPayments',
1235
+ ])
1236
+ .describe('App capability type.');
1237
+ export const notificationEventV1InstallMethod = z
1238
+ .enum(['with_oauth2', 'with_api_key', 'no_credentials_required'])
1239
+ .describe('Install method of the application.');
1240
+ export const notificationEventV1AppStatus = z
1241
+ .enum(['ready', 'unauthorized'])
1242
+ .describe('App installed status.');
1243
+ export const notificationEventV1BillingWorkflowCollectionAlignmentSubscription = z
1244
+ .object({
1245
+ type: z.literal('subscription').describe('The type of alignment.'),
1246
+ })
1247
+ .describe('BillingWorkflowCollectionAlignmentSubscription specifies the alignment for collecting the pending line items into an invoice.');
1248
+ export const notificationEventV1BillingWorkflowInvoicingSubscriptionEndProrationMode = z
1249
+ .enum(['bill_full_period', 'bill_actual_period'])
1250
+ .describe('Billing workflow subscription end proration mode.');
1251
+ export const notificationEventV1TaxBehavior = z
1252
+ .enum(['inclusive', 'exclusive'])
1253
+ .describe('Tax behavior. This enum is used to specify whether tax is included in the price or excluded from the price.');
1254
+ export const notificationEventV1StripeTaxConfig = z
1255
+ .object({
1256
+ code: z
1257
+ .string()
1258
+ .regex(new RegExp('^txcd_\\d{8}$'))
1259
+ .describe('Product tax code. See: https://docs.stripe.com/tax/tax-codes'),
1260
+ })
1261
+ .describe('The tax config for Stripe.');
1262
+ export const notificationEventV1CustomInvoicingTaxConfig = z
1263
+ .object({
1264
+ code: z
1265
+ .string()
1266
+ .describe('Tax code. The tax code should be interpreted by the custom invoicing provider.'),
1267
+ })
1268
+ .describe('Custom invoicing tax config.');
1269
+ export const notificationEventV1CollectionMethod = z
1270
+ .enum(['charge_automatically', 'send_invoice'])
1271
+ .describe('CollectionMethod specifies how the invoice should be collected (automatic vs manual)');
1272
+ export const notificationEventV1BillingWorkflowTaxSettings = z
1273
+ .object({
1274
+ enabled: z
1275
+ .boolean()
1276
+ .optional()
1277
+ .describe('Enable automatic tax calculation when tax is supported by the app. For example, with Stripe Invoicing when enabled, tax is calculated via Stripe Tax.'),
1278
+ enforced: z
1279
+ .boolean()
1280
+ .optional()
1281
+ .describe('Enforce tax calculation when tax is supported by the app. When enabled, OpenMeter will not allow to create an invoice without tax calculation. Enforcement is different per apps, for example, Stripe app requires customer to have a tax location when starting a paid subscription.'),
1282
+ })
1283
+ .describe('BillingWorkflowTaxSettings represents the tax settings for a billing workflow');
1284
+ export const notificationEventV1InvoiceLineManagedBy = z
1285
+ .enum(['subscription', 'system', 'manual'])
1286
+ .describe('InvoiceLineManagedBy specifies who manages the line.');
1287
+ export const notificationEventV1InvoiceLineStatus = z
1288
+ .enum(['valid', 'detailed', 'split'])
1289
+ .describe('Line status specifies the status of the line.');
1290
+ export const notificationEventV1DiscountReasonMaximumSpend = z
1291
+ .object({
1292
+ type: z.literal('maximum_spend').describe('type.'),
1293
+ })
1294
+ .describe('The reason for the discount is a maximum spend.');
1295
+ export const notificationEventV1Percentage = z
1296
+ .number()
1297
+ .describe('Numeric representation of a percentage 50% is represented as 50');
1298
+ export const notificationEventV1InvoiceLineAppExternalIds = z
1299
+ .object({
1300
+ invoicing: z
1301
+ .string()
1302
+ .optional()
1303
+ .describe('The external ID of the invoice in the invoicing app if available.'),
1304
+ tax: z
1305
+ .string()
1306
+ .optional()
1307
+ .describe('The external ID of the invoice in the tax app if available.'),
1308
+ })
1309
+ .describe('InvoiceLineAppExternalIds contains the external IDs of the invoice in other apps such as Stripe.');
1310
+ export const notificationEventV1InvoiceLineTaxBehavior = z
1311
+ .enum(['inclusive', 'exclusive'])
1312
+ .describe('InvoiceLineTaxBehavior details how the tax item is applied to the base amount. Inclusive means the tax is included in the base amount. Exclusive means the tax is added to the base amount.');
1313
+ export const notificationEventV1IdResource = z
1314
+ .object({
1315
+ id: z
1316
+ .string()
1317
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
1318
+ .describe('A unique identifier for the resource.'),
1319
+ })
1320
+ .describe('IDResource is a resouce with an ID.');
1321
+ export const notificationEventV1PricePaymentTerm = z
1322
+ .enum(['in_advance', 'in_arrears'])
1323
+ .describe('The payment term of a flat price. One of: in_advance or in_arrears.');
1324
+ export const notificationEventV1TieredPriceMode = z
1325
+ .enum(['volume', 'graduated'])
1326
+ .describe('The mode of the tiered price.');
1327
+ export const notificationEventV1InvoiceDetailedLineCostCategory = z
1328
+ .enum(['regular', 'commitment'])
1329
+ .describe('InvoiceDetailedLineCostCategory determines if the flat fee is a regular fee due to use due to a commitment.');
1330
+ export const notificationEventV1PaymentTermInstant = z
1331
+ .object({
1332
+ type: z.literal('instant').describe('Type of terms to be applied.'),
1333
+ detail: z
1334
+ .string()
1335
+ .optional()
1336
+ .describe('Text detail of the chosen payment terms.'),
1337
+ notes: z
1338
+ .string()
1339
+ .optional()
1340
+ .describe('Description of the conditions for payment.'),
1341
+ })
1342
+ .describe('PaymentTermInstant defines the terms for payment on receipt of invoice.');
1343
+ export const notificationEventV1ValidationIssueSeverity = z
1344
+ .enum(['critical', 'warning'])
1345
+ .describe('ValidationIssueSeverity describes the severity of a validation issue. Issues with severity "critical" will prevent the invoice from being issued.');
1346
+ export const notificationEventV1InvoiceAppExternalIds = z
1347
+ .object({
1348
+ invoicing: z
1349
+ .string()
1350
+ .optional()
1351
+ .describe('The external ID of the invoice in the invoicing app if available.'),
1352
+ tax: z
1353
+ .string()
1354
+ .optional()
1355
+ .describe('The external ID of the invoice in the tax app if available.'),
1356
+ payment: z
1357
+ .string()
1358
+ .optional()
1359
+ .describe('The external ID of the invoice in the payment app if available.'),
1360
+ })
1361
+ .describe('InvoiceAppExternalIds contains the external IDs of the invoice in other apps such as Stripe.');
959
1362
  export const queryFilterInteger = z
960
1363
  .object({
961
1364
  eq: z
@@ -1674,18 +2077,6 @@ export const notificationChannelReference = z
1674
2077
  id: ulid,
1675
2078
  })
1676
2079
  .describe('NotificationChannel reference.');
1677
- export const notificationEventFeatureReference = z
1678
- .object({
1679
- id: ulid,
1680
- key: z.string().describe('The immutable key of the feature.'),
1681
- })
1682
- .describe('A reference to the feature of an entitlement notification event.');
1683
- export const notificationEventInvoiceReference = z
1684
- .object({
1685
- id: ulid,
1686
- number: z.string().describe('The human-readable invoice number.'),
1687
- })
1688
- .describe('A reference to the invoice of an invoice notification event.');
1689
2080
  export const billingCustomerReference = z
1690
2081
  .object({
1691
2082
  id: ulid,
@@ -2833,61 +3224,353 @@ export const notificationEventDeliveryAttempt = z
2833
3224
  timestamp: dateTime,
2834
3225
  })
2835
3226
  .describe('A single delivery attempt to a channel.');
2836
- export const appCustomerData = z
3227
+ export const notificationEventV1RecurringPeriodInterval = z
3228
+ .union([z.string(), notificationEventV1RecurringPeriodIntervalEnum])
3229
+ .describe('Period duration for the recurrence');
3230
+ export const notificationEventV1FeatureManualUnitCost = z
2837
3231
  .object({
2838
- stripe: appCustomerDataStripe
2839
- .nullable()
2840
- .optional()
2841
- .describe('Used if the customer has a linked Stripe app. Set to `null` to remove the Stripe data of the customer; omit to leave it unchanged.'),
2842
- externalInvoicing: appCustomerDataExternalInvoicing
2843
- .nullable()
2844
- .optional()
2845
- .describe('Used if the customer has a linked external invoicing app. Set to `null` to remove the external invoicing data of the customer; omit to leave it unchanged.'),
3232
+ type: z.literal('manual').describe('type.'),
3233
+ amount: notificationEventV1Numeric,
2846
3234
  })
2847
- .describe('App customer data.');
2848
- export const upsertAppCustomerDataRequest = z
3235
+ .describe('A fixed per-unit cost amount.');
3236
+ export const notificationEventV1FeatureLlmUnitCostPricing = z
2849
3237
  .object({
2850
- stripe: appCustomerDataStripe
2851
- .nullable()
2852
- .optional()
2853
- .describe('Used if the customer has a linked Stripe app. Set to `null` to remove the Stripe data of the customer; omit to leave it unchanged.'),
2854
- externalInvoicing: appCustomerDataExternalInvoicing
2855
- .nullable()
2856
- .optional()
2857
- .describe('Used if the customer has a linked external invoicing app. Set to `null` to remove the external invoicing data of the customer; omit to leave it unchanged.'),
3238
+ inputPerToken: notificationEventV1Numeric,
3239
+ outputPerToken: notificationEventV1Numeric,
3240
+ cacheReadPerToken: notificationEventV1Numeric.optional(),
3241
+ reasoningPerToken: notificationEventV1Numeric.optional(),
3242
+ cacheWritePerToken: notificationEventV1Numeric.optional(),
2858
3243
  })
2859
- .describe('AppCustomerData upsert request.');
2860
- export const creditAdjustment = z
3244
+ .describe('Resolved per-token pricing from the LLM cost database.');
3245
+ export const notificationEventV1InvoiceTotals = z
2861
3246
  .object({
2862
- name: z
3247
+ amount: notificationEventV1Numeric,
3248
+ chargesTotal: notificationEventV1Numeric,
3249
+ discountsTotal: notificationEventV1Numeric,
3250
+ creditsTotal: notificationEventV1Numeric,
3251
+ taxesInclusiveTotal: notificationEventV1Numeric,
3252
+ taxesExclusiveTotal: notificationEventV1Numeric,
3253
+ taxesTotal: notificationEventV1Numeric,
3254
+ total: notificationEventV1Numeric,
3255
+ })
3256
+ .describe('Totals contains the summaries of all calculations for the invoice.');
3257
+ export const notificationEventV1DiscountReasonRatecardUsage = z
3258
+ .object({
3259
+ type: z.literal('ratecard_usage').describe('type.'),
3260
+ quantity: notificationEventV1Numeric,
3261
+ correlationId: z
2863
3262
  .string()
2864
- .min(1)
2865
- .max(256)
2866
- .describe('Display name of the resource. Between 1 and 256 characters.'),
3263
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
3264
+ .optional()
3265
+ .describe('Correlation ID for the discount. This is used to link discounts across different invoices (progressive billing use case). If not provided, the invoicing engine will auto-generate one. When editing an invoice line, please make sure to keep the same correlation ID of the discount or in progressive billing setups the discount amounts might be incorrect.'),
3266
+ })
3267
+ .describe('The reason for the discount is a ratecard usage.');
3268
+ export const notificationEventV1InvoiceLineCreditAllocation = z
3269
+ .object({
3270
+ amount: notificationEventV1Numeric,
2867
3271
  description: z
2868
3272
  .string()
2869
- .max(1024)
2870
3273
  .optional()
2871
- .describe('Optional description of the resource. Maximum 1024 characters.'),
2872
- labels: labels.optional(),
3274
+ .describe('Text description as to why the credit was allocated.'),
2873
3275
  })
2874
- .describe("A credit adjustment can be used to make manual adjustments to a customer's credit balance. Supported use-cases: - Usage correction");
2875
- export const listCreditGrantsParamsFilter = z
3276
+ .describe('InvoiceLineCreditAllocation represents a credit amount allocated to the line before taxes are applied.');
3277
+ export const notificationEventV1UnitPriceWithCommitments = z
2876
3278
  .object({
2877
- status: creditGrantStatus.optional(),
2878
- currency: billingCurrencyCode.optional(),
2879
- key: stringFieldFilter.optional(),
2880
- featureKey: stringFieldFilter.optional(),
3279
+ type: z.literal('unit').describe('The type of the price.'),
3280
+ amount: notificationEventV1Numeric,
3281
+ minimumAmount: notificationEventV1Numeric.optional(),
3282
+ maximumAmount: notificationEventV1Numeric.optional(),
2881
3283
  })
2882
- .describe('Filter options for listing credit grants.');
2883
- export const createCreditAdjustmentRequest = z
3284
+ .describe('Unit price with spend commitments.');
3285
+ export const notificationEventV1FlatPrice = z
2884
3286
  .object({
2885
- name: z
2886
- .string()
2887
- .min(1)
2888
- .max(256)
2889
- .describe('Display name of the resource. Between 1 and 256 characters.'),
2890
- description: z
3287
+ type: z.literal('flat').describe('The type of the price.'),
3288
+ amount: notificationEventV1Numeric,
3289
+ })
3290
+ .describe('Flat price.');
3291
+ export const notificationEventV1UnitPrice = z
3292
+ .object({
3293
+ type: z.literal('unit').describe('The type of the price.'),
3294
+ amount: notificationEventV1Numeric,
3295
+ })
3296
+ .describe('Unit price.');
3297
+ export const notificationEventV1DynamicPriceWithCommitments = z
3298
+ .object({
3299
+ type: z.literal('dynamic').describe('The type of the price.'),
3300
+ multiplier: notificationEventV1Numeric.optional(),
3301
+ minimumAmount: notificationEventV1Numeric.optional(),
3302
+ maximumAmount: notificationEventV1Numeric.optional(),
3303
+ })
3304
+ .describe('Dynamic price with spend commitments.');
3305
+ export const notificationEventV1PackagePriceWithCommitments = z
3306
+ .object({
3307
+ type: z.literal('package').describe('The type of the price.'),
3308
+ amount: notificationEventV1Numeric,
3309
+ quantityPerPackage: notificationEventV1Numeric,
3310
+ minimumAmount: notificationEventV1Numeric.optional(),
3311
+ maximumAmount: notificationEventV1Numeric.optional(),
3312
+ })
3313
+ .describe('Package price with spend commitments.');
3314
+ export const notificationEventV1BillingDiscountUsage = z
3315
+ .object({
3316
+ quantity: notificationEventV1Numeric,
3317
+ correlationId: z
3318
+ .string()
3319
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
3320
+ .optional()
3321
+ .describe('Correlation ID for the discount. This is used to link discounts across different invoices (progressive billing use case). If not provided, the invoicing engine will auto-generate one. When editing an invoice line, please make sure to keep the same correlation ID of the discount or in progressive billing setups the discount amounts might be incorrect.'),
3322
+ })
3323
+ .describe('A usage discount.');
3324
+ export const notificationEventV1SubscriptionCostBasisPin = z
3325
+ .object({
3326
+ customCurrencyId: z
3327
+ .string()
3328
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
3329
+ .describe('The managed custom currency ID.'),
3330
+ invoiceCurrency: notificationEventV1CurrencyCode,
3331
+ costBasisId: z
3332
+ .string()
3333
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
3334
+ .describe('The pinned cost basis resource ID.'),
3335
+ })
3336
+ .describe('A cost basis pinned to a custom-currency pair for the subscription.');
3337
+ export const notificationEventV1Address = z
3338
+ .object({
3339
+ country: notificationEventV1CountryCode.optional(),
3340
+ postalCode: z.string().optional().describe('Postal code.'),
3341
+ state: z.string().optional().describe('State or province.'),
3342
+ city: z.string().optional().describe('City.'),
3343
+ line1: z.string().optional().describe('First line of the address.'),
3344
+ line2: z.string().optional().describe('Second line of the address.'),
3345
+ phoneNumber: z.string().optional().describe('Phone number.'),
3346
+ })
3347
+ .describe('Address');
3348
+ export const notificationEventV1ProRatingConfig = z
3349
+ .object({
3350
+ enabled: z
3351
+ .boolean()
3352
+ .describe('Whether pro-rating is enabled for this plan.'),
3353
+ mode: notificationEventV1ProRatingMode,
3354
+ })
3355
+ .describe('Configuration for pro-rating behavior.');
3356
+ export const notificationEventV1RuleBalanceThresholdValue = z
3357
+ .object({
3358
+ value: z.number().describe('Value of the threshold.'),
3359
+ type: notificationEventV1RuleBalanceThresholdValueType,
3360
+ })
3361
+ .describe('Threshold value with multiple supported types.');
3362
+ export const notificationEventV1BillingPartyTaxIdentity = z
3363
+ .object({
3364
+ code: notificationEventV1BillingTaxIdentificationCode.optional(),
3365
+ })
3366
+ .describe('Identity stores the details required to identify an entity for tax purposes in a specific country.');
3367
+ export const notificationEventV1InvoiceReference = z
3368
+ .object({
3369
+ id: z
3370
+ .string()
3371
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
3372
+ .describe('The ID of the invoice.'),
3373
+ number: notificationEventV1InvoiceNumber.optional(),
3374
+ })
3375
+ .describe('Reference to an invoice.');
3376
+ export const notificationEventV1InvoiceDocumentRef = z
3377
+ .object({
3378
+ type: notificationEventV1InvoiceDocumentRefType,
3379
+ reason: z
3380
+ .string()
3381
+ .optional()
3382
+ .describe('Human readable description on why this reference is here or needs to be used.'),
3383
+ description: z
3384
+ .string()
3385
+ .optional()
3386
+ .describe('Additional details about the document.'),
3387
+ })
3388
+ .describe('InvoiceDocumentRef is used to describe a reference to an existing document (invoice). The v1 schema describes credit note references with issued_at, number and url, but the v1 API only ever sends the generic fields below.');
3389
+ export const notificationEventV1InvoiceGenericDocumentRef = z
3390
+ .object({
3391
+ type: notificationEventV1InvoiceDocumentRefType,
3392
+ reason: z
3393
+ .string()
3394
+ .optional()
3395
+ .describe('Human readable description on why this reference is here or needs to be used.'),
3396
+ description: z
3397
+ .string()
3398
+ .optional()
3399
+ .describe('Additional details about the document.'),
3400
+ })
3401
+ .describe('Omitted fields: period: Tax period in which the referred document had an effect required by some tax regimes and formats. stamps: Seals of approval from other organisations that may need to be listed. ext: Extensions for additional codes that may be required.');
3402
+ export const notificationEventV1InvoiceAvailableActions = z
3403
+ .object({
3404
+ advance: notificationEventV1InvoiceAvailableActionDetails.optional(),
3405
+ approve: notificationEventV1InvoiceAvailableActionDetails.optional(),
3406
+ delete: notificationEventV1InvoiceAvailableActionDetails.optional(),
3407
+ retry: notificationEventV1InvoiceAvailableActionDetails.optional(),
3408
+ snapshotQuantities: notificationEventV1InvoiceAvailableActionDetails.optional(),
3409
+ void: notificationEventV1InvoiceAvailableActionDetails.optional(),
3410
+ invoice: notificationEventV1InvoiceAvailableActionInvoiceDetails.optional(),
3411
+ })
3412
+ .describe('InvoiceAvailableActions represents the actions that can be performed on the invoice.');
3413
+ export const notificationEventV1AppCapability = z
3414
+ .object({
3415
+ type: notificationEventV1AppCapabilityType,
3416
+ key: z
3417
+ .string()
3418
+ .min(1)
3419
+ .max(64)
3420
+ .regex(new RegExp('^[a-z0-9]+(?:_[a-z0-9]+)*$'))
3421
+ .describe('Key'),
3422
+ name: z.string().describe('The capability name.'),
3423
+ description: z.string().describe('The capability description.'),
3424
+ })
3425
+ .describe("App capability. Capabilities only exist in config so they don't extend the Resource model.");
3426
+ export const notificationEventV1TaxConfig = z
3427
+ .object({
3428
+ behavior: notificationEventV1TaxBehavior.optional(),
3429
+ stripe: notificationEventV1StripeTaxConfig.optional(),
3430
+ customInvoicing: notificationEventV1CustomInvoicingTaxConfig.optional(),
3431
+ taxCodeId: z
3432
+ .string()
3433
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
3434
+ .optional()
3435
+ .describe('Tax code reference. When both `taxCodeId` and `stripe.code` are provided, `taxCodeId` takes precedence: the referenced tax code entity is used and `stripe.code` is ignored.'),
3436
+ })
3437
+ .describe('Set of provider specific tax configs.');
3438
+ export const notificationEventV1BillingWorkflowPaymentSettings = z
3439
+ .object({
3440
+ collectionMethod: notificationEventV1CollectionMethod.optional(),
3441
+ })
3442
+ .describe('BillingWorkflowPaymentSettings represents the payment settings for a billing workflow');
3443
+ export const notificationEventV1DiscountReasonRatecardPercentage = z
3444
+ .object({
3445
+ type: z.literal('ratecard_percentage').describe('type.'),
3446
+ percentage: notificationEventV1Percentage,
3447
+ correlationId: z
3448
+ .string()
3449
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
3450
+ .optional()
3451
+ .describe('Correlation ID for the discount. This is used to link discounts across different invoices (progressive billing use case). If not provided, the invoicing engine will auto-generate one. When editing an invoice line, please make sure to keep the same correlation ID of the discount or in progressive billing setups the discount amounts might be incorrect.'),
3452
+ })
3453
+ .describe('The reason for the discount is a ratecard percentage.');
3454
+ export const notificationEventV1BillingDiscountPercentage = z
3455
+ .object({
3456
+ percentage: notificationEventV1Percentage,
3457
+ correlationId: z
3458
+ .string()
3459
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
3460
+ .optional()
3461
+ .describe('Correlation ID for the discount. This is used to link discounts across different invoices (progressive billing use case). If not provided, the invoicing engine will auto-generate one. When editing an invoice line, please make sure to keep the same correlation ID of the discount or in progressive billing setups the discount amounts might be incorrect.'),
3462
+ })
3463
+ .describe('A percentage discount.');
3464
+ export const notificationEventV1PaymentDueDate = z
3465
+ .object({
3466
+ dueAt: z.date().describe('When the payment is due.'),
3467
+ notes: z
3468
+ .string()
3469
+ .optional()
3470
+ .describe('Other details to take into account for the due date.'),
3471
+ amount: notificationEventV1Numeric,
3472
+ percent: notificationEventV1Percentage.optional(),
3473
+ currency: notificationEventV1CurrencyCode.optional(),
3474
+ })
3475
+ .describe('PaymentDueDate contains an amount that should be paid by the given date.');
3476
+ export const notificationEventV1InvoiceLineSubscriptionReference = z
3477
+ .object({
3478
+ subscription: notificationEventV1IdResource,
3479
+ phase: notificationEventV1IdResource,
3480
+ item: notificationEventV1IdResource,
3481
+ billingPeriod: notificationEventV1Period,
3482
+ })
3483
+ .describe('InvoiceLineSubscriptionReference contains the references to the subscription that this line is related to.');
3484
+ export const notificationEventV1FlatPriceWithPaymentTerm = z
3485
+ .object({
3486
+ type: z.literal('flat').describe('The type of the price.'),
3487
+ amount: notificationEventV1Numeric,
3488
+ paymentTerm: notificationEventV1PricePaymentTerm.optional(),
3489
+ })
3490
+ .describe('Flat price with payment term.');
3491
+ export const notificationEventV1ValidationIssue = z
3492
+ .object({
3493
+ createdAt: z.date().describe('Timestamp of when the resource was created.'),
3494
+ updatedAt: z
3495
+ .date()
3496
+ .describe('Timestamp of when the resource was last updated.'),
3497
+ deletedAt: z
3498
+ .date()
3499
+ .optional()
3500
+ .describe('Timestamp of when the resource was permanently deleted.'),
3501
+ id: z
3502
+ .string()
3503
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
3504
+ .describe('ID of the charge or discount.'),
3505
+ severity: notificationEventV1ValidationIssueSeverity,
3506
+ field: z
3507
+ .string()
3508
+ .optional()
3509
+ .describe('The field that the issue is related to, if available in JSON path format.'),
3510
+ code: z
3511
+ .string()
3512
+ .optional()
3513
+ .describe('Machine indentifiable code for the issue, if available.'),
3514
+ component: z.string().describe('Component reporting the issue.'),
3515
+ message: z.string().describe('A human-readable description of the issue.'),
3516
+ metadata: notificationEventV1Metadata.optional(),
3517
+ })
3518
+ .describe('ValidationIssue captures any validation issues related to the invoice. Issues with severity "critical" will prevent the invoice from being issued.');
3519
+ export const appCustomerData = z
3520
+ .object({
3521
+ stripe: appCustomerDataStripe
3522
+ .nullable()
3523
+ .optional()
3524
+ .describe('Used if the customer has a linked Stripe app. Set to `null` to remove the Stripe data of the customer; omit to leave it unchanged.'),
3525
+ externalInvoicing: appCustomerDataExternalInvoicing
3526
+ .nullable()
3527
+ .optional()
3528
+ .describe('Used if the customer has a linked external invoicing app. Set to `null` to remove the external invoicing data of the customer; omit to leave it unchanged.'),
3529
+ })
3530
+ .describe('App customer data.');
3531
+ export const upsertAppCustomerDataRequest = z
3532
+ .object({
3533
+ stripe: appCustomerDataStripe
3534
+ .nullable()
3535
+ .optional()
3536
+ .describe('Used if the customer has a linked Stripe app. Set to `null` to remove the Stripe data of the customer; omit to leave it unchanged.'),
3537
+ externalInvoicing: appCustomerDataExternalInvoicing
3538
+ .nullable()
3539
+ .optional()
3540
+ .describe('Used if the customer has a linked external invoicing app. Set to `null` to remove the external invoicing data of the customer; omit to leave it unchanged.'),
3541
+ })
3542
+ .describe('AppCustomerData upsert request.');
3543
+ export const creditAdjustment = z
3544
+ .object({
3545
+ name: z
3546
+ .string()
3547
+ .min(1)
3548
+ .max(256)
3549
+ .describe('Display name of the resource. Between 1 and 256 characters.'),
3550
+ description: z
3551
+ .string()
3552
+ .max(1024)
3553
+ .optional()
3554
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
3555
+ labels: labels.optional(),
3556
+ })
3557
+ .describe("A credit adjustment can be used to make manual adjustments to a customer's credit balance. Supported use-cases: - Usage correction");
3558
+ export const listCreditGrantsParamsFilter = z
3559
+ .object({
3560
+ status: creditGrantStatus.optional(),
3561
+ currency: billingCurrencyCode.optional(),
3562
+ key: stringFieldFilter.optional(),
3563
+ featureKey: stringFieldFilter.optional(),
3564
+ })
3565
+ .describe('Filter options for listing credit grants.');
3566
+ export const createCreditAdjustmentRequest = z
3567
+ .object({
3568
+ name: z
3569
+ .string()
3570
+ .min(1)
3571
+ .max(256)
3572
+ .describe('Display name of the resource. Between 1 and 256 characters.'),
3573
+ description: z
2891
3574
  .string()
2892
3575
  .max(1024)
2893
3576
  .optional()
@@ -3431,17 +4114,6 @@ export const resendBillingNotificationEventRequest = z
3431
4114
  .describe('The channels to resend the event to. When omitted or empty, the event is resent to every enabled channel of the rule. Channels not targeted by the rule or disabled are rejected.'),
3432
4115
  })
3433
4116
  .describe('Request body for resending a notification event.');
3434
- export const notificationEventInvoiceData = z
3435
- .object({
3436
- invoice: notificationEventInvoiceReference,
3437
- customerId: ulid.optional(),
3438
- currency: currencyCode,
3439
- status: z
3440
- .string()
3441
- .describe('The status of the invoice at the time the event was generated.'),
3442
- total: numeric,
3443
- })
3444
- .describe('The invoice an invoice notification event refers to.');
3445
4117
  export const listEventsParamsFilter = z
3446
4118
  .object({
3447
4119
  id: stringFieldFilter.optional(),
@@ -4292,91 +4964,315 @@ export const notificationEventDeliveryStatus = z
4292
4964
  .describe('The delivery attempts made so far, most recent first.'),
4293
4965
  })
4294
4966
  .describe('The delivery status of a notification event for one channel of the generating rule.');
4295
- export const customerData = z
4967
+ export const notificationEventV1RecurringPeriod = z
4296
4968
  .object({
4297
- billingProfile: profileReference
4298
- .nullable()
4969
+ interval: notificationEventV1RecurringPeriodInterval,
4970
+ anchor: z
4971
+ .date()
4972
+ .describe('A date-time anchor to base the recurring period on.'),
4973
+ intervalIso: z
4974
+ .string()
4975
+ .duration()
4976
+ .describe('The unit of time for the interval in ISO8601 format.'),
4977
+ })
4978
+ .describe('Recurring period with an interval and an anchor.');
4979
+ export const notificationEventV1RecurringPeriodV2 = z
4980
+ .object({
4981
+ interval: notificationEventV1RecurringPeriodInterval,
4982
+ anchor: z
4983
+ .date()
4984
+ .describe('A date-time anchor to base the recurring period on.'),
4985
+ })
4986
+ .describe('Recurring period with an interval and an anchor.');
4987
+ export const notificationEventV1FeatureLlmUnitCost = z
4988
+ .object({
4989
+ type: z.literal('llm').describe('type.'),
4990
+ providerProperty: z
4991
+ .string()
4299
4992
  .optional()
4300
- .describe('The billing profile explicitly selected for the customer. Unpinned customers use the current namespace default. Selecting the current default explicitly pins the customer to that profile.'),
4301
- effectiveBillingProfile: profileReference,
4302
- appData: appCustomerData.optional(),
4993
+ .describe('Meter group-by property that holds the LLM provider. Use this when the meter has a group-by dimension for provider. Mutually exclusive with `provider`.'),
4994
+ provider: z
4995
+ .string()
4996
+ .optional()
4997
+ .describe('Static LLM provider value (e.g., "openai", "anthropic"). Use this when the feature tracks a single provider. Mutually exclusive with `providerProperty`.'),
4998
+ modelProperty: z
4999
+ .string()
5000
+ .optional()
5001
+ .describe('Meter group-by property that holds the model ID. Use this when the meter has a group-by dimension for model. Mutually exclusive with `model`.'),
5002
+ model: z
5003
+ .string()
5004
+ .optional()
5005
+ .describe('Static model ID value (e.g., "gpt-4", "claude-3-5-sonnet"). Use this when the feature tracks a single model. Mutually exclusive with `modelProperty`.'),
5006
+ tokenTypeProperty: z
5007
+ .string()
5008
+ .optional()
5009
+ .describe('Meter group-by property that holds the token type. Use this when the meter has a group-by dimension for token type. Mutually exclusive with `tokenType`.'),
5010
+ tokenType: z
5011
+ .string()
5012
+ .optional()
5013
+ .describe('Static token type value. Use this when the feature tracks a single token type (e.g., only input tokens). Expected values: input, output, cache_read, reasoning, cache_write, request, response. `request` is an alias for `input`, `response` is an alias for `output`. Mutually exclusive with `tokenTypeProperty`.'),
5014
+ pricing: notificationEventV1FeatureLlmUnitCostPricing.optional(),
4303
5015
  })
4304
- .describe('Billing customer data.');
4305
- export const upsertCustomerBillingDataRequest = z
5016
+ .describe('LLM cost lookup configuration. Maps meter group-by dimensions to LLM cost database fields.');
5017
+ export const notificationEventV1PriceTier = z
4306
5018
  .object({
4307
- billingProfile: profileReference
5019
+ upToAmount: notificationEventV1Numeric.optional(),
5020
+ flatPrice: notificationEventV1FlatPrice
4308
5021
  .nullable()
4309
- .optional()
4310
- .describe('The billing profile explicitly selected for the customer. Unpinned customers use the current namespace default. Selecting the current default explicitly pins the customer to that profile.'),
4311
- appData: appCustomerData.optional(),
5022
+ .describe('The flat price component of the tier.'),
5023
+ unitPrice: notificationEventV1UnitPrice
5024
+ .nullable()
5025
+ .describe('The unit price component of the tier.'),
4312
5026
  })
4313
- .describe('CustomerBillingData upsert request.');
4314
- export const chargeFlatFeeSystemIntent = z
5027
+ .describe('A price tier. At least one price component is required in each tier.');
5028
+ export const notificationEventV1Subscription = z
4315
5029
  .object({
5030
+ id: z
5031
+ .string()
5032
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
5033
+ .describe('A unique identifier for the resource.'),
4316
5034
  name: z
4317
5035
  .string()
4318
5036
  .min(1)
4319
5037
  .max(256)
4320
- .describe('Display name of the resource. Between 1 and 256 characters.'),
5038
+ .describe('Human-readable name for the resource. Between 1 and 256 characters.'),
4321
5039
  description: z
4322
5040
  .string()
4323
5041
  .max(1024)
4324
5042
  .optional()
4325
5043
  .describe('Optional description of the resource. Maximum 1024 characters.'),
4326
- labels: labels.optional(),
4327
- invoiceAt: dateTime,
4328
- servicePeriod: closedPeriod,
4329
- fullServicePeriod: closedPeriod,
4330
- billingPeriod: closedPeriod,
4331
- paymentTerm: pricePaymentTerm,
4332
- discounts: chargeFlatFeeDiscounts.optional(),
4333
- prorationConfiguration: rateCardProrationConfiguration,
4334
- amountBeforeProration: currencyAmount,
4335
- deletedAt: dateTime.optional(),
4336
- })
4337
- .describe('Flat fee intent fields from the system lifecycle controller shadowed by a manual override.');
4338
- export const listCustomerEntitlementAccessResponseData = z
4339
- .object({
4340
- data: z
4341
- .array(entitlementValueResult)
4342
- .describe('The list of entitlement access results.'),
4343
- })
4344
- .describe('List customer entitlement access response data.');
4345
- export const notificationEventBalanceThresholdData = z
4346
- .object({
4347
- entitlementId: ulid,
4348
- feature: notificationEventFeatureReference,
4349
- subjectKey: z
5044
+ metadata: notificationEventV1Metadata
5045
+ .nullable()
5046
+ .optional()
5047
+ .describe('Additional metadata for the resource.'),
5048
+ createdAt: z.date().describe('Timestamp of when the resource was created.'),
5049
+ updatedAt: z
5050
+ .date()
5051
+ .describe('Timestamp of when the resource was last updated.'),
5052
+ deletedAt: z
5053
+ .date()
5054
+ .optional()
5055
+ .describe('Timestamp of when the resource was permanently deleted.'),
5056
+ activeFrom: z.date().describe('The cadence start of the resource.'),
5057
+ activeTo: z.date().optional().describe('The cadence end of the resource.'),
5058
+ annotations: notificationEventV1Annotations.optional(),
5059
+ alignment: notificationEventV1Alignment.optional(),
5060
+ status: notificationEventV1SubscriptionStatus,
5061
+ customerId: z
5062
+ .string()
5063
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
5064
+ .describe('The customer ID of the subscription.'),
5065
+ plan: notificationEventV1PlanReference.optional(),
5066
+ currency: notificationEventV1CurrencyCode,
5067
+ costBasisMode: notificationEventV1SubscriptionCostBasisMode,
5068
+ costBasisPins: z
5069
+ .array(notificationEventV1SubscriptionCostBasisPin)
5070
+ .describe('Cost bases pinned to custom-currency pairs for this subscription.'),
5071
+ billingCadence: z
4350
5072
  .string()
4351
- .describe('The key of the subject the entitlement belongs to.'),
4352
- customerId: ulid.optional(),
4353
- value: entitlementValueResult,
4354
- threshold: notificationBalanceThreshold,
5073
+ .duration()
5074
+ .describe('The billing cadence for the subscriptions. Defines how often customers are billed using ISO8601 duration format. Examples: "P1M" (monthly), "P3M" (quarterly), "P1Y" (annually).'),
5075
+ proRatingConfig: notificationEventV1ProRatingConfig.optional(),
5076
+ billingAnchor: z
5077
+ .date()
5078
+ .describe('The normalizedbilling anchor of the subscription.'),
5079
+ settlementMode: notificationEventV1BillingSettlementMode,
4355
5080
  })
4356
- .describe('The entities and threshold a balance threshold event refers to.');
4357
- export const notificationEventEntitlementData = z
5081
+ .describe('Subscription is an exact subscription instance.');
5082
+ export const notificationEventV1BillingParty = z
4358
5083
  .object({
4359
- entitlementId: ulid,
4360
- feature: notificationEventFeatureReference,
4361
- subjectKey: z
5084
+ id: z
5085
+ .string()
5086
+ .optional()
5087
+ .describe('Unique identifier for the party (if available)'),
5088
+ key: z
4362
5089
  .string()
4363
- .describe('The key of the subject the entitlement belongs to.'),
4364
- customerId: ulid.optional(),
4365
- value: entitlementValueResult,
4366
- })
4367
- .describe('The entitlement, feature, and subject an entitlement notification event refers to.');
4368
- export const priceGraduated = z
4369
- .object({
4370
- type: z.literal('graduated').describe('The type of the price.'),
4371
- tiers: z
4372
- .array(priceTier)
4373
5090
  .min(1)
4374
- .describe('The tiers of the graduated price. At least one tier is required.'),
5091
+ .max(256)
5092
+ .optional()
5093
+ .describe('An optional unique key of the party (if available)'),
5094
+ name: z
5095
+ .string()
5096
+ .optional()
5097
+ .describe('Legal name or representation of the organization.'),
5098
+ taxId: notificationEventV1BillingPartyTaxIdentity.optional(),
5099
+ addresses: z
5100
+ .array(notificationEventV1Address)
5101
+ .max(1)
5102
+ .optional()
5103
+ .describe('Regular post addresses for where information should be sent if needed.'),
4375
5104
  })
4376
- .describe("Graduated tiered price. Each tier's rate applies only to the usage within that tier. Pricing can change as cumulative usage crosses tier boundaries. When UnitConfig is present on the containing resource, tier boundaries (up_to_amount) are expressed in converted billing units.");
4377
- export const priceVolume = z
5105
+ .describe('Party represents a person or business entity.');
5106
+ export const notificationEventV1BillingInvoiceCustomerExtendedDetails = z
4378
5107
  .object({
4379
- type: z.literal('volume').describe('The type of the price.'),
5108
+ id: z
5109
+ .string()
5110
+ .optional()
5111
+ .describe('Unique identifier for the party (if available)'),
5112
+ key: z
5113
+ .string()
5114
+ .min(1)
5115
+ .max(256)
5116
+ .optional()
5117
+ .describe('An optional unique key of the party (if available)'),
5118
+ name: z
5119
+ .string()
5120
+ .optional()
5121
+ .describe('Legal name or representation of the organization.'),
5122
+ taxId: notificationEventV1BillingPartyTaxIdentity.optional(),
5123
+ addresses: z
5124
+ .array(notificationEventV1Address)
5125
+ .max(1)
5126
+ .optional()
5127
+ .describe('Regular post addresses for where information should be sent if needed.'),
5128
+ usageAttribution: notificationEventV1CustomerUsageAttribution,
5129
+ })
5130
+ .describe('BillingInvoiceCustomerExtendedDetails is a collection of fields that are used to extend the billing party details for invoices. These fields contain the OpenMeter specific details for the customer, that are not strictly required for the invoice itself.');
5131
+ export const notificationEventV1InvoiceStatusDetails = z
5132
+ .object({
5133
+ immutable: z.boolean().describe('Is the invoice editable?'),
5134
+ failed: z.boolean().describe('Is the invoice in a failed state?'),
5135
+ extendedStatus: z
5136
+ .string()
5137
+ .describe('Extended status information for the invoice.'),
5138
+ availableActions: notificationEventV1InvoiceAvailableActions,
5139
+ })
5140
+ .describe('InvoiceStatusDetails represents the details of the invoice status. API users are encouraged to rely on the immutable/failed/avaliableActions fields to determine the next steps of the invoice instead of the extendedStatus field.');
5141
+ export const notificationEventV1MarketplaceListing = z
5142
+ .object({
5143
+ type: notificationEventV1AppType,
5144
+ name: z.string().describe("The app's name."),
5145
+ description: z.string().describe("The app's description."),
5146
+ capabilities: z
5147
+ .array(notificationEventV1AppCapability)
5148
+ .describe("The app's capabilities."),
5149
+ installMethods: z
5150
+ .array(notificationEventV1InstallMethod)
5151
+ .describe('Install methods. List of methods to install the app.'),
5152
+ })
5153
+ .describe("A marketplace listing. Represent an available app in the app marketplace that can be installed to the organization. Marketplace apps only exist in config so they don't extend the Resource model.");
5154
+ export const notificationEventV1BillingWorkflowInvoicingSettings = z
5155
+ .object({
5156
+ autoAdvance: z
5157
+ .boolean()
5158
+ .optional()
5159
+ .describe('Whether to automatically issue the invoice after the draftPeriod has passed.'),
5160
+ draftPeriod: z
5161
+ .string()
5162
+ .optional()
5163
+ .describe('The period for the invoice to be kept in draft status for manual reviews.'),
5164
+ dueAfter: z
5165
+ .string()
5166
+ .optional()
5167
+ .describe("The period after which the invoice is due. With some payment solutions it's only applicable for manual collection method."),
5168
+ progressiveBilling: z
5169
+ .boolean()
5170
+ .optional()
5171
+ .describe('Should progressive billing be allowed for this workflow?'),
5172
+ subscriptionEndProrationMode: notificationEventV1BillingWorkflowInvoicingSubscriptionEndProrationMode.optional(),
5173
+ defaultTaxConfig: notificationEventV1TaxConfig.optional(),
5174
+ })
5175
+ .describe('BillingWorkflowInvoicingSettings represents the invoice settings for a billing workflow');
5176
+ export const notificationEventV1InvoiceLineTaxItem = z
5177
+ .object({
5178
+ config: notificationEventV1TaxConfig.optional(),
5179
+ percent: notificationEventV1Percentage.optional(),
5180
+ surcharge: notificationEventV1Numeric.optional(),
5181
+ behavior: notificationEventV1InvoiceLineTaxBehavior.optional(),
5182
+ })
5183
+ .describe('TaxConfig stores the configuration for a tax line relative to an invoice line.');
5184
+ export const notificationEventV1BillingDiscountReason = z
5185
+ .discriminatedUnion('type', [
5186
+ notificationEventV1DiscountReasonMaximumSpend,
5187
+ notificationEventV1DiscountReasonRatecardPercentage,
5188
+ notificationEventV1DiscountReasonRatecardUsage,
5189
+ ])
5190
+ .describe('The reason for the discount.');
5191
+ export const notificationEventV1BillingDiscounts = z
5192
+ .object({
5193
+ percentage: notificationEventV1BillingDiscountPercentage.optional(),
5194
+ usage: notificationEventV1BillingDiscountUsage.optional(),
5195
+ })
5196
+ .describe('A discount by type.');
5197
+ export const notificationEventV1PaymentTermDueDate = z
5198
+ .object({
5199
+ type: z.literal('due_date').describe('Type of terms to be applied.'),
5200
+ detail: z
5201
+ .string()
5202
+ .optional()
5203
+ .describe('Text detail of the chosen payment terms.'),
5204
+ notes: z
5205
+ .string()
5206
+ .optional()
5207
+ .describe('Description of the conditions for payment.'),
5208
+ dueAt: z
5209
+ .array(notificationEventV1PaymentDueDate)
5210
+ .min(1)
5211
+ .describe('When the payment is due.'),
5212
+ })
5213
+ .describe('PaymentTermDueDate defines the terms for payment on a specific date.');
5214
+ export const customerData = z
5215
+ .object({
5216
+ billingProfile: profileReference
5217
+ .nullable()
5218
+ .optional()
5219
+ .describe('The billing profile explicitly selected for the customer. Unpinned customers use the current namespace default. Selecting the current default explicitly pins the customer to that profile.'),
5220
+ effectiveBillingProfile: profileReference,
5221
+ appData: appCustomerData.optional(),
5222
+ })
5223
+ .describe('Billing customer data.');
5224
+ export const upsertCustomerBillingDataRequest = z
5225
+ .object({
5226
+ billingProfile: profileReference
5227
+ .nullable()
5228
+ .optional()
5229
+ .describe('The billing profile explicitly selected for the customer. Unpinned customers use the current namespace default. Selecting the current default explicitly pins the customer to that profile.'),
5230
+ appData: appCustomerData.optional(),
5231
+ })
5232
+ .describe('CustomerBillingData upsert request.');
5233
+ export const chargeFlatFeeSystemIntent = z
5234
+ .object({
5235
+ name: z
5236
+ .string()
5237
+ .min(1)
5238
+ .max(256)
5239
+ .describe('Display name of the resource. Between 1 and 256 characters.'),
5240
+ description: z
5241
+ .string()
5242
+ .max(1024)
5243
+ .optional()
5244
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
5245
+ labels: labels.optional(),
5246
+ invoiceAt: dateTime,
5247
+ servicePeriod: closedPeriod,
5248
+ fullServicePeriod: closedPeriod,
5249
+ billingPeriod: closedPeriod,
5250
+ paymentTerm: pricePaymentTerm,
5251
+ discounts: chargeFlatFeeDiscounts.optional(),
5252
+ prorationConfiguration: rateCardProrationConfiguration,
5253
+ amountBeforeProration: currencyAmount,
5254
+ deletedAt: dateTime.optional(),
5255
+ })
5256
+ .describe('Flat fee intent fields from the system lifecycle controller shadowed by a manual override.');
5257
+ export const listCustomerEntitlementAccessResponseData = z
5258
+ .object({
5259
+ data: z
5260
+ .array(entitlementValueResult)
5261
+ .describe('The list of entitlement access results.'),
5262
+ })
5263
+ .describe('List customer entitlement access response data.');
5264
+ export const priceGraduated = z
5265
+ .object({
5266
+ type: z.literal('graduated').describe('The type of the price.'),
5267
+ tiers: z
5268
+ .array(priceTier)
5269
+ .min(1)
5270
+ .describe('The tiers of the graduated price. At least one tier is required.'),
5271
+ })
5272
+ .describe("Graduated tiered price. Each tier's rate applies only to the usage within that tier. Pricing can change as cumulative usage crosses tier boundaries. When UnitConfig is present on the containing resource, tier boundaries (up_to_amount) are expressed in converted billing units.");
5273
+ export const priceVolume = z
5274
+ .object({
5275
+ type: z.literal('volume').describe('The type of the price.'),
4380
5276
  tiers: z
4381
5277
  .array(priceTier)
4382
5278
  .min(1)
@@ -4498,22 +5394,6 @@ export const planAddonPagePaginatedResponse = z
4498
5394
  meta: paginatedMeta,
4499
5395
  })
4500
5396
  .describe('Page paginated response.');
4501
- export const notificationEventInvoiceCreatedPayload = z
4502
- .object({
4503
- id: ulid,
4504
- type: z.literal('invoice.created').describe('The type of the event.'),
4505
- timestamp: dateTime,
4506
- data: notificationEventInvoiceData,
4507
- })
4508
- .describe('An invoice created notification event payload.');
4509
- export const notificationEventInvoiceUpdatedPayload = z
4510
- .object({
4511
- id: ulid,
4512
- type: z.literal('invoice.updated').describe('The type of the event.'),
4513
- timestamp: dateTime,
4514
- data: notificationEventInvoiceData,
4515
- })
4516
- .describe('An invoice updated notification event payload.');
4517
5397
  export const ingestedEventPaginatedResponse = z
4518
5398
  .object({
4519
5399
  data: z.array(ingestedEvent),
@@ -4981,24 +5861,322 @@ export const notificationRuleRequest = z
4981
5861
  notificationRuleInvoiceUpdatedRequest,
4982
5862
  ])
4983
5863
  .describe("Request body for creating or updating a notification rule. Updates replace the rule's mutable state: omitting `disabled`, `labels`, or `features` resets them to their defaults. The `type` must match the existing rule on update.");
4984
- export const notificationEventBalanceThresholdPayload = z
5864
+ export const notificationEventV1EntitlementMetered = z
5865
+ .object({
5866
+ type: z.literal('metered').describe('type.'),
5867
+ isSoftLimit: z
5868
+ .boolean()
5869
+ .optional()
5870
+ .describe('If softLimit=true the subject can use the feature even if the entitlement is exhausted, hasAccess will always be true.'),
5871
+ isUnlimited: z
5872
+ .boolean()
5873
+ .optional()
5874
+ .describe('Deprecated, ignored by the backend. Please use isSoftLimit instead; this field will be removed in the future.'),
5875
+ issueAfterReset: z
5876
+ .number()
5877
+ .nonnegative()
5878
+ .optional()
5879
+ .describe('You can grant usage automatically alongside the entitlement, the example scenario would be creating a starting balance. If an amount is specified here, a grant will be created alongside the entitlement with the specified amount. That grant will have it\'s rollover settings configured in a way that after each reset operation, the balance will return the original amount specified here. Manually creating such a grant would mean having the "amount", "minRolloverAmount", and "maxRolloverAmount" fields all be the same.'),
5880
+ issueAfterResetPriority: z
5881
+ .number()
5882
+ .int()
5883
+ .gte(1)
5884
+ .lte(255)
5885
+ .optional()
5886
+ .describe('Defines the grant priority for the default grant.'),
5887
+ preserveOverageAtReset: z
5888
+ .boolean()
5889
+ .optional()
5890
+ .describe('If true, the overage is preserved at reset. If false, the usage is reset to 0.'),
5891
+ createdAt: z.date().describe('Timestamp of when the resource was created.'),
5892
+ updatedAt: z
5893
+ .date()
5894
+ .describe('Timestamp of when the resource was last updated.'),
5895
+ deletedAt: z
5896
+ .date()
5897
+ .optional()
5898
+ .describe('Timestamp of when the resource was permanently deleted.'),
5899
+ metadata: notificationEventV1Metadata.optional(),
5900
+ activeFrom: z.date().describe('The cadence start of the resource.'),
5901
+ activeTo: z.date().optional().describe('The cadence end of the resource.'),
5902
+ annotations: notificationEventV1Annotations.optional(),
5903
+ id: z
5904
+ .string()
5905
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
5906
+ .describe('Readonly unique ULID identifier.'),
5907
+ subjectKey: z
5908
+ .string()
5909
+ .describe('The identifier key unique to the subject. NOTE: Subjects are being deprecated, please use the new customer APIs.'),
5910
+ featureKey: z
5911
+ .string()
5912
+ .min(1)
5913
+ .max(64)
5914
+ .regex(new RegExp('^[a-z0-9]+(?:_[a-z0-9]+)*$'))
5915
+ .describe('The feature the subject is entitled to use.'),
5916
+ featureId: z
5917
+ .string()
5918
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
5919
+ .describe('The feature the subject is entitled to use.'),
5920
+ lastReset: z.date().describe('The time the last reset happened.'),
5921
+ currentUsagePeriod: notificationEventV1Period,
5922
+ measureUsageFrom: z
5923
+ .date()
5924
+ .describe('The time from which usage is measured. If not specified on creation, defaults to entitlement creation time.'),
5925
+ usagePeriod: notificationEventV1RecurringPeriod,
5926
+ })
5927
+ .describe('Metered entitlements are useful for many different use cases, from setting up usage based access to implementing complex credit systems. Access is determined based on feature usage using a balance calculation (the "usage allowance" provided by the issued grants is "burnt down" by the usage).');
5928
+ export const notificationEventV1BillingWorkflowCollectionAlignmentAnchored = z
5929
+ .object({
5930
+ type: z.literal('anchored').describe('The type of alignment.'),
5931
+ recurringPeriod: notificationEventV1RecurringPeriodV2,
5932
+ })
5933
+ .describe('BillingWorkflowCollectionAlignmentAnchored specifies the alignment for collecting the pending line items into an invoice.');
5934
+ export const notificationEventV1FeatureUnitCost = z
5935
+ .discriminatedUnion('type', [
5936
+ notificationEventV1FeatureManualUnitCost,
5937
+ notificationEventV1FeatureLlmUnitCost,
5938
+ ])
5939
+ .describe('Per-unit cost configuration for a feature. Either a fixed manual amount or a dynamic LLM cost lookup.');
5940
+ export const notificationEventV1TieredPriceWithCommitments = z
4985
5941
  .object({
4986
- id: ulid,
4987
5942
  type: z
4988
- .literal('entitlements.balance.threshold')
4989
- .describe('The type of the event.'),
4990
- timestamp: dateTime,
4991
- data: notificationEventBalanceThresholdData,
5943
+ .literal('tiered')
5944
+ .describe('The type of the price. One of: flat, unit, or tiered.'),
5945
+ mode: notificationEventV1TieredPriceMode,
5946
+ tiers: z
5947
+ .array(notificationEventV1PriceTier)
5948
+ .min(1)
5949
+ .describe('The tiers of the tiered price. At least one price component is required in each tier.'),
5950
+ minimumAmount: notificationEventV1Numeric.optional(),
5951
+ maximumAmount: notificationEventV1Numeric.optional(),
4992
5952
  })
4993
- .describe('A balance threshold notification event payload.');
4994
- export const notificationEventResetPayload = z
5953
+ .describe('Tiered price with spend commitments.');
5954
+ export const notificationEventV1Customer = z
4995
5955
  .object({
4996
- id: ulid,
4997
- type: z.literal('entitlements.reset').describe('The type of the event.'),
4998
- timestamp: dateTime,
4999
- data: notificationEventEntitlementData,
5956
+ id: z.string().describe('A unique identifier for the resource.'),
5957
+ name: z
5958
+ .string()
5959
+ .max(256)
5960
+ .describe('Human-readable name for the resource. Between 1 and 256 characters.'),
5961
+ description: z
5962
+ .string()
5963
+ .max(1024)
5964
+ .optional()
5965
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
5966
+ metadata: notificationEventV1Metadata
5967
+ .nullable()
5968
+ .optional()
5969
+ .describe('Additional metadata for the resource.'),
5970
+ createdAt: z.date().describe('Timestamp of when the resource was created.'),
5971
+ updatedAt: z
5972
+ .date()
5973
+ .describe('Timestamp of when the resource was last updated.'),
5974
+ deletedAt: z
5975
+ .date()
5976
+ .optional()
5977
+ .describe('Timestamp of when the resource was permanently deleted.'),
5978
+ key: z
5979
+ .string()
5980
+ .min(1)
5981
+ .max(256)
5982
+ .optional()
5983
+ .describe('An optional unique key of the customer. Either key or usageAttribution.subjectKeys must be provided. Useful to reference the customer in external systems. For example, your database ID.'),
5984
+ usageAttribution: notificationEventV1CustomerUsageAttribution.optional(),
5985
+ primaryEmail: z
5986
+ .string()
5987
+ .optional()
5988
+ .describe('The primary email address of the customer.'),
5989
+ currency: notificationEventV1CurrencyCode.optional(),
5990
+ billingAddress: notificationEventV1Address.optional(),
5991
+ currentSubscriptionId: z
5992
+ .string()
5993
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
5994
+ .optional()
5995
+ .describe('The ID of the Subscription if the customer has one.'),
5996
+ subscriptions: z
5997
+ .array(notificationEventV1Subscription)
5998
+ .optional()
5999
+ .describe('The subscriptions of the customer. Only with the `subscriptions` expand option.'),
6000
+ annotations: notificationEventV1Annotations.optional(),
5000
6001
  })
5001
- .describe('An entitlement reset notification event payload.');
6002
+ .describe('A customer object.');
6003
+ export const notificationEventV1StripeApp = z
6004
+ .object({
6005
+ id: z
6006
+ .string()
6007
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
6008
+ .describe('A unique identifier for the resource.'),
6009
+ name: z
6010
+ .string()
6011
+ .min(1)
6012
+ .max(256)
6013
+ .describe('Human-readable name for the resource. Between 1 and 256 characters.'),
6014
+ description: z
6015
+ .string()
6016
+ .max(1024)
6017
+ .optional()
6018
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
6019
+ metadata: notificationEventV1Metadata
6020
+ .nullable()
6021
+ .optional()
6022
+ .describe('Additional metadata for the resource.'),
6023
+ createdAt: z.date().describe('Timestamp of when the resource was created.'),
6024
+ updatedAt: z
6025
+ .date()
6026
+ .describe('Timestamp of when the resource was last updated.'),
6027
+ deletedAt: z
6028
+ .date()
6029
+ .optional()
6030
+ .describe('Timestamp of when the resource was permanently deleted.'),
6031
+ listing: notificationEventV1MarketplaceListing,
6032
+ status: notificationEventV1AppStatus,
6033
+ type: z.literal('stripe').describe("The app's type is Stripe."),
6034
+ stripeAccountId: z.string().describe('The Stripe account ID.'),
6035
+ livemode: z
6036
+ .boolean()
6037
+ .describe('Livemode, true if the app is in production mode.'),
6038
+ maskedApiKey: z
6039
+ .string()
6040
+ .describe('The masked API key. Only shows the first 8 and last 3 characters.'),
6041
+ })
6042
+ .describe('A installed Stripe app object.');
6043
+ export const notificationEventV1SandboxApp = z
6044
+ .object({
6045
+ id: z
6046
+ .string()
6047
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
6048
+ .describe('A unique identifier for the resource.'),
6049
+ name: z
6050
+ .string()
6051
+ .min(1)
6052
+ .max(256)
6053
+ .describe('Human-readable name for the resource. Between 1 and 256 characters.'),
6054
+ description: z
6055
+ .string()
6056
+ .max(1024)
6057
+ .optional()
6058
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
6059
+ metadata: notificationEventV1Metadata
6060
+ .nullable()
6061
+ .optional()
6062
+ .describe('Additional metadata for the resource.'),
6063
+ createdAt: z.date().describe('Timestamp of when the resource was created.'),
6064
+ updatedAt: z
6065
+ .date()
6066
+ .describe('Timestamp of when the resource was last updated.'),
6067
+ deletedAt: z
6068
+ .date()
6069
+ .optional()
6070
+ .describe('Timestamp of when the resource was permanently deleted.'),
6071
+ listing: notificationEventV1MarketplaceListing,
6072
+ status: notificationEventV1AppStatus,
6073
+ type: z.literal('sandbox').describe("The app's type is Sandbox."),
6074
+ })
6075
+ .describe('Sandbox app can be used for testing OpenMeter features. The app is not creating anything in external systems, thus it is safe to use for verifying OpenMeter features.');
6076
+ export const notificationEventV1CustomInvoicingApp = z
6077
+ .object({
6078
+ id: z
6079
+ .string()
6080
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
6081
+ .describe('A unique identifier for the resource.'),
6082
+ name: z
6083
+ .string()
6084
+ .min(1)
6085
+ .max(256)
6086
+ .describe('Human-readable name for the resource. Between 1 and 256 characters.'),
6087
+ description: z
6088
+ .string()
6089
+ .max(1024)
6090
+ .optional()
6091
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
6092
+ metadata: notificationEventV1Metadata
6093
+ .nullable()
6094
+ .optional()
6095
+ .describe('Additional metadata for the resource.'),
6096
+ createdAt: z.date().describe('Timestamp of when the resource was created.'),
6097
+ updatedAt: z
6098
+ .date()
6099
+ .describe('Timestamp of when the resource was last updated.'),
6100
+ deletedAt: z
6101
+ .date()
6102
+ .optional()
6103
+ .describe('Timestamp of when the resource was permanently deleted.'),
6104
+ listing: notificationEventV1MarketplaceListing,
6105
+ status: notificationEventV1AppStatus,
6106
+ type: z
6107
+ .literal('custom_invoicing')
6108
+ .describe("The app's type is CustomInvoicing."),
6109
+ enableDraftSyncHook: z
6110
+ .boolean()
6111
+ .describe('Enable draft.sync hook. If the hook is not enabled, the invoice will be progressed to the next state automatically.'),
6112
+ enableIssuingSyncHook: z
6113
+ .boolean()
6114
+ .describe('Enable issuing.sync hook. If the hook is not enabled, the invoice will be progressed to the next state automatically.'),
6115
+ })
6116
+ .describe('Custom Invoicing app can be used for interface with any invoicing or payment system. This app provides ways to manipulate invoices and payments, however the integration must rely on Notifications API to get notified about invoice changes.');
6117
+ export const notificationEventV1InvoiceLineAmountDiscount = z
6118
+ .object({
6119
+ createdAt: z.date().describe('Timestamp of when the resource was created.'),
6120
+ updatedAt: z
6121
+ .date()
6122
+ .describe('Timestamp of when the resource was last updated.'),
6123
+ deletedAt: z
6124
+ .date()
6125
+ .optional()
6126
+ .describe('Timestamp of when the resource was permanently deleted.'),
6127
+ id: z
6128
+ .string()
6129
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
6130
+ .describe('ID of the charge or discount.'),
6131
+ reason: notificationEventV1BillingDiscountReason,
6132
+ description: z
6133
+ .string()
6134
+ .optional()
6135
+ .describe('Text description as to why the discount was applied.'),
6136
+ externalIds: notificationEventV1InvoiceLineAppExternalIds.optional(),
6137
+ amount: notificationEventV1Numeric,
6138
+ })
6139
+ .describe('InvoiceLineAmountDiscount represents an amount deducted from the line, and will be applied before taxes.');
6140
+ export const notificationEventV1InvoiceLineUsageDiscount = z
6141
+ .object({
6142
+ createdAt: z.date().describe('Timestamp of when the resource was created.'),
6143
+ updatedAt: z
6144
+ .date()
6145
+ .describe('Timestamp of when the resource was last updated.'),
6146
+ deletedAt: z
6147
+ .date()
6148
+ .optional()
6149
+ .describe('Timestamp of when the resource was permanently deleted.'),
6150
+ id: z
6151
+ .string()
6152
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
6153
+ .describe('ID of the charge or discount.'),
6154
+ reason: notificationEventV1BillingDiscountReason,
6155
+ description: z
6156
+ .string()
6157
+ .optional()
6158
+ .describe('Text description as to why the discount was applied.'),
6159
+ externalIds: notificationEventV1InvoiceLineAppExternalIds.optional(),
6160
+ quantity: notificationEventV1Numeric,
6161
+ preLinePeriodQuantity: notificationEventV1Numeric.optional(),
6162
+ })
6163
+ .describe('InvoiceLineUsageDiscount represents an usage-based discount applied to the line. The deduction is done before the pricing algorithm is applied.');
6164
+ export const notificationEventV1InvoiceDetailedLineRateCard = z
6165
+ .object({
6166
+ taxConfig: notificationEventV1TaxConfig.optional(),
6167
+ price: notificationEventV1FlatPriceWithPaymentTerm
6168
+ .nullable()
6169
+ .describe('The price of the rate card. When null, the feature or service is free.'),
6170
+ quantity: notificationEventV1Numeric.optional(),
6171
+ discounts: notificationEventV1BillingDiscounts.optional(),
6172
+ })
6173
+ .describe('InvoiceDetailedLineRateCard represents the rate card (intent) for a flat fee line.');
6174
+ export const notificationEventV1PaymentTerms = z
6175
+ .discriminatedUnion('type', [
6176
+ notificationEventV1PaymentTermInstant,
6177
+ notificationEventV1PaymentTermDueDate,
6178
+ ])
6179
+ .describe('PaymentTerms defines the terms for payment.');
5002
6180
  export const price = z
5003
6181
  .discriminatedUnion('type', [
5004
6182
  priceFree,
@@ -5273,14 +6451,87 @@ export const notificationRulePagePaginatedResponse = z
5273
6451
  meta: paginatedMeta,
5274
6452
  })
5275
6453
  .describe('Page paginated response.');
5276
- export const notificationEventPayload = z
6454
+ export const notificationEventV1BillingWorkflowCollectionAlignment = z
5277
6455
  .discriminatedUnion('type', [
5278
- notificationEventBalanceThresholdPayload,
5279
- notificationEventResetPayload,
5280
- notificationEventInvoiceCreatedPayload,
5281
- notificationEventInvoiceUpdatedPayload,
6456
+ notificationEventV1BillingWorkflowCollectionAlignmentSubscription,
6457
+ notificationEventV1BillingWorkflowCollectionAlignmentAnchored,
5282
6458
  ])
5283
- .describe('The payload delivered to the channels, discriminated by the event type.');
6459
+ .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).');
6460
+ export const notificationEventV1Feature = z
6461
+ .object({
6462
+ createdAt: z.date().describe('Timestamp of when the resource was created.'),
6463
+ updatedAt: z
6464
+ .date()
6465
+ .describe('Timestamp of when the resource was last updated.'),
6466
+ deletedAt: z
6467
+ .date()
6468
+ .optional()
6469
+ .describe('Timestamp of when the resource was permanently deleted.'),
6470
+ archivedAt: z
6471
+ .date()
6472
+ .optional()
6473
+ .describe('Timestamp of when the resource was archived.'),
6474
+ key: z
6475
+ .string()
6476
+ .min(1)
6477
+ .max(64)
6478
+ .regex(new RegExp('^[a-z0-9]+(?:_[a-z0-9]+)*$'))
6479
+ .describe('A key is a unique string that is used to identify a resource.'),
6480
+ name: z.string().describe('The human-readable name of the feature.'),
6481
+ metadata: notificationEventV1Metadata.optional(),
6482
+ meterSlug: z
6483
+ .string()
6484
+ .min(1)
6485
+ .optional()
6486
+ .describe('A key is a unique string that is used to identify a resource.'),
6487
+ meterGroupByFilters: z
6488
+ .record(z.string(), z.string())
6489
+ .optional()
6490
+ .describe('Optional meter group by filters. Useful if the meter scope is broader than what feature tracks. Example scenario would be a meter tracking all token use with groupBy fields for the model, then the feature could filter for model=gpt-4. ⚠️ **Deprecated**: Use advancedMeterGroupByFilters instead'),
6491
+ advancedMeterGroupByFilters: z
6492
+ .record(z.string(), notificationEventV1FilterString)
6493
+ .optional()
6494
+ .describe('Optional advanced meter group by filters. You can use this to filter for values of the meter groupBy fields.'),
6495
+ unitCost: notificationEventV1FeatureUnitCost.optional(),
6496
+ id: z
6497
+ .string()
6498
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
6499
+ .describe('Readonly unique ULID identifier.'),
6500
+ })
6501
+ .describe('Represents a feature that can be enabled or disabled for a plan. Used both for product catalog and entitlements.');
6502
+ export const notificationEventV1RateCardUsageBasedPrice = z
6503
+ .discriminatedUnion('type', [
6504
+ notificationEventV1FlatPriceWithPaymentTerm,
6505
+ notificationEventV1UnitPriceWithCommitments,
6506
+ notificationEventV1TieredPriceWithCommitments,
6507
+ notificationEventV1DynamicPriceWithCommitments,
6508
+ notificationEventV1PackagePriceWithCommitments,
6509
+ ])
6510
+ .describe('The price of the usage based rate card.');
6511
+ export const notificationEventV1App = z
6512
+ .discriminatedUnion('type', [
6513
+ notificationEventV1StripeApp,
6514
+ notificationEventV1SandboxApp,
6515
+ notificationEventV1CustomInvoicingApp,
6516
+ ])
6517
+ .describe('App. One of: stripe');
6518
+ export const notificationEventV1InvoiceLineDiscounts = z
6519
+ .object({
6520
+ amount: z
6521
+ .array(notificationEventV1InvoiceLineAmountDiscount)
6522
+ .optional()
6523
+ .describe('Amount based discounts applied to the line. Amount based discounts are deduced from the total price of the line.'),
6524
+ usage: z
6525
+ .array(notificationEventV1InvoiceLineUsageDiscount)
6526
+ .optional()
6527
+ .describe('Usage based discounts applied to the line. Usage based discounts are deduced from the usage of the line before price calculations are applied.'),
6528
+ })
6529
+ .describe('InvoiceLineDiscounts represents the discounts applied to the invoice line by type.');
6530
+ export const notificationEventV1InvoicePaymentTerms = z
6531
+ .object({
6532
+ terms: notificationEventV1PaymentTerms.optional(),
6533
+ })
6534
+ .describe('Payment contains details as to how the invoice should be paid.');
5284
6535
  export const rateCard = z
5285
6536
  .object({
5286
6537
  name: z
@@ -5420,18 +6671,118 @@ export const profileApps = z
5420
6671
  payment: app,
5421
6672
  })
5422
6673
  .describe('Applications used by a billing profile.');
5423
- export const notificationEvent = z
6674
+ export const notificationEventV1BillingWorkflowCollectionSettings = z
5424
6675
  .object({
5425
- id: ulid,
5426
- type: notificationEventType,
5427
- createdAt: dateTime,
5428
- rule: notificationRuleReference,
5429
- deliveryStatus: z
5430
- .array(notificationEventDeliveryStatus)
5431
- .describe('The delivery status of the event, one entry per channel of the rule.'),
5432
- payload: notificationEventPayload,
6676
+ alignment: notificationEventV1BillingWorkflowCollectionAlignment.optional(),
6677
+ interval: z
6678
+ .string()
6679
+ .optional()
6680
+ .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.'),
5433
6681
  })
5434
- .describe('A notification event records that a notification rule fired and tracks the delivery of its payload to each channel of the rule. Events are created by the system and cannot be modified.');
6682
+ .describe('Workflow collection specifies how to collect the pending line items for an invoice');
6683
+ export const notificationEventV1BalanceThresholdPayloadData = z
6684
+ .object({
6685
+ entitlement: notificationEventV1EntitlementMetered,
6686
+ feature: notificationEventV1Feature,
6687
+ subject: notificationEventV1Subject,
6688
+ value: notificationEventV1EntitlementValue,
6689
+ customer: notificationEventV1Customer.optional(),
6690
+ threshold: notificationEventV1RuleBalanceThresholdValue,
6691
+ })
6692
+ .describe('Data of the payload for notification event with `entitlements.balance.threshold` type.');
6693
+ export const notificationEventV1EntitlementValuePayloadBase = z
6694
+ .object({
6695
+ entitlement: notificationEventV1EntitlementMetered,
6696
+ feature: notificationEventV1Feature,
6697
+ subject: notificationEventV1Subject,
6698
+ value: notificationEventV1EntitlementValue,
6699
+ customer: notificationEventV1Customer.optional(),
6700
+ })
6701
+ .describe('Base data for any payload with entitlement entitlement value.');
6702
+ export const notificationEventV1InvoiceUsageBasedRateCard = z
6703
+ .object({
6704
+ featureKey: z
6705
+ .string()
6706
+ .min(1)
6707
+ .max(64)
6708
+ .regex(new RegExp('^[a-z0-9]+(?:_[a-z0-9]+)*$'))
6709
+ .optional()
6710
+ .describe('The feature the customer is entitled to use.'),
6711
+ taxConfig: notificationEventV1TaxConfig.optional(),
6712
+ price: notificationEventV1RateCardUsageBasedPrice
6713
+ .nullable()
6714
+ .describe('The price of the rate card. When null, the feature or service is free.'),
6715
+ discounts: notificationEventV1BillingDiscounts.optional(),
6716
+ })
6717
+ .describe('InvoiceUsageBasedRateCard represents the rate card (intent) for an usage-based line.');
6718
+ export const notificationEventV1BillingProfileApps = z
6719
+ .object({
6720
+ tax: notificationEventV1App
6721
+ .nullable()
6722
+ .describe('The tax app used for this workflow'),
6723
+ invoicing: notificationEventV1App
6724
+ .nullable()
6725
+ .describe('The invoicing app used for this workflow'),
6726
+ payment: notificationEventV1App
6727
+ .nullable()
6728
+ .describe('The payment app used for this workflow'),
6729
+ })
6730
+ .describe('BillingProfileApps represents the applications used by a billing profile');
6731
+ export const notificationEventV1InvoiceDetailedLine = z
6732
+ .object({
6733
+ name: z
6734
+ .string()
6735
+ .min(1)
6736
+ .max(256)
6737
+ .describe('Human-readable name for the resource. Between 1 and 256 characters.'),
6738
+ description: z
6739
+ .string()
6740
+ .max(1024)
6741
+ .optional()
6742
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
6743
+ metadata: notificationEventV1Metadata
6744
+ .nullable()
6745
+ .optional()
6746
+ .describe('Additional metadata for the resource.'),
6747
+ createdAt: z.date().describe('Timestamp of when the resource was created.'),
6748
+ updatedAt: z
6749
+ .date()
6750
+ .describe('Timestamp of when the resource was last updated.'),
6751
+ deletedAt: z
6752
+ .date()
6753
+ .optional()
6754
+ .describe('Timestamp of when the resource was permanently deleted.'),
6755
+ id: z
6756
+ .string()
6757
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
6758
+ .describe('ID of the line.'),
6759
+ managedBy: notificationEventV1InvoiceLineManagedBy,
6760
+ status: notificationEventV1InvoiceLineStatus,
6761
+ discounts: notificationEventV1InvoiceLineDiscounts.optional(),
6762
+ creditAllocations: z
6763
+ .array(notificationEventV1InvoiceLineCreditAllocation)
6764
+ .optional()
6765
+ .describe('Credit allocations applied to this line. Credits are deducted from the line total before taxes are applied.'),
6766
+ invoice: notificationEventV1InvoiceReference.optional(),
6767
+ currency: notificationEventV1CurrencyCode,
6768
+ taxes: z
6769
+ .array(notificationEventV1InvoiceLineTaxItem)
6770
+ .optional()
6771
+ .describe('Taxes applied to the invoice totals.'),
6772
+ taxConfig: notificationEventV1TaxConfig.optional(),
6773
+ totals: notificationEventV1InvoiceTotals,
6774
+ period: notificationEventV1Period,
6775
+ externalIds: notificationEventV1InvoiceLineAppExternalIds.optional(),
6776
+ subscription: notificationEventV1InvoiceLineSubscriptionReference.optional(),
6777
+ invoiceAt: z.date().describe('The time this line item should be invoiced.'),
6778
+ type: z.literal('flat_fee').describe('Type of the line.'),
6779
+ perUnitAmount: notificationEventV1Numeric.optional(),
6780
+ paymentTerm: notificationEventV1PricePaymentTerm.optional(),
6781
+ quantity: notificationEventV1Numeric.optional(),
6782
+ rateCard: notificationEventV1InvoiceDetailedLineRateCard.optional(),
6783
+ category: notificationEventV1InvoiceDetailedLineCostCategory.optional(),
6784
+ })
6785
+ .describe('InvoiceDetailedLine represents a line item that is sold to the customer as a manually added fee.');
5435
6786
  export const subscriptionItem = z
5436
6787
  .object({
5437
6788
  id: ulid,
@@ -5694,12 +7045,99 @@ export const chargeRealization = z
5694
7045
  .describe('The detailed (rated) lines produced by the realization run. Requires the `realization.detailed_lines` expand.'),
5695
7046
  })
5696
7047
  .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).");
5697
- export const notificationEventPagePaginatedResponse = z
7048
+ export const notificationEventV1BillingWorkflow = z
5698
7049
  .object({
5699
- data: z.array(notificationEvent),
5700
- meta: paginatedMeta,
7050
+ collection: notificationEventV1BillingWorkflowCollectionSettings.optional(),
7051
+ invoicing: notificationEventV1BillingWorkflowInvoicingSettings.optional(),
7052
+ payment: notificationEventV1BillingWorkflowPaymentSettings.optional(),
7053
+ tax: notificationEventV1BillingWorkflowTaxSettings.optional(),
5701
7054
  })
5702
- .describe('Page paginated response.');
7055
+ .describe('BillingWorkflow represents the settings for a billing workflow.');
7056
+ export const notificationEventBalanceThresholdPayload = z
7057
+ .object({
7058
+ id: ulid,
7059
+ type: z
7060
+ .literal('entitlements.balance.threshold')
7061
+ .describe('The type of the event.'),
7062
+ timestamp: dateTime,
7063
+ data: notificationEventV1BalanceThresholdPayloadData,
7064
+ })
7065
+ .describe('A balance threshold notification event payload.');
7066
+ export const notificationEventResetPayload = z
7067
+ .object({
7068
+ id: ulid,
7069
+ type: z.literal('entitlements.reset').describe('The type of the event.'),
7070
+ timestamp: dateTime,
7071
+ data: notificationEventV1EntitlementValuePayloadBase,
7072
+ })
7073
+ .describe('An entitlement reset notification event payload.');
7074
+ export const notificationEventV1InvoiceLine = z
7075
+ .object({
7076
+ name: z
7077
+ .string()
7078
+ .min(1)
7079
+ .max(256)
7080
+ .describe('Human-readable name for the resource. Between 1 and 256 characters.'),
7081
+ description: z
7082
+ .string()
7083
+ .max(1024)
7084
+ .optional()
7085
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
7086
+ metadata: notificationEventV1Metadata
7087
+ .nullable()
7088
+ .optional()
7089
+ .describe('Additional metadata for the resource.'),
7090
+ createdAt: z.date().describe('Timestamp of when the resource was created.'),
7091
+ updatedAt: z
7092
+ .date()
7093
+ .describe('Timestamp of when the resource was last updated.'),
7094
+ deletedAt: z
7095
+ .date()
7096
+ .optional()
7097
+ .describe('Timestamp of when the resource was permanently deleted.'),
7098
+ id: z
7099
+ .string()
7100
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
7101
+ .describe('ID of the line.'),
7102
+ managedBy: notificationEventV1InvoiceLineManagedBy,
7103
+ status: notificationEventV1InvoiceLineStatus,
7104
+ discounts: notificationEventV1InvoiceLineDiscounts.optional(),
7105
+ creditAllocations: z
7106
+ .array(notificationEventV1InvoiceLineCreditAllocation)
7107
+ .optional()
7108
+ .describe('Credit allocations applied to this line. Credits are deducted from the line total before taxes are applied.'),
7109
+ invoice: notificationEventV1InvoiceReference.optional(),
7110
+ currency: notificationEventV1CurrencyCode,
7111
+ taxes: z
7112
+ .array(notificationEventV1InvoiceLineTaxItem)
7113
+ .optional()
7114
+ .describe('Taxes applied to the invoice totals.'),
7115
+ taxConfig: notificationEventV1TaxConfig.optional(),
7116
+ totals: notificationEventV1InvoiceTotals,
7117
+ period: notificationEventV1Period,
7118
+ invoiceAt: z.date().describe('The time this line item should be invoiced.'),
7119
+ externalIds: notificationEventV1InvoiceLineAppExternalIds.optional(),
7120
+ subscription: notificationEventV1InvoiceLineSubscriptionReference.optional(),
7121
+ type: z.literal('usage_based').describe('Type of the line.'),
7122
+ price: notificationEventV1RateCardUsageBasedPrice.optional(),
7123
+ featureKey: z
7124
+ .string()
7125
+ .min(1)
7126
+ .max(64)
7127
+ .regex(new RegExp('^[a-z0-9]+(?:_[a-z0-9]+)*$'))
7128
+ .optional()
7129
+ .describe('The feature that the usage is based on.'),
7130
+ children: z
7131
+ .array(notificationEventV1InvoiceDetailedLine)
7132
+ .optional()
7133
+ .describe('The lines detailing the item or service sold.'),
7134
+ rateCard: notificationEventV1InvoiceUsageBasedRateCard.optional(),
7135
+ quantity: notificationEventV1Numeric.optional(),
7136
+ meteredQuantity: notificationEventV1Numeric.optional(),
7137
+ preLinePeriodQuantity: notificationEventV1Numeric.optional(),
7138
+ meteredPreLinePeriodQuantity: notificationEventV1Numeric.optional(),
7139
+ })
7140
+ .describe('InvoiceUsageBasedLine represents a line item that is sold to the customer based on usage.');
5703
7141
  export const subscriptionPhase = z
5704
7142
  .object({
5705
7143
  id: ulid,
@@ -5911,6 +7349,16 @@ export const profilePagePaginatedResponse = z
5911
7349
  meta: paginatedMeta,
5912
7350
  })
5913
7351
  .describe('Page paginated response.');
7352
+ export const notificationEventV1InvoiceWorkflowSettings = z
7353
+ .object({
7354
+ apps: notificationEventV1BillingProfileApps.optional(),
7355
+ sourceBillingProfileId: z
7356
+ .string()
7357
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
7358
+ .describe('sourceBillingProfileID is the billing profile on which the workflow was based on. The profile is snapshotted on invoice creation, after which it can be altered independently of the profile itself.'),
7359
+ workflow: notificationEventV1BillingWorkflow,
7360
+ })
7361
+ .describe("InvoiceWorkflowSettings represents the workflow settings used by the invoice. This is a clone of the billing profile's workflow settings at the time of invoice creation with customer overrides considered.");
5914
7362
  export const subscription = z
5915
7363
  .object({
5916
7364
  id: ulid,
@@ -6095,6 +7543,83 @@ export const updateInvoiceStandardRequest = z
6095
7543
  .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.'),
6096
7544
  })
6097
7545
  .describe('InvoiceStandard update request.');
7546
+ export const notificationEventV1Invoice = z
7547
+ .object({
7548
+ id: z
7549
+ .string()
7550
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
7551
+ .describe('A unique identifier for the resource.'),
7552
+ description: z
7553
+ .string()
7554
+ .max(1024)
7555
+ .optional()
7556
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
7557
+ metadata: notificationEventV1Metadata
7558
+ .nullable()
7559
+ .optional()
7560
+ .describe('Additional metadata for the resource.'),
7561
+ createdAt: z.date().describe('Timestamp of when the resource was created.'),
7562
+ updatedAt: z
7563
+ .date()
7564
+ .describe('Timestamp of when the resource was last updated.'),
7565
+ deletedAt: z
7566
+ .date()
7567
+ .optional()
7568
+ .describe('Timestamp of when the resource was permanently deleted.'),
7569
+ type: notificationEventV1InvoiceType,
7570
+ supplier: notificationEventV1BillingParty,
7571
+ customer: notificationEventV1BillingInvoiceCustomerExtendedDetails,
7572
+ number: notificationEventV1InvoiceNumber,
7573
+ currency: notificationEventV1CurrencyCode,
7574
+ preceding: z
7575
+ .array(notificationEventV1InvoiceDocumentRef)
7576
+ .optional()
7577
+ .describe('Key information regarding previous invoices and potentially details as to why they were corrected.'),
7578
+ totals: notificationEventV1InvoiceTotals,
7579
+ status: notificationEventV1InvoiceStatus,
7580
+ statusDetails: notificationEventV1InvoiceStatusDetails,
7581
+ issuedAt: z
7582
+ .date()
7583
+ .optional()
7584
+ .describe('The time the invoice was issued. Depending on the status of the invoice this can mean multiple things: - draft, gathering: The time the invoice will be issued based on the workflow settings. - issued: The time the invoice was issued.'),
7585
+ draftUntil: z
7586
+ .date()
7587
+ .optional()
7588
+ .describe('The time until the invoice is in draft status. On draft invoice creation it is calculated from the workflow settings. If manual approval is required, the draftUntil time is set.'),
7589
+ quantitySnapshotedAt: z
7590
+ .date()
7591
+ .optional()
7592
+ .describe('The time when the quantity snapshots on the invoice lines were taken.'),
7593
+ collectionAt: z
7594
+ .date()
7595
+ .optional()
7596
+ .describe('The time when the invoice will be/has been collected.'),
7597
+ dueAt: z
7598
+ .date()
7599
+ .optional()
7600
+ .describe('Due time of the fulfillment of the invoice (if available).'),
7601
+ period: notificationEventV1Period.optional(),
7602
+ voidedAt: z
7603
+ .date()
7604
+ .optional()
7605
+ .describe('The time the invoice was voided. If the invoice was voided, this field will be set to the time the invoice was voided.'),
7606
+ sentToCustomerAt: z
7607
+ .date()
7608
+ .optional()
7609
+ .describe('The time the invoice was sent to customer.'),
7610
+ workflow: notificationEventV1InvoiceWorkflowSettings,
7611
+ lines: z
7612
+ .array(notificationEventV1InvoiceLine)
7613
+ .optional()
7614
+ .describe('List of invoice lines representing each of the items sold to the customer.'),
7615
+ payment: notificationEventV1InvoicePaymentTerms.optional(),
7616
+ validationIssues: z
7617
+ .array(notificationEventV1ValidationIssue)
7618
+ .optional()
7619
+ .describe('Validation issues reported by the invoice workflow.'),
7620
+ externalIds: notificationEventV1InvoiceAppExternalIds.optional(),
7621
+ })
7622
+ .describe('Invoice represents an invoice in the system.');
6098
7623
  export const subscriptionOrReference = z
6099
7624
  .union([subscription, subscriptionReference])
6100
7625
  .describe('Subscription or reference.');
@@ -6122,6 +7647,22 @@ export const invoice = z
6122
7647
  export const updateInvoiceRequest = z
6123
7648
  .discriminatedUnion('type', [updateInvoiceStandardRequest])
6124
7649
  .describe('UpdateInvoiceRequest update request.');
7650
+ export const notificationEventInvoiceCreatedPayload = z
7651
+ .object({
7652
+ id: ulid,
7653
+ type: z.literal('invoice.created').describe('The type of the event.'),
7654
+ timestamp: dateTime,
7655
+ data: notificationEventV1Invoice,
7656
+ })
7657
+ .describe('An invoice created notification event payload.');
7658
+ export const notificationEventInvoiceUpdatedPayload = z
7659
+ .object({
7660
+ id: ulid,
7661
+ type: z.literal('invoice.updated').describe('The type of the event.'),
7662
+ timestamp: dateTime,
7663
+ data: notificationEventV1Invoice,
7664
+ })
7665
+ .describe('An invoice updated notification event payload.');
6125
7666
  export const chargeFlatFee = z
6126
7667
  .object({
6127
7668
  id: ulid,
@@ -6238,15 +7779,41 @@ export const invoicePagePaginatedResponse = z
6238
7779
  meta: paginatedMeta,
6239
7780
  })
6240
7781
  .describe('Page paginated response.');
7782
+ export const notificationEventPayload = z
7783
+ .discriminatedUnion('type', [
7784
+ notificationEventBalanceThresholdPayload,
7785
+ notificationEventResetPayload,
7786
+ notificationEventInvoiceCreatedPayload,
7787
+ notificationEventInvoiceUpdatedPayload,
7788
+ ])
7789
+ .describe('The payload delivered to the channels, discriminated by the event type.');
6241
7790
  export const charge = z
6242
7791
  .discriminatedUnion('type', [chargeFlatFee, chargeUsageBased])
6243
7792
  .describe('Customer charge.');
7793
+ export const notificationEvent = z
7794
+ .object({
7795
+ id: ulid,
7796
+ type: notificationEventType,
7797
+ createdAt: dateTime,
7798
+ rule: notificationRuleReference,
7799
+ deliveryStatus: z
7800
+ .array(notificationEventDeliveryStatus)
7801
+ .describe('The delivery status of the event, one entry per channel of the rule.'),
7802
+ payload: notificationEventPayload,
7803
+ })
7804
+ .describe('A notification event records that a notification rule fired and tracks the delivery of its payload to each channel of the rule. Events are created by the system and cannot be modified.');
6244
7805
  export const chargePagePaginatedResponse = z
6245
7806
  .object({
6246
7807
  data: z.array(charge),
6247
7808
  meta: paginatedMeta,
6248
7809
  })
6249
7810
  .describe('Page paginated response.');
7811
+ export const notificationEventPagePaginatedResponse = z
7812
+ .object({
7813
+ data: z.array(notificationEvent),
7814
+ meta: paginatedMeta,
7815
+ })
7816
+ .describe('Page paginated response.');
6250
7817
  export const listMeteringEventsQueryParams = z.object({
6251
7818
  page: cursorPaginationQueryPage.optional(),
6252
7819
  filter: listEventsParamsFilter.optional(),
@@ -8183,75 +9750,485 @@ export const entitlementAccessQueryRequestCustomersWire = z
8183
9750
  .describe('List of customer identifiers to evaluate access for.');
8184
9751
  export const entitlementAccessQueryRequestFeaturesWire = z
8185
9752
  .strictObject({
8186
- keys: z
8187
- .array(z.string())
8188
- .min(1)
8189
- .max(100)
8190
- .describe('List of feature keys to evaluate access for.'),
9753
+ keys: z
9754
+ .array(z.string())
9755
+ .min(1)
9756
+ .max(100)
9757
+ .describe('List of feature keys to evaluate access for.'),
9758
+ })
9759
+ .describe('Optional list of feature keys to evaluate access for. If omitted, all features available in the organization are returned. Providing this list is recommended to reduce the response size and the load on the backend services.');
9760
+ export const entitlementFeatureAccessReasonCodeWire = z
9761
+ .enum([
9762
+ 'unknown',
9763
+ 'usage_limit_reached',
9764
+ 'feature_unavailable',
9765
+ 'feature_not_found',
9766
+ 'no_credit_available',
9767
+ ])
9768
+ .describe('Machine-readable reason code for denied feature access.');
9769
+ export const entitlementAccessQueryErrorCodeWire = z
9770
+ .enum(['unknown', 'customer_not_found'])
9771
+ .describe('Error code for an entitlement access query failure.');
9772
+ export const booleanFieldFilterWire = z
9773
+ .union([
9774
+ z.boolean(),
9775
+ z.strictObject({
9776
+ eq: z
9777
+ .boolean()
9778
+ .describe('Value strictly equals the given boolean value.'),
9779
+ }),
9780
+ ])
9781
+ .describe('Filter by a boolean value (true/false).');
9782
+ export const notificationChannelTypeWire = z
9783
+ .enum(['webhook'])
9784
+ .describe('The type of a notification channel. Currently the only supported channel type is `webhook`; the domain model anticipates additional channel types (e.g. email, Slack) in the future, so this is modeled as an enum rather than a boolean/constant even though it has a single member today.');
9785
+ export const notificationBalanceThresholdTypeWire = z
9786
+ .enum(['balance_value', 'usage_percentage', 'usage_value'])
9787
+ .describe('What a balance threshold is measured against.');
9788
+ export const notificationEventTypeWire = z
9789
+ .enum([
9790
+ 'entitlements.balance.threshold',
9791
+ 'entitlements.reset',
9792
+ 'invoice.created',
9793
+ 'invoice.updated',
9794
+ ])
9795
+ .describe('The type of a notification event. It determines which payload variant the event carries.');
9796
+ export const notificationEventDeliveryStateWire = z
9797
+ .enum(['success', 'failed', 'sending', 'pending', 'resending'])
9798
+ .describe('The delivery state of a notification event for a single channel.');
9799
+ export const notificationEventDeliveryAttemptResponseWire = z
9800
+ .strictObject({
9801
+ status_code: z
9802
+ .number()
9803
+ .int()
9804
+ .gte(-2147483648)
9805
+ .lte(2147483647)
9806
+ .optional()
9807
+ .describe('The HTTP status code returned by the recipient. Absent when no response was received.'),
9808
+ body: z
9809
+ .string()
9810
+ .describe('The response body returned by the recipient. Empty when no body was received.'),
9811
+ duration_ms: z.coerce
9812
+ .bigint()
9813
+ .gte(-9223372036854775808n)
9814
+ .lte(9223372036854775807n)
9815
+ .describe('How long the delivery attempt took, in milliseconds.'),
9816
+ url: z
9817
+ .string()
9818
+ .optional()
9819
+ .describe('The URL the event was delivered to. Only set for webhook channels.'),
9820
+ })
9821
+ .describe('The response the recipient returned for a delivery attempt. For webhook channels this is the HTTP response.');
9822
+ export const notificationEventV1MetadataWire = z
9823
+ .record(z.string(), z.string())
9824
+ .describe('Set of key-value pairs. Metadata can be used to store additional information about a resource.');
9825
+ export const notificationEventV1AnnotationsWire = z
9826
+ .record(z.string(), z.unknown())
9827
+ .describe('Set of key-value pairs managed by the system. Cannot be modified by user.');
9828
+ export const notificationEventV1PeriodWire = z
9829
+ .strictObject({
9830
+ from: z.string().datetime({ offset: true }).describe('Period start time.'),
9831
+ to: z.string().datetime({ offset: true }).describe('Period end time.'),
9832
+ })
9833
+ .describe('A period with a start and end time.');
9834
+ export const notificationEventV1RecurringPeriodIntervalEnumWire = z
9835
+ .enum(['DAY', 'WEEK', 'MONTH', 'YEAR'])
9836
+ .describe('The unit of time for the interval. One of: `day`, `week`, `month`, or `year`.');
9837
+ export const notificationEventV1FilterStringWire = z
9838
+ .strictObject({
9839
+ $eq: z
9840
+ .string()
9841
+ .nullable()
9842
+ .optional()
9843
+ .describe('The field must be equal to the provided value.'),
9844
+ $ne: z
9845
+ .string()
9846
+ .nullable()
9847
+ .optional()
9848
+ .describe('The field must not be equal to the provided value.'),
9849
+ $in: z
9850
+ .array(z.string())
9851
+ .nullable()
9852
+ .optional()
9853
+ .describe('The field must be in the provided list of values.'),
9854
+ $nin: z
9855
+ .array(z.string())
9856
+ .nullable()
9857
+ .optional()
9858
+ .describe('The field must not be in the provided list of values.'),
9859
+ $like: z
9860
+ .string()
9861
+ .nullable()
9862
+ .optional()
9863
+ .describe('The field must match the provided value.'),
9864
+ $nlike: z
9865
+ .string()
9866
+ .nullable()
9867
+ .optional()
9868
+ .describe('The field must not match the provided value.'),
9869
+ $ilike: z
9870
+ .string()
9871
+ .nullable()
9872
+ .optional()
9873
+ .describe('The field must match the provided value, ignoring case.'),
9874
+ $nilike: z
9875
+ .string()
9876
+ .nullable()
9877
+ .optional()
9878
+ .describe('The field must not match the provided value, ignoring case.'),
9879
+ $gt: z
9880
+ .string()
9881
+ .nullable()
9882
+ .optional()
9883
+ .describe('The field must be greater than the provided value.'),
9884
+ $gte: z
9885
+ .string()
9886
+ .nullable()
9887
+ .optional()
9888
+ .describe('The field must be greater than or equal to the provided value.'),
9889
+ $lt: z
9890
+ .string()
9891
+ .nullable()
9892
+ .optional()
9893
+ .describe('The field must be less than the provided value.'),
9894
+ $lte: z
9895
+ .string()
9896
+ .nullable()
9897
+ .optional()
9898
+ .describe('The field must be less than or equal to the provided value.'),
9899
+ get $and() {
9900
+ return z
9901
+ .array(notificationEventV1FilterStringWire)
9902
+ .nullable()
9903
+ .optional()
9904
+ .describe('Provide a list of filters to be combined with a logical AND.');
9905
+ },
9906
+ get $or() {
9907
+ return z
9908
+ .array(notificationEventV1FilterStringWire)
9909
+ .nullable()
9910
+ .optional()
9911
+ .describe('Provide a list of filters to be combined with a logical OR.');
9912
+ },
9913
+ })
9914
+ .describe('A filter for a string field.');
9915
+ export const notificationEventV1NumericWire = z
9916
+ .string()
9917
+ .regex(new RegExp('^\\-?[0-9]+(\\.[0-9]+)?$'))
9918
+ .describe('Numeric represents an arbitrary precision number.');
9919
+ export const notificationEventV1SubjectWire = z
9920
+ .strictObject({
9921
+ created_at: z
9922
+ .string()
9923
+ .datetime({ offset: true })
9924
+ .describe('Timestamp of when the resource was created.'),
9925
+ updated_at: z
9926
+ .string()
9927
+ .datetime({ offset: true })
9928
+ .describe('Timestamp of when the resource was last updated.'),
9929
+ deleted_at: z
9930
+ .string()
9931
+ .datetime({ offset: true })
9932
+ .optional()
9933
+ .describe('Timestamp of when the resource was permanently deleted.'),
9934
+ id: z.string().describe('A unique identifier for the subject.'),
9935
+ key: z
9936
+ .string()
9937
+ .describe('A unique, human-readable identifier for the subject. This is typically a database ID or a customer key.'),
9938
+ display_name: z
9939
+ .string()
9940
+ .nullable()
9941
+ .optional()
9942
+ .describe('A human-readable display name for the subject.'),
9943
+ metadata: z
9944
+ .record(z.string(), z.unknown())
9945
+ .nullable()
9946
+ .optional()
9947
+ .describe('Metadata for the subject.'),
9948
+ current_period_start: z
9949
+ .string()
9950
+ .datetime({ offset: true })
9951
+ .optional()
9952
+ .describe('The start of the current period for the subject.'),
9953
+ current_period_end: z
9954
+ .string()
9955
+ .datetime({ offset: true })
9956
+ .optional()
9957
+ .describe('The end of the current period for the subject.'),
9958
+ stripe_customer_id: z
9959
+ .string()
9960
+ .nullable()
9961
+ .optional()
9962
+ .describe('The Stripe customer ID for the subject.'),
9963
+ })
9964
+ .describe('A subject is a unique identifier for a usage attribution by its key. Subjects only exist in the concept of metering. Subjects are optional to create and work as an enrichment for the subject key like displayName, metadata, etc. Subjects are useful when you are reporting usage events with your own database ID but want to enrich the subject with a human-readable name or metadata. For most use cases, a subject is equivalent to a customer. ⚠️ **Deprecated**: Subjects as managable entities are being depracated, use customers with subject key usage attribution instead.');
9965
+ export const notificationEventV1EntitlementValueWire = z
9966
+ .strictObject({
9967
+ has_access: z
9968
+ .boolean()
9969
+ .describe('Whether the subject has access to the feature. Shared accross all entitlement types.'),
9970
+ balance: z
9971
+ .number()
9972
+ .optional()
9973
+ .describe("Only available for metered entitlements. Metered entitlements are built around a balance calculation where feature usage is deducted from the issued grants. Balance represents the remaining balance of the entitlement, it's value never turns negative."),
9974
+ usage: z
9975
+ .number()
9976
+ .optional()
9977
+ .describe('Only available for metered entitlements. Returns the total feature usage in the current period.'),
9978
+ overage: z
9979
+ .number()
9980
+ .optional()
9981
+ .describe("Only available for metered entitlements. Overage represents the usage that wasn't covered by grants, e.g. if the subject had a total feature usage of 100 in the period but they were only granted 80, there would be 20 overage."),
9982
+ total_available_grant_amount: z
9983
+ .number()
9984
+ .optional()
9985
+ .describe('Only available for metered entitlements. The summed amount of all grant active at query time PLUS the used amount of since inactive grants.'),
9986
+ config: z
9987
+ .string()
9988
+ .optional()
9989
+ .describe('Only available for static entitlements. The JSON parsable config of the entitlement.'),
9990
+ })
9991
+ .describe('Entitlements are the core of OpenMeter access management. They define access to features for subjects. Entitlements can be metered, boolean, or static.');
9992
+ export const notificationEventV1CustomerUsageAttributionWire = z
9993
+ .strictObject({
9994
+ subject_keys: z
9995
+ .array(z.string())
9996
+ .nullable()
9997
+ .describe('The subjects that are attributed to the customer. Can be empty when no subjects are associated with the customer.'),
9998
+ })
9999
+ .describe('Mapping to attribute metered usage to the customer. One customer can have zero or more subjects, but one subject can only belong to one customer.');
10000
+ export const notificationEventV1CurrencyCodeWire = z
10001
+ .string()
10002
+ .min(3)
10003
+ .max(3)
10004
+ .regex(new RegExp('^[A-Z]{3}$'))
10005
+ .describe('Three-letter [ISO4217](https://www.iso.org/iso-4217-currency-codes.html) currency code. Custom three-letter currency codes are also supported for convenience.');
10006
+ export const notificationEventV1CountryCodeWire = z
10007
+ .string()
10008
+ .min(2)
10009
+ .max(2)
10010
+ .regex(new RegExp('^[A-Z]{2}$'))
10011
+ .describe('[ISO 3166-1](https://www.iso.org/iso-3166-country-codes.html) alpha-2 country code. Custom two-letter country codes are also supported for convenience.');
10012
+ export const notificationEventV1AlignmentWire = z
10013
+ .strictObject({
10014
+ billables_must_align: z
10015
+ .boolean()
10016
+ .optional()
10017
+ .describe("Whether all Billable items and RateCards must align. Alignment means the Price's BillingCadence must align for both duration and anchor time."),
10018
+ })
10019
+ .describe('Alignment configuration for a plan or subscription.');
10020
+ export const notificationEventV1SubscriptionStatusWire = z
10021
+ .enum(['active', 'inactive', 'canceled', 'scheduled'])
10022
+ .describe('Subscription status.');
10023
+ export const notificationEventV1PlanReferenceWire = z
10024
+ .strictObject({
10025
+ id: z
10026
+ .string()
10027
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
10028
+ .describe('The plan ID.'),
10029
+ key: z
10030
+ .string()
10031
+ .min(1)
10032
+ .max(64)
10033
+ .regex(new RegExp('^[a-z0-9]+(?:_[a-z0-9]+)*$'))
10034
+ .describe('The plan key.'),
10035
+ version: z.number().int().describe('The plan version.'),
10036
+ })
10037
+ .describe('References an exact plan.');
10038
+ export const notificationEventV1SubscriptionCostBasisModeWire = z
10039
+ .enum(['dynamic', 'pinned'])
10040
+ .describe('Controls how custom-currency cost bases are selected for the subscription.');
10041
+ export const notificationEventV1ProRatingModeWire = z
10042
+ .enum(['prorate_prices'])
10043
+ .describe('Pro-rating mode options for handling billing period changes.');
10044
+ export const notificationEventV1BillingSettlementModeWire = z
10045
+ .enum(['credit_then_invoice', 'credit_only'])
10046
+ .describe('The settlement mode of a plan. It determines how the billing system generates invoices and credits for the subscriptions using this plan. - credit_then_invoice: credits from the previous billing period are applied first, then the remaining balance is invoiced. This is the default and most common settlement mode. - credit_only: only credits from the previous billing period are generated and applied. No invoices are generated for the subscription.');
10047
+ export const notificationEventV1RuleBalanceThresholdValueTypeWire = z
10048
+ .enum([
10049
+ 'PERCENT',
10050
+ 'NUMBER',
10051
+ 'balance_value',
10052
+ 'usage_percentage',
10053
+ 'usage_value',
10054
+ ])
10055
+ .describe('Type of the rule in the balance threshold specification: - `balance_value`: threshold defined by the remaining balance value based on usage and the total of grants in the current usage period - `usage_percentage`: threshold defined by the usage percentage compared to the total of grants in the current usage period - `usage_value`: threshold defined by the usage value in the current usage period - `NUMBER` (**deprecated**): see `usage_value` - `PERCENT` (**deprecated**): see `usage_percentage`');
10056
+ export const notificationEventV1InvoiceTypeWire = z
10057
+ .enum(['standard', 'credit_note'])
10058
+ .describe('InvoiceType represents the type of invoice. The type of invoice determines the purpose of the invoice and how it should be handled.');
10059
+ export const notificationEventV1BillingTaxIdentificationCodeWire = z
10060
+ .string()
10061
+ .min(1)
10062
+ .max(32)
10063
+ .describe('TaxIdentificationCode is a normalized tax code shown on the original identity document.');
10064
+ export const notificationEventV1InvoiceNumberWire = z
10065
+ .string()
10066
+ .min(1)
10067
+ .max(256)
10068
+ .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)');
10069
+ export const notificationEventV1InvoiceDocumentRefTypeWire = z
10070
+ .enum(['credit_note_original_invoice'])
10071
+ .describe('InvoiceDocumentRefType defines the type of document that is being referenced.');
10072
+ export const notificationEventV1InvoiceStatusWire = z
10073
+ .enum([
10074
+ 'gathering',
10075
+ 'draft',
10076
+ 'issuing',
10077
+ 'issued',
10078
+ 'payment_processing',
10079
+ 'overdue',
10080
+ 'paid',
10081
+ 'uncollectible',
10082
+ 'voided',
10083
+ ])
10084
+ .describe('InvoiceStatus describes the status of an invoice.');
10085
+ export const notificationEventV1InvoiceAvailableActionDetailsWire = z
10086
+ .strictObject({
10087
+ resulting_state: z
10088
+ .string()
10089
+ .describe('The state the invoice will reach if the action is activated and all intermediate steps are successful. For example advancing a draft_created invoice will result in a draft_manual_approval_needed invoice.'),
10090
+ })
10091
+ .describe('InvoiceAvailableActionInvoiceDetails represents the details of the invoice action for non-gathering invoices.');
10092
+ export const notificationEventV1InvoiceAvailableActionInvoiceDetailsWire = z
10093
+ .strictObject({})
10094
+ .describe('InvoiceAvailableActionInvoiceDetails represents the details of the invoice action for gathering invoices.');
10095
+ export const notificationEventV1AppTypeWire = z
10096
+ .enum(['stripe', 'sandbox', 'custom_invoicing'])
10097
+ .describe('Type of the app.');
10098
+ export const notificationEventV1AppCapabilityTypeWire = z
10099
+ .enum([
10100
+ 'reportUsage',
10101
+ 'reportEvents',
10102
+ 'calculateTax',
10103
+ 'invoiceCustomers',
10104
+ 'collectPayments',
10105
+ ])
10106
+ .describe('App capability type.');
10107
+ export const notificationEventV1InstallMethodWire = z
10108
+ .enum(['with_oauth2', 'with_api_key', 'no_credentials_required'])
10109
+ .describe('Install method of the application.');
10110
+ export const notificationEventV1AppStatusWire = z
10111
+ .enum(['ready', 'unauthorized'])
10112
+ .describe('App installed status.');
10113
+ export const notificationEventV1BillingWorkflowCollectionAlignmentSubscriptionWire = z
10114
+ .strictObject({
10115
+ type: z.literal('subscription').describe('The type of alignment.'),
10116
+ })
10117
+ .describe('BillingWorkflowCollectionAlignmentSubscription specifies the alignment for collecting the pending line items into an invoice.');
10118
+ export const notificationEventV1BillingWorkflowInvoicingSubscriptionEndProrationModeWire = z
10119
+ .enum(['bill_full_period', 'bill_actual_period'])
10120
+ .describe('Billing workflow subscription end proration mode.');
10121
+ export const notificationEventV1TaxBehaviorWire = z
10122
+ .enum(['inclusive', 'exclusive'])
10123
+ .describe('Tax behavior. This enum is used to specify whether tax is included in the price or excluded from the price.');
10124
+ export const notificationEventV1StripeTaxConfigWire = z
10125
+ .strictObject({
10126
+ code: z
10127
+ .string()
10128
+ .regex(new RegExp('^txcd_\\d{8}$'))
10129
+ .describe('Product tax code. See: https://docs.stripe.com/tax/tax-codes'),
10130
+ })
10131
+ .describe('The tax config for Stripe.');
10132
+ export const notificationEventV1CustomInvoicingTaxConfigWire = z
10133
+ .strictObject({
10134
+ code: z
10135
+ .string()
10136
+ .describe('Tax code. The tax code should be interpreted by the custom invoicing provider.'),
10137
+ })
10138
+ .describe('Custom invoicing tax config.');
10139
+ export const notificationEventV1CollectionMethodWire = z
10140
+ .enum(['charge_automatically', 'send_invoice'])
10141
+ .describe('CollectionMethod specifies how the invoice should be collected (automatic vs manual)');
10142
+ export const notificationEventV1BillingWorkflowTaxSettingsWire = z
10143
+ .strictObject({
10144
+ enabled: z
10145
+ .boolean()
10146
+ .optional()
10147
+ .describe('Enable automatic tax calculation when tax is supported by the app. For example, with Stripe Invoicing when enabled, tax is calculated via Stripe Tax.'),
10148
+ enforced: z
10149
+ .boolean()
10150
+ .optional()
10151
+ .describe('Enforce tax calculation when tax is supported by the app. When enabled, OpenMeter will not allow to create an invoice without tax calculation. Enforcement is different per apps, for example, Stripe app requires customer to have a tax location when starting a paid subscription.'),
10152
+ })
10153
+ .describe('BillingWorkflowTaxSettings represents the tax settings for a billing workflow');
10154
+ export const notificationEventV1InvoiceLineManagedByWire = z
10155
+ .enum(['subscription', 'system', 'manual'])
10156
+ .describe('InvoiceLineManagedBy specifies who manages the line.');
10157
+ export const notificationEventV1InvoiceLineStatusWire = z
10158
+ .enum(['valid', 'detailed', 'split'])
10159
+ .describe('Line status specifies the status of the line.');
10160
+ export const notificationEventV1DiscountReasonMaximumSpendWire = z
10161
+ .strictObject({
10162
+ type: z.literal('maximum_spend').describe('type.'),
10163
+ })
10164
+ .describe('The reason for the discount is a maximum spend.');
10165
+ export const notificationEventV1PercentageWire = z
10166
+ .number()
10167
+ .describe('Numeric representation of a percentage 50% is represented as 50');
10168
+ export const notificationEventV1InvoiceLineAppExternalIdsWire = z
10169
+ .strictObject({
10170
+ invoicing: z
10171
+ .string()
10172
+ .optional()
10173
+ .describe('The external ID of the invoice in the invoicing app if available.'),
10174
+ tax: z
10175
+ .string()
10176
+ .optional()
10177
+ .describe('The external ID of the invoice in the tax app if available.'),
10178
+ })
10179
+ .describe('InvoiceLineAppExternalIds contains the external IDs of the invoice in other apps such as Stripe.');
10180
+ export const notificationEventV1InvoiceLineTaxBehaviorWire = z
10181
+ .enum(['inclusive', 'exclusive'])
10182
+ .describe('InvoiceLineTaxBehavior details how the tax item is applied to the base amount. Inclusive means the tax is included in the base amount. Exclusive means the tax is added to the base amount.');
10183
+ export const notificationEventV1IdResourceWire = z
10184
+ .strictObject({
10185
+ id: z
10186
+ .string()
10187
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
10188
+ .describe('A unique identifier for the resource.'),
10189
+ })
10190
+ .describe('IDResource is a resouce with an ID.');
10191
+ export const notificationEventV1PricePaymentTermWire = z
10192
+ .enum(['in_advance', 'in_arrears'])
10193
+ .describe('The payment term of a flat price. One of: in_advance or in_arrears.');
10194
+ export const notificationEventV1TieredPriceModeWire = z
10195
+ .enum(['volume', 'graduated'])
10196
+ .describe('The mode of the tiered price.');
10197
+ export const notificationEventV1InvoiceDetailedLineCostCategoryWire = z
10198
+ .enum(['regular', 'commitment'])
10199
+ .describe('InvoiceDetailedLineCostCategory determines if the flat fee is a regular fee due to use due to a commitment.');
10200
+ export const notificationEventV1PaymentTermInstantWire = z
10201
+ .strictObject({
10202
+ type: z.literal('instant').describe('Type of terms to be applied.'),
10203
+ detail: z
10204
+ .string()
10205
+ .optional()
10206
+ .describe('Text detail of the chosen payment terms.'),
10207
+ notes: z
10208
+ .string()
10209
+ .optional()
10210
+ .describe('Description of the conditions for payment.'),
8191
10211
  })
8192
- .describe('Optional list of feature keys to evaluate access for. If omitted, all features available in the organization are returned. Providing this list is recommended to reduce the response size and the load on the backend services.');
8193
- export const entitlementFeatureAccessReasonCodeWire = z
8194
- .enum([
8195
- 'unknown',
8196
- 'usage_limit_reached',
8197
- 'feature_unavailable',
8198
- 'feature_not_found',
8199
- 'no_credit_available',
8200
- ])
8201
- .describe('Machine-readable reason code for denied feature access.');
8202
- export const entitlementAccessQueryErrorCodeWire = z
8203
- .enum(['unknown', 'customer_not_found'])
8204
- .describe('Error code for an entitlement access query failure.');
8205
- export const booleanFieldFilterWire = z
8206
- .union([
8207
- z.boolean(),
8208
- z.strictObject({
8209
- eq: z
8210
- .boolean()
8211
- .describe('Value strictly equals the given boolean value.'),
8212
- }),
8213
- ])
8214
- .describe('Filter by a boolean value (true/false).');
8215
- export const notificationChannelTypeWire = z
8216
- .enum(['webhook'])
8217
- .describe('The type of a notification channel. Currently the only supported channel type is `webhook`; the domain model anticipates additional channel types (e.g. email, Slack) in the future, so this is modeled as an enum rather than a boolean/constant even though it has a single member today.');
8218
- export const notificationBalanceThresholdTypeWire = z
8219
- .enum(['balance_value', 'usage_percentage', 'usage_value'])
8220
- .describe('What a balance threshold is measured against.');
8221
- export const notificationEventTypeWire = z
8222
- .enum([
8223
- 'entitlements.balance.threshold',
8224
- 'entitlements.reset',
8225
- 'invoice.created',
8226
- 'invoice.updated',
8227
- ])
8228
- .describe('The type of a notification event. It determines which payload variant the event carries.');
8229
- export const notificationEventDeliveryStateWire = z
8230
- .enum(['success', 'failed', 'sending', 'pending', 'resending'])
8231
- .describe('The delivery state of a notification event for a single channel.');
8232
- export const notificationEventDeliveryAttemptResponseWire = z
10212
+ .describe('PaymentTermInstant defines the terms for payment on receipt of invoice.');
10213
+ export const notificationEventV1ValidationIssueSeverityWire = z
10214
+ .enum(['critical', 'warning'])
10215
+ .describe('ValidationIssueSeverity describes the severity of a validation issue. Issues with severity "critical" will prevent the invoice from being issued.');
10216
+ export const notificationEventV1InvoiceAppExternalIdsWire = z
8233
10217
  .strictObject({
8234
- status_code: z
8235
- .number()
8236
- .int()
8237
- .gte(-2147483648)
8238
- .lte(2147483647)
10218
+ invoicing: z
10219
+ .string()
8239
10220
  .optional()
8240
- .describe('The HTTP status code returned by the recipient. Absent when no response was received.'),
8241
- body: z
10221
+ .describe('The external ID of the invoice in the invoicing app if available.'),
10222
+ tax: z
8242
10223
  .string()
8243
- .describe('The response body returned by the recipient. Empty when no body was received.'),
8244
- duration_ms: z.coerce
8245
- .bigint()
8246
- .gte(-9223372036854775808n)
8247
- .lte(9223372036854775807n)
8248
- .describe('How long the delivery attempt took, in milliseconds.'),
8249
- url: z
10224
+ .optional()
10225
+ .describe('The external ID of the invoice in the tax app if available.'),
10226
+ payment: z
8250
10227
  .string()
8251
10228
  .optional()
8252
- .describe('The URL the event was delivered to. Only set for webhook channels.'),
10229
+ .describe('The external ID of the invoice in the payment app if available.'),
8253
10230
  })
8254
- .describe('The response the recipient returned for a delivery attempt. For webhook channels this is the HTTP response.');
10231
+ .describe('InvoiceAppExternalIds contains the external IDs of the invoice in other apps such as Stripe.');
8255
10232
  export const queryFilterIntegerWire = z
8256
10233
  .strictObject({
8257
10234
  eq: z
@@ -8969,18 +10946,6 @@ export const notificationChannelReferenceWire = z
8969
10946
  id: ulidWire,
8970
10947
  })
8971
10948
  .describe('NotificationChannel reference.');
8972
- export const notificationEventFeatureReferenceWire = z
8973
- .strictObject({
8974
- id: ulidWire,
8975
- key: z.string().describe('The immutable key of the feature.'),
8976
- })
8977
- .describe('A reference to the feature of an entitlement notification event.');
8978
- export const notificationEventInvoiceReferenceWire = z
8979
- .strictObject({
8980
- id: ulidWire,
8981
- number: z.string().describe('The human-readable invoice number.'),
8982
- })
8983
- .describe('A reference to the invoice of an invoice notification event.');
8984
10949
  export const billingCustomerReferenceWire = z
8985
10950
  .strictObject({
8986
10951
  id: ulidWire,
@@ -9990,120 +11955,420 @@ export const entitlementFeatureAccessReasonWire = z
9990
11955
  .describe('Reason a feature is not accessible to a customer.');
9991
11956
  export const entitlementAccessQueryErrorWire = z
9992
11957
  .strictObject({
9993
- code: entitlementAccessQueryErrorCodeWire,
9994
- message: z.string().describe('Human-readable description of the error.'),
9995
- attributes: z
9996
- .record(z.string(), z.unknown())
11958
+ code: entitlementAccessQueryErrorCodeWire,
11959
+ message: z.string().describe('Human-readable description of the error.'),
11960
+ attributes: z
11961
+ .record(z.string(), z.unknown())
11962
+ .optional()
11963
+ .describe('Additional structured context.'),
11964
+ customer: z
11965
+ .string()
11966
+ .optional()
11967
+ .describe('The customer identifier from the request that produced this error.'),
11968
+ })
11969
+ .describe('Query error within a partially successful entitlement access query response.');
11970
+ export const notificationChannelWire = z
11971
+ .strictObject({
11972
+ id: ulidWire,
11973
+ name: z
11974
+ .string()
11975
+ .min(1)
11976
+ .max(256)
11977
+ .describe('Display name of the resource. Between 1 and 256 characters.'),
11978
+ labels: labelsWire.optional(),
11979
+ created_at: dateTimeWire,
11980
+ updated_at: dateTimeWire,
11981
+ deleted_at: dateTimeWire.optional(),
11982
+ type: notificationChannelTypeWire,
11983
+ disabled: z
11984
+ .boolean()
11985
+ .optional()
11986
+ .describe('Whether the channel is disabled. Disabled channels do not receive notification events.'),
11987
+ url: z
11988
+ .string()
11989
+ .describe('The URL that webhook notification events are delivered to.'),
11990
+ custom_headers: z
11991
+ .record(z.string(), z.string())
11992
+ .optional()
11993
+ .describe('Custom HTTP headers to include on every webhook delivery request, keyed by header name.'),
11994
+ signing_secret: z
11995
+ .string()
11996
+ .optional()
11997
+ .describe('Secret used to sign outgoing webhook payloads so recipients can verify their authenticity. If omitted on create, a secret is generated automatically by the delivery provider. This is a sensitive credential returned in responses (unlike most secrets) specifically so clients can retrieve a server-generated value and verify webhook signatures; handle it with the same care as any other credential.'),
11998
+ })
11999
+ .describe('A notification channel delivers notification events, such as entitlement balance threshold crossings, to an external system. Today the only supported channel type is a webhook delivered via Svix.');
12000
+ export const createNotificationChannelRequestWire = z
12001
+ .strictObject({
12002
+ name: z
12003
+ .string()
12004
+ .min(1)
12005
+ .max(256)
12006
+ .describe('Display name of the resource. Between 1 and 256 characters.'),
12007
+ labels: labelsWire.optional(),
12008
+ type: notificationChannelTypeWire,
12009
+ disabled: z
12010
+ .boolean()
12011
+ .optional()
12012
+ .describe('Whether the channel is disabled. Disabled channels do not receive notification events.'),
12013
+ url: z
12014
+ .string()
12015
+ .describe('The URL that webhook notification events are delivered to.'),
12016
+ custom_headers: z
12017
+ .record(z.string(), z.string())
12018
+ .optional()
12019
+ .describe('Custom HTTP headers to include on every webhook delivery request, keyed by header name.'),
12020
+ signing_secret: z
12021
+ .string()
12022
+ .optional()
12023
+ .describe('Secret used to sign outgoing webhook payloads so recipients can verify their authenticity. If omitted on create, a secret is generated automatically by the delivery provider. This is a sensitive credential returned in responses (unlike most secrets) specifically so clients can retrieve a server-generated value and verify webhook signatures; handle it with the same care as any other credential.'),
12024
+ })
12025
+ .describe('NotificationChannel create request.');
12026
+ export const updateBillingNotificationChannelRequestWire = z
12027
+ .strictObject({
12028
+ name: z
12029
+ .string()
12030
+ .min(1)
12031
+ .max(256)
12032
+ .describe('Display name of the resource. Between 1 and 256 characters.'),
12033
+ type: notificationChannelTypeWire,
12034
+ url: z
12035
+ .string()
12036
+ .describe('The URL that webhook notification events are delivered to.'),
12037
+ labels: labelsWire.optional(),
12038
+ disabled: z
12039
+ .boolean()
12040
+ .optional()
12041
+ .describe('Whether the channel is disabled. Disabled channels do not receive notification events.'),
12042
+ custom_headers: z
12043
+ .record(z.string(), z.string())
12044
+ .optional()
12045
+ .describe('Custom HTTP headers to include on every webhook delivery request, keyed by header name.'),
12046
+ signing_secret: z
12047
+ .string()
12048
+ .optional()
12049
+ .describe('Secret used to sign outgoing webhook payloads so recipients can verify their authenticity. If omitted on create, a secret is generated automatically by the delivery provider. This is a sensitive credential returned in responses (unlike most secrets) specifically so clients can retrieve a server-generated value and verify webhook signatures; handle it with the same care as any other credential.'),
12050
+ })
12051
+ .describe("Request body for updating a notification channel. Updates replace the channel's mutable state rather than merging it: `type`, `name`, and `url` must always be provided, and omitting `disabled`, `labels`, or `custom_headers` resets them to their defaults (enabled, no labels, no custom headers). `signing_secret` is the one exception: omitting it keeps the channel's current signing secret instead of clearing the credential.");
12052
+ export const notificationBalanceThresholdWire = z
12053
+ .strictObject({
12054
+ type: notificationBalanceThresholdTypeWire,
12055
+ value: z.number().describe('The threshold value.'),
12056
+ })
12057
+ .describe('A balance threshold of a notification rule. Crossing it generates an `entitlements.balance.threshold` event.');
12058
+ export const notificationRuleReferenceWire = z
12059
+ .strictObject({
12060
+ id: ulidWire,
12061
+ type: notificationEventTypeWire,
12062
+ name: z.string().describe('The user-provided name of the rule.'),
12063
+ })
12064
+ .describe('A reference to the notification rule that generated an event.');
12065
+ export const notificationEventDeliveryAttemptWire = z
12066
+ .strictObject({
12067
+ state: notificationEventDeliveryStateWire,
12068
+ response: notificationEventDeliveryAttemptResponseWire,
12069
+ timestamp: dateTimeWire,
12070
+ })
12071
+ .describe('A single delivery attempt to a channel.');
12072
+ export const notificationEventV1RecurringPeriodIntervalWire = z
12073
+ .union([z.string(), notificationEventV1RecurringPeriodIntervalEnumWire])
12074
+ .describe('Period duration for the recurrence');
12075
+ export const notificationEventV1FeatureManualUnitCostWire = z
12076
+ .strictObject({
12077
+ type: z.literal('manual').describe('type.'),
12078
+ amount: notificationEventV1NumericWire,
12079
+ })
12080
+ .describe('A fixed per-unit cost amount.');
12081
+ export const notificationEventV1FeatureLlmUnitCostPricingWire = z
12082
+ .strictObject({
12083
+ input_per_token: notificationEventV1NumericWire,
12084
+ output_per_token: notificationEventV1NumericWire,
12085
+ cache_read_per_token: notificationEventV1NumericWire.optional(),
12086
+ reasoning_per_token: notificationEventV1NumericWire.optional(),
12087
+ cache_write_per_token: notificationEventV1NumericWire.optional(),
12088
+ })
12089
+ .describe('Resolved per-token pricing from the LLM cost database.');
12090
+ export const notificationEventV1InvoiceTotalsWire = z
12091
+ .strictObject({
12092
+ amount: notificationEventV1NumericWire,
12093
+ charges_total: notificationEventV1NumericWire,
12094
+ discounts_total: notificationEventV1NumericWire,
12095
+ credits_total: notificationEventV1NumericWire,
12096
+ taxes_inclusive_total: notificationEventV1NumericWire,
12097
+ taxes_exclusive_total: notificationEventV1NumericWire,
12098
+ taxes_total: notificationEventV1NumericWire,
12099
+ total: notificationEventV1NumericWire,
12100
+ })
12101
+ .describe('Totals contains the summaries of all calculations for the invoice.');
12102
+ export const notificationEventV1DiscountReasonRatecardUsageWire = z
12103
+ .strictObject({
12104
+ type: z.literal('ratecard_usage').describe('type.'),
12105
+ quantity: notificationEventV1NumericWire,
12106
+ correlation_id: z
12107
+ .string()
12108
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
12109
+ .optional()
12110
+ .describe('Correlation ID for the discount. This is used to link discounts across different invoices (progressive billing use case). If not provided, the invoicing engine will auto-generate one. When editing an invoice line, please make sure to keep the same correlation ID of the discount or in progressive billing setups the discount amounts might be incorrect.'),
12111
+ })
12112
+ .describe('The reason for the discount is a ratecard usage.');
12113
+ export const notificationEventV1InvoiceLineCreditAllocationWire = z
12114
+ .strictObject({
12115
+ amount: notificationEventV1NumericWire,
12116
+ description: z
12117
+ .string()
12118
+ .optional()
12119
+ .describe('Text description as to why the credit was allocated.'),
12120
+ })
12121
+ .describe('InvoiceLineCreditAllocation represents a credit amount allocated to the line before taxes are applied.');
12122
+ export const notificationEventV1UnitPriceWithCommitmentsWire = z
12123
+ .strictObject({
12124
+ type: z.literal('unit').describe('The type of the price.'),
12125
+ amount: notificationEventV1NumericWire,
12126
+ minimum_amount: notificationEventV1NumericWire.optional(),
12127
+ maximum_amount: notificationEventV1NumericWire.optional(),
12128
+ })
12129
+ .describe('Unit price with spend commitments.');
12130
+ export const notificationEventV1FlatPriceWire = z
12131
+ .strictObject({
12132
+ type: z.literal('flat').describe('The type of the price.'),
12133
+ amount: notificationEventV1NumericWire,
12134
+ })
12135
+ .describe('Flat price.');
12136
+ export const notificationEventV1UnitPriceWire = z
12137
+ .strictObject({
12138
+ type: z.literal('unit').describe('The type of the price.'),
12139
+ amount: notificationEventV1NumericWire,
12140
+ })
12141
+ .describe('Unit price.');
12142
+ export const notificationEventV1DynamicPriceWithCommitmentsWire = z
12143
+ .strictObject({
12144
+ type: z.literal('dynamic').describe('The type of the price.'),
12145
+ multiplier: notificationEventV1NumericWire.optional(),
12146
+ minimum_amount: notificationEventV1NumericWire.optional(),
12147
+ maximum_amount: notificationEventV1NumericWire.optional(),
12148
+ })
12149
+ .describe('Dynamic price with spend commitments.');
12150
+ export const notificationEventV1PackagePriceWithCommitmentsWire = z
12151
+ .strictObject({
12152
+ type: z.literal('package').describe('The type of the price.'),
12153
+ amount: notificationEventV1NumericWire,
12154
+ quantity_per_package: notificationEventV1NumericWire,
12155
+ minimum_amount: notificationEventV1NumericWire.optional(),
12156
+ maximum_amount: notificationEventV1NumericWire.optional(),
12157
+ })
12158
+ .describe('Package price with spend commitments.');
12159
+ export const notificationEventV1BillingDiscountUsageWire = z
12160
+ .strictObject({
12161
+ quantity: notificationEventV1NumericWire,
12162
+ correlation_id: z
12163
+ .string()
12164
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
12165
+ .optional()
12166
+ .describe('Correlation ID for the discount. This is used to link discounts across different invoices (progressive billing use case). If not provided, the invoicing engine will auto-generate one. When editing an invoice line, please make sure to keep the same correlation ID of the discount or in progressive billing setups the discount amounts might be incorrect.'),
12167
+ })
12168
+ .describe('A usage discount.');
12169
+ export const notificationEventV1SubscriptionCostBasisPinWire = z
12170
+ .strictObject({
12171
+ custom_currency_id: z
12172
+ .string()
12173
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
12174
+ .describe('The managed custom currency ID.'),
12175
+ invoice_currency: notificationEventV1CurrencyCodeWire,
12176
+ cost_basis_id: z
12177
+ .string()
12178
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
12179
+ .describe('The pinned cost basis resource ID.'),
12180
+ })
12181
+ .describe('A cost basis pinned to a custom-currency pair for the subscription.');
12182
+ export const notificationEventV1AddressWire = z
12183
+ .strictObject({
12184
+ country: notificationEventV1CountryCodeWire.optional(),
12185
+ postal_code: z.string().optional().describe('Postal code.'),
12186
+ state: z.string().optional().describe('State or province.'),
12187
+ city: z.string().optional().describe('City.'),
12188
+ line1: z.string().optional().describe('First line of the address.'),
12189
+ line2: z.string().optional().describe('Second line of the address.'),
12190
+ phone_number: z.string().optional().describe('Phone number.'),
12191
+ })
12192
+ .describe('Address');
12193
+ export const notificationEventV1ProRatingConfigWire = z
12194
+ .strictObject({
12195
+ enabled: z
12196
+ .boolean()
12197
+ .describe('Whether pro-rating is enabled for this plan.'),
12198
+ mode: notificationEventV1ProRatingModeWire,
12199
+ })
12200
+ .describe('Configuration for pro-rating behavior.');
12201
+ export const notificationEventV1RuleBalanceThresholdValueWire = z
12202
+ .strictObject({
12203
+ value: z.number().describe('Value of the threshold.'),
12204
+ type: notificationEventV1RuleBalanceThresholdValueTypeWire,
12205
+ })
12206
+ .describe('Threshold value with multiple supported types.');
12207
+ export const notificationEventV1BillingPartyTaxIdentityWire = z
12208
+ .strictObject({
12209
+ code: notificationEventV1BillingTaxIdentificationCodeWire.optional(),
12210
+ })
12211
+ .describe('Identity stores the details required to identify an entity for tax purposes in a specific country.');
12212
+ export const notificationEventV1InvoiceReferenceWire = z
12213
+ .strictObject({
12214
+ id: z
12215
+ .string()
12216
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
12217
+ .describe('The ID of the invoice.'),
12218
+ number: notificationEventV1InvoiceNumberWire.optional(),
12219
+ })
12220
+ .describe('Reference to an invoice.');
12221
+ export const notificationEventV1InvoiceDocumentRefWire = z
12222
+ .strictObject({
12223
+ type: notificationEventV1InvoiceDocumentRefTypeWire,
12224
+ reason: z
12225
+ .string()
9997
12226
  .optional()
9998
- .describe('Additional structured context.'),
9999
- customer: z
12227
+ .describe('Human readable description on why this reference is here or needs to be used.'),
12228
+ description: z
10000
12229
  .string()
10001
12230
  .optional()
10002
- .describe('The customer identifier from the request that produced this error.'),
12231
+ .describe('Additional details about the document.'),
10003
12232
  })
10004
- .describe('Query error within a partially successful entitlement access query response.');
10005
- export const notificationChannelWire = z
12233
+ .describe('InvoiceDocumentRef is used to describe a reference to an existing document (invoice). The v1 schema describes credit note references with issued_at, number and url, but the v1 API only ever sends the generic fields below.');
12234
+ export const notificationEventV1InvoiceGenericDocumentRefWire = z
10006
12235
  .strictObject({
10007
- id: ulidWire,
10008
- name: z
10009
- .string()
10010
- .min(1)
10011
- .max(256)
10012
- .describe('Display name of the resource. Between 1 and 256 characters.'),
10013
- labels: labelsWire.optional(),
10014
- created_at: dateTimeWire,
10015
- updated_at: dateTimeWire,
10016
- deleted_at: dateTimeWire.optional(),
10017
- type: notificationChannelTypeWire,
10018
- disabled: z
10019
- .boolean()
10020
- .optional()
10021
- .describe('Whether the channel is disabled. Disabled channels do not receive notification events.'),
10022
- url: z
12236
+ type: notificationEventV1InvoiceDocumentRefTypeWire,
12237
+ reason: z
10023
12238
  .string()
10024
- .describe('The URL that webhook notification events are delivered to.'),
10025
- custom_headers: z
10026
- .record(z.string(), z.string())
10027
12239
  .optional()
10028
- .describe('Custom HTTP headers to include on every webhook delivery request, keyed by header name.'),
10029
- signing_secret: z
12240
+ .describe('Human readable description on why this reference is here or needs to be used.'),
12241
+ description: z
10030
12242
  .string()
10031
12243
  .optional()
10032
- .describe('Secret used to sign outgoing webhook payloads so recipients can verify their authenticity. If omitted on create, a secret is generated automatically by the delivery provider. This is a sensitive credential returned in responses (unlike most secrets) specifically so clients can retrieve a server-generated value and verify webhook signatures; handle it with the same care as any other credential.'),
12244
+ .describe('Additional details about the document.'),
10033
12245
  })
10034
- .describe('A notification channel delivers notification events, such as entitlement balance threshold crossings, to an external system. Today the only supported channel type is a webhook delivered via Svix.');
10035
- export const createNotificationChannelRequestWire = z
12246
+ .describe('Omitted fields: period: Tax period in which the referred document had an effect required by some tax regimes and formats. stamps: Seals of approval from other organisations that may need to be listed. ext: Extensions for additional codes that may be required.');
12247
+ export const notificationEventV1InvoiceAvailableActionsWire = z
10036
12248
  .strictObject({
10037
- name: z
12249
+ advance: notificationEventV1InvoiceAvailableActionDetailsWire.optional(),
12250
+ approve: notificationEventV1InvoiceAvailableActionDetailsWire.optional(),
12251
+ delete: notificationEventV1InvoiceAvailableActionDetailsWire.optional(),
12252
+ retry: notificationEventV1InvoiceAvailableActionDetailsWire.optional(),
12253
+ snapshot_quantities: notificationEventV1InvoiceAvailableActionDetailsWire.optional(),
12254
+ void: notificationEventV1InvoiceAvailableActionDetailsWire.optional(),
12255
+ invoice: notificationEventV1InvoiceAvailableActionInvoiceDetailsWire.optional(),
12256
+ })
12257
+ .describe('InvoiceAvailableActions represents the actions that can be performed on the invoice.');
12258
+ export const notificationEventV1AppCapabilityWire = z
12259
+ .strictObject({
12260
+ type: notificationEventV1AppCapabilityTypeWire,
12261
+ key: z
10038
12262
  .string()
10039
12263
  .min(1)
10040
- .max(256)
10041
- .describe('Display name of the resource. Between 1 and 256 characters.'),
10042
- labels: labelsWire.optional(),
10043
- type: notificationChannelTypeWire,
10044
- disabled: z
10045
- .boolean()
10046
- .optional()
10047
- .describe('Whether the channel is disabled. Disabled channels do not receive notification events.'),
10048
- url: z
12264
+ .max(64)
12265
+ .regex(new RegExp('^[a-z0-9]+(?:_[a-z0-9]+)*$'))
12266
+ .describe('Key'),
12267
+ name: z.string().describe('The capability name.'),
12268
+ description: z.string().describe('The capability description.'),
12269
+ })
12270
+ .describe("App capability. Capabilities only exist in config so they don't extend the Resource model.");
12271
+ export const notificationEventV1TaxConfigWire = z
12272
+ .strictObject({
12273
+ behavior: notificationEventV1TaxBehaviorWire.optional(),
12274
+ stripe: notificationEventV1StripeTaxConfigWire.optional(),
12275
+ custom_invoicing: notificationEventV1CustomInvoicingTaxConfigWire.optional(),
12276
+ tax_code_id: z
10049
12277
  .string()
10050
- .describe('The URL that webhook notification events are delivered to.'),
10051
- custom_headers: z
10052
- .record(z.string(), z.string())
12278
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
10053
12279
  .optional()
10054
- .describe('Custom HTTP headers to include on every webhook delivery request, keyed by header name.'),
10055
- signing_secret: z
12280
+ .describe('Tax code reference. When both `taxCodeId` and `stripe.code` are provided, `taxCodeId` takes precedence: the referenced tax code entity is used and `stripe.code` is ignored.'),
12281
+ })
12282
+ .describe('Set of provider specific tax configs.');
12283
+ export const notificationEventV1BillingWorkflowPaymentSettingsWire = z
12284
+ .strictObject({
12285
+ collection_method: notificationEventV1CollectionMethodWire.optional(),
12286
+ })
12287
+ .describe('BillingWorkflowPaymentSettings represents the payment settings for a billing workflow');
12288
+ export const notificationEventV1DiscountReasonRatecardPercentageWire = z
12289
+ .strictObject({
12290
+ type: z.literal('ratecard_percentage').describe('type.'),
12291
+ percentage: notificationEventV1PercentageWire,
12292
+ correlation_id: z
10056
12293
  .string()
12294
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
10057
12295
  .optional()
10058
- .describe('Secret used to sign outgoing webhook payloads so recipients can verify their authenticity. If omitted on create, a secret is generated automatically by the delivery provider. This is a sensitive credential returned in responses (unlike most secrets) specifically so clients can retrieve a server-generated value and verify webhook signatures; handle it with the same care as any other credential.'),
12296
+ .describe('Correlation ID for the discount. This is used to link discounts across different invoices (progressive billing use case). If not provided, the invoicing engine will auto-generate one. When editing an invoice line, please make sure to keep the same correlation ID of the discount or in progressive billing setups the discount amounts might be incorrect.'),
10059
12297
  })
10060
- .describe('NotificationChannel create request.');
10061
- export const updateBillingNotificationChannelRequestWire = z
12298
+ .describe('The reason for the discount is a ratecard percentage.');
12299
+ export const notificationEventV1BillingDiscountPercentageWire = z
10062
12300
  .strictObject({
10063
- name: z
10064
- .string()
10065
- .min(1)
10066
- .max(256)
10067
- .describe('Display name of the resource. Between 1 and 256 characters.'),
10068
- type: notificationChannelTypeWire,
10069
- url: z
12301
+ percentage: notificationEventV1PercentageWire,
12302
+ correlation_id: z
10070
12303
  .string()
10071
- .describe('The URL that webhook notification events are delivered to.'),
10072
- labels: labelsWire.optional(),
10073
- disabled: z
10074
- .boolean()
10075
- .optional()
10076
- .describe('Whether the channel is disabled. Disabled channels do not receive notification events.'),
10077
- custom_headers: z
10078
- .record(z.string(), z.string())
12304
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
10079
12305
  .optional()
10080
- .describe('Custom HTTP headers to include on every webhook delivery request, keyed by header name.'),
10081
- signing_secret: z
12306
+ .describe('Correlation ID for the discount. This is used to link discounts across different invoices (progressive billing use case). If not provided, the invoicing engine will auto-generate one. When editing an invoice line, please make sure to keep the same correlation ID of the discount or in progressive billing setups the discount amounts might be incorrect.'),
12307
+ })
12308
+ .describe('A percentage discount.');
12309
+ export const notificationEventV1PaymentDueDateWire = z
12310
+ .strictObject({
12311
+ due_at: z
12312
+ .string()
12313
+ .datetime({ offset: true })
12314
+ .describe('When the payment is due.'),
12315
+ notes: z
10082
12316
  .string()
10083
12317
  .optional()
10084
- .describe('Secret used to sign outgoing webhook payloads so recipients can verify their authenticity. If omitted on create, a secret is generated automatically by the delivery provider. This is a sensitive credential returned in responses (unlike most secrets) specifically so clients can retrieve a server-generated value and verify webhook signatures; handle it with the same care as any other credential.'),
12318
+ .describe('Other details to take into account for the due date.'),
12319
+ amount: notificationEventV1NumericWire,
12320
+ percent: notificationEventV1PercentageWire.optional(),
12321
+ currency: notificationEventV1CurrencyCodeWire.optional(),
10085
12322
  })
10086
- .describe("Request body for updating a notification channel. Updates replace the channel's mutable state rather than merging it: `type`, `name`, and `url` must always be provided, and omitting `disabled`, `labels`, or `custom_headers` resets them to their defaults (enabled, no labels, no custom headers). `signing_secret` is the one exception: omitting it keeps the channel's current signing secret instead of clearing the credential.");
10087
- export const notificationBalanceThresholdWire = z
12323
+ .describe('PaymentDueDate contains an amount that should be paid by the given date.');
12324
+ export const notificationEventV1InvoiceLineSubscriptionReferenceWire = z
10088
12325
  .strictObject({
10089
- type: notificationBalanceThresholdTypeWire,
10090
- value: z.number().describe('The threshold value.'),
12326
+ subscription: notificationEventV1IdResourceWire,
12327
+ phase: notificationEventV1IdResourceWire,
12328
+ item: notificationEventV1IdResourceWire,
12329
+ billing_period: notificationEventV1PeriodWire,
10091
12330
  })
10092
- .describe('A balance threshold of a notification rule. Crossing it generates an `entitlements.balance.threshold` event.');
10093
- export const notificationRuleReferenceWire = z
12331
+ .describe('InvoiceLineSubscriptionReference contains the references to the subscription that this line is related to.');
12332
+ export const notificationEventV1FlatPriceWithPaymentTermWire = z
10094
12333
  .strictObject({
10095
- id: ulidWire,
10096
- type: notificationEventTypeWire,
10097
- name: z.string().describe('The user-provided name of the rule.'),
12334
+ type: z.literal('flat').describe('The type of the price.'),
12335
+ amount: notificationEventV1NumericWire,
12336
+ payment_term: notificationEventV1PricePaymentTermWire.optional(),
10098
12337
  })
10099
- .describe('A reference to the notification rule that generated an event.');
10100
- export const notificationEventDeliveryAttemptWire = z
12338
+ .describe('Flat price with payment term.');
12339
+ export const notificationEventV1ValidationIssueWire = z
10101
12340
  .strictObject({
10102
- state: notificationEventDeliveryStateWire,
10103
- response: notificationEventDeliveryAttemptResponseWire,
10104
- timestamp: dateTimeWire,
12341
+ created_at: z
12342
+ .string()
12343
+ .datetime({ offset: true })
12344
+ .describe('Timestamp of when the resource was created.'),
12345
+ updated_at: z
12346
+ .string()
12347
+ .datetime({ offset: true })
12348
+ .describe('Timestamp of when the resource was last updated.'),
12349
+ deleted_at: z
12350
+ .string()
12351
+ .datetime({ offset: true })
12352
+ .optional()
12353
+ .describe('Timestamp of when the resource was permanently deleted.'),
12354
+ id: z
12355
+ .string()
12356
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
12357
+ .describe('ID of the charge or discount.'),
12358
+ severity: notificationEventV1ValidationIssueSeverityWire,
12359
+ field: z
12360
+ .string()
12361
+ .optional()
12362
+ .describe('The field that the issue is related to, if available in JSON path format.'),
12363
+ code: z
12364
+ .string()
12365
+ .optional()
12366
+ .describe('Machine indentifiable code for the issue, if available.'),
12367
+ component: z.string().describe('Component reporting the issue.'),
12368
+ message: z.string().describe('A human-readable description of the issue.'),
12369
+ metadata: notificationEventV1MetadataWire.optional(),
10105
12370
  })
10106
- .describe('A single delivery attempt to a channel.');
12371
+ .describe('ValidationIssue captures any validation issues related to the invoice. Issues with severity "critical" will prevent the invoice from being issued.');
10107
12372
  export const appCustomerDataWire = z
10108
12373
  .strictObject({
10109
12374
  stripe: appCustomerDataStripeWire
@@ -10696,17 +12961,6 @@ export const resendBillingNotificationEventRequestWire = z
10696
12961
  .describe('The channels to resend the event to. When omitted or empty, the event is resent to every enabled channel of the rule. Channels not targeted by the rule or disabled are rejected.'),
10697
12962
  })
10698
12963
  .describe('Request body for resending a notification event.');
10699
- export const notificationEventInvoiceDataWire = z
10700
- .strictObject({
10701
- invoice: notificationEventInvoiceReferenceWire,
10702
- customer_id: ulidWire.optional(),
10703
- currency: currencyCodeWire,
10704
- status: z
10705
- .string()
10706
- .describe('The status of the invoice at the time the event was generated.'),
10707
- total: numericWire,
10708
- })
10709
- .describe('The invoice an invoice notification event refers to.');
10710
12964
  export const listEventsParamsFilterWire = z
10711
12965
  .strictObject({
10712
12966
  id: stringFieldFilterWire.optional(),
@@ -11512,48 +13766,310 @@ export const notificationRuleBalanceThresholdWire = z
11512
13766
  .describe('A rule that generates an event when an entitlement balance crosses one of its thresholds.');
11513
13767
  export const notificationRuleBalanceThresholdRequestWire = z
11514
13768
  .strictObject({
11515
- name: z
13769
+ name: z
13770
+ .string()
13771
+ .min(1)
13772
+ .max(256)
13773
+ .describe('Display name of the resource. Between 1 and 256 characters.'),
13774
+ labels: labelsWire.optional(),
13775
+ type: z
13776
+ .literal('entitlements.balance.threshold')
13777
+ .describe('The type of event the rule generates. Immutable after creation.'),
13778
+ disabled: z
13779
+ .boolean()
13780
+ .optional()
13781
+ .describe('Whether the rule is disabled. Disabled rules do not generate events.'),
13782
+ channels: z
13783
+ .array(notificationChannelReferenceWire)
13784
+ .max(5)
13785
+ .describe('The channels the rule delivers its events to. At least one and at most five channels are required. Responses omit channels that have since been disabled or deleted.'),
13786
+ thresholds: z
13787
+ .array(notificationBalanceThresholdWire)
13788
+ .min(1)
13789
+ .max(10)
13790
+ .describe('The thresholds that generate an event when crossed.'),
13791
+ features: z
13792
+ .array(featureReferenceWire)
13793
+ .optional()
13794
+ .describe('The features the rule applies to. When omitted, the rule applies to every feature.'),
13795
+ })
13796
+ .describe('Request body for a balance threshold rule.');
13797
+ export const notificationEventDeliveryStatusWire = z
13798
+ .strictObject({
13799
+ channel_id: ulidWire,
13800
+ state: notificationEventDeliveryStateWire,
13801
+ reason: z
13802
+ .string()
13803
+ .describe('The reason for the last state change. Empty for successful deliveries.'),
13804
+ updated_at: dateTimeWire,
13805
+ next_attempt: dateTimeWire.optional(),
13806
+ attempts: z
13807
+ .array(notificationEventDeliveryAttemptWire)
13808
+ .describe('The delivery attempts made so far, most recent first.'),
13809
+ })
13810
+ .describe('The delivery status of a notification event for one channel of the generating rule.');
13811
+ export const notificationEventV1RecurringPeriodWire = z
13812
+ .strictObject({
13813
+ interval: notificationEventV1RecurringPeriodIntervalWire,
13814
+ anchor: z
13815
+ .string()
13816
+ .datetime({ offset: true })
13817
+ .describe('A date-time anchor to base the recurring period on.'),
13818
+ interval_iso: z
13819
+ .string()
13820
+ .duration()
13821
+ .describe('The unit of time for the interval in ISO8601 format.'),
13822
+ })
13823
+ .describe('Recurring period with an interval and an anchor.');
13824
+ export const notificationEventV1RecurringPeriodV2Wire = z
13825
+ .strictObject({
13826
+ interval: notificationEventV1RecurringPeriodIntervalWire,
13827
+ anchor: z
13828
+ .string()
13829
+ .datetime({ offset: true })
13830
+ .describe('A date-time anchor to base the recurring period on.'),
13831
+ })
13832
+ .describe('Recurring period with an interval and an anchor.');
13833
+ export const notificationEventV1FeatureLlmUnitCostWire = z
13834
+ .strictObject({
13835
+ type: z.literal('llm').describe('type.'),
13836
+ provider_property: z
13837
+ .string()
13838
+ .optional()
13839
+ .describe('Meter group-by property that holds the LLM provider. Use this when the meter has a group-by dimension for provider. Mutually exclusive with `provider`.'),
13840
+ provider: z
13841
+ .string()
13842
+ .optional()
13843
+ .describe('Static LLM provider value (e.g., "openai", "anthropic"). Use this when the feature tracks a single provider. Mutually exclusive with `providerProperty`.'),
13844
+ model_property: z
13845
+ .string()
13846
+ .optional()
13847
+ .describe('Meter group-by property that holds the model ID. Use this when the meter has a group-by dimension for model. Mutually exclusive with `model`.'),
13848
+ model: z
13849
+ .string()
13850
+ .optional()
13851
+ .describe('Static model ID value (e.g., "gpt-4", "claude-3-5-sonnet"). Use this when the feature tracks a single model. Mutually exclusive with `modelProperty`.'),
13852
+ token_type_property: z
13853
+ .string()
13854
+ .optional()
13855
+ .describe('Meter group-by property that holds the token type. Use this when the meter has a group-by dimension for token type. Mutually exclusive with `tokenType`.'),
13856
+ token_type: z
13857
+ .string()
13858
+ .optional()
13859
+ .describe('Static token type value. Use this when the feature tracks a single token type (e.g., only input tokens). Expected values: input, output, cache_read, reasoning, cache_write, request, response. `request` is an alias for `input`, `response` is an alias for `output`. Mutually exclusive with `tokenTypeProperty`.'),
13860
+ pricing: notificationEventV1FeatureLlmUnitCostPricingWire.optional(),
13861
+ })
13862
+ .describe('LLM cost lookup configuration. Maps meter group-by dimensions to LLM cost database fields.');
13863
+ export const notificationEventV1PriceTierWire = z
13864
+ .strictObject({
13865
+ up_to_amount: notificationEventV1NumericWire.optional(),
13866
+ flat_price: notificationEventV1FlatPriceWire
13867
+ .nullable()
13868
+ .describe('The flat price component of the tier.'),
13869
+ unit_price: notificationEventV1UnitPriceWire
13870
+ .nullable()
13871
+ .describe('The unit price component of the tier.'),
13872
+ })
13873
+ .describe('A price tier. At least one price component is required in each tier.');
13874
+ export const notificationEventV1SubscriptionWire = z
13875
+ .strictObject({
13876
+ id: z
13877
+ .string()
13878
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
13879
+ .describe('A unique identifier for the resource.'),
13880
+ name: z
13881
+ .string()
13882
+ .min(1)
13883
+ .max(256)
13884
+ .describe('Human-readable name for the resource. Between 1 and 256 characters.'),
13885
+ description: z
13886
+ .string()
13887
+ .max(1024)
13888
+ .optional()
13889
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
13890
+ metadata: notificationEventV1MetadataWire
13891
+ .nullable()
13892
+ .optional()
13893
+ .describe('Additional metadata for the resource.'),
13894
+ created_at: z
13895
+ .string()
13896
+ .datetime({ offset: true })
13897
+ .describe('Timestamp of when the resource was created.'),
13898
+ updated_at: z
13899
+ .string()
13900
+ .datetime({ offset: true })
13901
+ .describe('Timestamp of when the resource was last updated.'),
13902
+ deleted_at: z
13903
+ .string()
13904
+ .datetime({ offset: true })
13905
+ .optional()
13906
+ .describe('Timestamp of when the resource was permanently deleted.'),
13907
+ active_from: z
13908
+ .string()
13909
+ .datetime({ offset: true })
13910
+ .describe('The cadence start of the resource.'),
13911
+ active_to: z
13912
+ .string()
13913
+ .datetime({ offset: true })
13914
+ .optional()
13915
+ .describe('The cadence end of the resource.'),
13916
+ annotations: notificationEventV1AnnotationsWire.optional(),
13917
+ alignment: notificationEventV1AlignmentWire.optional(),
13918
+ status: notificationEventV1SubscriptionStatusWire,
13919
+ customer_id: z
13920
+ .string()
13921
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
13922
+ .describe('The customer ID of the subscription.'),
13923
+ plan: notificationEventV1PlanReferenceWire.optional(),
13924
+ currency: notificationEventV1CurrencyCodeWire,
13925
+ cost_basis_mode: notificationEventV1SubscriptionCostBasisModeWire,
13926
+ cost_basis_pins: z
13927
+ .array(notificationEventV1SubscriptionCostBasisPinWire)
13928
+ .describe('Cost bases pinned to custom-currency pairs for this subscription.'),
13929
+ billing_cadence: z
13930
+ .string()
13931
+ .duration()
13932
+ .describe('The billing cadence for the subscriptions. Defines how often customers are billed using ISO8601 duration format. Examples: "P1M" (monthly), "P3M" (quarterly), "P1Y" (annually).'),
13933
+ pro_rating_config: notificationEventV1ProRatingConfigWire.optional(),
13934
+ billing_anchor: z
13935
+ .string()
13936
+ .datetime({ offset: true })
13937
+ .describe('The normalizedbilling anchor of the subscription.'),
13938
+ settlement_mode: notificationEventV1BillingSettlementModeWire,
13939
+ })
13940
+ .describe('Subscription is an exact subscription instance.');
13941
+ export const notificationEventV1BillingPartyWire = z
13942
+ .strictObject({
13943
+ id: z
13944
+ .string()
13945
+ .optional()
13946
+ .describe('Unique identifier for the party (if available)'),
13947
+ key: z
13948
+ .string()
13949
+ .min(1)
13950
+ .max(256)
13951
+ .optional()
13952
+ .describe('An optional unique key of the party (if available)'),
13953
+ name: z
13954
+ .string()
13955
+ .optional()
13956
+ .describe('Legal name or representation of the organization.'),
13957
+ tax_id: notificationEventV1BillingPartyTaxIdentityWire.optional(),
13958
+ addresses: z
13959
+ .array(notificationEventV1AddressWire)
13960
+ .max(1)
13961
+ .optional()
13962
+ .describe('Regular post addresses for where information should be sent if needed.'),
13963
+ })
13964
+ .describe('Party represents a person or business entity.');
13965
+ export const notificationEventV1BillingInvoiceCustomerExtendedDetailsWire = z
13966
+ .strictObject({
13967
+ id: z
13968
+ .string()
13969
+ .optional()
13970
+ .describe('Unique identifier for the party (if available)'),
13971
+ key: z
13972
+ .string()
13973
+ .min(1)
13974
+ .max(256)
13975
+ .optional()
13976
+ .describe('An optional unique key of the party (if available)'),
13977
+ name: z
13978
+ .string()
13979
+ .optional()
13980
+ .describe('Legal name or representation of the organization.'),
13981
+ tax_id: notificationEventV1BillingPartyTaxIdentityWire.optional(),
13982
+ addresses: z
13983
+ .array(notificationEventV1AddressWire)
13984
+ .max(1)
13985
+ .optional()
13986
+ .describe('Regular post addresses for where information should be sent if needed.'),
13987
+ usage_attribution: notificationEventV1CustomerUsageAttributionWire,
13988
+ })
13989
+ .describe('BillingInvoiceCustomerExtendedDetails is a collection of fields that are used to extend the billing party details for invoices. These fields contain the OpenMeter specific details for the customer, that are not strictly required for the invoice itself.');
13990
+ export const notificationEventV1InvoiceStatusDetailsWire = z
13991
+ .strictObject({
13992
+ immutable: z.boolean().describe('Is the invoice editable?'),
13993
+ failed: z.boolean().describe('Is the invoice in a failed state?'),
13994
+ extended_status: z
11516
13995
  .string()
11517
- .min(1)
11518
- .max(256)
11519
- .describe('Display name of the resource. Between 1 and 256 characters.'),
11520
- labels: labelsWire.optional(),
11521
- type: z
11522
- .literal('entitlements.balance.threshold')
11523
- .describe('The type of event the rule generates. Immutable after creation.'),
11524
- disabled: z
13996
+ .describe('Extended status information for the invoice.'),
13997
+ available_actions: notificationEventV1InvoiceAvailableActionsWire,
13998
+ })
13999
+ .describe('InvoiceStatusDetails represents the details of the invoice status. API users are encouraged to rely on the immutable/failed/avaliableActions fields to determine the next steps of the invoice instead of the extendedStatus field.');
14000
+ export const notificationEventV1MarketplaceListingWire = z
14001
+ .strictObject({
14002
+ type: notificationEventV1AppTypeWire,
14003
+ name: z.string().describe("The app's name."),
14004
+ description: z.string().describe("The app's description."),
14005
+ capabilities: z
14006
+ .array(notificationEventV1AppCapabilityWire)
14007
+ .describe("The app's capabilities."),
14008
+ install_methods: z
14009
+ .array(notificationEventV1InstallMethodWire)
14010
+ .describe('Install methods. List of methods to install the app.'),
14011
+ })
14012
+ .describe("A marketplace listing. Represent an available app in the app marketplace that can be installed to the organization. Marketplace apps only exist in config so they don't extend the Resource model.");
14013
+ export const notificationEventV1BillingWorkflowInvoicingSettingsWire = z
14014
+ .strictObject({
14015
+ auto_advance: z
11525
14016
  .boolean()
11526
14017
  .optional()
11527
- .describe('Whether the rule is disabled. Disabled rules do not generate events.'),
11528
- channels: z
11529
- .array(notificationChannelReferenceWire)
11530
- .max(5)
11531
- .describe('The channels the rule delivers its events to. At least one and at most five channels are required. Responses omit channels that have since been disabled or deleted.'),
11532
- thresholds: z
11533
- .array(notificationBalanceThresholdWire)
11534
- .min(1)
11535
- .max(10)
11536
- .describe('The thresholds that generate an event when crossed.'),
11537
- features: z
11538
- .array(featureReferenceWire)
14018
+ .describe('Whether to automatically issue the invoice after the draftPeriod has passed.'),
14019
+ draft_period: z
14020
+ .string()
11539
14021
  .optional()
11540
- .describe('The features the rule applies to. When omitted, the rule applies to every feature.'),
14022
+ .describe('The period for the invoice to be kept in draft status for manual reviews.'),
14023
+ due_after: z
14024
+ .string()
14025
+ .optional()
14026
+ .describe("The period after which the invoice is due. With some payment solutions it's only applicable for manual collection method."),
14027
+ progressive_billing: z
14028
+ .boolean()
14029
+ .optional()
14030
+ .describe('Should progressive billing be allowed for this workflow?'),
14031
+ subscription_end_proration_mode: notificationEventV1BillingWorkflowInvoicingSubscriptionEndProrationModeWire.optional(),
14032
+ default_tax_config: notificationEventV1TaxConfigWire.optional(),
11541
14033
  })
11542
- .describe('Request body for a balance threshold rule.');
11543
- export const notificationEventDeliveryStatusWire = z
14034
+ .describe('BillingWorkflowInvoicingSettings represents the invoice settings for a billing workflow');
14035
+ export const notificationEventV1InvoiceLineTaxItemWire = z
11544
14036
  .strictObject({
11545
- channel_id: ulidWire,
11546
- state: notificationEventDeliveryStateWire,
11547
- reason: z
14037
+ config: notificationEventV1TaxConfigWire.optional(),
14038
+ percent: notificationEventV1PercentageWire.optional(),
14039
+ surcharge: notificationEventV1NumericWire.optional(),
14040
+ behavior: notificationEventV1InvoiceLineTaxBehaviorWire.optional(),
14041
+ })
14042
+ .describe('TaxConfig stores the configuration for a tax line relative to an invoice line.');
14043
+ export const notificationEventV1BillingDiscountReasonWire = z
14044
+ .discriminatedUnion('type', [
14045
+ notificationEventV1DiscountReasonMaximumSpendWire,
14046
+ notificationEventV1DiscountReasonRatecardPercentageWire,
14047
+ notificationEventV1DiscountReasonRatecardUsageWire,
14048
+ ])
14049
+ .describe('The reason for the discount.');
14050
+ export const notificationEventV1BillingDiscountsWire = z
14051
+ .strictObject({
14052
+ percentage: notificationEventV1BillingDiscountPercentageWire.optional(),
14053
+ usage: notificationEventV1BillingDiscountUsageWire.optional(),
14054
+ })
14055
+ .describe('A discount by type.');
14056
+ export const notificationEventV1PaymentTermDueDateWire = z
14057
+ .strictObject({
14058
+ type: z.literal('due_date').describe('Type of terms to be applied.'),
14059
+ detail: z
11548
14060
  .string()
11549
- .describe('The reason for the last state change. Empty for successful deliveries.'),
11550
- updated_at: dateTimeWire,
11551
- next_attempt: dateTimeWire.optional(),
11552
- attempts: z
11553
- .array(notificationEventDeliveryAttemptWire)
11554
- .describe('The delivery attempts made so far, most recent first.'),
14061
+ .optional()
14062
+ .describe('Text detail of the chosen payment terms.'),
14063
+ notes: z
14064
+ .string()
14065
+ .optional()
14066
+ .describe('Description of the conditions for payment.'),
14067
+ due_at: z
14068
+ .array(notificationEventV1PaymentDueDateWire)
14069
+ .min(1)
14070
+ .describe('When the payment is due.'),
11555
14071
  })
11556
- .describe('The delivery status of a notification event for one channel of the generating rule.');
14072
+ .describe('PaymentTermDueDate defines the terms for payment on a specific date.');
11557
14073
  export const customerDataWire = z
11558
14074
  .strictObject({
11559
14075
  billing_profile: profileReferenceWire
@@ -11604,29 +14120,6 @@ export const listCustomerEntitlementAccessResponseDataWire = z
11604
14120
  .describe('The list of entitlement access results.'),
11605
14121
  })
11606
14122
  .describe('List customer entitlement access response data.');
11607
- export const notificationEventBalanceThresholdDataWire = z
11608
- .strictObject({
11609
- entitlement_id: ulidWire,
11610
- feature: notificationEventFeatureReferenceWire,
11611
- subject_key: z
11612
- .string()
11613
- .describe('The key of the subject the entitlement belongs to.'),
11614
- customer_id: ulidWire.optional(),
11615
- value: entitlementValueResultWire,
11616
- threshold: notificationBalanceThresholdWire,
11617
- })
11618
- .describe('The entities and threshold a balance threshold event refers to.');
11619
- export const notificationEventEntitlementDataWire = z
11620
- .strictObject({
11621
- entitlement_id: ulidWire,
11622
- feature: notificationEventFeatureReferenceWire,
11623
- subject_key: z
11624
- .string()
11625
- .describe('The key of the subject the entitlement belongs to.'),
11626
- customer_id: ulidWire.optional(),
11627
- value: entitlementValueResultWire,
11628
- })
11629
- .describe('The entitlement, feature, and subject an entitlement notification event refers to.');
11630
14123
  export const priceGraduatedWire = z
11631
14124
  .strictObject({
11632
14125
  type: z.literal('graduated').describe('The type of the price.'),
@@ -11759,22 +14252,6 @@ export const planAddonPagePaginatedResponseWire = z
11759
14252
  meta: paginatedMetaWire,
11760
14253
  })
11761
14254
  .describe('Page paginated response.');
11762
- export const notificationEventInvoiceCreatedPayloadWire = z
11763
- .strictObject({
11764
- id: ulidWire,
11765
- type: z.literal('invoice.created').describe('The type of the event.'),
11766
- timestamp: dateTimeWire,
11767
- data: notificationEventInvoiceDataWire,
11768
- })
11769
- .describe('An invoice created notification event payload.');
11770
- export const notificationEventInvoiceUpdatedPayloadWire = z
11771
- .strictObject({
11772
- id: ulidWire,
11773
- type: z.literal('invoice.updated').describe('The type of the event.'),
11774
- timestamp: dateTimeWire,
11775
- data: notificationEventInvoiceDataWire,
11776
- })
11777
- .describe('An invoice updated notification event payload.');
11778
14255
  export const ingestedEventPaginatedResponseWire = z
11779
14256
  .strictObject({
11780
14257
  data: z.array(ingestedEventWire),
@@ -12219,41 +14696,385 @@ export const entitlementAccessQueryResultWire = z
12219
14696
  .describe('Map of features with their access status. Map keys are the feature keys requested in `feature.keys`, or every feature `key` available in the organization when the feature filter was omitted.'),
12220
14697
  updated_at: dateTimeWire,
12221
14698
  })
12222
- .describe('Access evaluation result for a single resolved customer.');
12223
- export const notificationRuleWire = z
12224
- .discriminatedUnion('type', [
12225
- notificationRuleBalanceThresholdWire,
12226
- notificationRuleEntitlementResetWire,
12227
- notificationRuleInvoiceCreatedWire,
12228
- notificationRuleInvoiceUpdatedWire,
12229
- ])
12230
- .describe('A notification rule selects the type of event to generate, the conditions specific to that type, and the channels to deliver the events to.');
12231
- export const notificationRuleRequestWire = z
12232
- .discriminatedUnion('type', [
12233
- notificationRuleBalanceThresholdRequestWire,
12234
- notificationRuleEntitlementResetRequestWire,
12235
- notificationRuleInvoiceCreatedRequestWire,
12236
- notificationRuleInvoiceUpdatedRequestWire,
12237
- ])
12238
- .describe("Request body for creating or updating a notification rule. Updates replace the rule's mutable state: omitting `disabled`, `labels`, or `features` resets them to their defaults. The `type` must match the existing rule on update.");
12239
- export const notificationEventBalanceThresholdPayloadWire = z
14699
+ .describe('Access evaluation result for a single resolved customer.');
14700
+ export const notificationRuleWire = z
14701
+ .discriminatedUnion('type', [
14702
+ notificationRuleBalanceThresholdWire,
14703
+ notificationRuleEntitlementResetWire,
14704
+ notificationRuleInvoiceCreatedWire,
14705
+ notificationRuleInvoiceUpdatedWire,
14706
+ ])
14707
+ .describe('A notification rule selects the type of event to generate, the conditions specific to that type, and the channels to deliver the events to.');
14708
+ export const notificationRuleRequestWire = z
14709
+ .discriminatedUnion('type', [
14710
+ notificationRuleBalanceThresholdRequestWire,
14711
+ notificationRuleEntitlementResetRequestWire,
14712
+ notificationRuleInvoiceCreatedRequestWire,
14713
+ notificationRuleInvoiceUpdatedRequestWire,
14714
+ ])
14715
+ .describe("Request body for creating or updating a notification rule. Updates replace the rule's mutable state: omitting `disabled`, `labels`, or `features` resets them to their defaults. The `type` must match the existing rule on update.");
14716
+ export const notificationEventV1EntitlementMeteredWire = z
14717
+ .strictObject({
14718
+ type: z.literal('metered').describe('type.'),
14719
+ is_soft_limit: z
14720
+ .boolean()
14721
+ .optional()
14722
+ .describe('If softLimit=true the subject can use the feature even if the entitlement is exhausted, hasAccess will always be true.'),
14723
+ is_unlimited: z
14724
+ .boolean()
14725
+ .optional()
14726
+ .describe('Deprecated, ignored by the backend. Please use isSoftLimit instead; this field will be removed in the future.'),
14727
+ issue_after_reset: z
14728
+ .number()
14729
+ .nonnegative()
14730
+ .optional()
14731
+ .describe('You can grant usage automatically alongside the entitlement, the example scenario would be creating a starting balance. If an amount is specified here, a grant will be created alongside the entitlement with the specified amount. That grant will have it\'s rollover settings configured in a way that after each reset operation, the balance will return the original amount specified here. Manually creating such a grant would mean having the "amount", "minRolloverAmount", and "maxRolloverAmount" fields all be the same.'),
14732
+ issue_after_reset_priority: z
14733
+ .number()
14734
+ .int()
14735
+ .gte(1)
14736
+ .lte(255)
14737
+ .optional()
14738
+ .describe('Defines the grant priority for the default grant.'),
14739
+ preserve_overage_at_reset: z
14740
+ .boolean()
14741
+ .optional()
14742
+ .describe('If true, the overage is preserved at reset. If false, the usage is reset to 0.'),
14743
+ created_at: z
14744
+ .string()
14745
+ .datetime({ offset: true })
14746
+ .describe('Timestamp of when the resource was created.'),
14747
+ updated_at: z
14748
+ .string()
14749
+ .datetime({ offset: true })
14750
+ .describe('Timestamp of when the resource was last updated.'),
14751
+ deleted_at: z
14752
+ .string()
14753
+ .datetime({ offset: true })
14754
+ .optional()
14755
+ .describe('Timestamp of when the resource was permanently deleted.'),
14756
+ metadata: notificationEventV1MetadataWire.optional(),
14757
+ active_from: z
14758
+ .string()
14759
+ .datetime({ offset: true })
14760
+ .describe('The cadence start of the resource.'),
14761
+ active_to: z
14762
+ .string()
14763
+ .datetime({ offset: true })
14764
+ .optional()
14765
+ .describe('The cadence end of the resource.'),
14766
+ annotations: notificationEventV1AnnotationsWire.optional(),
14767
+ id: z
14768
+ .string()
14769
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
14770
+ .describe('Readonly unique ULID identifier.'),
14771
+ subject_key: z
14772
+ .string()
14773
+ .describe('The identifier key unique to the subject. NOTE: Subjects are being deprecated, please use the new customer APIs.'),
14774
+ feature_key: z
14775
+ .string()
14776
+ .min(1)
14777
+ .max(64)
14778
+ .regex(new RegExp('^[a-z0-9]+(?:_[a-z0-9]+)*$'))
14779
+ .describe('The feature the subject is entitled to use.'),
14780
+ feature_id: z
14781
+ .string()
14782
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
14783
+ .describe('The feature the subject is entitled to use.'),
14784
+ last_reset: z
14785
+ .string()
14786
+ .datetime({ offset: true })
14787
+ .describe('The time the last reset happened.'),
14788
+ current_usage_period: notificationEventV1PeriodWire,
14789
+ measure_usage_from: z
14790
+ .string()
14791
+ .datetime({ offset: true })
14792
+ .describe('The time from which usage is measured. If not specified on creation, defaults to entitlement creation time.'),
14793
+ usage_period: notificationEventV1RecurringPeriodWire,
14794
+ })
14795
+ .describe('Metered entitlements are useful for many different use cases, from setting up usage based access to implementing complex credit systems. Access is determined based on feature usage using a balance calculation (the "usage allowance" provided by the issued grants is "burnt down" by the usage).');
14796
+ export const notificationEventV1BillingWorkflowCollectionAlignmentAnchoredWire = z
14797
+ .strictObject({
14798
+ type: z.literal('anchored').describe('The type of alignment.'),
14799
+ recurring_period: notificationEventV1RecurringPeriodV2Wire,
14800
+ })
14801
+ .describe('BillingWorkflowCollectionAlignmentAnchored specifies the alignment for collecting the pending line items into an invoice.');
14802
+ export const notificationEventV1FeatureUnitCostWire = z
14803
+ .discriminatedUnion('type', [
14804
+ notificationEventV1FeatureManualUnitCostWire,
14805
+ notificationEventV1FeatureLlmUnitCostWire,
14806
+ ])
14807
+ .describe('Per-unit cost configuration for a feature. Either a fixed manual amount or a dynamic LLM cost lookup.');
14808
+ export const notificationEventV1TieredPriceWithCommitmentsWire = z
14809
+ .strictObject({
14810
+ type: z
14811
+ .literal('tiered')
14812
+ .describe('The type of the price. One of: flat, unit, or tiered.'),
14813
+ mode: notificationEventV1TieredPriceModeWire,
14814
+ tiers: z
14815
+ .array(notificationEventV1PriceTierWire)
14816
+ .min(1)
14817
+ .describe('The tiers of the tiered price. At least one price component is required in each tier.'),
14818
+ minimum_amount: notificationEventV1NumericWire.optional(),
14819
+ maximum_amount: notificationEventV1NumericWire.optional(),
14820
+ })
14821
+ .describe('Tiered price with spend commitments.');
14822
+ export const notificationEventV1CustomerWire = z
14823
+ .strictObject({
14824
+ id: z.string().describe('A unique identifier for the resource.'),
14825
+ name: z
14826
+ .string()
14827
+ .max(256)
14828
+ .describe('Human-readable name for the resource. Between 1 and 256 characters.'),
14829
+ description: z
14830
+ .string()
14831
+ .max(1024)
14832
+ .optional()
14833
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
14834
+ metadata: notificationEventV1MetadataWire
14835
+ .nullable()
14836
+ .optional()
14837
+ .describe('Additional metadata for the resource.'),
14838
+ created_at: z
14839
+ .string()
14840
+ .datetime({ offset: true })
14841
+ .describe('Timestamp of when the resource was created.'),
14842
+ updated_at: z
14843
+ .string()
14844
+ .datetime({ offset: true })
14845
+ .describe('Timestamp of when the resource was last updated.'),
14846
+ deleted_at: z
14847
+ .string()
14848
+ .datetime({ offset: true })
14849
+ .optional()
14850
+ .describe('Timestamp of when the resource was permanently deleted.'),
14851
+ key: z
14852
+ .string()
14853
+ .min(1)
14854
+ .max(256)
14855
+ .optional()
14856
+ .describe('An optional unique key of the customer. Either key or usageAttribution.subjectKeys must be provided. Useful to reference the customer in external systems. For example, your database ID.'),
14857
+ usage_attribution: notificationEventV1CustomerUsageAttributionWire.optional(),
14858
+ primary_email: z
14859
+ .string()
14860
+ .optional()
14861
+ .describe('The primary email address of the customer.'),
14862
+ currency: notificationEventV1CurrencyCodeWire.optional(),
14863
+ billing_address: notificationEventV1AddressWire.optional(),
14864
+ current_subscription_id: z
14865
+ .string()
14866
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
14867
+ .optional()
14868
+ .describe('The ID of the Subscription if the customer has one.'),
14869
+ subscriptions: z
14870
+ .array(notificationEventV1SubscriptionWire)
14871
+ .optional()
14872
+ .describe('The subscriptions of the customer. Only with the `subscriptions` expand option.'),
14873
+ annotations: notificationEventV1AnnotationsWire.optional(),
14874
+ })
14875
+ .describe('A customer object.');
14876
+ export const notificationEventV1StripeAppWire = z
14877
+ .strictObject({
14878
+ id: z
14879
+ .string()
14880
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
14881
+ .describe('A unique identifier for the resource.'),
14882
+ name: z
14883
+ .string()
14884
+ .min(1)
14885
+ .max(256)
14886
+ .describe('Human-readable name for the resource. Between 1 and 256 characters.'),
14887
+ description: z
14888
+ .string()
14889
+ .max(1024)
14890
+ .optional()
14891
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
14892
+ metadata: notificationEventV1MetadataWire
14893
+ .nullable()
14894
+ .optional()
14895
+ .describe('Additional metadata for the resource.'),
14896
+ created_at: z
14897
+ .string()
14898
+ .datetime({ offset: true })
14899
+ .describe('Timestamp of when the resource was created.'),
14900
+ updated_at: z
14901
+ .string()
14902
+ .datetime({ offset: true })
14903
+ .describe('Timestamp of when the resource was last updated.'),
14904
+ deleted_at: z
14905
+ .string()
14906
+ .datetime({ offset: true })
14907
+ .optional()
14908
+ .describe('Timestamp of when the resource was permanently deleted.'),
14909
+ listing: notificationEventV1MarketplaceListingWire,
14910
+ status: notificationEventV1AppStatusWire,
14911
+ type: z.literal('stripe').describe("The app's type is Stripe."),
14912
+ stripe_account_id: z.string().describe('The Stripe account ID.'),
14913
+ livemode: z
14914
+ .boolean()
14915
+ .describe('Livemode, true if the app is in production mode.'),
14916
+ masked_api_key: z
14917
+ .string()
14918
+ .describe('The masked API key. Only shows the first 8 and last 3 characters.'),
14919
+ })
14920
+ .describe('A installed Stripe app object.');
14921
+ export const notificationEventV1SandboxAppWire = z
14922
+ .strictObject({
14923
+ id: z
14924
+ .string()
14925
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
14926
+ .describe('A unique identifier for the resource.'),
14927
+ name: z
14928
+ .string()
14929
+ .min(1)
14930
+ .max(256)
14931
+ .describe('Human-readable name for the resource. Between 1 and 256 characters.'),
14932
+ description: z
14933
+ .string()
14934
+ .max(1024)
14935
+ .optional()
14936
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
14937
+ metadata: notificationEventV1MetadataWire
14938
+ .nullable()
14939
+ .optional()
14940
+ .describe('Additional metadata for the resource.'),
14941
+ created_at: z
14942
+ .string()
14943
+ .datetime({ offset: true })
14944
+ .describe('Timestamp of when the resource was created.'),
14945
+ updated_at: z
14946
+ .string()
14947
+ .datetime({ offset: true })
14948
+ .describe('Timestamp of when the resource was last updated.'),
14949
+ deleted_at: z
14950
+ .string()
14951
+ .datetime({ offset: true })
14952
+ .optional()
14953
+ .describe('Timestamp of when the resource was permanently deleted.'),
14954
+ listing: notificationEventV1MarketplaceListingWire,
14955
+ status: notificationEventV1AppStatusWire,
14956
+ type: z.literal('sandbox').describe("The app's type is Sandbox."),
14957
+ })
14958
+ .describe('Sandbox app can be used for testing OpenMeter features. The app is not creating anything in external systems, thus it is safe to use for verifying OpenMeter features.');
14959
+ export const notificationEventV1CustomInvoicingAppWire = z
14960
+ .strictObject({
14961
+ id: z
14962
+ .string()
14963
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
14964
+ .describe('A unique identifier for the resource.'),
14965
+ name: z
14966
+ .string()
14967
+ .min(1)
14968
+ .max(256)
14969
+ .describe('Human-readable name for the resource. Between 1 and 256 characters.'),
14970
+ description: z
14971
+ .string()
14972
+ .max(1024)
14973
+ .optional()
14974
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
14975
+ metadata: notificationEventV1MetadataWire
14976
+ .nullable()
14977
+ .optional()
14978
+ .describe('Additional metadata for the resource.'),
14979
+ created_at: z
14980
+ .string()
14981
+ .datetime({ offset: true })
14982
+ .describe('Timestamp of when the resource was created.'),
14983
+ updated_at: z
14984
+ .string()
14985
+ .datetime({ offset: true })
14986
+ .describe('Timestamp of when the resource was last updated.'),
14987
+ deleted_at: z
14988
+ .string()
14989
+ .datetime({ offset: true })
14990
+ .optional()
14991
+ .describe('Timestamp of when the resource was permanently deleted.'),
14992
+ listing: notificationEventV1MarketplaceListingWire,
14993
+ status: notificationEventV1AppStatusWire,
14994
+ type: z
14995
+ .literal('custom_invoicing')
14996
+ .describe("The app's type is CustomInvoicing."),
14997
+ enable_draft_sync_hook: z
14998
+ .boolean()
14999
+ .describe('Enable draft.sync hook. If the hook is not enabled, the invoice will be progressed to the next state automatically.'),
15000
+ enable_issuing_sync_hook: z
15001
+ .boolean()
15002
+ .describe('Enable issuing.sync hook. If the hook is not enabled, the invoice will be progressed to the next state automatically.'),
15003
+ })
15004
+ .describe('Custom Invoicing app can be used for interface with any invoicing or payment system. This app provides ways to manipulate invoices and payments, however the integration must rely on Notifications API to get notified about invoice changes.');
15005
+ export const notificationEventV1InvoiceLineAmountDiscountWire = z
15006
+ .strictObject({
15007
+ created_at: z
15008
+ .string()
15009
+ .datetime({ offset: true })
15010
+ .describe('Timestamp of when the resource was created.'),
15011
+ updated_at: z
15012
+ .string()
15013
+ .datetime({ offset: true })
15014
+ .describe('Timestamp of when the resource was last updated.'),
15015
+ deleted_at: z
15016
+ .string()
15017
+ .datetime({ offset: true })
15018
+ .optional()
15019
+ .describe('Timestamp of when the resource was permanently deleted.'),
15020
+ id: z
15021
+ .string()
15022
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
15023
+ .describe('ID of the charge or discount.'),
15024
+ reason: notificationEventV1BillingDiscountReasonWire,
15025
+ description: z
15026
+ .string()
15027
+ .optional()
15028
+ .describe('Text description as to why the discount was applied.'),
15029
+ external_ids: notificationEventV1InvoiceLineAppExternalIdsWire.optional(),
15030
+ amount: notificationEventV1NumericWire,
15031
+ })
15032
+ .describe('InvoiceLineAmountDiscount represents an amount deducted from the line, and will be applied before taxes.');
15033
+ export const notificationEventV1InvoiceLineUsageDiscountWire = z
12240
15034
  .strictObject({
12241
- id: ulidWire,
12242
- type: z
12243
- .literal('entitlements.balance.threshold')
12244
- .describe('The type of the event.'),
12245
- timestamp: dateTimeWire,
12246
- data: notificationEventBalanceThresholdDataWire,
15035
+ created_at: z
15036
+ .string()
15037
+ .datetime({ offset: true })
15038
+ .describe('Timestamp of when the resource was created.'),
15039
+ updated_at: z
15040
+ .string()
15041
+ .datetime({ offset: true })
15042
+ .describe('Timestamp of when the resource was last updated.'),
15043
+ deleted_at: z
15044
+ .string()
15045
+ .datetime({ offset: true })
15046
+ .optional()
15047
+ .describe('Timestamp of when the resource was permanently deleted.'),
15048
+ id: z
15049
+ .string()
15050
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
15051
+ .describe('ID of the charge or discount.'),
15052
+ reason: notificationEventV1BillingDiscountReasonWire,
15053
+ description: z
15054
+ .string()
15055
+ .optional()
15056
+ .describe('Text description as to why the discount was applied.'),
15057
+ external_ids: notificationEventV1InvoiceLineAppExternalIdsWire.optional(),
15058
+ quantity: notificationEventV1NumericWire,
15059
+ pre_line_period_quantity: notificationEventV1NumericWire.optional(),
12247
15060
  })
12248
- .describe('A balance threshold notification event payload.');
12249
- export const notificationEventResetPayloadWire = z
15061
+ .describe('InvoiceLineUsageDiscount represents an usage-based discount applied to the line. The deduction is done before the pricing algorithm is applied.');
15062
+ export const notificationEventV1InvoiceDetailedLineRateCardWire = z
12250
15063
  .strictObject({
12251
- id: ulidWire,
12252
- type: z.literal('entitlements.reset').describe('The type of the event.'),
12253
- timestamp: dateTimeWire,
12254
- data: notificationEventEntitlementDataWire,
15064
+ tax_config: notificationEventV1TaxConfigWire.optional(),
15065
+ price: notificationEventV1FlatPriceWithPaymentTermWire
15066
+ .nullable()
15067
+ .describe('The price of the rate card. When null, the feature or service is free.'),
15068
+ quantity: notificationEventV1NumericWire.optional(),
15069
+ discounts: notificationEventV1BillingDiscountsWire.optional(),
12255
15070
  })
12256
- .describe('An entitlement reset notification event payload.');
15071
+ .describe('InvoiceDetailedLineRateCard represents the rate card (intent) for a flat fee line.');
15072
+ export const notificationEventV1PaymentTermsWire = z
15073
+ .discriminatedUnion('type', [
15074
+ notificationEventV1PaymentTermInstantWire,
15075
+ notificationEventV1PaymentTermDueDateWire,
15076
+ ])
15077
+ .describe('PaymentTerms defines the terms for payment.');
12257
15078
  export const priceWire = z
12258
15079
  .discriminatedUnion('type', [
12259
15080
  priceFreeWire,
@@ -12531,14 +15352,93 @@ export const notificationRulePagePaginatedResponseWire = z
12531
15352
  meta: paginatedMetaWire,
12532
15353
  })
12533
15354
  .describe('Page paginated response.');
12534
- export const notificationEventPayloadWire = z
15355
+ export const notificationEventV1BillingWorkflowCollectionAlignmentWire = z
12535
15356
  .discriminatedUnion('type', [
12536
- notificationEventBalanceThresholdPayloadWire,
12537
- notificationEventResetPayloadWire,
12538
- notificationEventInvoiceCreatedPayloadWire,
12539
- notificationEventInvoiceUpdatedPayloadWire,
15357
+ notificationEventV1BillingWorkflowCollectionAlignmentSubscriptionWire,
15358
+ notificationEventV1BillingWorkflowCollectionAlignmentAnchoredWire,
12540
15359
  ])
12541
- .describe('The payload delivered to the channels, discriminated by the event type.');
15360
+ .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).');
15361
+ export const notificationEventV1FeatureWire = z
15362
+ .strictObject({
15363
+ created_at: z
15364
+ .string()
15365
+ .datetime({ offset: true })
15366
+ .describe('Timestamp of when the resource was created.'),
15367
+ updated_at: z
15368
+ .string()
15369
+ .datetime({ offset: true })
15370
+ .describe('Timestamp of when the resource was last updated.'),
15371
+ deleted_at: z
15372
+ .string()
15373
+ .datetime({ offset: true })
15374
+ .optional()
15375
+ .describe('Timestamp of when the resource was permanently deleted.'),
15376
+ archived_at: z
15377
+ .string()
15378
+ .datetime({ offset: true })
15379
+ .optional()
15380
+ .describe('Timestamp of when the resource was archived.'),
15381
+ key: z
15382
+ .string()
15383
+ .min(1)
15384
+ .max(64)
15385
+ .regex(new RegExp('^[a-z0-9]+(?:_[a-z0-9]+)*$'))
15386
+ .describe('A key is a unique string that is used to identify a resource.'),
15387
+ name: z.string().describe('The human-readable name of the feature.'),
15388
+ metadata: notificationEventV1MetadataWire.optional(),
15389
+ meter_slug: z
15390
+ .string()
15391
+ .min(1)
15392
+ .optional()
15393
+ .describe('A key is a unique string that is used to identify a resource.'),
15394
+ meter_group_by_filters: z
15395
+ .record(z.string(), z.string())
15396
+ .optional()
15397
+ .describe('Optional meter group by filters. Useful if the meter scope is broader than what feature tracks. Example scenario would be a meter tracking all token use with groupBy fields for the model, then the feature could filter for model=gpt-4. ⚠️ **Deprecated**: Use advancedMeterGroupByFilters instead'),
15398
+ advanced_meter_group_by_filters: z
15399
+ .record(z.string(), notificationEventV1FilterStringWire)
15400
+ .optional()
15401
+ .describe('Optional advanced meter group by filters. You can use this to filter for values of the meter groupBy fields.'),
15402
+ unit_cost: notificationEventV1FeatureUnitCostWire.optional(),
15403
+ id: z
15404
+ .string()
15405
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
15406
+ .describe('Readonly unique ULID identifier.'),
15407
+ })
15408
+ .describe('Represents a feature that can be enabled or disabled for a plan. Used both for product catalog and entitlements.');
15409
+ export const notificationEventV1RateCardUsageBasedPriceWire = z
15410
+ .discriminatedUnion('type', [
15411
+ notificationEventV1FlatPriceWithPaymentTermWire,
15412
+ notificationEventV1UnitPriceWithCommitmentsWire,
15413
+ notificationEventV1TieredPriceWithCommitmentsWire,
15414
+ notificationEventV1DynamicPriceWithCommitmentsWire,
15415
+ notificationEventV1PackagePriceWithCommitmentsWire,
15416
+ ])
15417
+ .describe('The price of the usage based rate card.');
15418
+ export const notificationEventV1AppWire = z
15419
+ .discriminatedUnion('type', [
15420
+ notificationEventV1StripeAppWire,
15421
+ notificationEventV1SandboxAppWire,
15422
+ notificationEventV1CustomInvoicingAppWire,
15423
+ ])
15424
+ .describe('App. One of: stripe');
15425
+ export const notificationEventV1InvoiceLineDiscountsWire = z
15426
+ .strictObject({
15427
+ amount: z
15428
+ .array(notificationEventV1InvoiceLineAmountDiscountWire)
15429
+ .optional()
15430
+ .describe('Amount based discounts applied to the line. Amount based discounts are deduced from the total price of the line.'),
15431
+ usage: z
15432
+ .array(notificationEventV1InvoiceLineUsageDiscountWire)
15433
+ .optional()
15434
+ .describe('Usage based discounts applied to the line. Usage based discounts are deduced from the usage of the line before price calculations are applied.'),
15435
+ })
15436
+ .describe('InvoiceLineDiscounts represents the discounts applied to the invoice line by type.');
15437
+ export const notificationEventV1InvoicePaymentTermsWire = z
15438
+ .strictObject({
15439
+ terms: notificationEventV1PaymentTermsWire.optional(),
15440
+ })
15441
+ .describe('Payment contains details as to how the invoice should be paid.');
12542
15442
  export const rateCardWire = z
12543
15443
  .strictObject({
12544
15444
  name: z
@@ -12678,18 +15578,126 @@ export const profileAppsWire = z
12678
15578
  payment: appWire,
12679
15579
  })
12680
15580
  .describe('Applications used by a billing profile.');
12681
- export const notificationEventWire = z
15581
+ export const notificationEventV1BillingWorkflowCollectionSettingsWire = z
12682
15582
  .strictObject({
12683
- id: ulidWire,
12684
- type: notificationEventTypeWire,
12685
- created_at: dateTimeWire,
12686
- rule: notificationRuleReferenceWire,
12687
- delivery_status: z
12688
- .array(notificationEventDeliveryStatusWire)
12689
- .describe('The delivery status of the event, one entry per channel of the rule.'),
12690
- payload: notificationEventPayloadWire,
15583
+ alignment: notificationEventV1BillingWorkflowCollectionAlignmentWire.optional(),
15584
+ interval: z
15585
+ .string()
15586
+ .optional()
15587
+ .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.'),
12691
15588
  })
12692
- .describe('A notification event records that a notification rule fired and tracks the delivery of its payload to each channel of the rule. Events are created by the system and cannot be modified.');
15589
+ .describe('Workflow collection specifies how to collect the pending line items for an invoice');
15590
+ export const notificationEventV1BalanceThresholdPayloadDataWire = z
15591
+ .strictObject({
15592
+ entitlement: notificationEventV1EntitlementMeteredWire,
15593
+ feature: notificationEventV1FeatureWire,
15594
+ subject: notificationEventV1SubjectWire,
15595
+ value: notificationEventV1EntitlementValueWire,
15596
+ customer: notificationEventV1CustomerWire.optional(),
15597
+ threshold: notificationEventV1RuleBalanceThresholdValueWire,
15598
+ })
15599
+ .describe('Data of the payload for notification event with `entitlements.balance.threshold` type.');
15600
+ export const notificationEventV1EntitlementValuePayloadBaseWire = z
15601
+ .strictObject({
15602
+ entitlement: notificationEventV1EntitlementMeteredWire,
15603
+ feature: notificationEventV1FeatureWire,
15604
+ subject: notificationEventV1SubjectWire,
15605
+ value: notificationEventV1EntitlementValueWire,
15606
+ customer: notificationEventV1CustomerWire.optional(),
15607
+ })
15608
+ .describe('Base data for any payload with entitlement entitlement value.');
15609
+ export const notificationEventV1InvoiceUsageBasedRateCardWire = z
15610
+ .strictObject({
15611
+ feature_key: z
15612
+ .string()
15613
+ .min(1)
15614
+ .max(64)
15615
+ .regex(new RegExp('^[a-z0-9]+(?:_[a-z0-9]+)*$'))
15616
+ .optional()
15617
+ .describe('The feature the customer is entitled to use.'),
15618
+ tax_config: notificationEventV1TaxConfigWire.optional(),
15619
+ price: notificationEventV1RateCardUsageBasedPriceWire
15620
+ .nullable()
15621
+ .describe('The price of the rate card. When null, the feature or service is free.'),
15622
+ discounts: notificationEventV1BillingDiscountsWire.optional(),
15623
+ })
15624
+ .describe('InvoiceUsageBasedRateCard represents the rate card (intent) for an usage-based line.');
15625
+ export const notificationEventV1BillingProfileAppsWire = z
15626
+ .strictObject({
15627
+ tax: notificationEventV1AppWire
15628
+ .nullable()
15629
+ .describe('The tax app used for this workflow'),
15630
+ invoicing: notificationEventV1AppWire
15631
+ .nullable()
15632
+ .describe('The invoicing app used for this workflow'),
15633
+ payment: notificationEventV1AppWire
15634
+ .nullable()
15635
+ .describe('The payment app used for this workflow'),
15636
+ })
15637
+ .describe('BillingProfileApps represents the applications used by a billing profile');
15638
+ export const notificationEventV1InvoiceDetailedLineWire = z
15639
+ .strictObject({
15640
+ name: z
15641
+ .string()
15642
+ .min(1)
15643
+ .max(256)
15644
+ .describe('Human-readable name for the resource. Between 1 and 256 characters.'),
15645
+ description: z
15646
+ .string()
15647
+ .max(1024)
15648
+ .optional()
15649
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
15650
+ metadata: notificationEventV1MetadataWire
15651
+ .nullable()
15652
+ .optional()
15653
+ .describe('Additional metadata for the resource.'),
15654
+ created_at: z
15655
+ .string()
15656
+ .datetime({ offset: true })
15657
+ .describe('Timestamp of when the resource was created.'),
15658
+ updated_at: z
15659
+ .string()
15660
+ .datetime({ offset: true })
15661
+ .describe('Timestamp of when the resource was last updated.'),
15662
+ deleted_at: z
15663
+ .string()
15664
+ .datetime({ offset: true })
15665
+ .optional()
15666
+ .describe('Timestamp of when the resource was permanently deleted.'),
15667
+ id: z
15668
+ .string()
15669
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
15670
+ .describe('ID of the line.'),
15671
+ managed_by: notificationEventV1InvoiceLineManagedByWire,
15672
+ status: notificationEventV1InvoiceLineStatusWire,
15673
+ discounts: notificationEventV1InvoiceLineDiscountsWire.optional(),
15674
+ credit_allocations: z
15675
+ .array(notificationEventV1InvoiceLineCreditAllocationWire)
15676
+ .optional()
15677
+ .describe('Credit allocations applied to this line. Credits are deducted from the line total before taxes are applied.'),
15678
+ invoice: notificationEventV1InvoiceReferenceWire.optional(),
15679
+ currency: notificationEventV1CurrencyCodeWire,
15680
+ taxes: z
15681
+ .array(notificationEventV1InvoiceLineTaxItemWire)
15682
+ .optional()
15683
+ .describe('Taxes applied to the invoice totals.'),
15684
+ tax_config: notificationEventV1TaxConfigWire.optional(),
15685
+ totals: notificationEventV1InvoiceTotalsWire,
15686
+ period: notificationEventV1PeriodWire,
15687
+ external_ids: notificationEventV1InvoiceLineAppExternalIdsWire.optional(),
15688
+ subscription: notificationEventV1InvoiceLineSubscriptionReferenceWire.optional(),
15689
+ invoice_at: z
15690
+ .string()
15691
+ .datetime({ offset: true })
15692
+ .describe('The time this line item should be invoiced.'),
15693
+ type: z.literal('flat_fee').describe('Type of the line.'),
15694
+ per_unit_amount: notificationEventV1NumericWire.optional(),
15695
+ payment_term: notificationEventV1PricePaymentTermWire.optional(),
15696
+ quantity: notificationEventV1NumericWire.optional(),
15697
+ rate_card: notificationEventV1InvoiceDetailedLineRateCardWire.optional(),
15698
+ category: notificationEventV1InvoiceDetailedLineCostCategoryWire.optional(),
15699
+ })
15700
+ .describe('InvoiceDetailedLine represents a line item that is sold to the customer as a manually added fee.');
12693
15701
  export const subscriptionItemWire = z
12694
15702
  .strictObject({
12695
15703
  id: ulidWire,
@@ -12951,12 +15959,107 @@ export const chargeRealizationWire = z
12951
15959
  .describe('The detailed (rated) lines produced by the realization run. Requires the `realization.detailed_lines` expand.'),
12952
15960
  })
12953
15961
  .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).");
12954
- export const notificationEventPagePaginatedResponseWire = z
15962
+ export const notificationEventV1BillingWorkflowWire = z
12955
15963
  .strictObject({
12956
- data: z.array(notificationEventWire),
12957
- meta: paginatedMetaWire,
15964
+ collection: notificationEventV1BillingWorkflowCollectionSettingsWire.optional(),
15965
+ invoicing: notificationEventV1BillingWorkflowInvoicingSettingsWire.optional(),
15966
+ payment: notificationEventV1BillingWorkflowPaymentSettingsWire.optional(),
15967
+ tax: notificationEventV1BillingWorkflowTaxSettingsWire.optional(),
12958
15968
  })
12959
- .describe('Page paginated response.');
15969
+ .describe('BillingWorkflow represents the settings for a billing workflow.');
15970
+ export const notificationEventBalanceThresholdPayloadWire = z
15971
+ .strictObject({
15972
+ id: ulidWire,
15973
+ type: z
15974
+ .literal('entitlements.balance.threshold')
15975
+ .describe('The type of the event.'),
15976
+ timestamp: dateTimeWire,
15977
+ data: notificationEventV1BalanceThresholdPayloadDataWire,
15978
+ })
15979
+ .describe('A balance threshold notification event payload.');
15980
+ export const notificationEventResetPayloadWire = z
15981
+ .strictObject({
15982
+ id: ulidWire,
15983
+ type: z.literal('entitlements.reset').describe('The type of the event.'),
15984
+ timestamp: dateTimeWire,
15985
+ data: notificationEventV1EntitlementValuePayloadBaseWire,
15986
+ })
15987
+ .describe('An entitlement reset notification event payload.');
15988
+ export const notificationEventV1InvoiceLineWire = z
15989
+ .strictObject({
15990
+ name: z
15991
+ .string()
15992
+ .min(1)
15993
+ .max(256)
15994
+ .describe('Human-readable name for the resource. Between 1 and 256 characters.'),
15995
+ description: z
15996
+ .string()
15997
+ .max(1024)
15998
+ .optional()
15999
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
16000
+ metadata: notificationEventV1MetadataWire
16001
+ .nullable()
16002
+ .optional()
16003
+ .describe('Additional metadata for the resource.'),
16004
+ created_at: z
16005
+ .string()
16006
+ .datetime({ offset: true })
16007
+ .describe('Timestamp of when the resource was created.'),
16008
+ updated_at: z
16009
+ .string()
16010
+ .datetime({ offset: true })
16011
+ .describe('Timestamp of when the resource was last updated.'),
16012
+ deleted_at: z
16013
+ .string()
16014
+ .datetime({ offset: true })
16015
+ .optional()
16016
+ .describe('Timestamp of when the resource was permanently deleted.'),
16017
+ id: z
16018
+ .string()
16019
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
16020
+ .describe('ID of the line.'),
16021
+ managed_by: notificationEventV1InvoiceLineManagedByWire,
16022
+ status: notificationEventV1InvoiceLineStatusWire,
16023
+ discounts: notificationEventV1InvoiceLineDiscountsWire.optional(),
16024
+ credit_allocations: z
16025
+ .array(notificationEventV1InvoiceLineCreditAllocationWire)
16026
+ .optional()
16027
+ .describe('Credit allocations applied to this line. Credits are deducted from the line total before taxes are applied.'),
16028
+ invoice: notificationEventV1InvoiceReferenceWire.optional(),
16029
+ currency: notificationEventV1CurrencyCodeWire,
16030
+ taxes: z
16031
+ .array(notificationEventV1InvoiceLineTaxItemWire)
16032
+ .optional()
16033
+ .describe('Taxes applied to the invoice totals.'),
16034
+ tax_config: notificationEventV1TaxConfigWire.optional(),
16035
+ totals: notificationEventV1InvoiceTotalsWire,
16036
+ period: notificationEventV1PeriodWire,
16037
+ invoice_at: z
16038
+ .string()
16039
+ .datetime({ offset: true })
16040
+ .describe('The time this line item should be invoiced.'),
16041
+ external_ids: notificationEventV1InvoiceLineAppExternalIdsWire.optional(),
16042
+ subscription: notificationEventV1InvoiceLineSubscriptionReferenceWire.optional(),
16043
+ type: z.literal('usage_based').describe('Type of the line.'),
16044
+ price: notificationEventV1RateCardUsageBasedPriceWire.optional(),
16045
+ feature_key: z
16046
+ .string()
16047
+ .min(1)
16048
+ .max(64)
16049
+ .regex(new RegExp('^[a-z0-9]+(?:_[a-z0-9]+)*$'))
16050
+ .optional()
16051
+ .describe('The feature that the usage is based on.'),
16052
+ children: z
16053
+ .array(notificationEventV1InvoiceDetailedLineWire)
16054
+ .optional()
16055
+ .describe('The lines detailing the item or service sold.'),
16056
+ rate_card: notificationEventV1InvoiceUsageBasedRateCardWire.optional(),
16057
+ quantity: notificationEventV1NumericWire.optional(),
16058
+ metered_quantity: notificationEventV1NumericWire.optional(),
16059
+ pre_line_period_quantity: notificationEventV1NumericWire.optional(),
16060
+ metered_pre_line_period_quantity: notificationEventV1NumericWire.optional(),
16061
+ })
16062
+ .describe('InvoiceUsageBasedLine represents a line item that is sold to the customer based on usage.');
12960
16063
  export const subscriptionPhaseWire = z
12961
16064
  .strictObject({
12962
16065
  id: ulidWire,
@@ -13163,6 +16266,16 @@ export const profilePagePaginatedResponseWire = z
13163
16266
  meta: paginatedMetaWire,
13164
16267
  })
13165
16268
  .describe('Page paginated response.');
16269
+ export const notificationEventV1InvoiceWorkflowSettingsWire = z
16270
+ .strictObject({
16271
+ apps: notificationEventV1BillingProfileAppsWire.optional(),
16272
+ source_billing_profile_id: z
16273
+ .string()
16274
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
16275
+ .describe('sourceBillingProfileID is the billing profile on which the workflow was based on. The profile is snapshotted on invoice creation, after which it can be altered independently of the profile itself.'),
16276
+ workflow: notificationEventV1BillingWorkflowWire,
16277
+ })
16278
+ .describe("InvoiceWorkflowSettings represents the workflow settings used by the invoice. This is a clone of the billing profile's workflow settings at the time of invoice creation with customer overrides considered.");
13166
16279
  export const subscriptionWire = z
13167
16280
  .strictObject({
13168
16281
  id: ulidWire,
@@ -13347,6 +16460,95 @@ export const updateInvoiceStandardRequestWire = z
13347
16460
  .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.'),
13348
16461
  })
13349
16462
  .describe('InvoiceStandard update request.');
16463
+ export const notificationEventV1InvoiceWire = z
16464
+ .strictObject({
16465
+ id: z
16466
+ .string()
16467
+ .regex(new RegExp('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$'))
16468
+ .describe('A unique identifier for the resource.'),
16469
+ description: z
16470
+ .string()
16471
+ .max(1024)
16472
+ .optional()
16473
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
16474
+ metadata: notificationEventV1MetadataWire
16475
+ .nullable()
16476
+ .optional()
16477
+ .describe('Additional metadata for the resource.'),
16478
+ created_at: z
16479
+ .string()
16480
+ .datetime({ offset: true })
16481
+ .describe('Timestamp of when the resource was created.'),
16482
+ updated_at: z
16483
+ .string()
16484
+ .datetime({ offset: true })
16485
+ .describe('Timestamp of when the resource was last updated.'),
16486
+ deleted_at: z
16487
+ .string()
16488
+ .datetime({ offset: true })
16489
+ .optional()
16490
+ .describe('Timestamp of when the resource was permanently deleted.'),
16491
+ type: notificationEventV1InvoiceTypeWire,
16492
+ supplier: notificationEventV1BillingPartyWire,
16493
+ customer: notificationEventV1BillingInvoiceCustomerExtendedDetailsWire,
16494
+ number: notificationEventV1InvoiceNumberWire,
16495
+ currency: notificationEventV1CurrencyCodeWire,
16496
+ preceding: z
16497
+ .array(notificationEventV1InvoiceDocumentRefWire)
16498
+ .optional()
16499
+ .describe('Key information regarding previous invoices and potentially details as to why they were corrected.'),
16500
+ totals: notificationEventV1InvoiceTotalsWire,
16501
+ status: notificationEventV1InvoiceStatusWire,
16502
+ status_details: notificationEventV1InvoiceStatusDetailsWire,
16503
+ issued_at: z
16504
+ .string()
16505
+ .datetime({ offset: true })
16506
+ .optional()
16507
+ .describe('The time the invoice was issued. Depending on the status of the invoice this can mean multiple things: - draft, gathering: The time the invoice will be issued based on the workflow settings. - issued: The time the invoice was issued.'),
16508
+ draft_until: z
16509
+ .string()
16510
+ .datetime({ offset: true })
16511
+ .optional()
16512
+ .describe('The time until the invoice is in draft status. On draft invoice creation it is calculated from the workflow settings. If manual approval is required, the draftUntil time is set.'),
16513
+ quantity_snapshoted_at: z
16514
+ .string()
16515
+ .datetime({ offset: true })
16516
+ .optional()
16517
+ .describe('The time when the quantity snapshots on the invoice lines were taken.'),
16518
+ collection_at: z
16519
+ .string()
16520
+ .datetime({ offset: true })
16521
+ .optional()
16522
+ .describe('The time when the invoice will be/has been collected.'),
16523
+ due_at: z
16524
+ .string()
16525
+ .datetime({ offset: true })
16526
+ .optional()
16527
+ .describe('Due time of the fulfillment of the invoice (if available).'),
16528
+ period: notificationEventV1PeriodWire.optional(),
16529
+ voided_at: z
16530
+ .string()
16531
+ .datetime({ offset: true })
16532
+ .optional()
16533
+ .describe('The time the invoice was voided. If the invoice was voided, this field will be set to the time the invoice was voided.'),
16534
+ sent_to_customer_at: z
16535
+ .string()
16536
+ .datetime({ offset: true })
16537
+ .optional()
16538
+ .describe('The time the invoice was sent to customer.'),
16539
+ workflow: notificationEventV1InvoiceWorkflowSettingsWire,
16540
+ lines: z
16541
+ .array(notificationEventV1InvoiceLineWire)
16542
+ .optional()
16543
+ .describe('List of invoice lines representing each of the items sold to the customer.'),
16544
+ payment: notificationEventV1InvoicePaymentTermsWire.optional(),
16545
+ validation_issues: z
16546
+ .array(notificationEventV1ValidationIssueWire)
16547
+ .optional()
16548
+ .describe('Validation issues reported by the invoice workflow.'),
16549
+ external_ids: notificationEventV1InvoiceAppExternalIdsWire.optional(),
16550
+ })
16551
+ .describe('Invoice represents an invoice in the system.');
13350
16552
  export const subscriptionOrReferenceWire = z
13351
16553
  .union([subscriptionWire, subscriptionReferenceWire])
13352
16554
  .describe('Subscription or reference.');
@@ -13374,6 +16576,22 @@ export const invoiceWire = z
13374
16576
  export const updateInvoiceRequestWire = z
13375
16577
  .discriminatedUnion('type', [updateInvoiceStandardRequestWire])
13376
16578
  .describe('UpdateInvoiceRequest update request.');
16579
+ export const notificationEventInvoiceCreatedPayloadWire = z
16580
+ .strictObject({
16581
+ id: ulidWire,
16582
+ type: z.literal('invoice.created').describe('The type of the event.'),
16583
+ timestamp: dateTimeWire,
16584
+ data: notificationEventV1InvoiceWire,
16585
+ })
16586
+ .describe('An invoice created notification event payload.');
16587
+ export const notificationEventInvoiceUpdatedPayloadWire = z
16588
+ .strictObject({
16589
+ id: ulidWire,
16590
+ type: z.literal('invoice.updated').describe('The type of the event.'),
16591
+ timestamp: dateTimeWire,
16592
+ data: notificationEventV1InvoiceWire,
16593
+ })
16594
+ .describe('An invoice updated notification event payload.');
13377
16595
  export const chargeFlatFeeWire = z
13378
16596
  .strictObject({
13379
16597
  id: ulidWire,
@@ -13490,15 +16708,41 @@ export const invoicePagePaginatedResponseWire = z
13490
16708
  meta: paginatedMetaWire,
13491
16709
  })
13492
16710
  .describe('Page paginated response.');
16711
+ export const notificationEventPayloadWire = z
16712
+ .discriminatedUnion('type', [
16713
+ notificationEventBalanceThresholdPayloadWire,
16714
+ notificationEventResetPayloadWire,
16715
+ notificationEventInvoiceCreatedPayloadWire,
16716
+ notificationEventInvoiceUpdatedPayloadWire,
16717
+ ])
16718
+ .describe('The payload delivered to the channels, discriminated by the event type.');
13493
16719
  export const chargeWire = z
13494
16720
  .discriminatedUnion('type', [chargeFlatFeeWire, chargeUsageBasedWire])
13495
16721
  .describe('Customer charge.');
16722
+ export const notificationEventWire = z
16723
+ .strictObject({
16724
+ id: ulidWire,
16725
+ type: notificationEventTypeWire,
16726
+ created_at: dateTimeWire,
16727
+ rule: notificationRuleReferenceWire,
16728
+ delivery_status: z
16729
+ .array(notificationEventDeliveryStatusWire)
16730
+ .describe('The delivery status of the event, one entry per channel of the rule.'),
16731
+ payload: notificationEventPayloadWire,
16732
+ })
16733
+ .describe('A notification event records that a notification rule fired and tracks the delivery of its payload to each channel of the rule. Events are created by the system and cannot be modified.');
13496
16734
  export const chargePagePaginatedResponseWire = z
13497
16735
  .strictObject({
13498
16736
  data: z.array(chargeWire),
13499
16737
  meta: paginatedMetaWire,
13500
16738
  })
13501
16739
  .describe('Page paginated response.');
16740
+ export const notificationEventPagePaginatedResponseWire = z
16741
+ .strictObject({
16742
+ data: z.array(notificationEventWire),
16743
+ meta: paginatedMetaWire,
16744
+ })
16745
+ .describe('Page paginated response.');
13502
16746
  export const listMeteringEventsQueryParamsWire = z.object({
13503
16747
  page: cursorPaginationQueryPageWire.optional(),
13504
16748
  filter: listEventsParamsFilterWire.optional(),