@openmeter/sdk 1.0.0-beta.13 → 1.0.0-beta.130

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +224 -46
  2. package/dist/cjs/clients/client.cjs +120 -0
  3. package/dist/cjs/clients/client.d.cts +37 -0
  4. package/dist/cjs/clients/client.js.map +1 -0
  5. package/dist/cjs/clients/entitlement.cjs +27 -0
  6. package/dist/cjs/clients/entitlement.d.cts +26 -0
  7. package/dist/cjs/clients/entitlement.js.map +1 -0
  8. package/dist/cjs/clients/event.cjs +71 -0
  9. package/dist/cjs/clients/event.d.cts +79 -0
  10. package/dist/cjs/clients/event.js.map +1 -0
  11. package/dist/cjs/clients/feature.cjs +80 -0
  12. package/dist/cjs/clients/feature.d.cts +46 -0
  13. package/dist/cjs/clients/feature.js.map +1 -0
  14. package/dist/cjs/clients/grant.cjs +41 -0
  15. package/dist/cjs/clients/grant.d.cts +24 -0
  16. package/dist/cjs/clients/grant.js.map +1 -0
  17. package/dist/cjs/clients/meter.cjs +83 -0
  18. package/dist/cjs/clients/meter.d.cts +79 -0
  19. package/dist/cjs/clients/meter.js.map +1 -0
  20. package/dist/cjs/clients/pagination.cjs +3 -0
  21. package/dist/cjs/clients/pagination.d.cts +6 -0
  22. package/dist/cjs/clients/pagination.js.map +1 -0
  23. package/dist/cjs/clients/portal.cjs +41 -0
  24. package/dist/cjs/clients/portal.d.cts +22 -0
  25. package/dist/cjs/clients/portal.js.map +1 -0
  26. package/dist/cjs/clients/subject.cjs +242 -0
  27. package/dist/cjs/clients/subject.d.cts +125 -0
  28. package/dist/cjs/clients/subject.js.map +1 -0
  29. package/dist/cjs/index.cjs +33 -0
  30. package/dist/cjs/index.d.cts +21 -0
  31. package/dist/cjs/index.js.map +1 -0
  32. package/dist/cjs/schemas/openapi.cjs +7 -0
  33. package/dist/cjs/schemas/openapi.d.cts +2994 -0
  34. package/dist/cjs/schemas/openapi.js.map +1 -0
  35. package/dist/cjs/test/agent.cjs +485 -0
  36. package/dist/cjs/test/agent.d.cts +2 -0
  37. package/dist/cjs/test/agent.js.map +1 -0
  38. package/dist/cjs/test/mocks.cjs +153 -0
  39. package/dist/cjs/test/mocks.d.cts +25 -0
  40. package/dist/cjs/test/mocks.js.map +1 -0
  41. package/dist/cjs/tsconfig.3903caa3.tsbuildinfo +1 -0
  42. package/dist/cjs/tsconfig.a5854dc7.tsbuildinfo +1 -0
  43. package/dist/clients/client.d.ts +1 -4
  44. package/dist/clients/client.js +12 -1
  45. package/dist/clients/client.js.map +1 -0
  46. package/dist/clients/entitlement.d.ts +26 -0
  47. package/dist/clients/entitlement.js +23 -0
  48. package/dist/clients/entitlement.js.map +1 -0
  49. package/dist/clients/event.d.ts +5 -5
  50. package/dist/clients/event.js +29 -18
  51. package/dist/clients/event.js.map +1 -0
  52. package/dist/clients/feature.d.ts +46 -0
  53. package/dist/clients/feature.js +76 -0
  54. package/dist/clients/feature.js.map +1 -0
  55. package/dist/clients/grant.d.ts +24 -0
  56. package/dist/clients/grant.js +37 -0
  57. package/dist/clients/grant.js.map +1 -0
  58. package/dist/clients/meter.d.ts +13 -30
  59. package/dist/clients/meter.js +15 -0
  60. package/dist/clients/meter.js.map +1 -0
  61. package/dist/clients/pagination.d.ts +6 -0
  62. package/dist/clients/pagination.js +2 -0
  63. package/dist/clients/pagination.js.map +1 -0
  64. package/dist/clients/portal.d.ts +22 -0
  65. package/dist/clients/portal.js +37 -0
  66. package/dist/clients/portal.js.map +1 -0
  67. package/dist/clients/subject.d.ts +125 -0
  68. package/dist/clients/subject.js +238 -0
  69. package/dist/clients/subject.js.map +1 -0
  70. package/dist/index.d.ts +11 -2
  71. package/dist/index.js +16 -1
  72. package/dist/index.js.map +1 -0
  73. package/dist/schemas/openapi.d.ts +2754 -166
  74. package/dist/schemas/openapi.js +1 -0
  75. package/dist/schemas/openapi.js.map +1 -0
  76. package/dist/test/agent.js +327 -29
  77. package/dist/test/agent.js.map +1 -0
  78. package/dist/test/mocks.d.ts +13 -0
  79. package/dist/test/mocks.js +118 -0
  80. package/dist/test/mocks.js.map +1 -0
  81. package/dist/tsconfig.tsbuildinfo +1 -1
  82. package/package.json +40 -30
  83. package/dist/next.d.ts +0 -15
  84. package/dist/next.js +0 -46
  85. package/index.ts +0 -19
  86. package/next.ts +0 -76
@@ -0,0 +1,2994 @@
1
+ /**
2
+ * This file was auto-generated by openapi-typescript.
3
+ * Do not make direct changes to the file.
4
+ */
5
+ /** OneOf type helpers */
6
+ type Without<T, U> = {
7
+ [P in Exclude<keyof T, keyof U>]?: never;
8
+ };
9
+ type XOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
10
+ type OneOf<T extends any[]> = T extends [infer Only] ? Only : T extends [infer A, infer B, ...infer Rest] ? OneOf<[XOR<A, B>, ...Rest]> : never;
11
+ export interface paths {
12
+ '/api/v1/events': {
13
+ /**
14
+ * List ingested events
15
+ * @description List ingested events within a time range.
16
+ */
17
+ get: operations['listEvents'];
18
+ /**
19
+ * Ingest events
20
+ * @description Ingests an event or batch of events following the CloudEvents specification.
21
+ */
22
+ post: operations['ingestEvents'];
23
+ };
24
+ '/api/v1/meters': {
25
+ /**
26
+ * List meters
27
+ * @description List meters.
28
+ */
29
+ get: operations['listMeters'];
30
+ /**
31
+ * ☁ Create meter
32
+ * @description *Available in OpenMeter Cloud.*
33
+ * *In the open-source version, meters are created in the configuration file.*
34
+ *
35
+ * Create a meter.
36
+ */
37
+ post: operations['createMeter'];
38
+ };
39
+ '/api/v1/meters/{meterIdOrSlug}': {
40
+ /**
41
+ * Get meter
42
+ * @description Get meter by ID or slug
43
+ */
44
+ get: operations['getMeter'];
45
+ /**
46
+ * ☁ Delete meter
47
+ * @description *Available in OpenMeter Cloud.*
48
+ *
49
+ * Delete a meter by ID or slug.
50
+ */
51
+ delete: operations['deleteMeter'];
52
+ };
53
+ '/api/v1/meters/{meterIdOrSlug}/query': {
54
+ /**
55
+ * Query meter
56
+ * @description Query meter for usage.
57
+ */
58
+ get: operations['queryMeter'];
59
+ };
60
+ '/api/v1/meters/{meterIdOrSlug}/subjects': {
61
+ /**
62
+ * List meter subjects
63
+ * @description List subjects for a meter.
64
+ */
65
+ get: operations['listMeterSubjects'];
66
+ };
67
+ '/api/v1/portal/tokens': {
68
+ /**
69
+ * ☁ List portal tokens
70
+ * @description *Available in OpenMeter Cloud.*
71
+ *
72
+ * List consumer portal tokens.
73
+ */
74
+ get: operations['listPortalTokens'];
75
+ /**
76
+ * Create portal token
77
+ * @description Create a consumer portal token.
78
+ */
79
+ post: operations['createPortalToken'];
80
+ };
81
+ '/api/v1/portal/tokens/invalidate': {
82
+ /**
83
+ * ☁ Invalidate portal tokens
84
+ * @description *Available in OpenMeter Cloud.*
85
+ *
86
+ * Invalidates consumer portal tokens by ID or subject.
87
+ */
88
+ post: operations['invalidatePortalTokens'];
89
+ };
90
+ '/api/v1/subjects': {
91
+ /**
92
+ * ☁ List subjects
93
+ * @description *Available in OpenMeter Cloud.*
94
+ *
95
+ * List subjects.
96
+ */
97
+ get: operations['listSubjects'];
98
+ /**
99
+ * ☁ Upsert subject
100
+ * @description *Available in OpenMeter Cloud.*
101
+ *
102
+ * Upserts a subject. Creates or updates subject.
103
+ * If the subject doesn't exist, it will be created.
104
+ * If the subject exists, it will be partially updated with the provided fields.
105
+ */
106
+ post: operations['upsertSubject'];
107
+ };
108
+ '/api/v1/subjects/{subjectIdOrKey}': {
109
+ /**
110
+ * ☁ Get subject
111
+ * @description *Available in OpenMeter Cloud.*
112
+ *
113
+ * Get subject by ID or key.
114
+ */
115
+ get: operations['getSubject'];
116
+ /**
117
+ * ☁ Delete subject
118
+ * @description *Available in OpenMeter Cloud.*
119
+ *
120
+ * Delete a subject by ID or key.
121
+ */
122
+ delete: operations['deleteSubject'];
123
+ };
124
+ '/api/v1/portal/meters/{meterSlug}/query': {
125
+ /**
126
+ * Query portal meter
127
+ * @description Query meter for consumer portal. This endpoint is publicly exposable to consumers.
128
+ */
129
+ get: operations['queryPortalMeter'];
130
+ };
131
+ '/api/v1/entitlements': {
132
+ /**
133
+ * List entitlements
134
+ * @description List all entitlements regardless of subject. This endpoint is intended for administrative purposes.
135
+ * If page is provided that takes precedence and the paginated response is returned.
136
+ */
137
+ get: operations['listEntitlements'];
138
+ };
139
+ '/api/v1/features': {
140
+ /**
141
+ * List features
142
+ * @description List all features. If page is provided that takes precedence and the paginated response is returned.
143
+ */
144
+ get: operations['listFeatures'];
145
+ /**
146
+ * Create a feature
147
+ * @description Features are either metered or static. A feature is metered if meterSlug is provided at creation.
148
+ * For metered features you can pass additional filters that will be applied when calculating feature usage, based on the meter's groupBy fields. Only meters with SUM and COUNT aggregation are supported for features.
149
+ *
150
+ * Features cannot be updated later, only archived.
151
+ */
152
+ post: operations['createFeature'];
153
+ };
154
+ '/api/v1/features/{featureId}': {
155
+ /**
156
+ * Get feature
157
+ * @description Get a feature by id.
158
+ */
159
+ get: operations['getFeature'];
160
+ /**
161
+ * Archive a feature
162
+ * @description Once a feature is archived it cannot be unarchived. If a feature is archived, new entitlements cannot be created for it, but archiving the feature does not affect existing entitlements. This means, if you want to create a new feature with the same key, and then create entitlements for it, the previous entitlements have to be deleted first on a per subject basis.
163
+ */
164
+ delete: operations['deleteFeature'];
165
+ };
166
+ '/api/v1/grants': {
167
+ /**
168
+ * List grants
169
+ * @description List all grants for all the subjects and entitlements. This endpoint is intended for administrative purposes only. To fetch the grants of a specific entitlement please use the /api/v1/subjects/{subjectKeyOrID}/entitlements/{entitlementOrFeatureID}/grants endpoint.
170
+ *
171
+ * If page is provided that takes precedence and the paginated response is returned.
172
+ */
173
+ get: operations['listGrants'];
174
+ };
175
+ '/api/v1/grants/{grantId}': {
176
+ /**
177
+ * Void a grant
178
+ * @description Voiding a grant means it is no longer valid, it doesn't take part in further balance calculations. Voiding a grant does not retroactively take effect, meaning any usage that has already been attributed to the grant will remain, but future usage cannot be burnt down from the grant.
179
+ *
180
+ * For example, if you have a single grant for your metered entitlement with an initial amount of 100, and so far 60 usage has been metered, the grant (and the entitlement itself) would have a balance of 40. If you then void that grant, balance becomes 0, but the 60 previous usage will not be affected.
181
+ */
182
+ delete: operations['voidGrant'];
183
+ };
184
+ '/api/v1/subjects/{subjectIdOrKey}/entitlements': {
185
+ /**
186
+ * List entitlements of a subject
187
+ * @description List all entitlements for a subject. For checking entitlement access, use the /value endpoint instead.
188
+ */
189
+ get: operations['listSubjectEntitlements'];
190
+ /**
191
+ * Create an entitlement
192
+ * @description OpenMeter has three types of entitlements: metered, boolean, and static. The type property determines the type of entitlement. The underlying feature has to be compatible with the entitlement type specified in the request (e.g., a metered entitlement needs a feature associated with a meter).
193
+ *
194
+ * - Boolean entitlements define static feature access, e.g. "Can use SSO authentication".
195
+ * - Static entitlements let you pass along a configuration while granting access, e.g. "Using this feature with X Y settings" (passed in the config).
196
+ * - Metered entitlements have many use cases, from setting up usage-based access to implementing complex credit systems. Example: The customer can use 10000 AI tokens during the usage period of the entitlement.
197
+ *
198
+ * A given subject can only have one active (non-deleted) entitlement per featureKey. If you try to create a new entitlement for a featureKey that already has an active entitlement, the request will fail with a 409 error.
199
+ *
200
+ * Once an entitlement is created you cannot modify it, only delete it.
201
+ */
202
+ post: operations['createEntitlement'];
203
+ };
204
+ '/api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementId}': {
205
+ /**
206
+ * Get an entitlement
207
+ * @description Get entitlement by id. For checking entitlement access, use the /value endpoint instead.
208
+ */
209
+ get: operations['getEntitlement'];
210
+ /**
211
+ * Delete an entitlement
212
+ * @description Deleting an entitlement revokes access to the associated feature. As a single subject can only have one entitlement per featureKey, when "migrating" features you have to delete the old entitlements as well.
213
+ * As access and status checks can be historical queries, deleting an entitlement populates the deletedAt timestamp. When queried for a time before that, the entitlement is still considered active, you cannot have retroactive changes to access, which is important for, among other things, auditing.
214
+ */
215
+ delete: operations['deleteEntitlement'];
216
+ };
217
+ '/api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/grants': {
218
+ /**
219
+ * List grants for an entitlement
220
+ * @description List all grants issued for an entitlement. The entitlement can be defined either by its id or featureKey.
221
+ */
222
+ get: operations['listEntitlementGrants'];
223
+ /**
224
+ * Create a grant
225
+ * @description Grants define a behavior of granting usage for a metered entitlement. They can have complicated recurrence and rollover rules, thanks to which you can define a wide range of access patterns with a single grant, in most cases you don't have to periodically create new grants. You can only issue grants for active metered entitlements.
226
+ *
227
+ * A grant defines a given amount of usage that can be consumed for the entitlement. The grant is in effect between its effective date and its expiration date. Specifying both is mandatory for new grants.
228
+ *
229
+ * Grants have a priority setting that determines their order of use. Lower numbers have higher priority, with 0 being the highest priority.
230
+ *
231
+ * Grants can have a recurrence setting intended to automate the manual reissuing of grants. For example, a daily recurrence is equal to reissuing that same grant every day (ignoring rollover settings).
232
+ *
233
+ * Rollover settings define what happens to the remaining balance of a grant at a reset. Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset, MinRolloverAmount))
234
+ *
235
+ * Grants cannot be changed once created, only deleted. This is to ensure that balance is deterministic regardless of when it is queried.
236
+ */
237
+ post: operations['createGrant'];
238
+ };
239
+ '/api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/value': {
240
+ /**
241
+ * Get the current value and access of an entitlement
242
+ * @description This endpoint should be used for access checks and enforcement. All entitlement types share the hasAccess property in their value response, but multiple other properties are returned based on the entitlement type.
243
+ *
244
+ * For convenience reasons, /value works with both entitlementId and featureKey.
245
+ */
246
+ get: operations['getEntitlementValue'];
247
+ };
248
+ '/api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementId}/history': {
249
+ /**
250
+ * Get the balance history of a specific entitlement.
251
+ * @description Returns historical balance and usage data for the entitlement. The queried history can span accross multiple reset events.
252
+ *
253
+ * BurndownHistory returns a continous history of segments, where the segments are seperated by events that changed either the grant burndown priority or the usage period.
254
+ *
255
+ * WindowedHistory returns windowed usage data for the period enriched with balance information and the list of grants that were being burnt down in that window.
256
+ */
257
+ get: operations['getEntitlementHistory'];
258
+ };
259
+ '/api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementId}/reset': {
260
+ /**
261
+ * Reset an entitlement
262
+ * @description Reset marks the start of a new usage period for the entitlement and initiates grant rollover. At the start of a period usage is zerod out and grants are rolled over based on their rollover settings. It would typically be synced with the subjects billing period to enforce usage based on their subscription.
263
+ *
264
+ * Usage is automatically reset for metered entitlements based on their usage period, but this endpoint allows to manually reset it at any time. When doing so the period anchor of the entitlement can be changed if needed.
265
+ */
266
+ post: operations['resetEntitlementUsage'];
267
+ };
268
+ '/api/v1/debug/metrics': {
269
+ /**
270
+ * Get event metrics
271
+ * @description Returns debug metrics like the number of ingested events since mindnight UTC.
272
+ * The OpenMetrics Counter(s) reset every day at midnight UTC.
273
+ */
274
+ get: operations['getDebugMetrics'];
275
+ };
276
+ '/api/v1/notification/channels': {
277
+ /**
278
+ * List notification channels
279
+ * @description List all notification channels.
280
+ */
281
+ get: operations['listNotificationChannels'];
282
+ /**
283
+ * Create a notification channel
284
+ * @description Create a new notification channel.
285
+ */
286
+ post: operations['createNotificationChannel'];
287
+ };
288
+ '/api/v1/notification/channels/{channelId}': {
289
+ /**
290
+ * Get notification channel
291
+ * @description Get a notification channel by id.
292
+ */
293
+ get: operations['getNotificationChannel'];
294
+ /**
295
+ * Update notification channel
296
+ * @description Update a notification channel by id.
297
+ */
298
+ put: operations['updateNotificationChannel'];
299
+ /**
300
+ * Delete a notification channel
301
+ * @description Delete notification channel by id.
302
+ */
303
+ delete: operations['deleteNotificationChannel'];
304
+ };
305
+ '/api/v1/notification/rules': {
306
+ /**
307
+ * List notification rules
308
+ * @description List all notification rules.
309
+ */
310
+ get: operations['listNotificationRules'];
311
+ /**
312
+ * Create a notification rule
313
+ * @description Create a new notification rule.
314
+ */
315
+ post: operations['createNotificationRule'];
316
+ };
317
+ '/api/v1/notification/rules/{ruleId}': {
318
+ /**
319
+ * Get notification rule
320
+ * @description Get a notification rule by id.
321
+ */
322
+ get: operations['getNotificationRule'];
323
+ /**
324
+ * Update a notification rule
325
+ * @description Update a notification rule by id.
326
+ */
327
+ put: operations['updateNotificationRule'];
328
+ /**
329
+ * Delete a notification rule
330
+ * @description Delete notification rule by id.
331
+ */
332
+ delete: operations['deleteNotificationRule'];
333
+ };
334
+ '/api/v1/notification/events': {
335
+ /**
336
+ * List notification evens
337
+ * @description List all notification events.
338
+ */
339
+ get: operations['listNotificationEvents'];
340
+ };
341
+ '/api/v1/notification/events/{eventId}': {
342
+ /**
343
+ * Get notification event
344
+ * @description Get a notification event by id.
345
+ */
346
+ get: operations['getNotificationEvent'];
347
+ };
348
+ }
349
+ export type webhooks = Record<string, never>;
350
+ export interface components {
351
+ schemas: {
352
+ /**
353
+ * @description Metadata fields for all resources.
354
+ * These fields are automatically populated by the system for managed entities. Their use and meaning is uniform across all resources.
355
+ */
356
+ SharedMetaFields: {
357
+ /**
358
+ * @description Readonly unique ULID identifier.
359
+ *
360
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
361
+ */
362
+ id: string;
363
+ /**
364
+ * Format: date-time
365
+ * @description The date and time the resource was created.
366
+ * @example 2023-01-01T00:00:00Z
367
+ */
368
+ createdAt: string;
369
+ /**
370
+ * Format: date-time
371
+ * @description The date and time the resource was last updated. The initial value is the same as createdAt.
372
+ * @example 2023-01-01T00:00:00Z
373
+ */
374
+ updatedAt: string;
375
+ /**
376
+ * Format: date-time
377
+ * @description The date and time the resource was deleted.
378
+ * @example 2023-01-01T00:00:00Z
379
+ */
380
+ deletedAt?: string;
381
+ };
382
+ /**
383
+ * @description Conflict
384
+ * @example {
385
+ * "type": "about:blank",
386
+ * "title": "Conflict",
387
+ * "status": 409,
388
+ * "detail": "ledger (default.01HXVNDJR532E8GTBVSC2XK5D4) already exitst for subject subject-1",
389
+ * "instance": "urn:request:local/JMOlctsKV8-000001",
390
+ * "conflictingEntityId": "01HXVNDJR532E8GTBVSC2XK5D4"
391
+ * }
392
+ */
393
+ ConflictProblem: {
394
+ /**
395
+ * Format: uri
396
+ * @description Type contains a URI that identifies the problem type.
397
+ * @example urn:problem-type:bad-request
398
+ */
399
+ type: string;
400
+ /**
401
+ * @description A a short, human-readable summary of the problem type.
402
+ * @example Bad Request
403
+ */
404
+ title: string;
405
+ /**
406
+ * Format: int32
407
+ * @description The HTTP status code generated by the origin server for this occurrence of the problem.
408
+ * @example 400
409
+ */
410
+ status: number;
411
+ /**
412
+ * @description A human-readable explanation specific to this occurrence of the problem.
413
+ * @example body must be a JSON object
414
+ */
415
+ detail: string;
416
+ /**
417
+ * Format: uri
418
+ * @description A URI reference that identifies the specific occurrence of the problem.
419
+ * @example urn:request:local/JMOlctsKV8-000001
420
+ */
421
+ instance?: string;
422
+ extensions?: {
423
+ /**
424
+ * @description The id of the conflicting entity.
425
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
426
+ */
427
+ conflictingEntityId: string;
428
+ };
429
+ [key: string]: unknown;
430
+ };
431
+ /**
432
+ * @description A Problem Details object (RFC 7807).
433
+ * Additional properties specific to the problem type may be present.
434
+ * @example {
435
+ * "type": "urn:problem-type:bad-request",
436
+ * "title": "Bad Request",
437
+ * "status": 400,
438
+ * "detail": "body must be a JSON object"
439
+ * }
440
+ */
441
+ Problem: {
442
+ /**
443
+ * Format: uri
444
+ * @description Type contains a URI that identifies the problem type.
445
+ * @example urn:problem-type:bad-request
446
+ */
447
+ type: string;
448
+ /**
449
+ * @description A a short, human-readable summary of the problem type.
450
+ * @example Bad Request
451
+ */
452
+ title: string;
453
+ /**
454
+ * Format: int32
455
+ * @description The HTTP status code generated by the origin server for this occurrence of the problem.
456
+ * @example 400
457
+ */
458
+ status: number;
459
+ /**
460
+ * @description A human-readable explanation specific to this occurrence of the problem.
461
+ * @example body must be a JSON object
462
+ */
463
+ detail: string;
464
+ /**
465
+ * Format: uri
466
+ * @description A URI reference that identifies the specific occurrence of the problem.
467
+ * @example urn:request:local/JMOlctsKV8-000001
468
+ */
469
+ instance?: string;
470
+ [key: string]: unknown;
471
+ };
472
+ /**
473
+ * @description CloudEvents Specification JSON Schema
474
+ * @example {
475
+ * "id": "5c10fade-1c9e-4d6c-8275-c52c36731d3c",
476
+ * "source": "service-name",
477
+ * "specversion": "1.0",
478
+ * "type": "prompt",
479
+ * "subject": "customer-id",
480
+ * "time": "2023-01-01T01:01:01.001Z",
481
+ * "data": {
482
+ * "tokens": "1234",
483
+ * "model": "gpt-4-turbo",
484
+ * "type": "input"
485
+ * }
486
+ * }
487
+ */
488
+ Event: {
489
+ /**
490
+ * @description Identifies the event.
491
+ * @example 5c10fade-1c9e-4d6c-8275-c52c36731d3c
492
+ */
493
+ id: string;
494
+ /**
495
+ * Format: uri-reference
496
+ * @description Identifies the context in which an event happened.
497
+ * @example service-name
498
+ */
499
+ source: string;
500
+ /**
501
+ * @description The version of the CloudEvents specification which the event uses.
502
+ * @example 1.0
503
+ */
504
+ specversion: string;
505
+ /**
506
+ * @description Describes the type of event related to the originating occurrence.
507
+ * @example prompt
508
+ */
509
+ type: string;
510
+ /**
511
+ * @description Content type of the data value. Must adhere to RFC 2046 format.
512
+ * @example application/json
513
+ * @enum {string|null}
514
+ */
515
+ datacontenttype?: 'application/json' | null;
516
+ /**
517
+ * Format: uri
518
+ * @description Identifies the schema that data adheres to.
519
+ */
520
+ dataschema?: string | null;
521
+ /**
522
+ * @description Describes the subject of the event in the context of the event producer (identified by source).
523
+ * @example customer-id
524
+ */
525
+ subject: string;
526
+ /**
527
+ * Format: date-time
528
+ * @description Timestamp of when the occurrence happened. Must adhere to RFC 3339.
529
+ * @example 2023-01-01T01:01:01.001Z
530
+ */
531
+ time?: string | null;
532
+ /**
533
+ * @description The event payload.
534
+ * @example {
535
+ * "tokens": "1234",
536
+ * "model": "gpt-4-turbo"
537
+ * }
538
+ */
539
+ data?: {
540
+ [key: string]: unknown;
541
+ };
542
+ };
543
+ /**
544
+ * @description An ingested event with optional validation error.
545
+ * @example {
546
+ * "event": {
547
+ * "id": "5c10fade-1c9e-4d6c-8275-c52c36731d3d",
548
+ * "source": "service-name",
549
+ * "specversion": "1.0",
550
+ * "type": "prompt",
551
+ * "subject": "customer-id",
552
+ * "time": "2023-01-01T01:01:01.001Z",
553
+ * "data": {
554
+ * "tokens": "1234",
555
+ * "model": "gpt-4-turbo"
556
+ * }
557
+ * },
558
+ * "validationError": "meter not found for event"
559
+ * }
560
+ */
561
+ IngestedEvent: {
562
+ event: components['schemas']['Event'];
563
+ /** @example invalid event */
564
+ validationError?: string;
565
+ };
566
+ /**
567
+ * @description A feature is a feature or service offered to a customer.
568
+ * For example: CPU-Hours, Tokens, API Calls, etc.
569
+ */
570
+ FeatureCreateInputs: {
571
+ /**
572
+ * @description The key is an immutable unique identifier of the feature used throughout the API, for example when interacting with a subject's entitlements. The key has to be unique across all active features, but archived features can share the same key. The key should consist of lowercase alphanumeric characters and dashes.
573
+ *
574
+ * @example gpt4_tokens
575
+ */
576
+ key: string;
577
+ /**
578
+ * @description The name of the feature.
579
+ *
580
+ * @example AI Tokens
581
+ */
582
+ name: string;
583
+ /** @description Additional metadata for the feature, useful for syncing with external systems and annotating custom fields. */
584
+ metadata?: {
585
+ [key: string]: string;
586
+ };
587
+ /**
588
+ * @description The meter that the feature is associated with and and based on which usage is calculated.
589
+ * The meter selected must have SUM or COUNT aggregation.
590
+ *
591
+ * @example tokens_total
592
+ */
593
+ meterSlug?: string;
594
+ /**
595
+ * @description 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.
596
+ *
597
+ * @example {
598
+ * "model": "gpt-4"
599
+ * }
600
+ */
601
+ meterGroupByFilters?: {
602
+ [key: string]: string;
603
+ };
604
+ };
605
+ /**
606
+ * @description A feature is a feature or service offered to a customer.
607
+ * For example: CPU-Hours, Tokens, API Calls, etc.
608
+ */
609
+ Feature: {
610
+ /**
611
+ * Format: date-time
612
+ * @description If the feature is archived, no new entitlements can be created for it.
613
+ *
614
+ * @example 2023-01-01T00:00:00Z
615
+ */
616
+ archivedAt?: string;
617
+ } & components['schemas']['FeatureCreateInputs'] & components['schemas']['SharedMetaFields'];
618
+ ListFeatureResponse: OneOf<[
619
+ components['schemas']['Feature'][],
620
+ {
621
+ /**
622
+ * @description Total number of features.
623
+ * @example 500
624
+ */
625
+ totalCount: number;
626
+ /**
627
+ * @description Current page number.
628
+ * @example 1
629
+ */
630
+ page: number;
631
+ /**
632
+ * @description Number of features per page.
633
+ * @example 100
634
+ */
635
+ pageSize: number;
636
+ /** @description List of features. */
637
+ items: components['schemas']['Feature'][];
638
+ }
639
+ ]>;
640
+ /** @description Limited representation of a feature resource which includes only its unique identifiers (id, key). */
641
+ FeatureMeta: {
642
+ /**
643
+ * @description A unique identifier for the notification rule.
644
+ * @example 01J2KNP1YTXQRXHTDJ4KPR7PZ0
645
+ */
646
+ id: string;
647
+ /**
648
+ * @description The key is an immutable unique identifier of the feature used throughout the API,
649
+ * for example when interacting with a subject's entitlements.
650
+ *
651
+ * @example gpt4_tokens
652
+ */
653
+ key: string;
654
+ };
655
+ EntitlementCreateSharedFields: {
656
+ /**
657
+ * @description The feature the subject is entitled to use.
658
+ * Either featureKey or featureId is required.
659
+ *
660
+ * @example example-feature-key
661
+ */
662
+ featureKey?: string;
663
+ /**
664
+ * @description The feature the subject is entitled to use.
665
+ * Either featureKey or featureId is required.
666
+ *
667
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
668
+ */
669
+ featureId?: string;
670
+ /** @description Additional metadata for the feature. */
671
+ metadata?: {
672
+ [key: string]: string;
673
+ };
674
+ usagePeriod?: components['schemas']['RecurringPeriodCreateInput'];
675
+ };
676
+ EntitlementSharedFields: components['schemas']['SharedMetaFields'] & components['schemas']['EntitlementCreateSharedFields'] & {
677
+ /**
678
+ * @description The feature the subject is entitled to use.
679
+ * Either featureKey or featureId is required.
680
+ *
681
+ * @example example-feature-key
682
+ */
683
+ featureKey: string;
684
+ /**
685
+ * @description The feature the subject is entitled to use.
686
+ * Either featureKey or featureId is required.
687
+ *
688
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
689
+ */
690
+ featureId: string;
691
+ /**
692
+ * @description The identifier key unique to the subject
693
+ * @example customer-1
694
+ */
695
+ subjectKey: string;
696
+ usagePeriod?: components['schemas']['RecurringPeriod'];
697
+ currentUsagePeriod?: components['schemas']['Period'];
698
+ };
699
+ /** @enum {string} */
700
+ MeasureUsageFromEnum: 'CURRENT_PERIOD_START' | 'NOW';
701
+ /** Format: date-time */
702
+ MeasureUsageFromTime: string;
703
+ /**
704
+ * @description The time from which usage is measured, defaults to the entitlement creation time.
705
+ * The provided value is truncated to the granularity of the underlying meter.
706
+ */
707
+ MeasureUsageFrom: components['schemas']['MeasureUsageFromEnum'] | components['schemas']['MeasureUsageFromTime'];
708
+ EntitlementMeteredCreateInputs: components['schemas']['EntitlementCreateSharedFields'] & {
709
+ /**
710
+ * @example metered
711
+ * @enum {string}
712
+ */
713
+ type: 'metered';
714
+ /**
715
+ * @description If softLimit=true the subject can use the feature even if the entitlement is exhausted, hasAccess will always be true.
716
+ *
717
+ * @default false
718
+ */
719
+ isSoftLimit?: boolean;
720
+ /**
721
+ * @description Deprecated, ignored by the backend. Please use isSoftLimit instead; this field will be removed in the future.
722
+ *
723
+ * @default false
724
+ */
725
+ isUnlimited?: boolean;
726
+ usagePeriod: components['schemas']['RecurringPeriodCreateInput'];
727
+ measureUsageFrom?: components['schemas']['MeasureUsageFrom'];
728
+ /**
729
+ * Format: double
730
+ * @description 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.
731
+ * 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.
732
+ *
733
+ * Manually creating such a grant would mean having the "amount", "minRolloverAmount", and "maxRolloverAmount" fields all be the same.
734
+ */
735
+ issueAfterReset?: number;
736
+ /**
737
+ * @description Defines the grant priority for the default grant. If provided, issueAfterReset must have a value.
738
+ *
739
+ * @default 1
740
+ * @example 1
741
+ */
742
+ issueAfterResetPriority?: number;
743
+ };
744
+ EntitlementCreateInputs: components['schemas']['EntitlementMeteredCreateInputs'] | components['schemas']['EntitlementStaticCreateInputs'] | components['schemas']['EntitlementBooleanCreateInputs'];
745
+ /** @description 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). */
746
+ EntitlementMetered: components['schemas']['EntitlementMeteredCreateInputs'] & components['schemas']['EntitlementMeteredCalculatedFields'] & components['schemas']['EntitlementSharedFields'];
747
+ /** @description Calculated fields for a metered entitlement. */
748
+ EntitlementMeteredCalculatedFields: {
749
+ /**
750
+ * Format: date-time
751
+ * @description The last time a reset happened.
752
+ *
753
+ * @example 2023-01-01T00:00:00Z
754
+ */
755
+ lastReset: string;
756
+ currentUsagePeriod: components['schemas']['Period'];
757
+ /**
758
+ * Format: date-time
759
+ * @description The time from which usage is measured. If not specified on creation, defaults to the entitlement creation time.
760
+ */
761
+ measureUsageFrom: string;
762
+ };
763
+ EntitlementStaticCreateInputs: components['schemas']['EntitlementCreateSharedFields'] & {
764
+ /**
765
+ * @example static
766
+ * @enum {string}
767
+ */
768
+ type: 'static';
769
+ /**
770
+ * @description The JSON parsable config of the entitlement. This value is also returned when checking entitlement access and it is useful for configuring fine-grained access settings to the feature, implemented in your own system. Has to be an object.
771
+ *
772
+ * @example {"key1": "value1"}
773
+ */
774
+ config: string;
775
+ };
776
+ /** @description Entitles a subject to use a feature. */
777
+ EntitlementStatic: components['schemas']['EntitlementStaticCreateInputs'] & components['schemas']['EntitlementSharedFields'];
778
+ EntitlementBooleanCreateInputs: components['schemas']['EntitlementCreateSharedFields'] & {
779
+ /**
780
+ * @example boolean
781
+ * @enum {string}
782
+ */
783
+ type: 'boolean';
784
+ };
785
+ /** @description Entitles a subject to use a feature. */
786
+ EntitlementBoolean: components['schemas']['EntitlementBooleanCreateInputs'] & components['schemas']['EntitlementSharedFields'];
787
+ Entitlement: components['schemas']['EntitlementMetered'] | components['schemas']['EntitlementStatic'] | components['schemas']['EntitlementBoolean'];
788
+ ListEntitlementResponse: OneOf<[
789
+ components['schemas']['Entitlement'][],
790
+ {
791
+ /**
792
+ * @description Total number of entitlements.
793
+ * @example 500
794
+ */
795
+ totalCount: number;
796
+ /**
797
+ * @description Current page number.
798
+ * @example 1
799
+ */
800
+ page: number;
801
+ /**
802
+ * @description Number of entitlements per page.
803
+ * @example 100
804
+ */
805
+ pageSize: number;
806
+ /** @description List of entitlements. */
807
+ items: components['schemas']['Entitlement'][];
808
+ }
809
+ ]>;
810
+ /**
811
+ * @description A segment of the grant burn down history.
812
+ *
813
+ * A given segment represents the usage of a grant between events that changed either the grant burn down priority order or the usag period.
814
+ */
815
+ GrantBurnDownHistorySegment: {
816
+ period?: components['schemas']['Period'];
817
+ /**
818
+ * Format: double
819
+ * @description The usage of the grant in the period.
820
+ *
821
+ * @example 100
822
+ */
823
+ usage?: number;
824
+ /**
825
+ * Format: double
826
+ * @description Overuse that wasn't covered by grants.
827
+ *
828
+ * @example 25
829
+ */
830
+ overage?: number;
831
+ /**
832
+ * Format: double
833
+ * @description The entitlement balance at the start of the period.
834
+ *
835
+ * @example 100
836
+ */
837
+ balanceAtStart?: number;
838
+ /**
839
+ * @description The balance breakdown of each active grant at the start of the period: GrantID: Balance
840
+ *
841
+ * @example {
842
+ * "01ARZ3NDEKTSV4RRFFQ69G5FAV": 100
843
+ * }
844
+ */
845
+ grantBalancesAtStart?: {
846
+ [key: string]: number;
847
+ };
848
+ /**
849
+ * Format: double
850
+ * @description The entitlement balance at the end of the period.
851
+ *
852
+ * @example 100
853
+ */
854
+ balanceAtEnd?: number;
855
+ /**
856
+ * @description The balance breakdown of each active grant at the start of the period: GrantID: Balance
857
+ *
858
+ * @example {
859
+ * "01ARZ3NDEKTSV4RRFFQ69G5FAV": 100
860
+ * }
861
+ */
862
+ grantBalancesAtEnd?: {
863
+ [key: string]: number;
864
+ };
865
+ /** @description Which grants were actually burnt down in the period and by what amount. */
866
+ grantUsages?: readonly components['schemas']['GrantUsageRecord'][];
867
+ };
868
+ GrantUsageRecord: {
869
+ /**
870
+ * @description The id of the grant.
871
+ *
872
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
873
+ */
874
+ grantId?: string;
875
+ /**
876
+ * Format: double
877
+ * @description The usage of the grant.
878
+ *
879
+ * @example 100
880
+ */
881
+ usage?: number;
882
+ };
883
+ /** @description Windowed usage and balance information. */
884
+ BalanceHistoryWindow: {
885
+ period?: components['schemas']['Period'];
886
+ /**
887
+ * Format: double
888
+ * @description The total usage of the feature in the period.
889
+ *
890
+ * @example 100
891
+ */
892
+ usage?: number;
893
+ /**
894
+ * Format: double
895
+ * @description The entitlement balance at the start of the period.
896
+ *
897
+ * @example 100
898
+ */
899
+ balanceAtStart?: number;
900
+ };
901
+ /** @description The windowed balance history. */
902
+ WindowedBalanceHistory: {
903
+ /**
904
+ * @description The windowed balance history.
905
+ * - It only returns rows for windows where there was usage.
906
+ * - The windows are inclusive at their start and exclusive at their end.
907
+ * - The last window may be smaller than the window size and is inclusive at both ends.
908
+ */
909
+ windowedHistory?: components['schemas']['BalanceHistoryWindow'][];
910
+ /** @description Grant burndown history. */
911
+ burndownHistory?: components['schemas']['GrantBurnDownHistorySegment'][];
912
+ };
913
+ /** @description A time period */
914
+ Period: {
915
+ /**
916
+ * Format: date-time
917
+ * @description Period start time where the amount was applied. If applicable.
918
+ *
919
+ * @example 2023-01-01T00:00:00Z
920
+ */
921
+ from: string;
922
+ /**
923
+ * Format: date-time
924
+ * @description Period end time where the amount was applied. If applicable.
925
+ *
926
+ * @example 2023-01-01T00:00:00Z
927
+ */
928
+ to: string;
929
+ };
930
+ /**
931
+ * @description List of pre-defined periods that can be used for recurring & scheduling.
932
+ *
933
+ * DAY: Every day
934
+ * WEEK: Every week
935
+ * MONTH: Every month
936
+ * YEAR: Every year
937
+ *
938
+ * @enum {string}
939
+ */
940
+ RecurringPeriodEnum: 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';
941
+ /** @description Recurring period of an entitlement. */
942
+ RecurringPeriodCreateInput: {
943
+ interval: components['schemas']['RecurringPeriodEnum'];
944
+ /**
945
+ * Format: date-time
946
+ * @description An arbitrary anchor to base the recurring period on.
947
+ * If not provided then defaults to now truncated to the hour.
948
+ */
949
+ anchor?: string;
950
+ };
951
+ /** @description Recurring period of an entitlement. */
952
+ RecurringPeriod: {
953
+ interval: components['schemas']['RecurringPeriodEnum'];
954
+ /**
955
+ * Format: date-time
956
+ * @description An arbitrary anchor to base the recurring period on.
957
+ */
958
+ anchor: string;
959
+ };
960
+ /** @description Grants are used to increase balance of specific subjects. */
961
+ EntitlementGrantCreateInput: {
962
+ /**
963
+ * Format: double
964
+ * @description The amount to grant. Should be a positive number.
965
+ *
966
+ * @example 100
967
+ */
968
+ amount: number;
969
+ /**
970
+ * @description The priority of the grant. Grants with higher priority are applied first.
971
+ * Priority is a positive decimal numbers. With lower numbers indicating higher importance.
972
+ * For example, a priority of 1 is more urgent than a priority of 2.
973
+ * When there are several grants available for the same subject, the system selects the grant with the highest priority.
974
+ * In cases where grants share the same priority level, the grant closest to its expiration will be used first.
975
+ * In the case of two grants have identical priorities and expiration dates, the system will use the grant that was created first.
976
+ *
977
+ * @default 1
978
+ * @example 1
979
+ */
980
+ priority?: number;
981
+ /**
982
+ * Format: date-time
983
+ * @description Effective date for grants and anchor for recurring grants. Provided value will be ceiled to metering windowSize (minute).
984
+ *
985
+ * @example 2023-01-01T00:00:00Z
986
+ */
987
+ effectiveAt: string;
988
+ expiration: components['schemas']['ExpirationPeriod'];
989
+ /**
990
+ * Format: double
991
+ * @description Grants are rolled over at reset, after which they can have a different balance compared to what they had before the reset.
992
+ *
993
+ * Balance after the reset is calculated as:
994
+ * Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset, MinRolloverAmount))
995
+ *
996
+ * @default 0
997
+ * @example 100
998
+ */
999
+ maxRolloverAmount?: number;
1000
+ /**
1001
+ * Format: double
1002
+ * @description Grants are rolled over at reset, after which they can have a different balance compared to what they had before the reset.
1003
+ *
1004
+ * Balance after the reset is calculated as:
1005
+ * Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset, MinRolloverAmount))
1006
+ *
1007
+ * @default 0
1008
+ * @example 100
1009
+ */
1010
+ minRolloverAmount?: number;
1011
+ /**
1012
+ * @example {
1013
+ * "stripePaymentId": "pi_4OrAkhLvyihio9p51h9iiFnB"
1014
+ * }
1015
+ */
1016
+ metadata?: {
1017
+ [key: string]: string;
1018
+ };
1019
+ recurrence?: components['schemas']['RecurringPeriodCreateInput'];
1020
+ };
1021
+ EntitlementGrant: components['schemas']['EntitlementGrantCreateInput'] & components['schemas']['SharedMetaFields'] & {
1022
+ /**
1023
+ * @description The unique entitlement ULID that the grant is associated with.
1024
+ *
1025
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
1026
+ */
1027
+ entitlementId: string;
1028
+ /**
1029
+ * Format: date-time
1030
+ * @description The next time the grant will recurr.
1031
+ *
1032
+ * @example 2023-01-01T00:00:00Z
1033
+ */
1034
+ nextRecurrence?: string;
1035
+ /**
1036
+ * Format: date-time
1037
+ * @description The expiration date of the grant.
1038
+ *
1039
+ * @example 2023-01-01T00:00:00Z
1040
+ */
1041
+ expiresAt?: string;
1042
+ /**
1043
+ * Format: date-time
1044
+ * @description The date and time the grant was voided (cannot be used after that).
1045
+ */
1046
+ voidedAt?: string;
1047
+ recurrence?: components['schemas']['RecurringPeriod'];
1048
+ };
1049
+ ListEntitlementGrantResponse: OneOf<[
1050
+ components['schemas']['EntitlementGrant'][],
1051
+ {
1052
+ /**
1053
+ * @description Total number of grants.
1054
+ * @example 500
1055
+ */
1056
+ totalCount: number;
1057
+ /**
1058
+ * @description Current page number.
1059
+ * @example 1
1060
+ */
1061
+ page: number;
1062
+ /**
1063
+ * @description Number of grants per page.
1064
+ * @example 100
1065
+ */
1066
+ pageSize: number;
1067
+ /** @description List of grants. */
1068
+ items: components['schemas']['EntitlementGrant'][];
1069
+ }
1070
+ ]>;
1071
+ EntitlementValue: {
1072
+ /**
1073
+ * @description Whether the subject has access to the feature. Shared accross all entitlement types.
1074
+ *
1075
+ * @example true
1076
+ */
1077
+ hasAccess: boolean;
1078
+ /**
1079
+ * Format: double
1080
+ * @description 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.
1081
+ *
1082
+ * @example 100
1083
+ */
1084
+ balance?: number;
1085
+ /**
1086
+ * Format: double
1087
+ * @description Only available for metered entitlements. Returns the total feature usage in the current period.
1088
+ *
1089
+ * @example 50
1090
+ */
1091
+ usage?: number;
1092
+ /**
1093
+ * Format: double
1094
+ * @description 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.
1095
+ *
1096
+ * @example 0
1097
+ */
1098
+ overage?: number;
1099
+ /**
1100
+ * @description Only available for static entitlements. The JSON parsable config of the entitlement.
1101
+ *
1102
+ * @example {"key1": "value1"}
1103
+ */
1104
+ config?: string;
1105
+ };
1106
+ /** @description Expiration period of a grant. */
1107
+ ExpirationPeriod: {
1108
+ /**
1109
+ * @description The expiration period duration like month.
1110
+ *
1111
+ * @enum {string}
1112
+ */
1113
+ duration: 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';
1114
+ /**
1115
+ * @description The expiration period count like 12 months.
1116
+ *
1117
+ * @example 12
1118
+ */
1119
+ count: number;
1120
+ };
1121
+ /**
1122
+ * @description A meter is a configuration that defines how to match and aggregate events.
1123
+ * @example {
1124
+ * "slug": "tokens_total",
1125
+ * "description": "AI token usage",
1126
+ * "aggregation": "SUM",
1127
+ * "windowSize": "MINUTE",
1128
+ * "eventType": "prompt",
1129
+ * "valueProperty": "$.tokens",
1130
+ * "groupBy": {
1131
+ * "model": "$.model",
1132
+ * "type": "$.type"
1133
+ * }
1134
+ * }
1135
+ */
1136
+ Meter: {
1137
+ /**
1138
+ * @description A unique identifier for the meter.
1139
+ * @example 01G65Z755AFWAKHE12NY0CQ9FH
1140
+ */
1141
+ id?: string;
1142
+ /**
1143
+ * @description A unique, human-readable identifier for the meter. Must consist only alphanumeric and underscore characters.
1144
+ * @example tokens_total
1145
+ */
1146
+ slug: string;
1147
+ /**
1148
+ * @description A description of the meter.
1149
+ * @example AI Token Usage
1150
+ */
1151
+ description?: string | null;
1152
+ aggregation: components['schemas']['MeterAggregation'];
1153
+ windowSize: components['schemas']['WindowSize'];
1154
+ /**
1155
+ * @description The event type to aggregate.
1156
+ * @example prompt
1157
+ */
1158
+ eventType: string;
1159
+ /**
1160
+ * @description JSONPath expression to extract the value from the ingested event's data property.
1161
+ * The ingested value for SUM, AVG, MIN, and MAX aggregations is a number or a string that can be parsed to a number.
1162
+ * For UNIQUE_COUNT aggregation, the ingested value must be a string. For COUNT aggregation the valueProperty is ignored.
1163
+ *
1164
+ * @example $.tokens
1165
+ */
1166
+ valueProperty?: string;
1167
+ /**
1168
+ * @description Named JSONPath expressions to extract the group by values from the event data. Keys must be unique and consist only alphanumeric and underscore characters.
1169
+ * @example {
1170
+ * "model": "$.model",
1171
+ * "type": "$.type"
1172
+ * }
1173
+ */
1174
+ groupBy?: {
1175
+ [key: string]: string;
1176
+ };
1177
+ };
1178
+ /**
1179
+ * @description The aggregation type to use for the meter.
1180
+ * @example SUM
1181
+ * @enum {string}
1182
+ */
1183
+ MeterAggregation: 'SUM' | 'COUNT' | 'UNIQUE_COUNT' | 'AVG' | 'MIN' | 'MAX';
1184
+ /**
1185
+ * @description Aggregation window size.
1186
+ * @example MINUTE
1187
+ * @enum {string}
1188
+ */
1189
+ WindowSize: 'MINUTE' | 'HOUR' | 'DAY';
1190
+ /**
1191
+ * @description The result of a meter query.
1192
+ * @example {
1193
+ * "from": "2023-01-01T00:00:00Z",
1194
+ * "to": "2023-01-02T00:00:00Z",
1195
+ * "windowSize": "MINUTE",
1196
+ * "data": [
1197
+ * {
1198
+ * "value": 12,
1199
+ * "windowStart": "2023-01-01T00:00:00Z",
1200
+ * "windowEnd": "2023-01-02T00:00:00Z",
1201
+ * "subject": "customer-id",
1202
+ * "groupBy": {
1203
+ * "model": "gpt-4-turbo",
1204
+ * "type": "prompt"
1205
+ * }
1206
+ * }
1207
+ * ]
1208
+ * }
1209
+ */
1210
+ MeterQueryResult: {
1211
+ /**
1212
+ * Format: date-time
1213
+ * @example 2023-01-01T00:00:00Z
1214
+ */
1215
+ from?: string;
1216
+ /**
1217
+ * Format: date-time
1218
+ * @example 2023-01-02T00:00:00Z
1219
+ */
1220
+ to?: string;
1221
+ windowSize?: components['schemas']['WindowSize'];
1222
+ /**
1223
+ * @example [
1224
+ * {
1225
+ * "value": 12,
1226
+ * "windowStart": "2023-01-01T00:00:00Z",
1227
+ * "windowEnd": "2023-01-02T00:00:00Z",
1228
+ * "subject": "customer-id",
1229
+ * "groupBy": {
1230
+ * "model": "gpt-4-turbo",
1231
+ * "type": "prompt"
1232
+ * }
1233
+ * }
1234
+ * ]
1235
+ */
1236
+ data: components['schemas']['MeterQueryRow'][];
1237
+ };
1238
+ /**
1239
+ * @description A row in the result of a meter query.
1240
+ * @example {
1241
+ * "value": 12,
1242
+ * "windowStart": "2023-01-01T00:00:00Z",
1243
+ * "windowEnd": "2023-01-02T00:00:00Z",
1244
+ * "subject": "customer-id",
1245
+ * "groupBy": {
1246
+ * "model": "gpt-4-turbo",
1247
+ * "type": "prompt"
1248
+ * }
1249
+ * }
1250
+ */
1251
+ MeterQueryRow: {
1252
+ /** @example 12 */
1253
+ value: number;
1254
+ /**
1255
+ * Format: date-time
1256
+ * @example 2023-01-01T00:00:00Z
1257
+ */
1258
+ windowStart: string;
1259
+ /**
1260
+ * Format: date-time
1261
+ * @example 2023-01-02T00:00:00Z
1262
+ */
1263
+ windowEnd: string;
1264
+ /**
1265
+ * @description The subject of the meter value.
1266
+ * @example customer-id
1267
+ */
1268
+ subject?: string | null;
1269
+ /**
1270
+ * @example {
1271
+ * "model": "gpt-4-turbo",
1272
+ * "type": "prompt"
1273
+ * }
1274
+ */
1275
+ groupBy?: {
1276
+ [key: string]: string;
1277
+ } | null;
1278
+ };
1279
+ /**
1280
+ * @description A consumer portal token.
1281
+ * @example {
1282
+ * "id": "01G65Z755AFWAKHE12NY0CQ9FH",
1283
+ * "subject": "customer-id",
1284
+ * "expiresAt": "2023-01-02T00:00:00Z",
1285
+ * "expired": false,
1286
+ * "createdAt": "2023-01-01T00:00:00Z",
1287
+ * "token": "om_portal_IAnD3PpWW2A2Wr8m9jfzeHlGX8xmCXwG.y5q4S-AWqFu6qjfaFz0zQq4Ez28RsnyVwJffX5qxMvo",
1288
+ * "allowedMeterSlugs": [
1289
+ * "tokens_total"
1290
+ * ]
1291
+ * }
1292
+ */
1293
+ PortalToken: {
1294
+ /** @example 01G65Z755AFWAKHE12NY0CQ9FH */
1295
+ id?: string;
1296
+ /** @example customer-id */
1297
+ subject: string;
1298
+ /**
1299
+ * Format: date-time
1300
+ * @example 2023-01-02T00:00:00Z
1301
+ */
1302
+ expiresAt?: string;
1303
+ expired?: boolean;
1304
+ /**
1305
+ * Format: date-time
1306
+ * @example 2023-01-01T00:00:00Z
1307
+ */
1308
+ createdAt?: string;
1309
+ /**
1310
+ * @description The token is only returned at creation.
1311
+ * @example om_portal_IAnD3PpWW2A2Wr8m9jfzeHlGX8xmCXwG.y5q4S-AWqFu6qjfaFz0zQq4Ez28RsnyVwJffX5qxMvo
1312
+ */
1313
+ token?: string;
1314
+ /**
1315
+ * @description Optional, if defined only the specified meters will be allowed
1316
+ * @example [
1317
+ * "tokens_total"
1318
+ * ]
1319
+ */
1320
+ allowedMeterSlugs?: string[];
1321
+ };
1322
+ /**
1323
+ * @description A subject is a unique identifier for a user or entity.
1324
+ * @example {
1325
+ * "id": "01G65Z755AFWAKHE12NY0CQ9FH",
1326
+ * "key": "customer-id",
1327
+ * "displayName": "Customer Name",
1328
+ * "metadata": {
1329
+ * "hubspotId": "123456"
1330
+ * },
1331
+ * "currentPeriodStart": "2023-01-01T00:00:00Z",
1332
+ * "currentPeriodEnd": "2023-02-01T00:00:00Z",
1333
+ * "stripeCustomerId": "cus_JMOlctsKV8"
1334
+ * }
1335
+ */
1336
+ Subject: {
1337
+ /** @example 01G65Z755AFWAKHE12NY0CQ9FH */
1338
+ id?: string;
1339
+ /** @example customer-id */
1340
+ key: string;
1341
+ /** @example Customer Name */
1342
+ displayName?: string | null;
1343
+ /**
1344
+ * @example {
1345
+ * "hubspotId": "123456"
1346
+ * }
1347
+ */
1348
+ metadata?: {
1349
+ [key: string]: unknown;
1350
+ } | null;
1351
+ /**
1352
+ * Format: date-time
1353
+ * @example 2023-01-01T00:00:00Z
1354
+ */
1355
+ currentPeriodStart?: string | null;
1356
+ /**
1357
+ * Format: date-time
1358
+ * @example 2023-02-01T00:00:00Z
1359
+ */
1360
+ currentPeriodEnd?: string | null;
1361
+ /** @example cus_JMOlctsKV8 */
1362
+ stripeCustomerId?: string | null;
1363
+ };
1364
+ /**
1365
+ * @description A unique identifier.
1366
+ * @example tokens_total
1367
+ */
1368
+ IdOrSlug: string;
1369
+ NotificationChannelCreateRequest: components['schemas']['NotificationChannelWebhookCreateRequest'];
1370
+ NotificationChannel: components['schemas']['NotificationChannelWebhook'];
1371
+ NotificationChannels: components['schemas']['NotificationChannel'][];
1372
+ NotificationChannelWebhookCreateRequest: components['schemas']['NotificationChannelCommonCreateRequest'] & {
1373
+ /**
1374
+ * @description Webhook URL where the notification is sent.
1375
+ * @example https://example.com/webhook
1376
+ */
1377
+ url: string;
1378
+ /**
1379
+ * @description Custom HTTP headers sent as part of the webhook request.
1380
+ * @example {
1381
+ * "X-CUSTOM-HEADER": "value"
1382
+ * }
1383
+ */
1384
+ customHeaders?: {
1385
+ [key: string]: unknown;
1386
+ } | null;
1387
+ /**
1388
+ * @description Signing secret used for webhook request validation on the receiving end. Automatically generated if not provided.
1389
+ *
1390
+ * Format: `base64` encoded random bytes optionally prefixed with `whsec_`. Recommended size: 24
1391
+ *
1392
+ * @example whsec_S6g2HLnTwd9AhHwUIMFggVS9OfoPafN8
1393
+ */
1394
+ signingSecret?: string | null;
1395
+ };
1396
+ /** @description Notification channel with webhook type. */
1397
+ NotificationChannelWebhook: components['schemas']['NotificationChannelCommon'] & {
1398
+ /**
1399
+ * @description Webhook URL where the notification is sent.
1400
+ * @example https://example.com/webhook
1401
+ */
1402
+ url: string;
1403
+ /**
1404
+ * @description Custom HTTP headers sent as part of the webhook request.
1405
+ * @example {
1406
+ * "X-CUSTOM-HEADER": "value"
1407
+ * }
1408
+ */
1409
+ customHeaders?: {
1410
+ [key: string]: unknown;
1411
+ } | null;
1412
+ /**
1413
+ * @description Signing secret used for webhook request validation on the receiving end.
1414
+ *
1415
+ * Format: `base64` encoded random bytes optionally prefixed with `whsec_`. Recommended size: 24
1416
+ *
1417
+ * @example whsec_S6g2HLnTwd9AhHwUIMFggVS9OfoPafN8
1418
+ */
1419
+ signingSecret: string;
1420
+ };
1421
+ /**
1422
+ * @description The type of the notification channel.
1423
+ * @example WEBHOOK
1424
+ * @enum {string}
1425
+ */
1426
+ NotificationChannelType: 'WEBHOOK';
1427
+ /** @description Common fields for create notification channel request. */
1428
+ NotificationChannelCommonCreateRequest: {
1429
+ /**
1430
+ * @description User friendly name of the channel.
1431
+ * @example customer-webhook
1432
+ */
1433
+ name: string;
1434
+ /**
1435
+ * @description Whether the channel is disabled or not.
1436
+ * @default false
1437
+ * @example false
1438
+ */
1439
+ disabled?: boolean;
1440
+ type: components['schemas']['NotificationChannelType'];
1441
+ };
1442
+ /** @description Limited representation of notification channel which includes only the channel identifier and its type. */
1443
+ NotificationChannelMeta: {
1444
+ /**
1445
+ * @description A unique identifier for the notification channel.
1446
+ * @example 01J2KNP1YTXQRXHTDJ4KPR7PZ0
1447
+ */
1448
+ id: string;
1449
+ type: components['schemas']['NotificationChannelType'];
1450
+ };
1451
+ /** @description Common fields for notification channel resources. */
1452
+ NotificationChannelCommon: components['schemas']['NotificationChannelMeta'] & {
1453
+ /**
1454
+ * @description User friendly name of the channel.
1455
+ * @example customer-webhook
1456
+ */
1457
+ name?: string;
1458
+ /**
1459
+ * Format: date-time
1460
+ * @description Timestamp when the channel was created.
1461
+ * @example 2023-01-01T00:00:00Z
1462
+ */
1463
+ createdAt?: string;
1464
+ /**
1465
+ * Format: date-time
1466
+ * @description Timestamp when the channel was modified.
1467
+ * @example 2023-01-02T00:00:00Z
1468
+ */
1469
+ updatedAt?: string;
1470
+ /**
1471
+ * @description Whether the channel is disabled or not.
1472
+ * @default false
1473
+ * @example false
1474
+ */
1475
+ disabled?: boolean;
1476
+ };
1477
+ NotificationRuleCreateRequest: components['schemas']['NotificationRuleBalanceThresholdCreateRequest'];
1478
+ NotificationRule: components['schemas']['NotificationRuleBalanceThreshold'];
1479
+ NotificationRules: components['schemas']['NotificationRule'][];
1480
+ /**
1481
+ * @description Request for creating new notification rule for triggering notification events base on conditions
1482
+ * applied to current balance of entitlements.
1483
+ */
1484
+ NotificationRuleBalanceThresholdCreateRequest: components['schemas']['NotificationRuleCommonCreateRequest'] & {
1485
+ /**
1486
+ * @description List of thresholds the rule suppose to be triggered.
1487
+ * @example [
1488
+ * {
1489
+ * "value": 100,
1490
+ * "type": "PERCENT"
1491
+ * },
1492
+ * {
1493
+ * "value": 10000,
1494
+ * "type": "NUMBER"
1495
+ * }
1496
+ * ]
1497
+ */
1498
+ thresholds: components['schemas']['NotificationRuleBalanceThresholdValue'][];
1499
+ /**
1500
+ * @description Optional field for defining the scope of notification by feature. It may contain features by id or key.
1501
+ *
1502
+ * @example [
1503
+ * "gpt4_tokens",
1504
+ * "01ARZ3NDEKTSV4RRFFQ69G5FAV"
1505
+ * ]
1506
+ */
1507
+ features?: string[] | null;
1508
+ };
1509
+ /** @description Threshold value with multiple supported types. */
1510
+ NotificationRuleBalanceThresholdValue: {
1511
+ /** Format: double */
1512
+ value: number;
1513
+ /** @enum {string} */
1514
+ type: 'NUMBER' | 'PERCENT';
1515
+ };
1516
+ /** @description Notification rule for triggering notification events by applying conditions to current balance of entitlements. */
1517
+ NotificationRuleBalanceThreshold: components['schemas']['NotificationRuleCommon'] & {
1518
+ /**
1519
+ * @description List of thresholds the rule suppose to be triggered.
1520
+ * @example [
1521
+ * {
1522
+ * "value": 100,
1523
+ * "type": "PERCENT"
1524
+ * },
1525
+ * {
1526
+ * "value": 10000,
1527
+ * "type": "NUMBER"
1528
+ * }
1529
+ * ]
1530
+ */
1531
+ thresholds: components['schemas']['NotificationRuleBalanceThresholdValue'][];
1532
+ /** @description Optional field containing list of features the rule applies to. */
1533
+ features?: components['schemas']['FeatureMeta'][] | null;
1534
+ };
1535
+ /**
1536
+ * @description The type of the notification event.
1537
+ * @example entitlements.balance.threshold
1538
+ * @enum {string}
1539
+ */
1540
+ NotificationEventType: 'entitlements.balance.threshold';
1541
+ /** @description Defines the common fields for create notification rule request. */
1542
+ NotificationRuleCommonCreateRequest: {
1543
+ type: components['schemas']['NotificationEventType'];
1544
+ /**
1545
+ * @description The user friendly name of the notification rule.
1546
+ * @example Balance threshold reached
1547
+ */
1548
+ name: string;
1549
+ /**
1550
+ * @description List of notification channel identifiers or names the rule applies to.
1551
+ * @example [
1552
+ * "01G65Z755AFWAKHE12NY0CQ9FH"
1553
+ * ]
1554
+ */
1555
+ channels: string[];
1556
+ /**
1557
+ * @description Whether the rule is disabled or not.
1558
+ * @default false
1559
+ * @example false
1560
+ */
1561
+ disabled?: boolean;
1562
+ };
1563
+ /** @description Defines the common fields of a notification rule. */
1564
+ NotificationRuleMeta: {
1565
+ /**
1566
+ * @description A unique identifier for the notification rule.
1567
+ * @example 01J2KNP1YTXQRXHTDJ4KPR7PZ0
1568
+ */
1569
+ id: string;
1570
+ type: components['schemas']['NotificationEventType'];
1571
+ };
1572
+ /** @description Common fields for notification rules. */
1573
+ NotificationRuleCommon: components['schemas']['NotificationRuleMeta'] & {
1574
+ /**
1575
+ * @description The user friendly name of the notification rule.
1576
+ * @example Balance threshold reached
1577
+ */
1578
+ name?: string;
1579
+ /** @description List of notification channels the rule applies to. */
1580
+ channels?: components['schemas']['NotificationChannelMeta'][];
1581
+ /**
1582
+ * Format: date-time
1583
+ * @description Timestamp when the rule was created.
1584
+ * @example 2023-01-01T00:00:00Z
1585
+ */
1586
+ createdAt?: string;
1587
+ /**
1588
+ * Format: date-time
1589
+ * @description Timestamp when the rule was modified.
1590
+ * @example 2023-01-02T00:00:00Z
1591
+ */
1592
+ updatedAt?: string;
1593
+ /**
1594
+ * @description Whether the rule is disabled or not.
1595
+ * @default false
1596
+ * @example false
1597
+ */
1598
+ disabled?: boolean;
1599
+ };
1600
+ /**
1601
+ * @description Notification event generated by the system based on the criteria defined in the corresponding
1602
+ * a notification rule.
1603
+ *
1604
+ * The `payload` field contains the actual message sent to the notification channel.
1605
+ */
1606
+ NotificationEvent: {
1607
+ /**
1608
+ * @description A unique identifier for the notification event.
1609
+ * @example 01J2KNP1YTXQRXHTDJ4KPR7PZ0
1610
+ */
1611
+ id: string;
1612
+ /**
1613
+ * Format: date-time
1614
+ * @description Timestamp when the notification event was created.
1615
+ * @example 2023-01-01T00:00:00Z
1616
+ */
1617
+ createdAt: string;
1618
+ rule?: components['schemas']['NotificationRuleMeta'];
1619
+ /** @description The delivery status of the notification event. */
1620
+ deliveryStatus: components['schemas']['NotificationEventDeliveryStatus'][];
1621
+ payload: components['schemas']['NotificationEventPayload'];
1622
+ };
1623
+ /** @description The actual payload sent to channel as part of the notification event. */
1624
+ NotificationEventPayload: components['schemas']['NotificationEventBalanceThresholdPayload'];
1625
+ /** @description Common fields for notification event payload. */
1626
+ NotificationEventCommonPayload: {
1627
+ /**
1628
+ * @description A unique identifier for the notification event the payload belongs to.
1629
+ * @example 01J2KNP1YTXQRXHTDJ4KPR7PZ0
1630
+ */
1631
+ id: string;
1632
+ type: components['schemas']['NotificationEventType'];
1633
+ /**
1634
+ * Format: date-time
1635
+ * @description Timestamp when the notification event was created.
1636
+ * @example 2023-01-01T00:00:00Z
1637
+ */
1638
+ timestamp: string;
1639
+ };
1640
+ /**
1641
+ * @description Defines payload for notification event which is triggered when the `balance` of the `entitlement`
1642
+ * surpass the user defined `threshold`.
1643
+ */
1644
+ NotificationEventBalanceThresholdPayload: components['schemas']['NotificationEventCommonPayload'] & {
1645
+ data: {
1646
+ entitlement: components['schemas']['EntitlementMetered'];
1647
+ feature: components['schemas']['Feature'];
1648
+ subject: components['schemas']['Subject'];
1649
+ balance: components['schemas']['EntitlementValue'];
1650
+ threshold: components['schemas']['NotificationRuleBalanceThresholdValue'];
1651
+ };
1652
+ };
1653
+ NotificationEventDeliveryStatus: {
1654
+ channel: components['schemas']['NotificationChannelMeta'];
1655
+ /** @enum {string} */
1656
+ state: 'SUCCESS' | 'FAILED' | 'SENDING';
1657
+ /**
1658
+ * Format: date-time
1659
+ * @example 2023-01-01T00:00:00Z
1660
+ */
1661
+ updatedAt: string;
1662
+ };
1663
+ };
1664
+ responses: {
1665
+ /** @description Conflict */
1666
+ ConflictProblemResponse: {
1667
+ content: {
1668
+ 'application/problem+json': components['schemas']['ConflictProblem'];
1669
+ };
1670
+ };
1671
+ /** @description Bad Request */
1672
+ BadRequestProblemResponse: {
1673
+ content: {
1674
+ 'application/problem+json': components['schemas']['Problem'];
1675
+ };
1676
+ };
1677
+ /** @description Unauthorized */
1678
+ UnauthorizedProblemResponse: {
1679
+ content: {
1680
+ 'application/problem+json': components['schemas']['Problem'];
1681
+ };
1682
+ };
1683
+ /** @description Not Found */
1684
+ NotFoundProblemResponse: {
1685
+ content: {
1686
+ 'application/problem+json': components['schemas']['Problem'];
1687
+ };
1688
+ };
1689
+ /** @description Not Implemented */
1690
+ NotImplementedProblemResponse: {
1691
+ content: {
1692
+ 'application/problem+json': components['schemas']['Problem'];
1693
+ };
1694
+ };
1695
+ /** @description Unexpected error */
1696
+ UnexpectedProblemResponse: {
1697
+ content: {
1698
+ 'application/problem+json': components['schemas']['Problem'];
1699
+ };
1700
+ };
1701
+ };
1702
+ parameters: {
1703
+ /** @description A unique identifier for the meter. */
1704
+ meterIdOrSlug: components['schemas']['IdOrSlug'];
1705
+ /** @description A unique identifier for a subject. */
1706
+ subjectIdOrKey: string;
1707
+ /** @description A unique ULID identifier for a feature. */
1708
+ featureId: string;
1709
+ /** @description A unique identifier for a grant. */
1710
+ grantId: string;
1711
+ /** @description A unique ULID for an entitlement. */
1712
+ entitlementId: string;
1713
+ /** @description The id of the entitlement or the key of the feature. */
1714
+ entitlementIdOrFeatureKey: string;
1715
+ /** @description Include deleted entries. */
1716
+ includeDeleted?: boolean;
1717
+ /** @description Page number to return */
1718
+ queryPage?: number;
1719
+ /** @description Number of entries to return per page */
1720
+ queryPageSize?: number;
1721
+ /** @description Number of entries to return */
1722
+ queryLimit?: number;
1723
+ /** @description Number of entries to skip */
1724
+ queryOffset?: number;
1725
+ /**
1726
+ * @description Start date-time in RFC 3339 format.
1727
+ * Inclusive.
1728
+ */
1729
+ queryFrom?: string;
1730
+ /**
1731
+ * @description End date-time in RFC 3339 format.
1732
+ * Inclusive.
1733
+ */
1734
+ queryTo?: string;
1735
+ /** @description If not specified, a single usage aggregate will be returned for the entirety of the specified period for each subject and group. */
1736
+ queryWindowSize?: components['schemas']['WindowSize'];
1737
+ /**
1738
+ * @description The value is the name of the time zone as defined in the IANA Time Zone Database (http://www.iana.org/time-zones).
1739
+ * If not specified, the UTC timezone will be used.
1740
+ */
1741
+ queryWindowTimeZone?: string;
1742
+ /**
1743
+ * @description Filtering by multiple subjects.
1744
+ *
1745
+ * Usage: `?subject=customer-1&subject=customer-2`
1746
+ */
1747
+ queryFilterSubject?: string[];
1748
+ /**
1749
+ * @description Filtering by multiple features.
1750
+ *
1751
+ * Usage: `?feature=feature-1&feature=feature-2`
1752
+ */
1753
+ queryFilterFeature?: string[];
1754
+ /**
1755
+ * @description Filtering by multiple meterSlug.
1756
+ *
1757
+ * Usage: `?meterSlug=meter-1&meterSlug=meter-2`
1758
+ */
1759
+ queryFilterMeterSlug?: string[];
1760
+ /**
1761
+ * @description Filtering by multiple entitlement types.
1762
+ *
1763
+ * Usage: `?entitlementType=metered&entitlementType=static`
1764
+ */
1765
+ queryFilterEntitlementType?: string[];
1766
+ queryFilterGroupBy?: {
1767
+ [key: string]: string;
1768
+ };
1769
+ /**
1770
+ * @description If not specified a single aggregate will be returned for each subject and time window.
1771
+ * `subject` is a reserved group by value.
1772
+ */
1773
+ queryGroupBy?: string[];
1774
+ /** @description A unique ULID identifier for a notification channel. */
1775
+ channelId: string;
1776
+ /** @description A unique ULID identifier for a notification rule. */
1777
+ ruleId: string;
1778
+ /** @description A unique ULID identifier for a notification event. */
1779
+ eventId: string;
1780
+ /** @description Include disabled entries. */
1781
+ queryIncludeDisabled?: boolean;
1782
+ /**
1783
+ * @description Order by field.
1784
+ *
1785
+ * Usage: `?order=ASC`
1786
+ */
1787
+ order?: 'ASC' | 'DESC';
1788
+ };
1789
+ requestBodies: never;
1790
+ headers: never;
1791
+ pathItems: never;
1792
+ }
1793
+ export type $defs = Record<string, never>;
1794
+ export type external = Record<string, never>;
1795
+ export interface operations {
1796
+ /**
1797
+ * List ingested events
1798
+ * @description List ingested events within a time range.
1799
+ */
1800
+ listEvents: {
1801
+ parameters: {
1802
+ query?: {
1803
+ from?: components['parameters']['queryFrom'];
1804
+ to?: components['parameters']['queryTo'];
1805
+ /** @description Number of events to return */
1806
+ limit?: number;
1807
+ };
1808
+ };
1809
+ responses: {
1810
+ /** @description List of events for debugging. */
1811
+ 200: {
1812
+ content: {
1813
+ 'application/json': components['schemas']['IngestedEvent'][];
1814
+ };
1815
+ };
1816
+ 400: components['responses']['BadRequestProblemResponse'];
1817
+ 401: components['responses']['UnauthorizedProblemResponse'];
1818
+ default: components['responses']['UnexpectedProblemResponse'];
1819
+ };
1820
+ };
1821
+ /**
1822
+ * Ingest events
1823
+ * @description Ingests an event or batch of events following the CloudEvents specification.
1824
+ */
1825
+ ingestEvents: {
1826
+ /**
1827
+ * @description The event or batch of events to ingest.
1828
+ * The request body must be a CloudEvents JSON object or an array of CloudEvents JSON objects.
1829
+ * The CloudEvents JSON object must adhere to the CloudEvents Specification JSON Schema.
1830
+ */
1831
+ requestBody: {
1832
+ content: {
1833
+ 'application/cloudevents+json': components['schemas']['Event'];
1834
+ 'application/cloudevents-batch+json': components['schemas']['Event'][];
1835
+ };
1836
+ };
1837
+ responses: {
1838
+ /** @description Successfully ingested. */
1839
+ 204: {
1840
+ content: never;
1841
+ };
1842
+ 400: components['responses']['BadRequestProblemResponse'];
1843
+ 401: components['responses']['UnauthorizedProblemResponse'];
1844
+ default: components['responses']['UnexpectedProblemResponse'];
1845
+ };
1846
+ };
1847
+ /**
1848
+ * List meters
1849
+ * @description List meters.
1850
+ */
1851
+ listMeters: {
1852
+ responses: {
1853
+ /** @description List of meters. */
1854
+ 200: {
1855
+ content: {
1856
+ 'application/json': components['schemas']['Meter'][];
1857
+ };
1858
+ };
1859
+ 401: components['responses']['UnauthorizedProblemResponse'];
1860
+ default: components['responses']['UnexpectedProblemResponse'];
1861
+ };
1862
+ };
1863
+ /**
1864
+ * ☁ Create meter
1865
+ * @description *Available in OpenMeter Cloud.*
1866
+ * *In the open-source version, meters are created in the configuration file.*
1867
+ *
1868
+ * Create a meter.
1869
+ */
1870
+ createMeter: {
1871
+ /** @description The meter to create. */
1872
+ requestBody: {
1873
+ content: {
1874
+ 'application/json': components['schemas']['Meter'];
1875
+ };
1876
+ };
1877
+ responses: {
1878
+ /** @description Created. */
1879
+ 201: {
1880
+ content: {
1881
+ 'application/json': components['schemas']['Meter'];
1882
+ };
1883
+ };
1884
+ 400: components['responses']['BadRequestProblemResponse'];
1885
+ 401: components['responses']['UnauthorizedProblemResponse'];
1886
+ 501: components['responses']['NotImplementedProblemResponse'];
1887
+ default: components['responses']['UnexpectedProblemResponse'];
1888
+ };
1889
+ };
1890
+ /**
1891
+ * Get meter
1892
+ * @description Get meter by ID or slug
1893
+ */
1894
+ getMeter: {
1895
+ parameters: {
1896
+ path: {
1897
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
1898
+ };
1899
+ };
1900
+ responses: {
1901
+ /** @description Meter found. */
1902
+ 200: {
1903
+ content: {
1904
+ 'application/json': components['schemas']['Meter'];
1905
+ };
1906
+ };
1907
+ 404: components['responses']['NotFoundProblemResponse'];
1908
+ default: components['responses']['UnexpectedProblemResponse'];
1909
+ };
1910
+ };
1911
+ /**
1912
+ * ☁ Delete meter
1913
+ * @description *Available in OpenMeter Cloud.*
1914
+ *
1915
+ * Delete a meter by ID or slug.
1916
+ */
1917
+ deleteMeter: {
1918
+ parameters: {
1919
+ path: {
1920
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
1921
+ };
1922
+ };
1923
+ responses: {
1924
+ /** @description Meter deleted. */
1925
+ 204: {
1926
+ content: never;
1927
+ };
1928
+ 404: components['responses']['NotFoundProblemResponse'];
1929
+ 501: components['responses']['NotImplementedProblemResponse'];
1930
+ default: components['responses']['UnexpectedProblemResponse'];
1931
+ };
1932
+ };
1933
+ /**
1934
+ * Query meter
1935
+ * @description Query meter for usage.
1936
+ */
1937
+ queryMeter: {
1938
+ parameters: {
1939
+ query?: {
1940
+ from?: components['parameters']['queryFrom'];
1941
+ to?: components['parameters']['queryTo'];
1942
+ windowSize?: components['parameters']['queryWindowSize'];
1943
+ windowTimeZone?: components['parameters']['queryWindowTimeZone'];
1944
+ subject?: components['parameters']['queryFilterSubject'];
1945
+ filterGroupBy?: components['parameters']['queryFilterGroupBy'];
1946
+ groupBy?: components['parameters']['queryGroupBy'];
1947
+ };
1948
+ path: {
1949
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
1950
+ };
1951
+ };
1952
+ responses: {
1953
+ /** @description Usage data. */
1954
+ 200: {
1955
+ content: {
1956
+ 'application/json': components['schemas']['MeterQueryResult'];
1957
+ 'text/csv': string;
1958
+ };
1959
+ };
1960
+ 400: components['responses']['BadRequestProblemResponse'];
1961
+ 401: components['responses']['UnauthorizedProblemResponse'];
1962
+ default: components['responses']['UnexpectedProblemResponse'];
1963
+ };
1964
+ };
1965
+ /**
1966
+ * List meter subjects
1967
+ * @description List subjects for a meter.
1968
+ */
1969
+ listMeterSubjects: {
1970
+ parameters: {
1971
+ path: {
1972
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
1973
+ };
1974
+ };
1975
+ responses: {
1976
+ /** @description List of subjects. */
1977
+ 200: {
1978
+ content: {
1979
+ 'application/json': string[];
1980
+ };
1981
+ };
1982
+ 400: components['responses']['BadRequestProblemResponse'];
1983
+ default: components['responses']['UnexpectedProblemResponse'];
1984
+ };
1985
+ };
1986
+ /**
1987
+ * ☁ List portal tokens
1988
+ * @description *Available in OpenMeter Cloud.*
1989
+ *
1990
+ * List consumer portal tokens.
1991
+ */
1992
+ listPortalTokens: {
1993
+ parameters: {
1994
+ query?: {
1995
+ /** @description Number of portal tokens to return. Default is 25. */
1996
+ limit?: number;
1997
+ };
1998
+ };
1999
+ responses: {
2000
+ /** @description List of portal tokens. */
2001
+ 200: {
2002
+ content: {
2003
+ 'application/json': components['schemas']['PortalToken'][];
2004
+ };
2005
+ };
2006
+ 400: components['responses']['BadRequestProblemResponse'];
2007
+ 401: components['responses']['UnauthorizedProblemResponse'];
2008
+ 501: components['responses']['NotImplementedProblemResponse'];
2009
+ default: components['responses']['UnexpectedProblemResponse'];
2010
+ };
2011
+ };
2012
+ /**
2013
+ * Create portal token
2014
+ * @description Create a consumer portal token.
2015
+ */
2016
+ createPortalToken: {
2017
+ /** @description The portal token to create. */
2018
+ requestBody: {
2019
+ content: {
2020
+ /**
2021
+ * @example {
2022
+ * "subject": "customer-id",
2023
+ * "allowedMeterSlugs": [
2024
+ * "tokens_total"
2025
+ * ]
2026
+ * }
2027
+ */
2028
+ 'application/json': components['schemas']['PortalToken'];
2029
+ };
2030
+ };
2031
+ responses: {
2032
+ /** @description Created. */
2033
+ 200: {
2034
+ content: {
2035
+ 'application/json': components['schemas']['PortalToken'];
2036
+ };
2037
+ };
2038
+ 400: components['responses']['BadRequestProblemResponse'];
2039
+ 401: components['responses']['UnauthorizedProblemResponse'];
2040
+ default: components['responses']['UnexpectedProblemResponse'];
2041
+ };
2042
+ };
2043
+ /**
2044
+ * ☁ Invalidate portal tokens
2045
+ * @description *Available in OpenMeter Cloud.*
2046
+ *
2047
+ * Invalidates consumer portal tokens by ID or subject.
2048
+ */
2049
+ invalidatePortalTokens: {
2050
+ /** @description If no id or subject is specified, all tokens will be invalidated. */
2051
+ requestBody: {
2052
+ content: {
2053
+ 'application/json': {
2054
+ /** @description Invalidate a portal token by ID. */
2055
+ id?: string;
2056
+ /** @description Invalidate all portal tokens for a subject. */
2057
+ subject?: string;
2058
+ };
2059
+ };
2060
+ };
2061
+ responses: {
2062
+ /** @description Portal tokens invalidated. */
2063
+ 204: {
2064
+ content: never;
2065
+ };
2066
+ 400: components['responses']['BadRequestProblemResponse'];
2067
+ 401: components['responses']['UnauthorizedProblemResponse'];
2068
+ 501: components['responses']['NotImplementedProblemResponse'];
2069
+ default: components['responses']['UnexpectedProblemResponse'];
2070
+ };
2071
+ };
2072
+ /**
2073
+ * ☁ List subjects
2074
+ * @description *Available in OpenMeter Cloud.*
2075
+ *
2076
+ * List subjects.
2077
+ */
2078
+ listSubjects: {
2079
+ responses: {
2080
+ /** @description List of subjects. */
2081
+ 200: {
2082
+ content: {
2083
+ 'application/json': components['schemas']['Subject'][];
2084
+ };
2085
+ };
2086
+ 401: components['responses']['UnauthorizedProblemResponse'];
2087
+ default: components['responses']['UnexpectedProblemResponse'];
2088
+ };
2089
+ };
2090
+ /**
2091
+ * ☁ Upsert subject
2092
+ * @description *Available in OpenMeter Cloud.*
2093
+ *
2094
+ * Upserts a subject. Creates or updates subject.
2095
+ * If the subject doesn't exist, it will be created.
2096
+ * If the subject exists, it will be partially updated with the provided fields.
2097
+ */
2098
+ upsertSubject: {
2099
+ /** @description The subject to upsert. */
2100
+ requestBody: {
2101
+ content: {
2102
+ 'application/json': components['schemas']['Subject'][];
2103
+ };
2104
+ };
2105
+ responses: {
2106
+ /** @description Subject upserted. */
2107
+ 200: {
2108
+ content: {
2109
+ 'application/json': components['schemas']['Subject'][];
2110
+ };
2111
+ };
2112
+ 400: components['responses']['BadRequestProblemResponse'];
2113
+ 401: components['responses']['UnauthorizedProblemResponse'];
2114
+ 501: components['responses']['NotImplementedProblemResponse'];
2115
+ default: components['responses']['UnexpectedProblemResponse'];
2116
+ };
2117
+ };
2118
+ /**
2119
+ * ☁ Get subject
2120
+ * @description *Available in OpenMeter Cloud.*
2121
+ *
2122
+ * Get subject by ID or key.
2123
+ */
2124
+ getSubject: {
2125
+ parameters: {
2126
+ path: {
2127
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
2128
+ };
2129
+ };
2130
+ responses: {
2131
+ /** @description Subject found. */
2132
+ 200: {
2133
+ content: {
2134
+ 'application/json': components['schemas']['Subject'];
2135
+ };
2136
+ };
2137
+ 401: components['responses']['UnauthorizedProblemResponse'];
2138
+ 404: components['responses']['NotFoundProblemResponse'];
2139
+ default: components['responses']['UnexpectedProblemResponse'];
2140
+ };
2141
+ };
2142
+ /**
2143
+ * ☁ Delete subject
2144
+ * @description *Available in OpenMeter Cloud.*
2145
+ *
2146
+ * Delete a subject by ID or key.
2147
+ */
2148
+ deleteSubject: {
2149
+ parameters: {
2150
+ path: {
2151
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
2152
+ };
2153
+ };
2154
+ responses: {
2155
+ /** @description Subject deleted. */
2156
+ 204: {
2157
+ content: never;
2158
+ };
2159
+ 400: components['responses']['BadRequestProblemResponse'];
2160
+ 401: components['responses']['UnauthorizedProblemResponse'];
2161
+ 404: components['responses']['NotFoundProblemResponse'];
2162
+ 501: components['responses']['NotImplementedProblemResponse'];
2163
+ default: components['responses']['UnexpectedProblemResponse'];
2164
+ };
2165
+ };
2166
+ /**
2167
+ * Query portal meter
2168
+ * @description Query meter for consumer portal. This endpoint is publicly exposable to consumers.
2169
+ */
2170
+ queryPortalMeter: {
2171
+ parameters: {
2172
+ query?: {
2173
+ from?: components['parameters']['queryFrom'];
2174
+ to?: components['parameters']['queryTo'];
2175
+ windowSize?: components['parameters']['queryWindowSize'];
2176
+ windowTimeZone?: components['parameters']['queryWindowTimeZone'];
2177
+ filterGroupBy?: components['parameters']['queryFilterGroupBy'];
2178
+ groupBy?: components['parameters']['queryGroupBy'];
2179
+ };
2180
+ path: {
2181
+ /** @description A unique identifier for the meter. */
2182
+ meterSlug: string;
2183
+ };
2184
+ };
2185
+ responses: {
2186
+ /** @description Usage data. */
2187
+ 200: {
2188
+ content: {
2189
+ 'application/json': components['schemas']['MeterQueryResult'];
2190
+ 'text/csv': string;
2191
+ };
2192
+ };
2193
+ 400: components['responses']['BadRequestProblemResponse'];
2194
+ 401: components['responses']['UnauthorizedProblemResponse'];
2195
+ default: components['responses']['UnexpectedProblemResponse'];
2196
+ };
2197
+ };
2198
+ /**
2199
+ * List entitlements
2200
+ * @description List all entitlements regardless of subject. This endpoint is intended for administrative purposes.
2201
+ * If page is provided that takes precedence and the paginated response is returned.
2202
+ */
2203
+ listEntitlements: {
2204
+ parameters: {
2205
+ query?: {
2206
+ page?: components['parameters']['queryPage'];
2207
+ pageSize?: components['parameters']['queryPageSize'];
2208
+ limit?: components['parameters']['queryLimit'];
2209
+ offset?: components['parameters']['queryOffset'];
2210
+ subject?: components['parameters']['queryFilterSubject'];
2211
+ feature?: components['parameters']['queryFilterFeature'];
2212
+ entitlementType?: components['parameters']['queryFilterEntitlementType'];
2213
+ order?: components['parameters']['order'];
2214
+ /** @description Order by field */
2215
+ orderBy?: 'createdAt' | 'updatedAt';
2216
+ };
2217
+ };
2218
+ responses: {
2219
+ /** @description List of entitlements. If page is provided that takes precedence and the paginated response is returned. */
2220
+ 200: {
2221
+ content: {
2222
+ 'application/json': components['schemas']['ListEntitlementResponse'];
2223
+ };
2224
+ };
2225
+ 400: components['responses']['BadRequestProblemResponse'];
2226
+ 401: components['responses']['UnauthorizedProblemResponse'];
2227
+ default: components['responses']['UnexpectedProblemResponse'];
2228
+ };
2229
+ };
2230
+ /**
2231
+ * List features
2232
+ * @description List all features. If page is provided that takes precedence and the paginated response is returned.
2233
+ */
2234
+ listFeatures: {
2235
+ parameters: {
2236
+ query?: {
2237
+ page?: components['parameters']['queryPage'];
2238
+ pageSize?: components['parameters']['queryPageSize'];
2239
+ limit?: components['parameters']['queryLimit'];
2240
+ offset?: components['parameters']['queryOffset'];
2241
+ meterSlug?: components['parameters']['queryFilterMeterSlug'];
2242
+ order?: components['parameters']['order'];
2243
+ /** @description Order by field */
2244
+ orderBy?: 'id' | 'createdAt' | 'updatedAt';
2245
+ /** @description Include archived features. */
2246
+ includeArchived?: boolean;
2247
+ };
2248
+ };
2249
+ responses: {
2250
+ /** @description List of features. If page is provided that takes precedence and the paginated response is returned. */
2251
+ 200: {
2252
+ content: {
2253
+ 'application/json': components['schemas']['ListFeatureResponse'];
2254
+ };
2255
+ };
2256
+ 400: components['responses']['BadRequestProblemResponse'];
2257
+ 401: components['responses']['UnauthorizedProblemResponse'];
2258
+ default: components['responses']['UnexpectedProblemResponse'];
2259
+ };
2260
+ };
2261
+ /**
2262
+ * Create a feature
2263
+ * @description Features are either metered or static. A feature is metered if meterSlug is provided at creation.
2264
+ * For metered features you can pass additional filters that will be applied when calculating feature usage, based on the meter's groupBy fields. Only meters with SUM and COUNT aggregation are supported for features.
2265
+ *
2266
+ * Features cannot be updated later, only archived.
2267
+ */
2268
+ createFeature: {
2269
+ /** @description The feature to create. */
2270
+ requestBody: {
2271
+ content: {
2272
+ 'application/json': components['schemas']['FeatureCreateInputs'];
2273
+ };
2274
+ };
2275
+ responses: {
2276
+ /** @description Feature created. */
2277
+ 201: {
2278
+ content: {
2279
+ 'application/json': components['schemas']['Feature'];
2280
+ };
2281
+ };
2282
+ 400: components['responses']['BadRequestProblemResponse'];
2283
+ 401: components['responses']['UnauthorizedProblemResponse'];
2284
+ 501: components['responses']['NotImplementedProblemResponse'];
2285
+ default: components['responses']['UnexpectedProblemResponse'];
2286
+ };
2287
+ };
2288
+ /**
2289
+ * Get feature
2290
+ * @description Get a feature by id.
2291
+ */
2292
+ getFeature: {
2293
+ parameters: {
2294
+ path: {
2295
+ featureId: components['parameters']['featureId'];
2296
+ };
2297
+ };
2298
+ responses: {
2299
+ /** @description Feature found. */
2300
+ 200: {
2301
+ content: {
2302
+ 'application/json': components['schemas']['Feature'];
2303
+ };
2304
+ };
2305
+ 401: components['responses']['UnauthorizedProblemResponse'];
2306
+ 404: components['responses']['NotFoundProblemResponse'];
2307
+ default: components['responses']['UnexpectedProblemResponse'];
2308
+ };
2309
+ };
2310
+ /**
2311
+ * Archive a feature
2312
+ * @description Once a feature is archived it cannot be unarchived. If a feature is archived, new entitlements cannot be created for it, but archiving the feature does not affect existing entitlements. This means, if you want to create a new feature with the same key, and then create entitlements for it, the previous entitlements have to be deleted first on a per subject basis.
2313
+ */
2314
+ deleteFeature: {
2315
+ parameters: {
2316
+ path: {
2317
+ featureId: components['parameters']['featureId'];
2318
+ };
2319
+ };
2320
+ responses: {
2321
+ /** @description Feature deleted. */
2322
+ 204: {
2323
+ content: never;
2324
+ };
2325
+ 401: components['responses']['UnauthorizedProblemResponse'];
2326
+ 404: components['responses']['NotFoundProblemResponse'];
2327
+ default: components['responses']['UnexpectedProblemResponse'];
2328
+ };
2329
+ };
2330
+ /**
2331
+ * List grants
2332
+ * @description List all grants for all the subjects and entitlements. This endpoint is intended for administrative purposes only. To fetch the grants of a specific entitlement please use the /api/v1/subjects/{subjectKeyOrID}/entitlements/{entitlementOrFeatureID}/grants endpoint.
2333
+ *
2334
+ * If page is provided that takes precedence and the paginated response is returned.
2335
+ */
2336
+ listGrants: {
2337
+ parameters: {
2338
+ query?: {
2339
+ page?: components['parameters']['queryPage'];
2340
+ pageSize?: components['parameters']['queryPageSize'];
2341
+ limit?: components['parameters']['queryLimit'];
2342
+ offset?: components['parameters']['queryOffset'];
2343
+ subject?: components['parameters']['queryFilterSubject'];
2344
+ feature?: components['parameters']['queryFilterFeature'];
2345
+ order?: components['parameters']['order'];
2346
+ /** @description Order by field */
2347
+ orderBy?: 'id' | 'createdAt' | 'updatedAt';
2348
+ includeDeleted?: components['parameters']['includeDeleted'];
2349
+ };
2350
+ };
2351
+ responses: {
2352
+ /** @description List of grants. If page is provided that takes precedence and the paginated response is returned. */
2353
+ 200: {
2354
+ content: {
2355
+ 'application/json': components['schemas']['ListEntitlementGrantResponse'];
2356
+ };
2357
+ };
2358
+ 401: components['responses']['UnauthorizedProblemResponse'];
2359
+ default: components['responses']['UnexpectedProblemResponse'];
2360
+ };
2361
+ };
2362
+ /**
2363
+ * Void a grant
2364
+ * @description Voiding a grant means it is no longer valid, it doesn't take part in further balance calculations. Voiding a grant does not retroactively take effect, meaning any usage that has already been attributed to the grant will remain, but future usage cannot be burnt down from the grant.
2365
+ *
2366
+ * For example, if you have a single grant for your metered entitlement with an initial amount of 100, and so far 60 usage has been metered, the grant (and the entitlement itself) would have a balance of 40. If you then void that grant, balance becomes 0, but the 60 previous usage will not be affected.
2367
+ */
2368
+ voidGrant: {
2369
+ parameters: {
2370
+ path: {
2371
+ grantId: components['parameters']['grantId'];
2372
+ };
2373
+ };
2374
+ responses: {
2375
+ /** @description Grant has been voided. */
2376
+ 204: {
2377
+ content: never;
2378
+ };
2379
+ 400: components['responses']['BadRequestProblemResponse'];
2380
+ 401: components['responses']['UnauthorizedProblemResponse'];
2381
+ 404: components['responses']['NotFoundProblemResponse'];
2382
+ 409: components['responses']['ConflictProblemResponse'];
2383
+ default: components['responses']['UnexpectedProblemResponse'];
2384
+ };
2385
+ };
2386
+ /**
2387
+ * List entitlements of a subject
2388
+ * @description List all entitlements for a subject. For checking entitlement access, use the /value endpoint instead.
2389
+ */
2390
+ listSubjectEntitlements: {
2391
+ parameters: {
2392
+ query?: {
2393
+ includeDeleted?: components['parameters']['includeDeleted'];
2394
+ };
2395
+ path: {
2396
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
2397
+ };
2398
+ };
2399
+ responses: {
2400
+ /** @description List of entitlements. */
2401
+ 200: {
2402
+ content: {
2403
+ 'application/json': components['schemas']['Entitlement'][];
2404
+ };
2405
+ };
2406
+ 401: components['responses']['UnauthorizedProblemResponse'];
2407
+ default: components['responses']['UnexpectedProblemResponse'];
2408
+ };
2409
+ };
2410
+ /**
2411
+ * Create an entitlement
2412
+ * @description OpenMeter has three types of entitlements: metered, boolean, and static. The type property determines the type of entitlement. The underlying feature has to be compatible with the entitlement type specified in the request (e.g., a metered entitlement needs a feature associated with a meter).
2413
+ *
2414
+ * - Boolean entitlements define static feature access, e.g. "Can use SSO authentication".
2415
+ * - Static entitlements let you pass along a configuration while granting access, e.g. "Using this feature with X Y settings" (passed in the config).
2416
+ * - Metered entitlements have many use cases, from setting up usage-based access to implementing complex credit systems. Example: The customer can use 10000 AI tokens during the usage period of the entitlement.
2417
+ *
2418
+ * A given subject can only have one active (non-deleted) entitlement per featureKey. If you try to create a new entitlement for a featureKey that already has an active entitlement, the request will fail with a 409 error.
2419
+ *
2420
+ * Once an entitlement is created you cannot modify it, only delete it.
2421
+ */
2422
+ createEntitlement: {
2423
+ parameters: {
2424
+ path: {
2425
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
2426
+ };
2427
+ };
2428
+ /** @description The entitlement to create. */
2429
+ requestBody: {
2430
+ content: {
2431
+ 'application/json': components['schemas']['EntitlementCreateInputs'];
2432
+ };
2433
+ };
2434
+ responses: {
2435
+ /** @description Entitlement created. */
2436
+ 201: {
2437
+ content: {
2438
+ 'application/json': components['schemas']['Entitlement'];
2439
+ };
2440
+ };
2441
+ 400: components['responses']['BadRequestProblemResponse'];
2442
+ 401: components['responses']['UnauthorizedProblemResponse'];
2443
+ 409: components['responses']['ConflictProblemResponse'];
2444
+ 501: components['responses']['NotImplementedProblemResponse'];
2445
+ default: components['responses']['UnexpectedProblemResponse'];
2446
+ };
2447
+ };
2448
+ /**
2449
+ * Get an entitlement
2450
+ * @description Get entitlement by id. For checking entitlement access, use the /value endpoint instead.
2451
+ */
2452
+ getEntitlement: {
2453
+ parameters: {
2454
+ path: {
2455
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
2456
+ entitlementId: components['parameters']['entitlementId'];
2457
+ };
2458
+ };
2459
+ responses: {
2460
+ /** @description Entitlement found. */
2461
+ 200: {
2462
+ content: {
2463
+ 'application/json': {
2464
+ type: 'json';
2465
+ } & Omit<components['schemas']['Entitlement'], 'type'> & {
2466
+ /**
2467
+ * Format: date-time
2468
+ * @description The last time usage was reset.
2469
+ * @example 2023-01-01T00:00:00Z
2470
+ */
2471
+ lastReset?: string;
2472
+ };
2473
+ };
2474
+ };
2475
+ 401: components['responses']['UnauthorizedProblemResponse'];
2476
+ 404: components['responses']['NotFoundProblemResponse'];
2477
+ default: components['responses']['UnexpectedProblemResponse'];
2478
+ };
2479
+ };
2480
+ /**
2481
+ * Delete an entitlement
2482
+ * @description Deleting an entitlement revokes access to the associated feature. As a single subject can only have one entitlement per featureKey, when "migrating" features you have to delete the old entitlements as well.
2483
+ * As access and status checks can be historical queries, deleting an entitlement populates the deletedAt timestamp. When queried for a time before that, the entitlement is still considered active, you cannot have retroactive changes to access, which is important for, among other things, auditing.
2484
+ */
2485
+ deleteEntitlement: {
2486
+ parameters: {
2487
+ path: {
2488
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
2489
+ entitlementId: components['parameters']['entitlementId'];
2490
+ };
2491
+ };
2492
+ responses: {
2493
+ /** @description Entitlement deleted. */
2494
+ 204: {
2495
+ content: never;
2496
+ };
2497
+ 401: components['responses']['UnauthorizedProblemResponse'];
2498
+ 404: components['responses']['NotFoundProblemResponse'];
2499
+ default: components['responses']['UnexpectedProblemResponse'];
2500
+ };
2501
+ };
2502
+ /**
2503
+ * List grants for an entitlement
2504
+ * @description List all grants issued for an entitlement. The entitlement can be defined either by its id or featureKey.
2505
+ */
2506
+ listEntitlementGrants: {
2507
+ parameters: {
2508
+ query?: {
2509
+ includeDeleted?: components['parameters']['includeDeleted'];
2510
+ /** @description Order by field */
2511
+ orderBy?: 'id' | 'createdAt' | 'updatedAt';
2512
+ };
2513
+ path: {
2514
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
2515
+ entitlementIdOrFeatureKey: components['parameters']['entitlementIdOrFeatureKey'];
2516
+ };
2517
+ };
2518
+ responses: {
2519
+ /** @description List of grants. */
2520
+ 200: {
2521
+ content: {
2522
+ 'application/json': components['schemas']['EntitlementGrant'][];
2523
+ };
2524
+ };
2525
+ 401: components['responses']['UnauthorizedProblemResponse'];
2526
+ default: components['responses']['UnexpectedProblemResponse'];
2527
+ };
2528
+ };
2529
+ /**
2530
+ * Create a grant
2531
+ * @description Grants define a behavior of granting usage for a metered entitlement. They can have complicated recurrence and rollover rules, thanks to which you can define a wide range of access patterns with a single grant, in most cases you don't have to periodically create new grants. You can only issue grants for active metered entitlements.
2532
+ *
2533
+ * A grant defines a given amount of usage that can be consumed for the entitlement. The grant is in effect between its effective date and its expiration date. Specifying both is mandatory for new grants.
2534
+ *
2535
+ * Grants have a priority setting that determines their order of use. Lower numbers have higher priority, with 0 being the highest priority.
2536
+ *
2537
+ * Grants can have a recurrence setting intended to automate the manual reissuing of grants. For example, a daily recurrence is equal to reissuing that same grant every day (ignoring rollover settings).
2538
+ *
2539
+ * Rollover settings define what happens to the remaining balance of a grant at a reset. Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset, MinRolloverAmount))
2540
+ *
2541
+ * Grants cannot be changed once created, only deleted. This is to ensure that balance is deterministic regardless of when it is queried.
2542
+ */
2543
+ createGrant: {
2544
+ parameters: {
2545
+ path: {
2546
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
2547
+ entitlementIdOrFeatureKey: components['parameters']['entitlementIdOrFeatureKey'];
2548
+ };
2549
+ };
2550
+ /** @description The grant to create. */
2551
+ requestBody: {
2552
+ content: {
2553
+ 'application/json': components['schemas']['EntitlementGrantCreateInput'];
2554
+ };
2555
+ };
2556
+ responses: {
2557
+ /** @description Grant created. */
2558
+ 201: {
2559
+ content: {
2560
+ 'application/json': components['schemas']['EntitlementGrant'];
2561
+ };
2562
+ };
2563
+ 400: components['responses']['BadRequestProblemResponse'];
2564
+ 401: components['responses']['UnauthorizedProblemResponse'];
2565
+ 501: components['responses']['NotImplementedProblemResponse'];
2566
+ default: components['responses']['UnexpectedProblemResponse'];
2567
+ };
2568
+ };
2569
+ /**
2570
+ * Get the current value and access of an entitlement
2571
+ * @description This endpoint should be used for access checks and enforcement. All entitlement types share the hasAccess property in their value response, but multiple other properties are returned based on the entitlement type.
2572
+ *
2573
+ * For convenience reasons, /value works with both entitlementId and featureKey.
2574
+ */
2575
+ getEntitlementValue: {
2576
+ parameters: {
2577
+ query?: {
2578
+ /** @description Point of time to check value: date-time in RFC 3339 format. Defaults to now. */
2579
+ time?: string;
2580
+ };
2581
+ path: {
2582
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
2583
+ entitlementIdOrFeatureKey: components['parameters']['entitlementIdOrFeatureKey'];
2584
+ };
2585
+ };
2586
+ responses: {
2587
+ /** @description The entitlement value. */
2588
+ 200: {
2589
+ content: {
2590
+ 'application/json': components['schemas']['EntitlementValue'];
2591
+ };
2592
+ };
2593
+ 400: components['responses']['BadRequestProblemResponse'];
2594
+ 401: components['responses']['UnauthorizedProblemResponse'];
2595
+ 404: components['responses']['NotFoundProblemResponse'];
2596
+ default: components['responses']['UnexpectedProblemResponse'];
2597
+ };
2598
+ };
2599
+ /**
2600
+ * Get the balance history of a specific entitlement.
2601
+ * @description Returns historical balance and usage data for the entitlement. The queried history can span accross multiple reset events.
2602
+ *
2603
+ * BurndownHistory returns a continous history of segments, where the segments are seperated by events that changed either the grant burndown priority or the usage period.
2604
+ *
2605
+ * WindowedHistory returns windowed usage data for the period enriched with balance information and the list of grants that were being burnt down in that window.
2606
+ */
2607
+ getEntitlementHistory: {
2608
+ parameters: {
2609
+ query: {
2610
+ /**
2611
+ * @description Start of time range to query entitlement: date-time in RFC 3339 format. Defaults to
2612
+ * the last reset.
2613
+ * Gets truncated to the granularity of the underlying meter.
2614
+ */
2615
+ from?: string;
2616
+ /**
2617
+ * @description End of time range to query entitlement: date-time in RFC 3339 format. Defaults to now.
2618
+ * If not now then gets truncated to the granularity of the underlying meter.
2619
+ */
2620
+ to?: string;
2621
+ /** @description Size of the time window to group the history by. Cannot be shorter than meter granularity. */
2622
+ windowSize: 'MINUTE' | 'HOUR' | 'DAY';
2623
+ windowTimeZone?: components['parameters']['queryWindowTimeZone'];
2624
+ };
2625
+ path: {
2626
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
2627
+ entitlementId: components['parameters']['entitlementId'];
2628
+ };
2629
+ };
2630
+ responses: {
2631
+ /** @description The history response. */
2632
+ 200: {
2633
+ content: {
2634
+ 'application/json': components['schemas']['WindowedBalanceHistory'];
2635
+ };
2636
+ };
2637
+ 400: components['responses']['BadRequestProblemResponse'];
2638
+ 401: components['responses']['UnauthorizedProblemResponse'];
2639
+ 404: components['responses']['NotFoundProblemResponse'];
2640
+ default: components['responses']['UnexpectedProblemResponse'];
2641
+ };
2642
+ };
2643
+ /**
2644
+ * Reset an entitlement
2645
+ * @description Reset marks the start of a new usage period for the entitlement and initiates grant rollover. At the start of a period usage is zerod out and grants are rolled over based on their rollover settings. It would typically be synced with the subjects billing period to enforce usage based on their subscription.
2646
+ *
2647
+ * Usage is automatically reset for metered entitlements based on their usage period, but this endpoint allows to manually reset it at any time. When doing so the period anchor of the entitlement can be changed if needed.
2648
+ */
2649
+ resetEntitlementUsage: {
2650
+ parameters: {
2651
+ path: {
2652
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
2653
+ entitlementId: components['parameters']['entitlementId'];
2654
+ };
2655
+ };
2656
+ requestBody: {
2657
+ content: {
2658
+ 'application/json': {
2659
+ /**
2660
+ * Format: date-time
2661
+ * @description The time at which the reset takes effect, defaults to now. The reset cannot be in the future. The provided value is truncated to the minute due to how historical meter data is stored.
2662
+ *
2663
+ * @example 2023-01-01T00:00:00Z
2664
+ */
2665
+ effectiveAt?: string;
2666
+ /**
2667
+ * @description Determines whether the usage period anchor is retained or reset to the effectiveAt time.
2668
+ * - If true, the usage period anchor is retained.
2669
+ * - If false, the usage period anchor is reset to the effectiveAt time.
2670
+ */
2671
+ retainAnchor?: boolean;
2672
+ };
2673
+ };
2674
+ };
2675
+ responses: {
2676
+ /** @description Entitlement reset. */
2677
+ 204: {
2678
+ content: never;
2679
+ };
2680
+ 400: components['responses']['BadRequestProblemResponse'];
2681
+ 401: components['responses']['UnauthorizedProblemResponse'];
2682
+ 404: components['responses']['NotFoundProblemResponse'];
2683
+ default: components['responses']['UnexpectedProblemResponse'];
2684
+ };
2685
+ };
2686
+ /**
2687
+ * Get event metrics
2688
+ * @description Returns debug metrics like the number of ingested events since mindnight UTC.
2689
+ * The OpenMetrics Counter(s) reset every day at midnight UTC.
2690
+ */
2691
+ getDebugMetrics: {
2692
+ responses: {
2693
+ /** @description Dbeug metrics, like number of ingested events. */
2694
+ 200: {
2695
+ content: {
2696
+ 'text/plain': string;
2697
+ };
2698
+ };
2699
+ 401: components['responses']['UnauthorizedProblemResponse'];
2700
+ default: components['responses']['UnexpectedProblemResponse'];
2701
+ };
2702
+ };
2703
+ /**
2704
+ * List notification channels
2705
+ * @description List all notification channels.
2706
+ */
2707
+ listNotificationChannels: {
2708
+ parameters: {
2709
+ query?: {
2710
+ limit?: components['parameters']['queryLimit'];
2711
+ offset?: components['parameters']['queryOffset'];
2712
+ /** @description Order by field */
2713
+ orderBy?: 'id' | 'type' | 'createdAt' | 'updatedAt';
2714
+ includeDisabled?: components['parameters']['queryIncludeDisabled'];
2715
+ };
2716
+ };
2717
+ responses: {
2718
+ /** @description List of notification channels. */
2719
+ 200: {
2720
+ content: {
2721
+ 'application/json': components['schemas']['NotificationChannels'];
2722
+ };
2723
+ };
2724
+ 400: components['responses']['BadRequestProblemResponse'];
2725
+ 401: components['responses']['UnauthorizedProblemResponse'];
2726
+ default: components['responses']['UnexpectedProblemResponse'];
2727
+ };
2728
+ };
2729
+ /**
2730
+ * Create a notification channel
2731
+ * @description Create a new notification channel.
2732
+ */
2733
+ createNotificationChannel: {
2734
+ /** @description The notification channel to create. */
2735
+ requestBody: {
2736
+ content: {
2737
+ 'application/json': components['schemas']['NotificationChannelCreateRequest'];
2738
+ };
2739
+ };
2740
+ responses: {
2741
+ /** @description Notification channel created. */
2742
+ 201: {
2743
+ content: {
2744
+ 'application/json': components['schemas']['NotificationChannel'];
2745
+ };
2746
+ };
2747
+ 400: components['responses']['BadRequestProblemResponse'];
2748
+ 401: components['responses']['UnauthorizedProblemResponse'];
2749
+ 409: components['responses']['ConflictProblemResponse'];
2750
+ default: components['responses']['UnexpectedProblemResponse'];
2751
+ };
2752
+ };
2753
+ /**
2754
+ * Get notification channel
2755
+ * @description Get a notification channel by id.
2756
+ */
2757
+ getNotificationChannel: {
2758
+ parameters: {
2759
+ path: {
2760
+ channelId: components['parameters']['channelId'];
2761
+ };
2762
+ };
2763
+ responses: {
2764
+ /** @description Notification channel found. */
2765
+ 200: {
2766
+ content: {
2767
+ 'application/json': components['schemas']['NotificationChannel'];
2768
+ };
2769
+ };
2770
+ 401: components['responses']['UnauthorizedProblemResponse'];
2771
+ 404: components['responses']['NotFoundProblemResponse'];
2772
+ default: components['responses']['UnexpectedProblemResponse'];
2773
+ };
2774
+ };
2775
+ /**
2776
+ * Update notification channel
2777
+ * @description Update a notification channel by id.
2778
+ */
2779
+ updateNotificationChannel: {
2780
+ parameters: {
2781
+ path: {
2782
+ channelId: components['parameters']['channelId'];
2783
+ };
2784
+ };
2785
+ /** @description The notification channel to update. */
2786
+ requestBody: {
2787
+ content: {
2788
+ 'application/json': components['schemas']['NotificationChannelCreateRequest'];
2789
+ };
2790
+ };
2791
+ responses: {
2792
+ /** @description Notification channel updated. */
2793
+ 200: {
2794
+ content: {
2795
+ 'application/json': components['schemas']['NotificationChannel'];
2796
+ };
2797
+ };
2798
+ 401: components['responses']['UnauthorizedProblemResponse'];
2799
+ 404: components['responses']['NotFoundProblemResponse'];
2800
+ default: components['responses']['UnexpectedProblemResponse'];
2801
+ };
2802
+ };
2803
+ /**
2804
+ * Delete a notification channel
2805
+ * @description Delete notification channel by id.
2806
+ */
2807
+ deleteNotificationChannel: {
2808
+ parameters: {
2809
+ path: {
2810
+ channelId: components['parameters']['channelId'];
2811
+ };
2812
+ };
2813
+ responses: {
2814
+ /** @description Notification channel deleted. */
2815
+ 204: {
2816
+ content: never;
2817
+ };
2818
+ 401: components['responses']['UnauthorizedProblemResponse'];
2819
+ 404: components['responses']['NotFoundProblemResponse'];
2820
+ default: components['responses']['UnexpectedProblemResponse'];
2821
+ };
2822
+ };
2823
+ /**
2824
+ * List notification rules
2825
+ * @description List all notification rules.
2826
+ */
2827
+ listNotificationRules: {
2828
+ parameters: {
2829
+ query?: {
2830
+ limit?: components['parameters']['queryLimit'];
2831
+ offset?: components['parameters']['queryOffset'];
2832
+ /** @description Order by field */
2833
+ orderBy?: 'id' | 'type' | 'createdAt' | 'updatedAt';
2834
+ includeDisabled?: components['parameters']['queryIncludeDisabled'];
2835
+ feature?: components['parameters']['queryFilterFeature'];
2836
+ };
2837
+ };
2838
+ responses: {
2839
+ /** @description List of notification rules. */
2840
+ 200: {
2841
+ content: {
2842
+ 'application/json': components['schemas']['NotificationRules'];
2843
+ };
2844
+ };
2845
+ 400: components['responses']['BadRequestProblemResponse'];
2846
+ 401: components['responses']['UnauthorizedProblemResponse'];
2847
+ default: components['responses']['UnexpectedProblemResponse'];
2848
+ };
2849
+ };
2850
+ /**
2851
+ * Create a notification rule
2852
+ * @description Create a new notification rule.
2853
+ */
2854
+ createNotificationRule: {
2855
+ /** @description The notification rule to create. */
2856
+ requestBody: {
2857
+ content: {
2858
+ 'application/json': components['schemas']['NotificationRuleCreateRequest'];
2859
+ };
2860
+ };
2861
+ responses: {
2862
+ /** @description Notification rule created. */
2863
+ 201: {
2864
+ content: {
2865
+ 'application/json': components['schemas']['NotificationRule'];
2866
+ };
2867
+ };
2868
+ 400: components['responses']['BadRequestProblemResponse'];
2869
+ 401: components['responses']['UnauthorizedProblemResponse'];
2870
+ 409: components['responses']['ConflictProblemResponse'];
2871
+ default: components['responses']['UnexpectedProblemResponse'];
2872
+ };
2873
+ };
2874
+ /**
2875
+ * Get notification rule
2876
+ * @description Get a notification rule by id.
2877
+ */
2878
+ getNotificationRule: {
2879
+ parameters: {
2880
+ path: {
2881
+ ruleId: components['parameters']['ruleId'];
2882
+ };
2883
+ };
2884
+ responses: {
2885
+ /** @description Rule found. */
2886
+ 200: {
2887
+ content: {
2888
+ 'application/json': components['schemas']['NotificationRule'];
2889
+ };
2890
+ };
2891
+ 401: components['responses']['UnauthorizedProblemResponse'];
2892
+ 404: components['responses']['NotFoundProblemResponse'];
2893
+ default: components['responses']['UnexpectedProblemResponse'];
2894
+ };
2895
+ };
2896
+ /**
2897
+ * Update a notification rule
2898
+ * @description Update a notification rule by id.
2899
+ */
2900
+ updateNotificationRule: {
2901
+ parameters: {
2902
+ path: {
2903
+ ruleId: components['parameters']['ruleId'];
2904
+ };
2905
+ };
2906
+ /** @description The notification rule to update. */
2907
+ requestBody: {
2908
+ content: {
2909
+ 'application/json': components['schemas']['NotificationRuleCreateRequest'];
2910
+ };
2911
+ };
2912
+ responses: {
2913
+ /** @description Notification Rule updated. */
2914
+ 200: {
2915
+ content: {
2916
+ 'application/json': components['schemas']['NotificationRule'];
2917
+ };
2918
+ };
2919
+ 401: components['responses']['UnauthorizedProblemResponse'];
2920
+ 404: components['responses']['NotFoundProblemResponse'];
2921
+ default: components['responses']['UnexpectedProblemResponse'];
2922
+ };
2923
+ };
2924
+ /**
2925
+ * Delete a notification rule
2926
+ * @description Delete notification rule by id.
2927
+ */
2928
+ deleteNotificationRule: {
2929
+ parameters: {
2930
+ path: {
2931
+ ruleId: components['parameters']['ruleId'];
2932
+ };
2933
+ };
2934
+ responses: {
2935
+ /** @description Notification rule deleted. */
2936
+ 204: {
2937
+ content: never;
2938
+ };
2939
+ 401: components['responses']['UnauthorizedProblemResponse'];
2940
+ 404: components['responses']['NotFoundProblemResponse'];
2941
+ default: components['responses']['UnexpectedProblemResponse'];
2942
+ };
2943
+ };
2944
+ /**
2945
+ * List notification evens
2946
+ * @description List all notification events.
2947
+ */
2948
+ listNotificationEvents: {
2949
+ parameters: {
2950
+ query?: {
2951
+ limit?: components['parameters']['queryLimit'];
2952
+ offset?: components['parameters']['queryOffset'];
2953
+ /** @description Order by field */
2954
+ orderBy?: 'id' | 'createdAt';
2955
+ feature?: components['parameters']['queryFilterFeature'];
2956
+ subject?: components['parameters']['queryFilterSubject'];
2957
+ };
2958
+ };
2959
+ responses: {
2960
+ /** @description List of notification events. */
2961
+ 200: {
2962
+ content: {
2963
+ 'application/json': components['schemas']['NotificationEvent'][];
2964
+ };
2965
+ };
2966
+ 400: components['responses']['BadRequestProblemResponse'];
2967
+ 401: components['responses']['UnauthorizedProblemResponse'];
2968
+ default: components['responses']['UnexpectedProblemResponse'];
2969
+ };
2970
+ };
2971
+ /**
2972
+ * Get notification event
2973
+ * @description Get a notification event by id.
2974
+ */
2975
+ getNotificationEvent: {
2976
+ parameters: {
2977
+ path: {
2978
+ eventId: components['parameters']['eventId'];
2979
+ };
2980
+ };
2981
+ responses: {
2982
+ /** @description Notification event found. */
2983
+ 200: {
2984
+ content: {
2985
+ 'application/json': components['schemas']['NotificationEvent'];
2986
+ };
2987
+ };
2988
+ 401: components['responses']['UnauthorizedProblemResponse'];
2989
+ 404: components['responses']['NotFoundProblemResponse'];
2990
+ default: components['responses']['UnexpectedProblemResponse'];
2991
+ };
2992
+ };
2993
+ }
2994
+ export {};