@openmeter/sdk 1.0.0-beta.9 → 1.0.0-beta.90

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 (62) hide show
  1. package/README.md +62 -50
  2. package/dist/cjs/clients/client.cjs +117 -0
  3. package/dist/cjs/clients/client.d.cts +40 -0
  4. package/dist/cjs/clients/client.js.map +1 -0
  5. package/dist/cjs/clients/event.cjs +71 -0
  6. package/dist/cjs/clients/event.d.cts +79 -0
  7. package/dist/cjs/clients/event.js.map +1 -0
  8. package/dist/cjs/clients/meter.cjs +69 -0
  9. package/dist/cjs/clients/meter.d.cts +75 -0
  10. package/dist/cjs/clients/meter.js.map +1 -0
  11. package/dist/cjs/clients/portal.cjs +41 -0
  12. package/dist/cjs/clients/portal.d.cts +22 -0
  13. package/dist/cjs/clients/portal.js.map +1 -0
  14. package/dist/cjs/clients/subject.cjs +60 -0
  15. package/dist/cjs/clients/subject.d.cts +27 -0
  16. package/dist/cjs/clients/subject.js.map +1 -0
  17. package/dist/cjs/index.cjs +24 -0
  18. package/dist/cjs/index.d.cts +15 -0
  19. package/dist/cjs/index.js.map +1 -0
  20. package/dist/cjs/schemas/openapi.cjs +7 -0
  21. package/dist/cjs/schemas/openapi.d.cts +1850 -0
  22. package/dist/cjs/schemas/openapi.js.map +1 -0
  23. package/dist/cjs/test/agent.cjs +266 -0
  24. package/dist/cjs/test/agent.d.cts +2 -0
  25. package/dist/cjs/test/agent.js.map +1 -0
  26. package/dist/cjs/test/mocks.cjs +44 -0
  27. package/dist/cjs/test/mocks.d.cts +14 -0
  28. package/dist/cjs/test/mocks.js.map +1 -0
  29. package/dist/cjs/tsconfig.acfee89b.tsbuildinfo +1 -0
  30. package/dist/cjs/tsconfig.e6ebbd29.tsbuildinfo +1 -0
  31. package/dist/clients/client.d.ts +1 -1
  32. package/dist/clients/client.js +9 -1
  33. package/dist/clients/client.js.map +1 -0
  34. package/dist/clients/event.d.ts +5 -5
  35. package/dist/clients/event.js +29 -18
  36. package/dist/clients/event.js.map +1 -0
  37. package/dist/clients/meter.d.ts +9 -37
  38. package/dist/clients/meter.js +1 -15
  39. package/dist/clients/meter.js.map +1 -0
  40. package/dist/clients/portal.d.ts +22 -0
  41. package/dist/clients/portal.js +37 -0
  42. package/dist/clients/portal.js.map +1 -0
  43. package/dist/clients/subject.d.ts +27 -0
  44. package/dist/clients/subject.js +56 -0
  45. package/dist/clients/subject.js.map +1 -0
  46. package/dist/index.d.ts +6 -3
  47. package/dist/index.js +8 -2
  48. package/dist/index.js.map +1 -0
  49. package/dist/schemas/openapi.d.ts +1561 -250
  50. package/dist/schemas/openapi.js +1 -0
  51. package/dist/schemas/openapi.js.map +1 -0
  52. package/dist/test/agent.js +108 -29
  53. package/dist/test/agent.js.map +1 -0
  54. package/dist/test/mocks.d.ts +2 -0
  55. package/dist/test/mocks.js +9 -0
  56. package/dist/test/mocks.js.map +1 -0
  57. package/dist/tsconfig.tsbuildinfo +1 -1
  58. package/package.json +43 -33
  59. package/dist/next.d.ts +0 -15
  60. package/dist/next.js +0 -46
  61. package/index.ts +0 -24
  62. package/next.ts +0 -76
@@ -0,0 +1,1850 @@
1
+ /**
2
+ * This file was auto-generated by openapi-typescript.
3
+ * Do not make direct changes to the file.
4
+ */
5
+ export interface paths {
6
+ '/api/v1/events': {
7
+ /**
8
+ * List ingested events
9
+ * @description List ingested events within a time range.
10
+ */
11
+ get: operations['listEvents'];
12
+ /**
13
+ * Ingest events
14
+ * @description Ingests an event or batch of events following the CloudEvents specification.
15
+ */
16
+ post: operations['ingestEvents'];
17
+ };
18
+ '/api/v1/meters': {
19
+ /**
20
+ * List meters
21
+ * @description List meters.
22
+ */
23
+ get: operations['listMeters'];
24
+ /**
25
+ * ☁ Create meter
26
+ * @description *Available in OpenMeter Cloud.*
27
+ * *In the open-source version, meters are created in the configuration file.*
28
+ *
29
+ * Create a meter.
30
+ */
31
+ post: operations['createMeter'];
32
+ };
33
+ '/api/v1/meters/{meterIdOrSlug}': {
34
+ /**
35
+ * Get meter
36
+ * @description Get meter by ID or slug
37
+ */
38
+ get: operations['getMeter'];
39
+ /**
40
+ * ☁ Delete meter
41
+ * @description *Available in OpenMeter Cloud.*
42
+ *
43
+ * Delete a meter by ID or slug.
44
+ */
45
+ delete: operations['deleteMeter'];
46
+ };
47
+ '/api/v1/meters/{meterIdOrSlug}/query': {
48
+ /**
49
+ * Query meter
50
+ * @description Query meter for usage.
51
+ */
52
+ get: operations['queryMeter'];
53
+ };
54
+ '/api/v1/meters/{meterIdOrSlug}/subjects': {
55
+ /**
56
+ * List meter subjects
57
+ * @description List subjects for a meter.
58
+ */
59
+ get: operations['listMeterSubjects'];
60
+ };
61
+ '/api/v1/portal/tokens': {
62
+ /**
63
+ * ☁ List portal tokens
64
+ * @description *Available in OpenMeter Cloud.*
65
+ *
66
+ * List consumer portal tokens.
67
+ */
68
+ get: operations['listPortalTokens'];
69
+ /**
70
+ * Create portal token
71
+ * @description Create a consumer portal token.
72
+ */
73
+ post: operations['createPortalToken'];
74
+ };
75
+ '/api/v1/portal/tokens/invalidate': {
76
+ /**
77
+ * ☁ Invalidate portal tokens
78
+ * @description *Available in OpenMeter Cloud.*
79
+ *
80
+ * Invalidates consumer portal tokens by ID or subject.
81
+ */
82
+ post: operations['invalidatePortalTokens'];
83
+ };
84
+ '/api/v1/subjects': {
85
+ /**
86
+ * ☁ List subjects
87
+ * @description *Available in OpenMeter Cloud.*
88
+ *
89
+ * List subjects.
90
+ */
91
+ get: operations['listSubjects'];
92
+ /**
93
+ * ☁ Upsert subject
94
+ * @description *Available in OpenMeter Cloud.*
95
+ *
96
+ * Upserts a subject. Creates or updates subject.
97
+ * If the subject doesn't exist, it will be created.
98
+ * If the subject exists, it will be partially updated with the provided fields.
99
+ */
100
+ post: operations['upsertSubject'];
101
+ };
102
+ '/api/v1/subjects/{subjectIdOrKey}': {
103
+ /**
104
+ * ☁ Get subject
105
+ * @description *Available in OpenMeter Cloud.*
106
+ *
107
+ * Get subject by ID or key.
108
+ */
109
+ get: operations['getSubject'];
110
+ /**
111
+ * ☁ Delete subject
112
+ * @description *Available in OpenMeter Cloud.*
113
+ *
114
+ * Delete a subject by ID or key.
115
+ */
116
+ delete: operations['deleteSubject'];
117
+ };
118
+ '/api/v1/portal/meters/{meterSlug}/query': {
119
+ /**
120
+ * Query portal meter
121
+ * @description Query meter for consumer portal. This endpoint is publicly exposable to consumers.
122
+ */
123
+ get: operations['queryPortalMeter'];
124
+ };
125
+ '/api/v1/features': {
126
+ /**
127
+ * List features
128
+ * @description List features.
129
+ */
130
+ get: operations['listFeatures'];
131
+ /**
132
+ * Create feature
133
+ * @description Creates a feature.
134
+ */
135
+ post: operations['createFeature'];
136
+ };
137
+ '/api/v1/features/{featureID}': {
138
+ /**
139
+ * Get feature
140
+ * @description Get feature by key.
141
+ */
142
+ get: operations['getFeature'];
143
+ /**
144
+ * Delete feature
145
+ * @description Delete a feature by key.
146
+ */
147
+ delete: operations['deleteFeature'];
148
+ };
149
+ '/api/v1/ledgers': {
150
+ /**
151
+ * List the already defined ledgers.
152
+ * @description List the already defined ledgers.
153
+ */
154
+ get: operations['listLedgers'];
155
+ /**
156
+ * Creates the specified ledger
157
+ * @description Create or update the specified ledger.
158
+ */
159
+ post: operations['createLedger'];
160
+ };
161
+ '/api/v1/ledgers/{ledgerID}/balance': {
162
+ /**
163
+ * Get the balance of a specific subject.
164
+ * @description Get the balance of a specific subject.
165
+ */
166
+ get: operations['getLedgerBalance'];
167
+ };
168
+ '/api/v1/ledgers/{ledgerID}/history': {
169
+ /**
170
+ * Get the history of a ledger
171
+ * @description Get the history of a specific ledger
172
+ */
173
+ get: operations['getLedgerHistory'];
174
+ };
175
+ '/api/v1/ledgers/{ledgerID}/reset': {
176
+ /**
177
+ * Reset the ledger's balance
178
+ * @description Resets the ledger's balances to zero for a specific subject and re-apply active grants with rollover configuration.
179
+ */
180
+ post: operations['resetLedger'];
181
+ };
182
+ '/api/v1/ledgers/grants': {
183
+ /**
184
+ * List grants for multiple ledgers.
185
+ * @description List grants for multiple ledgers.
186
+ */
187
+ get: operations['listLedgerGrants'];
188
+ };
189
+ '/api/v1/ledgers/{ledgerID}/grants': {
190
+ /**
191
+ * List ledger grants
192
+ * @description List ledger grants for a specific ledger.
193
+ */
194
+ get: operations['listLedgerGrantsByLedger'];
195
+ /**
196
+ * Create a grant on a specific ledger.
197
+ * @description Create a grant on a specific ledger.
198
+ */
199
+ post: operations['createLedgerGrant'];
200
+ };
201
+ '/api/v1/ledgers/{ledgerID}/grants/{ledgerGrantID}': {
202
+ /**
203
+ * Get a single grant.
204
+ * @description Gets the grant for a ledger by ID.
205
+ */
206
+ get: operations['getLedgerGrant'];
207
+ /**
208
+ * Void ledger grant
209
+ * @description Void a ledger grant by ID. Partially or fully used grants cannot be voided.
210
+ * Voided grant won't be applied to the subject's balance anymore.
211
+ */
212
+ delete: operations['voidLedgerGrant'];
213
+ };
214
+ }
215
+ export type webhooks = Record<string, never>;
216
+ export interface components {
217
+ schemas: {
218
+ /**
219
+ * @description A Problem Details object (RFC 7807).
220
+ * Additional properties specific to the problem type may be present.
221
+ * @example {
222
+ * "type": "urn:problem-type:bad-request",
223
+ * "title": "Bad Request",
224
+ * "status": 400,
225
+ * "detail": "body must be a JSON object"
226
+ * }
227
+ */
228
+ Problem: {
229
+ /**
230
+ * Format: uri
231
+ * @description Type contains a URI that identifies the problem type.
232
+ * @example urn:problem-type:bad-request
233
+ */
234
+ type: string;
235
+ /**
236
+ * @description A a short, human-readable summary of the problem type.
237
+ * @example Bad Request
238
+ */
239
+ title: string;
240
+ /**
241
+ * Format: int32
242
+ * @description The HTTP status code generated by the origin server for this occurrence of the problem.
243
+ * @example 400
244
+ */
245
+ status: number;
246
+ /**
247
+ * @description A human-readable explanation specific to this occurrence of the problem.
248
+ * @example body must be a JSON object
249
+ */
250
+ detail: string;
251
+ /**
252
+ * Format: uri
253
+ * @description A URI reference that identifies the specific occurrence of the problem.
254
+ * @example urn:request:local/JMOlctsKV8-000001
255
+ */
256
+ instance?: string;
257
+ [key: string]: unknown;
258
+ };
259
+ /**
260
+ * @description CloudEvents Specification JSON Schema
261
+ * @example {
262
+ * "id": "5c10fade-1c9e-4d6c-8275-c52c36731d3c",
263
+ * "source": "service-name",
264
+ * "specversion": "1.0",
265
+ * "type": "prompt",
266
+ * "subject": "customer-id",
267
+ * "time": "2023-01-01T01:01:01.001Z",
268
+ * "data": {
269
+ * "tokens": "1234",
270
+ * "model": "gpt-4-turbo",
271
+ * "type": "input"
272
+ * }
273
+ * }
274
+ */
275
+ Event: {
276
+ /**
277
+ * @description Identifies the event.
278
+ * @example 5c10fade-1c9e-4d6c-8275-c52c36731d3c
279
+ */
280
+ id: string;
281
+ /**
282
+ * Format: uri-reference
283
+ * @description Identifies the context in which an event happened.
284
+ * @example service-name
285
+ */
286
+ source: string;
287
+ /**
288
+ * @description The version of the CloudEvents specification which the event uses.
289
+ * @example 1.0
290
+ */
291
+ specversion: string;
292
+ /**
293
+ * @description Describes the type of event related to the originating occurrence.
294
+ * @example prompt
295
+ */
296
+ type: string;
297
+ /**
298
+ * @description Content type of the data value. Must adhere to RFC 2046 format.
299
+ * @example application/json
300
+ * @enum {string|null}
301
+ */
302
+ datacontenttype?: 'application/json' | null;
303
+ /**
304
+ * Format: uri
305
+ * @description Identifies the schema that data adheres to.
306
+ */
307
+ dataschema?: string | null;
308
+ /**
309
+ * @description Describes the subject of the event in the context of the event producer (identified by source).
310
+ * @example customer-id
311
+ */
312
+ subject: string;
313
+ /**
314
+ * Format: date-time
315
+ * @description Timestamp of when the occurrence happened. Must adhere to RFC 3339.
316
+ * @example 2023-01-01T01:01:01.001Z
317
+ */
318
+ time?: string | null;
319
+ /**
320
+ * @description The event payload.
321
+ * @example {
322
+ * "tokens": "1234",
323
+ * "model": "gpt-4-turbo"
324
+ * }
325
+ */
326
+ data?: {
327
+ [key: string]: unknown;
328
+ };
329
+ };
330
+ /**
331
+ * @description An ingested event with optional validation error.
332
+ * @example {
333
+ * "event": {
334
+ * "id": "5c10fade-1c9e-4d6c-8275-c52c36731d3d",
335
+ * "source": "service-name",
336
+ * "specversion": "1.0",
337
+ * "type": "prompt",
338
+ * "subject": "customer-id",
339
+ * "time": "2023-01-01T01:01:01.001Z",
340
+ * "data": {
341
+ * "tokens": "1234",
342
+ * "model": "gpt-4-turbo"
343
+ * }
344
+ * },
345
+ * "validationError": "meter not found for event"
346
+ * }
347
+ */
348
+ IngestedEvent: {
349
+ event: components['schemas']['Event'];
350
+ /** @example invalid event */
351
+ validationError?: string;
352
+ };
353
+ /**
354
+ * @description A feature is a feature or service offered to a customer.
355
+ * For example: CPU-Hours, Tokens, API Calls, etc.
356
+ */
357
+ CreateFeatureRequest: {
358
+ /**
359
+ * @description The name of the feature.
360
+ *
361
+ * @example AI Tokens
362
+ */
363
+ name: string;
364
+ /**
365
+ * @description The meter that the feature is associated with and decreases grants by usage.
366
+ *
367
+ * @example tokens_total
368
+ */
369
+ meterSlug: string;
370
+ /**
371
+ * @description Optional meter group by filters. Useful if the meter scope is broader than what feature tracks.
372
+ *
373
+ * @example {
374
+ * "model": "gpt-4"
375
+ * }
376
+ */
377
+ meterGroupByFilters?: {
378
+ [key: string]: string;
379
+ };
380
+ /**
381
+ * @description If the feature is archived, it will not be used for grants or usage.
382
+ *
383
+ * @example false
384
+ */
385
+ archived?: boolean;
386
+ };
387
+ /**
388
+ * @description A feature is a feature or service offered to a customer.
389
+ * For example: CPU-Hours, Tokens, API Calls, etc.
390
+ */
391
+ Feature: components['schemas']['CreateFeatureRequest'] & {
392
+ /**
393
+ * @description Readonly unique ULID identifier of the feature.
394
+ *
395
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
396
+ */
397
+ id: string;
398
+ /**
399
+ * Format: date-time
400
+ * @description The time the feature was created.
401
+ *
402
+ * @example 2023-01-01T00:00:00Z
403
+ */
404
+ createdAt?: string;
405
+ /**
406
+ * Format: date-time
407
+ * @description The time the feature was last updated.
408
+ *
409
+ * @example 2023-01-01T00:00:00Z
410
+ */
411
+ updatedAt?: string;
412
+ };
413
+ /**
414
+ * @description A ledger represented in open meter. A ledger must be assigned to a single
415
+ * subject.
416
+ */
417
+ CreateLedger: {
418
+ /** @description The metering subject this ledger used to track grants for. */
419
+ subject: string;
420
+ /**
421
+ * @example {
422
+ * "stripePaymentId": "pi_4OrAkhLvyihio9p51h9iiFnB"
423
+ * }
424
+ */
425
+ metadata?: {
426
+ [key: string]: string;
427
+ };
428
+ };
429
+ /**
430
+ * @description Ledger Exists
431
+ * @example {
432
+ * "type": "about:blank",
433
+ * "title": "Conflict",
434
+ * "status": 409,
435
+ * "detail": "ledger (default.01HXVNDJR532E8GTBVSC2XK5D4) already exitst for subject subject-1",
436
+ * "instance": "urn:request:local/JMOlctsKV8-000001",
437
+ * "conflictingEntity": {
438
+ * "id": "01HXVNDJR532E8GTBVSC2XK5D4",
439
+ * "subject": "subject-1"
440
+ * }
441
+ * }
442
+ */
443
+ LedgerAlreadyExistsProblem: {
444
+ /**
445
+ * Format: uri
446
+ * @description Type contains a URI that identifies the problem type.
447
+ * @example urn:problem-type:bad-request
448
+ */
449
+ type: string;
450
+ /**
451
+ * @description A a short, human-readable summary of the problem type.
452
+ * @example Bad Request
453
+ */
454
+ title: string;
455
+ /**
456
+ * Format: int32
457
+ * @description The HTTP status code generated by the origin server for this occurrence of the problem.
458
+ * @example 400
459
+ */
460
+ status: number;
461
+ /**
462
+ * @description A human-readable explanation specific to this occurrence of the problem.
463
+ * @example body must be a JSON object
464
+ */
465
+ detail: string;
466
+ /**
467
+ * Format: uri
468
+ * @description A URI reference that identifies the specific occurrence of the problem.
469
+ * @example urn:request:local/JMOlctsKV8-000001
470
+ */
471
+ instance?: string;
472
+ conflictingEntity?: components['schemas']['Ledger'];
473
+ [key: string]: unknown;
474
+ };
475
+ /** @description A ledger represented in our system. */
476
+ Ledger: components['schemas']['CreateLedger'] & {
477
+ /**
478
+ * @description Readonly unique ULID identifier of the ledger.
479
+ *
480
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
481
+ */
482
+ id: string;
483
+ /**
484
+ * Format: date-time
485
+ * @description The time the ledger was created.
486
+ *
487
+ * @example 2023-01-01T00:00:00Z
488
+ */
489
+ createdAt?: string;
490
+ };
491
+ /** @description A ledger entry. */
492
+ LedgerEntry: {
493
+ /**
494
+ * @description Readonly unique ULID identifier of the ledger entry.
495
+ *
496
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
497
+ */
498
+ id: string;
499
+ type: components['schemas']['LedgerEntryType'];
500
+ /**
501
+ * Format: date-time
502
+ * @description The time the ledger entry was created.
503
+ *
504
+ * @example 2023-01-01T00:00:00Z
505
+ */
506
+ time: string;
507
+ /**
508
+ * Format: double
509
+ * @description The amount to apply. Can be positive or negative number. If applicable.
510
+ *
511
+ * @example 100
512
+ */
513
+ amount: number;
514
+ /**
515
+ * @description The unique feature ULID that the entry is associated with.
516
+ *
517
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
518
+ */
519
+ featureID: string;
520
+ period?: components['schemas']['Period'];
521
+ };
522
+ /** @description A time period */
523
+ Period: {
524
+ /**
525
+ * Format: date-time
526
+ * @description Period start time where the amount was applied. If applicable.
527
+ *
528
+ * @example 2023-01-01T00:00:00Z
529
+ */
530
+ from: string;
531
+ /**
532
+ * Format: date-time
533
+ * @description Period end time where the amount was applied. If applicable.
534
+ *
535
+ * @example 2023-01-01T00:00:00Z
536
+ */
537
+ to: string;
538
+ };
539
+ /**
540
+ * @example GRANT
541
+ * @enum {string}
542
+ */
543
+ LedgerEntryType: 'GRANT' | 'VOID' | 'RESET' | 'GRANT_USAGE';
544
+ /** @description Balance of a subject. */
545
+ LedgerBalance: {
546
+ /** @description Features with balances. */
547
+ featureBalances: components['schemas']['FeatureBalance'][];
548
+ /** @description The grants applied to the subject. */
549
+ grantBalances: components['schemas']['LedgerGrantBalance'][];
550
+ /**
551
+ * @example {
552
+ * "stripePaymentId": "pi_4OrAkhLvyihio9p51h9iiFnB"
553
+ * }
554
+ */
555
+ metadata?: {
556
+ [key: string]: string;
557
+ };
558
+ /**
559
+ * @description The subject of the ledger.
560
+ *
561
+ * @example subject-1
562
+ */
563
+ subject: string;
564
+ /**
565
+ * Format: date-time
566
+ * @description The last reset of the ledger.
567
+ *
568
+ * @example 2023-01-01T00:00:00Z
569
+ */
570
+ lastReset?: string;
571
+ };
572
+ /** @description Ledger reset configuration. */
573
+ LedgerReset: {
574
+ /**
575
+ * @description Readonly unique ULID identifier of the reset.
576
+ *
577
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
578
+ */
579
+ id: string;
580
+ /**
581
+ * Format: date-time
582
+ * @description The time to reset the ledger. It cannot be in the future.
583
+ * The value will be floored to metering windowSize (minute).
584
+ *
585
+ * @example 2023-01-01T00:00:00Z
586
+ */
587
+ effectiveAt: string;
588
+ };
589
+ LedgerGrantBalance: components['schemas']['LedgerGrantResponse'] & {
590
+ /**
591
+ * Format: double
592
+ * @description The balance of the grant.
593
+ *
594
+ * @example 100
595
+ */
596
+ balance: number;
597
+ };
598
+ FeatureBalance: components['schemas']['Feature'] & {
599
+ /**
600
+ * Format: double
601
+ * @description The balance of the feature.
602
+ *
603
+ * @example 100
604
+ */
605
+ balance: number;
606
+ /**
607
+ * Format: double
608
+ * @description The usage of the feature.
609
+ *
610
+ * @example 100
611
+ */
612
+ usage: number;
613
+ };
614
+ /** @description Grants are used to increase balance of specific subjects. */
615
+ CreateLedgerGrantRequest: {
616
+ type: components['schemas']['LedgerGrantType'];
617
+ /**
618
+ * Format: double
619
+ * @description The amount to grant. Can be positive or negative number.
620
+ *
621
+ * @example 100
622
+ */
623
+ amount: number;
624
+ /**
625
+ * @description The unique feature ULID that the grant is associated with, if any.
626
+ *
627
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
628
+ */
629
+ featureID: string;
630
+ /**
631
+ * @description The priority of the grant. Grants with higher priority are applied first.
632
+ * Priority is a positive decimal numbers. With lower numbers indicating higher importance.
633
+ * For example, a priority of 1 is more urgent than a priority of 2.
634
+ * When there are several grants available for the same subject, the system selects the grant with the highest priority.
635
+ * In cases where grants share the same priority level, the grant closest to its expiration will be used first.
636
+ * In the case of two grants have identical priorities and expiration dates, the system will use the grant that was created first.
637
+ *
638
+ * @default 1
639
+ * @example 1
640
+ */
641
+ priority?: number;
642
+ /**
643
+ * Format: date-time
644
+ * @description The effective time. Provided value will be ceiled to metering windowSize (minute).
645
+ *
646
+ * @example 2023-01-01T00:00:00Z
647
+ */
648
+ effectiveAt: string;
649
+ expiration: components['schemas']['LedgerGrantExpirationPeriod'];
650
+ rollover?: components['schemas']['LedgerGrantRollover'];
651
+ /**
652
+ * @example {
653
+ * "stripePaymentId": "pi_4OrAkhLvyihio9p51h9iiFnB"
654
+ * }
655
+ */
656
+ metadata?: {
657
+ [key: string]: string;
658
+ };
659
+ /**
660
+ * @description The parent grant ULID that the grant is associated with, if any.
661
+ *
662
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
663
+ */
664
+ parentId?: string;
665
+ /**
666
+ * Format: date-time
667
+ * @description The time the grant was created.
668
+ *
669
+ * @example 2023-01-01T00:00:00Z
670
+ */
671
+ createdAt?: string;
672
+ /**
673
+ * Format: date-time
674
+ * @description The time the grant was last updated.
675
+ *
676
+ * @example 2023-01-01T00:00:00Z
677
+ */
678
+ updatedAt?: string;
679
+ };
680
+ LedgerGrantResponse: components['schemas']['CreateLedgerGrantRequest'] & {
681
+ /**
682
+ * @description Readonly unique ULID identifier of the grant.
683
+ *
684
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
685
+ */
686
+ id: string;
687
+ /**
688
+ * @description The ledger ID.
689
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
690
+ */
691
+ ledgerID: string;
692
+ /**
693
+ * @description If the grant is voided, it will not be applied to the subject's balance anymore.
694
+ *
695
+ * @example false
696
+ */
697
+ void: boolean;
698
+ /**
699
+ * Format: date-time
700
+ * @description The expiration date of the grant.
701
+ *
702
+ * @example 2023-01-01T00:00:00Z
703
+ */
704
+ expiresAt?: string;
705
+ };
706
+ /**
707
+ * @description The grant type:
708
+ * - `USAGE` - Increase balance by the amount in the unit of the associated meter.
709
+ *
710
+ * @example USAGE
711
+ * @enum {string}
712
+ */
713
+ LedgerGrantType: 'USAGE';
714
+ /** @description Grant rollover configuration. */
715
+ LedgerGrantRollover: {
716
+ type: components['schemas']['LedgerGrantRolloverType'];
717
+ /** @description Maximum amount to rollover. */
718
+ maxAmount?: number;
719
+ };
720
+ /**
721
+ * @description The rollover type to use:
722
+ * - `REMAINING_AMOUNT` - Rollover remaining amount.
723
+ * - `ORIGINAL_AMOUNT` - Rollover re-applies the full grant amount.
724
+ *
725
+ * @example ORIGINAL_AMOUNT
726
+ * @enum {string}
727
+ */
728
+ LedgerGrantRolloverType: 'REMAINING_AMOUNT' | 'ORIGINAL_AMOUNT';
729
+ /** @description Expiration period of a ledger grant. */
730
+ LedgerGrantExpirationPeriod: {
731
+ /**
732
+ * @description The expiration period duration like month.
733
+ *
734
+ * @enum {string}
735
+ */
736
+ duration: 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';
737
+ /**
738
+ * @description The expiration period count like 12 months.
739
+ *
740
+ * @example 12
741
+ */
742
+ count: number;
743
+ };
744
+ /**
745
+ * @description A meter is a configuration that defines how to match and aggregate events.
746
+ * @example {
747
+ * "slug": "tokens_total",
748
+ * "description": "AI token usage",
749
+ * "aggregation": "SUM",
750
+ * "windowSize": "MINUTE",
751
+ * "eventType": "prompt",
752
+ * "valueProperty": "$.tokens",
753
+ * "groupBy": {
754
+ * "model": "$.model",
755
+ * "type": "$.type"
756
+ * }
757
+ * }
758
+ */
759
+ Meter: {
760
+ /**
761
+ * @description A unique identifier for the meter.
762
+ * @example 01G65Z755AFWAKHE12NY0CQ9FH
763
+ */
764
+ id?: string;
765
+ /**
766
+ * @description A unique, human-readable identifier for the meter. Must consist only alphanumeric and underscore characters.
767
+ * @example tokens_total
768
+ */
769
+ slug: string;
770
+ /**
771
+ * @description A description of the meter.
772
+ * @example AI Token Usage
773
+ */
774
+ description?: string | null;
775
+ aggregation: components['schemas']['MeterAggregation'];
776
+ windowSize: components['schemas']['WindowSize'];
777
+ /**
778
+ * @description The event type to aggregate.
779
+ * @example prompt
780
+ */
781
+ eventType: string;
782
+ /**
783
+ * @description JSONPath expression to extract the value from the ingested event's data property.
784
+ * The ingested value for SUM, AVG, MIN, and MAX aggregations is a number or a string that can be parsed to a number.
785
+ * For UNIQUE_COUNT aggregation, the ingested value must be a string. For COUNT aggregation the valueProperty is ignored.
786
+ *
787
+ * @example $.tokens
788
+ */
789
+ valueProperty?: string;
790
+ /**
791
+ * @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.
792
+ * @example {
793
+ * "model": "$.model",
794
+ * "type": "$.type"
795
+ * }
796
+ */
797
+ groupBy?: {
798
+ [key: string]: string;
799
+ };
800
+ };
801
+ /**
802
+ * @description The aggregation type to use for the meter.
803
+ * @example SUM
804
+ * @enum {string}
805
+ */
806
+ MeterAggregation: 'SUM' | 'COUNT' | 'UNIQUE_COUNT' | 'AVG' | 'MIN' | 'MAX';
807
+ /**
808
+ * @description Aggregation window size.
809
+ * @example MINUTE
810
+ * @enum {string}
811
+ */
812
+ WindowSize: 'MINUTE' | 'HOUR' | 'DAY';
813
+ /**
814
+ * @description The result of a meter query.
815
+ * @example {
816
+ * "from": "2023-01-01T00:00:00Z",
817
+ * "to": "2023-01-02T00:00:00Z",
818
+ * "windowSize": "MINUTE",
819
+ * "data": [
820
+ * {
821
+ * "value": 12,
822
+ * "windowStart": "2023-01-01T00:00:00Z",
823
+ * "windowEnd": "2023-01-02T00:00:00Z",
824
+ * "subject": "customer-id",
825
+ * "groupBy": {
826
+ * "model": "gpt-4-turbo",
827
+ * "type": "prompt"
828
+ * }
829
+ * }
830
+ * ]
831
+ * }
832
+ */
833
+ MeterQueryResult: {
834
+ /**
835
+ * Format: date-time
836
+ * @example 2023-01-01T00:00:00Z
837
+ */
838
+ from?: string;
839
+ /**
840
+ * Format: date-time
841
+ * @example 2023-01-02T00:00:00Z
842
+ */
843
+ to?: string;
844
+ windowSize?: components['schemas']['WindowSize'];
845
+ /**
846
+ * @example [
847
+ * {
848
+ * "value": 12,
849
+ * "windowStart": "2023-01-01T00:00:00Z",
850
+ * "windowEnd": "2023-01-02T00:00:00Z",
851
+ * "subject": "customer-id",
852
+ * "groupBy": {
853
+ * "model": "gpt-4-turbo",
854
+ * "type": "prompt"
855
+ * }
856
+ * }
857
+ * ]
858
+ */
859
+ data: components['schemas']['MeterQueryRow'][];
860
+ };
861
+ /**
862
+ * @description A row in the result of a meter query.
863
+ * @example {
864
+ * "value": 12,
865
+ * "windowStart": "2023-01-01T00:00:00Z",
866
+ * "windowEnd": "2023-01-02T00:00:00Z",
867
+ * "subject": "customer-id",
868
+ * "groupBy": {
869
+ * "model": "gpt-4-turbo",
870
+ * "type": "prompt"
871
+ * }
872
+ * }
873
+ */
874
+ MeterQueryRow: {
875
+ /** @example 12 */
876
+ value: number;
877
+ /**
878
+ * Format: date-time
879
+ * @example 2023-01-01T00:00:00Z
880
+ */
881
+ windowStart: string;
882
+ /**
883
+ * Format: date-time
884
+ * @example 2023-01-02T00:00:00Z
885
+ */
886
+ windowEnd: string;
887
+ /**
888
+ * @description The subject of the meter value.
889
+ * @example customer-id
890
+ */
891
+ subject?: string | null;
892
+ /**
893
+ * @example {
894
+ * "model": "gpt-4-turbo",
895
+ * "type": "prompt"
896
+ * }
897
+ */
898
+ groupBy?: {
899
+ [key: string]: string;
900
+ } | null;
901
+ };
902
+ /**
903
+ * @description A consumer portal token.
904
+ * @example {
905
+ * "id": "01G65Z755AFWAKHE12NY0CQ9FH",
906
+ * "subject": "customer-id",
907
+ * "expiresAt": "2023-01-02T00:00:00Z",
908
+ * "expired": false,
909
+ * "createdAt": "2023-01-01T00:00:00Z",
910
+ * "token": "om_portal_IAnD3PpWW2A2Wr8m9jfzeHlGX8xmCXwG.y5q4S-AWqFu6qjfaFz0zQq4Ez28RsnyVwJffX5qxMvo",
911
+ * "allowedMeterSlugs": [
912
+ * "tokens_total"
913
+ * ]
914
+ * }
915
+ */
916
+ PortalToken: {
917
+ /** @example 01G65Z755AFWAKHE12NY0CQ9FH */
918
+ id?: string;
919
+ /** @example customer-id */
920
+ subject: string;
921
+ /**
922
+ * Format: date-time
923
+ * @example 2023-01-02T00:00:00Z
924
+ */
925
+ expiresAt?: string;
926
+ expired?: boolean;
927
+ /**
928
+ * Format: date-time
929
+ * @example 2023-01-01T00:00:00Z
930
+ */
931
+ createdAt?: string;
932
+ /**
933
+ * @description The token is only returned at creation.
934
+ * @example om_portal_IAnD3PpWW2A2Wr8m9jfzeHlGX8xmCXwG.y5q4S-AWqFu6qjfaFz0zQq4Ez28RsnyVwJffX5qxMvo
935
+ */
936
+ token?: string;
937
+ /**
938
+ * @description Optional, if defined only the specified meters will be allowed
939
+ * @example [
940
+ * "tokens_total"
941
+ * ]
942
+ */
943
+ allowedMeterSlugs?: string[];
944
+ };
945
+ /**
946
+ * @description A subject is a unique identifier for a user or entity.
947
+ * @example {
948
+ * "id": "01G65Z755AFWAKHE12NY0CQ9FH",
949
+ * "key": "customer-id",
950
+ * "displayName": "Customer Name",
951
+ * "metadata": {
952
+ * "hubspotId": "123456"
953
+ * },
954
+ * "currentPeriodStart": "2023-01-01T00:00:00Z",
955
+ * "currentPeriodEnd": "2023-02-01T00:00:00Z",
956
+ * "stripeCustomerId": "cus_JMOlctsKV8"
957
+ * }
958
+ */
959
+ Subject: {
960
+ /** @example 01G65Z755AFWAKHE12NY0CQ9FH */
961
+ id?: string;
962
+ /** @example customer-id */
963
+ key: string;
964
+ /** @example Customer Name */
965
+ displayName?: string | null;
966
+ /**
967
+ * @example {
968
+ * "hubspotId": "123456"
969
+ * }
970
+ */
971
+ metadata?: {
972
+ [key: string]: unknown;
973
+ } | null;
974
+ /**
975
+ * Format: date-time
976
+ * @example 2023-01-01T00:00:00Z
977
+ */
978
+ currentPeriodStart?: string | null;
979
+ /**
980
+ * Format: date-time
981
+ * @example 2023-02-01T00:00:00Z
982
+ */
983
+ currentPeriodEnd?: string | null;
984
+ /** @example cus_JMOlctsKV8 */
985
+ stripeCustomerId?: string | null;
986
+ };
987
+ /**
988
+ * @description A unique identifier.
989
+ * @example tokens_total
990
+ */
991
+ IdOrSlug: string;
992
+ };
993
+ responses: {
994
+ /** @description Bad Request */
995
+ BadRequestProblemResponse: {
996
+ content: {
997
+ 'application/problem+json': components['schemas']['Problem'];
998
+ };
999
+ };
1000
+ /** @description Unauthorized */
1001
+ UnauthorizedProblemResponse: {
1002
+ content: {
1003
+ 'application/problem+json': components['schemas']['Problem'];
1004
+ };
1005
+ };
1006
+ /** @description Ledger Exists */
1007
+ LedgerAlreadyExistsProblemResponse: {
1008
+ content: {
1009
+ 'application/problem+json': components['schemas']['LedgerAlreadyExistsProblem'];
1010
+ };
1011
+ };
1012
+ /** @description Not Found */
1013
+ NotFoundProblemResponse: {
1014
+ content: {
1015
+ 'application/problem+json': components['schemas']['Problem'];
1016
+ };
1017
+ };
1018
+ /** @description Not Implemented */
1019
+ NotImplementedProblemResponse: {
1020
+ content: {
1021
+ 'application/problem+json': components['schemas']['Problem'];
1022
+ };
1023
+ };
1024
+ /** @description Unexpected error */
1025
+ UnexpectedProblemResponse: {
1026
+ content: {
1027
+ 'application/problem+json': components['schemas']['Problem'];
1028
+ };
1029
+ };
1030
+ };
1031
+ parameters: {
1032
+ /** @description A unique identifier for the meter. */
1033
+ meterIdOrSlug: components['schemas']['IdOrSlug'];
1034
+ /** @description A unique identifier for a subject. */
1035
+ subjectIdOrKey: string;
1036
+ /** @description A unique ULID identifier for a feature. */
1037
+ featureID: string;
1038
+ /** @description A unique identifier for a ledger grant. */
1039
+ ledgerGrantID: string;
1040
+ /** @description A unique identifier for a ledger. */
1041
+ ledgerID: string;
1042
+ /** @description Include void entries in the response. */
1043
+ ledgerIncludeVoids?: boolean;
1044
+ /** @description Number of entries to return */
1045
+ ledgerQueryLimit?: number;
1046
+ /** @description Number of entries to skip */
1047
+ ledgerQueryOffset?: number;
1048
+ /**
1049
+ * @description Start date-time in RFC 3339 format.
1050
+ * Inclusive.
1051
+ */
1052
+ queryFrom?: string;
1053
+ /**
1054
+ * @description End date-time in RFC 3339 format.
1055
+ * Inclusive.
1056
+ */
1057
+ queryTo?: string;
1058
+ /** @description If not specified, a single usage aggregate will be returned for the entirety of the specified period for each subject and group. */
1059
+ queryWindowSize?: components['schemas']['WindowSize'];
1060
+ /**
1061
+ * @description The value is the name of the time zone as defined in the IANA Time Zone Database (http://www.iana.org/time-zones).
1062
+ * If not specified, the UTC timezone will be used.
1063
+ */
1064
+ queryWindowTimeZone?: string;
1065
+ /**
1066
+ * @description Filtering and group by multiple subjects.
1067
+ *
1068
+ * Usage: `?ledgerID=01HX6VK5C498B3ABY9PR1069PP`
1069
+ *
1070
+ * @example 01HX6VK5C498B3ABY9PR1069PP
1071
+ */
1072
+ queryFilterLedgerID?: string;
1073
+ /**
1074
+ * @description Filtering by multiple subjects.
1075
+ *
1076
+ * Usage: ?subject=customer-1&subject=customer-2
1077
+ */
1078
+ queryFilterSubject?: string[];
1079
+ queryFilterGroupBy?: {
1080
+ [key: string]: string;
1081
+ };
1082
+ /**
1083
+ * @description If not specified a single aggregate will be returned for each subject and time window.
1084
+ * `subject` is a reserved group by value.
1085
+ */
1086
+ queryGroupBy?: string[];
1087
+ };
1088
+ requestBodies: never;
1089
+ headers: never;
1090
+ pathItems: never;
1091
+ }
1092
+ export type $defs = Record<string, never>;
1093
+ export type external = Record<string, never>;
1094
+ export interface operations {
1095
+ /**
1096
+ * List ingested events
1097
+ * @description List ingested events within a time range.
1098
+ */
1099
+ listEvents: {
1100
+ parameters: {
1101
+ query?: {
1102
+ from?: components['parameters']['queryFrom'];
1103
+ to?: components['parameters']['queryTo'];
1104
+ /** @description Number of events to return */
1105
+ limit?: number;
1106
+ };
1107
+ };
1108
+ responses: {
1109
+ /** @description List of events for debugging. */
1110
+ 200: {
1111
+ content: {
1112
+ 'application/json': components['schemas']['IngestedEvent'][];
1113
+ };
1114
+ };
1115
+ 400: components['responses']['BadRequestProblemResponse'];
1116
+ 401: components['responses']['UnauthorizedProblemResponse'];
1117
+ default: components['responses']['UnexpectedProblemResponse'];
1118
+ };
1119
+ };
1120
+ /**
1121
+ * Ingest events
1122
+ * @description Ingests an event or batch of events following the CloudEvents specification.
1123
+ */
1124
+ ingestEvents: {
1125
+ /**
1126
+ * @description The event or batch of events to ingest.
1127
+ * The request body must be a CloudEvents JSON object or an array of CloudEvents JSON objects.
1128
+ * The CloudEvents JSON object must adhere to the CloudEvents Specification JSON Schema.
1129
+ */
1130
+ requestBody: {
1131
+ content: {
1132
+ 'application/cloudevents+json': components['schemas']['Event'];
1133
+ 'application/cloudevents-batch+json': components['schemas']['Event'][];
1134
+ };
1135
+ };
1136
+ responses: {
1137
+ /** @description Successfully ingested. */
1138
+ 204: {
1139
+ content: never;
1140
+ };
1141
+ 400: components['responses']['BadRequestProblemResponse'];
1142
+ 401: components['responses']['UnauthorizedProblemResponse'];
1143
+ default: components['responses']['UnexpectedProblemResponse'];
1144
+ };
1145
+ };
1146
+ /**
1147
+ * List meters
1148
+ * @description List meters.
1149
+ */
1150
+ listMeters: {
1151
+ responses: {
1152
+ /** @description List of meters. */
1153
+ 200: {
1154
+ content: {
1155
+ 'application/json': components['schemas']['Meter'][];
1156
+ };
1157
+ };
1158
+ 401: components['responses']['UnauthorizedProblemResponse'];
1159
+ default: components['responses']['UnexpectedProblemResponse'];
1160
+ };
1161
+ };
1162
+ /**
1163
+ * ☁ Create meter
1164
+ * @description *Available in OpenMeter Cloud.*
1165
+ * *In the open-source version, meters are created in the configuration file.*
1166
+ *
1167
+ * Create a meter.
1168
+ */
1169
+ createMeter: {
1170
+ /** @description The meter to create. */
1171
+ requestBody: {
1172
+ content: {
1173
+ 'application/json': components['schemas']['Meter'];
1174
+ };
1175
+ };
1176
+ responses: {
1177
+ /** @description Created. */
1178
+ 201: {
1179
+ content: {
1180
+ 'application/json': components['schemas']['Meter'];
1181
+ };
1182
+ };
1183
+ 400: components['responses']['BadRequestProblemResponse'];
1184
+ 401: components['responses']['UnauthorizedProblemResponse'];
1185
+ 501: components['responses']['NotImplementedProblemResponse'];
1186
+ default: components['responses']['UnexpectedProblemResponse'];
1187
+ };
1188
+ };
1189
+ /**
1190
+ * Get meter
1191
+ * @description Get meter by ID or slug
1192
+ */
1193
+ getMeter: {
1194
+ parameters: {
1195
+ path: {
1196
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
1197
+ };
1198
+ };
1199
+ responses: {
1200
+ /** @description Meter found. */
1201
+ 200: {
1202
+ content: {
1203
+ 'application/json': components['schemas']['Meter'];
1204
+ };
1205
+ };
1206
+ 404: components['responses']['NotFoundProblemResponse'];
1207
+ default: components['responses']['UnexpectedProblemResponse'];
1208
+ };
1209
+ };
1210
+ /**
1211
+ * ☁ Delete meter
1212
+ * @description *Available in OpenMeter Cloud.*
1213
+ *
1214
+ * Delete a meter by ID or slug.
1215
+ */
1216
+ deleteMeter: {
1217
+ parameters: {
1218
+ path: {
1219
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
1220
+ };
1221
+ };
1222
+ responses: {
1223
+ /** @description Meter deleted. */
1224
+ 204: {
1225
+ content: never;
1226
+ };
1227
+ 404: components['responses']['NotFoundProblemResponse'];
1228
+ 501: components['responses']['NotImplementedProblemResponse'];
1229
+ default: components['responses']['UnexpectedProblemResponse'];
1230
+ };
1231
+ };
1232
+ /**
1233
+ * Query meter
1234
+ * @description Query meter for usage.
1235
+ */
1236
+ queryMeter: {
1237
+ parameters: {
1238
+ query?: {
1239
+ from?: components['parameters']['queryFrom'];
1240
+ to?: components['parameters']['queryTo'];
1241
+ windowSize?: components['parameters']['queryWindowSize'];
1242
+ windowTimeZone?: components['parameters']['queryWindowTimeZone'];
1243
+ subject?: components['parameters']['queryFilterSubject'];
1244
+ filterGroupBy?: components['parameters']['queryFilterGroupBy'];
1245
+ groupBy?: components['parameters']['queryGroupBy'];
1246
+ };
1247
+ path: {
1248
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
1249
+ };
1250
+ };
1251
+ responses: {
1252
+ /** @description Usage data. */
1253
+ 200: {
1254
+ content: {
1255
+ 'application/json': components['schemas']['MeterQueryResult'];
1256
+ 'text/csv': string;
1257
+ };
1258
+ };
1259
+ 400: components['responses']['BadRequestProblemResponse'];
1260
+ 401: components['responses']['UnauthorizedProblemResponse'];
1261
+ default: components['responses']['UnexpectedProblemResponse'];
1262
+ };
1263
+ };
1264
+ /**
1265
+ * List meter subjects
1266
+ * @description List subjects for a meter.
1267
+ */
1268
+ listMeterSubjects: {
1269
+ parameters: {
1270
+ path: {
1271
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
1272
+ };
1273
+ };
1274
+ responses: {
1275
+ /** @description List of subjects. */
1276
+ 200: {
1277
+ content: {
1278
+ 'application/json': string[];
1279
+ };
1280
+ };
1281
+ 400: components['responses']['BadRequestProblemResponse'];
1282
+ default: components['responses']['UnexpectedProblemResponse'];
1283
+ };
1284
+ };
1285
+ /**
1286
+ * ☁ List portal tokens
1287
+ * @description *Available in OpenMeter Cloud.*
1288
+ *
1289
+ * List consumer portal tokens.
1290
+ */
1291
+ listPortalTokens: {
1292
+ parameters: {
1293
+ query?: {
1294
+ /** @description Number of portal tokens to return. Default is 25. */
1295
+ limit?: number;
1296
+ };
1297
+ };
1298
+ responses: {
1299
+ /** @description List of portal tokens. */
1300
+ 200: {
1301
+ content: {
1302
+ 'application/json': components['schemas']['PortalToken'][];
1303
+ };
1304
+ };
1305
+ 400: components['responses']['BadRequestProblemResponse'];
1306
+ 401: components['responses']['UnauthorizedProblemResponse'];
1307
+ 501: components['responses']['NotImplementedProblemResponse'];
1308
+ default: components['responses']['UnexpectedProblemResponse'];
1309
+ };
1310
+ };
1311
+ /**
1312
+ * Create portal token
1313
+ * @description Create a consumer portal token.
1314
+ */
1315
+ createPortalToken: {
1316
+ /** @description The portal token to create. */
1317
+ requestBody: {
1318
+ content: {
1319
+ /**
1320
+ * @example {
1321
+ * "subject": "customer-id",
1322
+ * "allowedMeterSlugs": [
1323
+ * "tokens_total"
1324
+ * ]
1325
+ * }
1326
+ */
1327
+ 'application/json': components['schemas']['PortalToken'];
1328
+ };
1329
+ };
1330
+ responses: {
1331
+ /** @description Created. */
1332
+ 200: {
1333
+ content: {
1334
+ 'application/json': components['schemas']['PortalToken'];
1335
+ };
1336
+ };
1337
+ 400: components['responses']['BadRequestProblemResponse'];
1338
+ 401: components['responses']['UnauthorizedProblemResponse'];
1339
+ default: components['responses']['UnexpectedProblemResponse'];
1340
+ };
1341
+ };
1342
+ /**
1343
+ * ☁ Invalidate portal tokens
1344
+ * @description *Available in OpenMeter Cloud.*
1345
+ *
1346
+ * Invalidates consumer portal tokens by ID or subject.
1347
+ */
1348
+ invalidatePortalTokens: {
1349
+ /** @description If no id or subject is specified, all tokens will be invalidated. */
1350
+ requestBody: {
1351
+ content: {
1352
+ 'application/json': {
1353
+ /** @description Invalidate a portal token by ID. */
1354
+ id?: string;
1355
+ /** @description Invalidate all portal tokens for a subject. */
1356
+ subject?: string;
1357
+ };
1358
+ };
1359
+ };
1360
+ responses: {
1361
+ /** @description Portal tokens invalidated. */
1362
+ 204: {
1363
+ content: never;
1364
+ };
1365
+ 400: components['responses']['BadRequestProblemResponse'];
1366
+ 401: components['responses']['UnauthorizedProblemResponse'];
1367
+ 501: components['responses']['NotImplementedProblemResponse'];
1368
+ default: components['responses']['UnexpectedProblemResponse'];
1369
+ };
1370
+ };
1371
+ /**
1372
+ * ☁ List subjects
1373
+ * @description *Available in OpenMeter Cloud.*
1374
+ *
1375
+ * List subjects.
1376
+ */
1377
+ listSubjects: {
1378
+ responses: {
1379
+ /** @description List of subjects. */
1380
+ 200: {
1381
+ content: {
1382
+ 'application/json': components['schemas']['Subject'][];
1383
+ };
1384
+ };
1385
+ 401: components['responses']['UnauthorizedProblemResponse'];
1386
+ default: components['responses']['UnexpectedProblemResponse'];
1387
+ };
1388
+ };
1389
+ /**
1390
+ * ☁ Upsert subject
1391
+ * @description *Available in OpenMeter Cloud.*
1392
+ *
1393
+ * Upserts a subject. Creates or updates subject.
1394
+ * If the subject doesn't exist, it will be created.
1395
+ * If the subject exists, it will be partially updated with the provided fields.
1396
+ */
1397
+ upsertSubject: {
1398
+ /** @description The subject to upsert. */
1399
+ requestBody: {
1400
+ content: {
1401
+ 'application/json': components['schemas']['Subject'][];
1402
+ };
1403
+ };
1404
+ responses: {
1405
+ /** @description Subject upserted. */
1406
+ 200: {
1407
+ content: {
1408
+ 'application/json': components['schemas']['Subject'][];
1409
+ };
1410
+ };
1411
+ 400: components['responses']['BadRequestProblemResponse'];
1412
+ 401: components['responses']['UnauthorizedProblemResponse'];
1413
+ 501: components['responses']['NotImplementedProblemResponse'];
1414
+ default: components['responses']['UnexpectedProblemResponse'];
1415
+ };
1416
+ };
1417
+ /**
1418
+ * ☁ Get subject
1419
+ * @description *Available in OpenMeter Cloud.*
1420
+ *
1421
+ * Get subject by ID or key.
1422
+ */
1423
+ getSubject: {
1424
+ parameters: {
1425
+ path: {
1426
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
1427
+ };
1428
+ };
1429
+ responses: {
1430
+ /** @description Subject found. */
1431
+ 200: {
1432
+ content: {
1433
+ 'application/json': components['schemas']['Subject'];
1434
+ };
1435
+ };
1436
+ 401: components['responses']['UnauthorizedProblemResponse'];
1437
+ 404: components['responses']['NotFoundProblemResponse'];
1438
+ default: components['responses']['UnexpectedProblemResponse'];
1439
+ };
1440
+ };
1441
+ /**
1442
+ * ☁ Delete subject
1443
+ * @description *Available in OpenMeter Cloud.*
1444
+ *
1445
+ * Delete a subject by ID or key.
1446
+ */
1447
+ deleteSubject: {
1448
+ parameters: {
1449
+ path: {
1450
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
1451
+ };
1452
+ };
1453
+ responses: {
1454
+ /** @description Subject deleted. */
1455
+ 204: {
1456
+ content: never;
1457
+ };
1458
+ 400: components['responses']['BadRequestProblemResponse'];
1459
+ 401: components['responses']['UnauthorizedProblemResponse'];
1460
+ 404: components['responses']['NotFoundProblemResponse'];
1461
+ 501: components['responses']['NotImplementedProblemResponse'];
1462
+ default: components['responses']['UnexpectedProblemResponse'];
1463
+ };
1464
+ };
1465
+ /**
1466
+ * Query portal meter
1467
+ * @description Query meter for consumer portal. This endpoint is publicly exposable to consumers.
1468
+ */
1469
+ queryPortalMeter: {
1470
+ parameters: {
1471
+ query?: {
1472
+ from?: components['parameters']['queryFrom'];
1473
+ to?: components['parameters']['queryTo'];
1474
+ windowSize?: components['parameters']['queryWindowSize'];
1475
+ windowTimeZone?: components['parameters']['queryWindowTimeZone'];
1476
+ filterGroupBy?: components['parameters']['queryFilterGroupBy'];
1477
+ groupBy?: components['parameters']['queryGroupBy'];
1478
+ };
1479
+ path: {
1480
+ /** @description A unique identifier for the meter. */
1481
+ meterSlug: string;
1482
+ };
1483
+ };
1484
+ responses: {
1485
+ /** @description Usage data. */
1486
+ 200: {
1487
+ content: {
1488
+ 'application/json': components['schemas']['MeterQueryResult'];
1489
+ 'text/csv': string;
1490
+ };
1491
+ };
1492
+ 400: components['responses']['BadRequestProblemResponse'];
1493
+ 401: components['responses']['UnauthorizedProblemResponse'];
1494
+ default: components['responses']['UnexpectedProblemResponse'];
1495
+ };
1496
+ };
1497
+ /**
1498
+ * List features
1499
+ * @description List features.
1500
+ */
1501
+ listFeatures: {
1502
+ parameters: {
1503
+ query?: {
1504
+ limit?: components['parameters']['ledgerQueryLimit'];
1505
+ offset?: components['parameters']['ledgerQueryOffset'];
1506
+ /** @description Order by field */
1507
+ orderBy?: 'id' | 'createdAt' | 'updatedAt';
1508
+ /** @description Include archived features. */
1509
+ includeArchived?: boolean;
1510
+ };
1511
+ };
1512
+ responses: {
1513
+ /** @description List of features. */
1514
+ 200: {
1515
+ content: {
1516
+ 'application/json': components['schemas']['Feature'][];
1517
+ };
1518
+ };
1519
+ 401: components['responses']['UnauthorizedProblemResponse'];
1520
+ default: components['responses']['UnexpectedProblemResponse'];
1521
+ };
1522
+ };
1523
+ /**
1524
+ * Create feature
1525
+ * @description Creates a feature.
1526
+ */
1527
+ createFeature: {
1528
+ /** @description The feature to create. */
1529
+ requestBody: {
1530
+ content: {
1531
+ 'application/json': components['schemas']['CreateFeatureRequest'];
1532
+ };
1533
+ };
1534
+ responses: {
1535
+ /** @description Feature created. */
1536
+ 201: {
1537
+ content: {
1538
+ 'application/json': components['schemas']['Feature'];
1539
+ };
1540
+ };
1541
+ 400: components['responses']['BadRequestProblemResponse'];
1542
+ 401: components['responses']['UnauthorizedProblemResponse'];
1543
+ 501: components['responses']['NotImplementedProblemResponse'];
1544
+ default: components['responses']['UnexpectedProblemResponse'];
1545
+ };
1546
+ };
1547
+ /**
1548
+ * Get feature
1549
+ * @description Get feature by key.
1550
+ */
1551
+ getFeature: {
1552
+ parameters: {
1553
+ path: {
1554
+ featureID: components['parameters']['featureID'];
1555
+ };
1556
+ };
1557
+ responses: {
1558
+ /** @description Feature found. */
1559
+ 200: {
1560
+ content: {
1561
+ 'application/json': components['schemas']['Feature'];
1562
+ };
1563
+ };
1564
+ 401: components['responses']['UnauthorizedProblemResponse'];
1565
+ 404: components['responses']['NotFoundProblemResponse'];
1566
+ default: components['responses']['UnexpectedProblemResponse'];
1567
+ };
1568
+ };
1569
+ /**
1570
+ * Delete feature
1571
+ * @description Delete a feature by key.
1572
+ */
1573
+ deleteFeature: {
1574
+ parameters: {
1575
+ path: {
1576
+ featureID: components['parameters']['featureID'];
1577
+ };
1578
+ };
1579
+ responses: {
1580
+ /** @description Feature deleted. */
1581
+ 204: {
1582
+ content: never;
1583
+ };
1584
+ 401: components['responses']['UnauthorizedProblemResponse'];
1585
+ 404: components['responses']['NotFoundProblemResponse'];
1586
+ default: components['responses']['UnexpectedProblemResponse'];
1587
+ };
1588
+ };
1589
+ /**
1590
+ * List the already defined ledgers.
1591
+ * @description List the already defined ledgers.
1592
+ */
1593
+ listLedgers: {
1594
+ parameters: {
1595
+ query?: {
1596
+ /** @description Query ledgers specific to subjects. */
1597
+ subject?: string[];
1598
+ /** @description Query ledgers with subjects that are similar to the provided text. */
1599
+ subjectSimilarTo?: string;
1600
+ limit?: components['parameters']['ledgerQueryLimit'];
1601
+ offset?: components['parameters']['ledgerQueryOffset'];
1602
+ /** @description Order by field */
1603
+ orderBy?: 'subject' | 'createdAt' | 'id';
1604
+ };
1605
+ };
1606
+ responses: {
1607
+ /** @description List of the matching ledgers. */
1608
+ 200: {
1609
+ content: {
1610
+ 'application/json': components['schemas']['Ledger'][];
1611
+ };
1612
+ };
1613
+ 400: components['responses']['BadRequestProblemResponse'];
1614
+ 401: components['responses']['UnauthorizedProblemResponse'];
1615
+ default: components['responses']['UnexpectedProblemResponse'];
1616
+ };
1617
+ };
1618
+ /**
1619
+ * Creates the specified ledger
1620
+ * @description Create or update the specified ledger.
1621
+ */
1622
+ createLedger: {
1623
+ /** @description The ledger to be created */
1624
+ requestBody: {
1625
+ content: {
1626
+ 'application/json': components['schemas']['CreateLedger'];
1627
+ };
1628
+ };
1629
+ responses: {
1630
+ /** @description The created ledger. */
1631
+ 201: {
1632
+ content: {
1633
+ 'application/json': components['schemas']['Ledger'];
1634
+ };
1635
+ };
1636
+ 400: components['responses']['BadRequestProblemResponse'];
1637
+ 401: components['responses']['UnauthorizedProblemResponse'];
1638
+ 409: components['responses']['LedgerAlreadyExistsProblemResponse'];
1639
+ default: components['responses']['UnexpectedProblemResponse'];
1640
+ };
1641
+ };
1642
+ /**
1643
+ * Get the balance of a specific subject.
1644
+ * @description Get the balance of a specific subject.
1645
+ */
1646
+ getLedgerBalance: {
1647
+ parameters: {
1648
+ query?: {
1649
+ /** @description Point of time to query balances: date-time in RFC 3339 format. Defaults to now. */
1650
+ time?: string;
1651
+ };
1652
+ path: {
1653
+ ledgerID: components['parameters']['ledgerID'];
1654
+ };
1655
+ };
1656
+ responses: {
1657
+ /** @description Ledger balances available. */
1658
+ 200: {
1659
+ content: {
1660
+ 'application/json': components['schemas']['LedgerBalance'];
1661
+ };
1662
+ };
1663
+ 401: components['responses']['UnauthorizedProblemResponse'];
1664
+ 404: components['responses']['NotFoundProblemResponse'];
1665
+ default: components['responses']['UnexpectedProblemResponse'];
1666
+ };
1667
+ };
1668
+ /**
1669
+ * Get the history of a ledger
1670
+ * @description Get the history of a specific ledger
1671
+ */
1672
+ getLedgerHistory: {
1673
+ parameters: {
1674
+ query: {
1675
+ limit?: components['parameters']['ledgerQueryLimit'];
1676
+ offset?: components['parameters']['ledgerQueryOffset'];
1677
+ /** @description Start of time range to query ledger: date-time in RFC 3339 format. */
1678
+ from: string;
1679
+ /** @description End of time range to query ledger: date-time in RFC 3339 format. Defaults to now. */
1680
+ to?: string;
1681
+ };
1682
+ path: {
1683
+ ledgerID: components['parameters']['ledgerID'];
1684
+ };
1685
+ };
1686
+ responses: {
1687
+ /** @description Ledger balance history. */
1688
+ 200: {
1689
+ content: {
1690
+ 'application/json': components['schemas']['LedgerEntry'][];
1691
+ };
1692
+ };
1693
+ 401: components['responses']['UnauthorizedProblemResponse'];
1694
+ 404: components['responses']['NotFoundProblemResponse'];
1695
+ default: components['responses']['UnexpectedProblemResponse'];
1696
+ };
1697
+ };
1698
+ /**
1699
+ * Reset the ledger's balance
1700
+ * @description Resets the ledger's balances to zero for a specific subject and re-apply active grants with rollover configuration.
1701
+ */
1702
+ resetLedger: {
1703
+ parameters: {
1704
+ path: {
1705
+ ledgerID: components['parameters']['ledgerID'];
1706
+ };
1707
+ };
1708
+ /** @description Details for the reset. */
1709
+ requestBody: {
1710
+ content: {
1711
+ 'application/json': components['schemas']['LedgerReset'];
1712
+ };
1713
+ };
1714
+ responses: {
1715
+ /** @description Ledger balance reset. */
1716
+ 201: {
1717
+ content: {
1718
+ 'application/json': components['schemas']['LedgerReset'];
1719
+ };
1720
+ };
1721
+ 400: components['responses']['BadRequestProblemResponse'];
1722
+ 401: components['responses']['UnauthorizedProblemResponse'];
1723
+ 404: components['responses']['NotFoundProblemResponse'];
1724
+ default: components['responses']['UnexpectedProblemResponse'];
1725
+ };
1726
+ };
1727
+ /**
1728
+ * List grants for multiple ledgers.
1729
+ * @description List grants for multiple ledgers.
1730
+ */
1731
+ listLedgerGrants: {
1732
+ parameters: {
1733
+ query?: {
1734
+ ledgerID?: components['parameters']['queryFilterLedgerID'];
1735
+ limit?: components['parameters']['ledgerQueryLimit'];
1736
+ includeVoids?: components['parameters']['ledgerIncludeVoids'];
1737
+ };
1738
+ };
1739
+ responses: {
1740
+ /** @description List of ledger grants. */
1741
+ 200: {
1742
+ content: {
1743
+ 'application/json': components['schemas']['LedgerGrantResponse'][];
1744
+ };
1745
+ };
1746
+ 400: components['responses']['BadRequestProblemResponse'];
1747
+ 401: components['responses']['UnauthorizedProblemResponse'];
1748
+ default: components['responses']['UnexpectedProblemResponse'];
1749
+ };
1750
+ };
1751
+ /**
1752
+ * List ledger grants
1753
+ * @description List ledger grants for a specific ledger.
1754
+ */
1755
+ listLedgerGrantsByLedger: {
1756
+ parameters: {
1757
+ query?: {
1758
+ limit?: components['parameters']['ledgerQueryLimit'];
1759
+ includeVoids?: components['parameters']['ledgerIncludeVoids'];
1760
+ };
1761
+ path: {
1762
+ ledgerID: components['parameters']['ledgerID'];
1763
+ };
1764
+ };
1765
+ responses: {
1766
+ /** @description List of ledger grants created. */
1767
+ 200: {
1768
+ content: {
1769
+ 'application/json': components['schemas']['LedgerGrantResponse'][];
1770
+ };
1771
+ };
1772
+ 400: components['responses']['BadRequestProblemResponse'];
1773
+ 401: components['responses']['UnauthorizedProblemResponse'];
1774
+ default: components['responses']['UnexpectedProblemResponse'];
1775
+ };
1776
+ };
1777
+ /**
1778
+ * Create a grant on a specific ledger.
1779
+ * @description Create a grant on a specific ledger.
1780
+ */
1781
+ createLedgerGrant: {
1782
+ parameters: {
1783
+ path: {
1784
+ ledgerID: components['parameters']['ledgerID'];
1785
+ };
1786
+ };
1787
+ /** @description The grant to create. */
1788
+ requestBody: {
1789
+ content: {
1790
+ 'application/json': components['schemas']['CreateLedgerGrantRequest'];
1791
+ };
1792
+ };
1793
+ responses: {
1794
+ /** @description LedgerGrant created. */
1795
+ 201: {
1796
+ content: {
1797
+ 'application/json': components['schemas']['LedgerGrantResponse'];
1798
+ };
1799
+ };
1800
+ 400: components['responses']['BadRequestProblemResponse'];
1801
+ 401: components['responses']['UnauthorizedProblemResponse'];
1802
+ default: components['responses']['UnexpectedProblemResponse'];
1803
+ };
1804
+ };
1805
+ /**
1806
+ * Get a single grant.
1807
+ * @description Gets the grant for a ledger by ID.
1808
+ */
1809
+ getLedgerGrant: {
1810
+ parameters: {
1811
+ path: {
1812
+ ledgerID: components['parameters']['ledgerID'];
1813
+ ledgerGrantID: components['parameters']['ledgerGrantID'];
1814
+ };
1815
+ };
1816
+ responses: {
1817
+ /** @description Ledger grant found. */
1818
+ 200: {
1819
+ content: {
1820
+ 'application/json': components['schemas']['LedgerGrantResponse'];
1821
+ };
1822
+ };
1823
+ 401: components['responses']['UnauthorizedProblemResponse'];
1824
+ 404: components['responses']['NotFoundProblemResponse'];
1825
+ default: components['responses']['UnexpectedProblemResponse'];
1826
+ };
1827
+ };
1828
+ /**
1829
+ * Void ledger grant
1830
+ * @description Void a ledger grant by ID. Partially or fully used grants cannot be voided.
1831
+ * Voided grant won't be applied to the subject's balance anymore.
1832
+ */
1833
+ voidLedgerGrant: {
1834
+ parameters: {
1835
+ path: {
1836
+ ledgerGrantID: components['parameters']['ledgerGrantID'];
1837
+ ledgerID: components['parameters']['ledgerID'];
1838
+ };
1839
+ };
1840
+ responses: {
1841
+ /** @description Ledger grant voided. */
1842
+ 204: {
1843
+ content: never;
1844
+ };
1845
+ 401: components['responses']['UnauthorizedProblemResponse'];
1846
+ 404: components['responses']['NotFoundProblemResponse'];
1847
+ default: components['responses']['UnexpectedProblemResponse'];
1848
+ };
1849
+ };
1850
+ }