@unkey/api 0.19.5 → 0.20.1

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.
package/dist/index.d.ts CHANGED
@@ -9,1189 +9,1656 @@ export { Flatten, and, or } from '@unkey/rbac';
9
9
 
10
10
  interface paths {
11
11
  "/v1/liveness": {
12
- get: {
13
- responses: {
14
- /** @description The configured services and their status */
15
- 200: {
16
- content: {
17
- "application/json": {
18
- /** @description The status of the server */
19
- status: string;
20
- services: {
21
- /**
22
- * @description The name of the connected metrics service
23
- * @example AxiomMetrics
24
- */
25
- metrics: string;
26
- /**
27
- * @description The name of the connected logger service
28
- * @example AxiomLogger or ConsoleLogger
29
- */
30
- logger: string;
31
- /** @description The name of the connected ratelimit service */
32
- ratelimit: string;
33
- /** @description The name of the connected usagelimit service */
34
- usagelimit: string;
35
- /** @description The name of the connected analytics service */
36
- analytics: string;
37
- };
12
+ get: operations["v1.liveness"];
13
+ };
14
+ "/v1/keys.getKey": {
15
+ get: operations["getKey"];
16
+ };
17
+ "/v1/keys.deleteKey": {
18
+ post: operations["deleteKey"];
19
+ };
20
+ "/v1/keys.createKey": {
21
+ post: operations["createKey"];
22
+ };
23
+ "/v1/keys.verifyKey": {
24
+ post: operations["verifyKey"];
25
+ };
26
+ "/v1/keys.updateKey": {
27
+ post: operations["updateKey"];
28
+ };
29
+ "/v1/keys.updateRemaining": {
30
+ post: operations["updateRemaining"];
31
+ };
32
+ "/v1/keys.getVerifications": {
33
+ get: operations["getVerifications"];
34
+ };
35
+ "/v1/apis.getApi": {
36
+ get: operations["getApi"];
37
+ };
38
+ "/v1/apis.createApi": {
39
+ post: operations["createApi"];
40
+ };
41
+ "/v1/apis.listKeys": {
42
+ get: operations["listKeys"];
43
+ };
44
+ "/v1/apis.deleteApi": {
45
+ post: operations["deleteApi"];
46
+ };
47
+ "/v1/ratelimits.limit": {
48
+ post: operations["limit"];
49
+ };
50
+ "/v1/migrations.createKeys": {
51
+ post: operations["v1.migrations.createKeys"];
52
+ };
53
+ "/v1/keys": {
54
+ post: operations["deprecated.createKey"];
55
+ };
56
+ "/v1/keys/verify": {
57
+ /** @deprecated */
58
+ post: operations["deprecated.verifyKey"];
59
+ };
60
+ "/v1/apis/{apiId}/keys": {
61
+ get: operations["deprecated.listKeys"];
62
+ };
63
+ }
64
+
65
+ interface components {
66
+ schemas: {
67
+ ErrBadRequest: {
68
+ error: {
69
+ /**
70
+ * @description A machine readable error code.
71
+ * @example BAD_REQUEST
72
+ * @enum {string}
73
+ */
74
+ code: "BAD_REQUEST";
75
+ /**
76
+ * @description A link to our documentation with more details about this error code
77
+ * @example https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST
78
+ */
79
+ docs: string;
80
+ /** @description A human readable explanation of what went wrong */
81
+ message: string;
82
+ /**
83
+ * @description Please always include the requestId in your error report
84
+ * @example req_1234
85
+ */
86
+ requestId: string;
87
+ };
88
+ };
89
+ ErrUnauthorized: {
90
+ error: {
91
+ /**
92
+ * @description A machine readable error code.
93
+ * @example UNAUTHORIZED
94
+ * @enum {string}
95
+ */
96
+ code: "UNAUTHORIZED";
97
+ /**
98
+ * @description A link to our documentation with more details about this error code
99
+ * @example https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED
100
+ */
101
+ docs: string;
102
+ /** @description A human readable explanation of what went wrong */
103
+ message: string;
104
+ /**
105
+ * @description Please always include the requestId in your error report
106
+ * @example req_1234
107
+ */
108
+ requestId: string;
109
+ };
110
+ };
111
+ ErrForbidden: {
112
+ error: {
113
+ /**
114
+ * @description A machine readable error code.
115
+ * @example FORBIDDEN
116
+ * @enum {string}
117
+ */
118
+ code: "FORBIDDEN";
119
+ /**
120
+ * @description A link to our documentation with more details about this error code
121
+ * @example https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN
122
+ */
123
+ docs: string;
124
+ /** @description A human readable explanation of what went wrong */
125
+ message: string;
126
+ /**
127
+ * @description Please always include the requestId in your error report
128
+ * @example req_1234
129
+ */
130
+ requestId: string;
131
+ };
132
+ };
133
+ ErrNotFound: {
134
+ error: {
135
+ /**
136
+ * @description A machine readable error code.
137
+ * @example NOT_FOUND
138
+ * @enum {string}
139
+ */
140
+ code: "NOT_FOUND";
141
+ /**
142
+ * @description A link to our documentation with more details about this error code
143
+ * @example https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND
144
+ */
145
+ docs: string;
146
+ /** @description A human readable explanation of what went wrong */
147
+ message: string;
148
+ /**
149
+ * @description Please always include the requestId in your error report
150
+ * @example req_1234
151
+ */
152
+ requestId: string;
153
+ };
154
+ };
155
+ ErrConflict: {
156
+ error: {
157
+ /**
158
+ * @description A machine readable error code.
159
+ * @example CONFLICT
160
+ * @enum {string}
161
+ */
162
+ code: "CONFLICT";
163
+ /**
164
+ * @description A link to our documentation with more details about this error code
165
+ * @example https://unkey.dev/docs/api-reference/errors/code/CONFLICT
166
+ */
167
+ docs: string;
168
+ /** @description A human readable explanation of what went wrong */
169
+ message: string;
170
+ /**
171
+ * @description Please always include the requestId in your error report
172
+ * @example req_1234
173
+ */
174
+ requestId: string;
175
+ };
176
+ };
177
+ ErrTooManyRequests: {
178
+ error: {
179
+ /**
180
+ * @description A machine readable error code.
181
+ * @example TOO_MANY_REQUESTS
182
+ * @enum {string}
183
+ */
184
+ code: "TOO_MANY_REQUESTS";
185
+ /**
186
+ * @description A link to our documentation with more details about this error code
187
+ * @example https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS
188
+ */
189
+ docs: string;
190
+ /** @description A human readable explanation of what went wrong */
191
+ message: string;
192
+ /**
193
+ * @description Please always include the requestId in your error report
194
+ * @example req_1234
195
+ */
196
+ requestId: string;
197
+ };
198
+ };
199
+ ErrInternalServerError: {
200
+ error: {
201
+ /**
202
+ * @description A machine readable error code.
203
+ * @example INTERNAL_SERVER_ERROR
204
+ * @enum {string}
205
+ */
206
+ code: "INTERNAL_SERVER_ERROR";
207
+ /**
208
+ * @description A link to our documentation with more details about this error code
209
+ * @example https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR
210
+ */
211
+ docs: string;
212
+ /** @description A human readable explanation of what went wrong */
213
+ message: string;
214
+ /**
215
+ * @description Please always include the requestId in your error report
216
+ * @example req_1234
217
+ */
218
+ requestId: string;
219
+ };
220
+ };
221
+ Key: {
222
+ /**
223
+ * @description The id of the key
224
+ * @example key_1234
225
+ */
226
+ id: string;
227
+ /**
228
+ * @description The first few characters of the key to visually identify it
229
+ * @example sk_5j1
230
+ */
231
+ start: string;
232
+ /**
233
+ * @description The id of the workspace that owns the key
234
+ * @example ws_1234
235
+ */
236
+ workspaceId: string;
237
+ /**
238
+ * @description The id of the api that this key is for
239
+ * @example api_1234
240
+ */
241
+ apiId?: string;
242
+ /**
243
+ * @description The name of the key, give keys a name to easily identify their purpose
244
+ * @example Customer X
245
+ */
246
+ name?: string;
247
+ /**
248
+ * @description The id of the tenant associated with this key. Use whatever reference you have in your system to identify the tenant. When verifying the key, we will send this field back to you, so you know who is accessing your API.
249
+ * @example user_123
250
+ */
251
+ ownerId?: string;
252
+ /**
253
+ * @description Any additional metadata you want to store with the key
254
+ * @example {
255
+ * "roles": [
256
+ * "admin",
257
+ * "user"
258
+ * ],
259
+ * "stripeCustomerId": "cus_1234"
260
+ * }
261
+ */
262
+ meta?: {
263
+ [key: string]: unknown;
264
+ };
265
+ /**
266
+ * @description The unix timestamp in milliseconds when the key was created
267
+ * @example 0
268
+ */
269
+ createdAt?: number;
270
+ /**
271
+ * @description The unix timestamp in milliseconds when the key was deleted. We don't delete the key outright, you can restore it later.
272
+ * @example 0
273
+ */
274
+ deletedAt?: number;
275
+ /**
276
+ * @description The unix timestamp in milliseconds when the key will expire. If this field is null or undefined, the key is not expiring.
277
+ * @example 0
278
+ */
279
+ expires?: number;
280
+ /**
281
+ * @description The number of requests that can be made with this key before it becomes invalid. If this field is null or undefined, the key has no request limit.
282
+ * @example 1000
283
+ */
284
+ remaining?: number;
285
+ /**
286
+ * @description Unkey allows you to refill remaining verifications on a key on a regular interval.
287
+ * @example {
288
+ * "interval": "daily",
289
+ * "amount": 10
290
+ * }
291
+ */
292
+ refill?: {
293
+ /**
294
+ * @description Determines the rate at which verifications will be refilled.
295
+ * @example daily
296
+ * @enum {string}
297
+ */
298
+ interval: "daily" | "monthly";
299
+ /**
300
+ * @description Resets `remaining` to this value every interval.
301
+ * @example 100
302
+ */
303
+ amount: number;
304
+ /**
305
+ * @description The unix timestamp in miliseconds when the key was last refilled.
306
+ * @example 100
307
+ */
308
+ lastRefillAt?: number;
309
+ };
310
+ /**
311
+ * @description Unkey comes with per-key ratelimiting out of the box.
312
+ * @example {
313
+ * "type": "fast",
314
+ * "limit": 10,
315
+ * "refillRate": 1,
316
+ * "refillInterval": 60
317
+ * }
318
+ */
319
+ ratelimit?: {
320
+ /**
321
+ * @description Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate.
322
+ * @default fast
323
+ * @enum {string}
324
+ */
325
+ type?: "fast" | "consistent";
326
+ /** @description The total amount of burstable requests. */
327
+ limit: number;
328
+ /** @description How many tokens to refill during each refillInterval. */
329
+ refillRate: number;
330
+ /** @description Determines the speed at which tokens are refilled, in milliseconds. */
331
+ refillInterval: number;
332
+ };
333
+ /**
334
+ * @description All roles this key belongs to
335
+ * @example [
336
+ * "admin",
337
+ * "finance"
338
+ * ]
339
+ */
340
+ roles?: string[];
341
+ /**
342
+ * @description All permissions this key has
343
+ * @example [
344
+ * "domain.dns.create_record",
345
+ * "finance.read_receipt"
346
+ * ]
347
+ */
348
+ permissions?: string[];
349
+ /**
350
+ * @description Sets if key is enabled or disabled. Disabled keys are not valid.
351
+ * @example true
352
+ */
353
+ enabled?: boolean;
354
+ };
355
+ V1KeysVerifyKeyResponse: {
356
+ /**
357
+ * @description The id of the key
358
+ * @example key_1234
359
+ */
360
+ keyId?: string;
361
+ /**
362
+ * @description Whether the key is valid or not.
363
+ * A key could be invalid for a number of reasons, for example if it has expired, has no more verifications left or if it has been deleted.
364
+ * @example true
365
+ */
366
+ valid: boolean;
367
+ /**
368
+ * @description The name of the key, give keys a name to easily identifiy their purpose
369
+ * @example Customer X
370
+ */
371
+ name?: string;
372
+ /**
373
+ * @description The id of the tenant associated with this key. Use whatever reference you have in your system to identify the tenant. When verifying the key, we will send this field back to you, so you know who is accessing your API.
374
+ * @example user_123
375
+ */
376
+ ownerId?: string;
377
+ /**
378
+ * @description Any additional metadata you want to store with the key
379
+ * @example {
380
+ * "roles": [
381
+ * "admin",
382
+ * "user"
383
+ * ],
384
+ * "stripeCustomerId": "cus_1234"
385
+ * }
386
+ */
387
+ meta?: {
388
+ [key: string]: unknown;
389
+ };
390
+ /**
391
+ * @description The unix timestamp in milliseconds when the key will expire. If this field is null or undefined, the key is not expiring.
392
+ * @example 123
393
+ */
394
+ expires?: number;
395
+ /**
396
+ * @description The ratelimit configuration for this key. If this field is null or undefined, the key has no ratelimit.
397
+ * @example {
398
+ * "limit": 10,
399
+ * "remaining": 9,
400
+ * "reset": 3600000
401
+ * }
402
+ */
403
+ ratelimit?: {
404
+ /**
405
+ * @description Maximum number of requests that can be made inside a window
406
+ * @example 10
407
+ */
408
+ limit: number;
409
+ /**
410
+ * @description Remaining requests after this verification
411
+ * @example 9
412
+ */
413
+ remaining: number;
414
+ /**
415
+ * @description Unix timestamp in milliseconds when the ratelimit will reset
416
+ * @example 3600000
417
+ */
418
+ reset: number;
419
+ };
420
+ /**
421
+ * @description The number of requests that can be made with this key before it becomes invalid. If this field is null or undefined, the key has no request limit.
422
+ * @example 1000
423
+ */
424
+ remaining?: number;
425
+ /**
426
+ * @description A machine readable code why the key is not valid.
427
+ * Possible values are:
428
+ * - VALID: the key is valid and you should proceed
429
+ * - NOT_FOUND: the key does not exist or has expired
430
+ * - FORBIDDEN: the key is not allowed to access the api
431
+ * - USAGE_EXCEEDED: the key has exceeded its request limit
432
+ * - RATE_LIMITED: the key has been ratelimited
433
+ * - UNAUTHORIZED: the key is not authorized
434
+ * - DISABLED: the key is disabled
435
+ * - INSUFFICIENT_PERMISSIONS: you do not have the required permissions to perform this action
436
+ *
437
+ * @enum {string}
438
+ */
439
+ code: "VALID" | "NOT_FOUND" | "FORBIDDEN" | "USAGE_EXCEEDED" | "RATE_LIMITED" | "UNAUTHORIZED" | "DISABLED" | "INSUFFICIENT_PERMISSIONS";
440
+ /** @description Sets the key to be enabled or disabled. Disabled keys will not verify. */
441
+ enabled?: boolean;
442
+ /**
443
+ * @description A list of all the permissions this key is connected to.
444
+ * @example [
445
+ * "dns.record.update",
446
+ * "dns.record.delete"
447
+ * ]
448
+ */
449
+ permissions?: string[];
450
+ /**
451
+ * @description The environment of the key, this is what what you set when you crated the key
452
+ * @example test
453
+ */
454
+ environment?: string;
455
+ };
456
+ V1KeysVerifyKeyRequest: {
457
+ /**
458
+ * @description The id of the api where the key belongs to. This is optional for now but will be required soon.
459
+ * The key will be verified against the api's configuration. If the key does not belong to the api, the verification will fail.
460
+ * @example api_1234
461
+ */
462
+ apiId?: string;
463
+ /**
464
+ * @description The key to verify
465
+ * @example sk_1234
466
+ */
467
+ key: string;
468
+ /** @description Perform RBAC checks */
469
+ authorization?: {
470
+ /**
471
+ * @description A query for which permissions you require
472
+ * @example {
473
+ * "or": [
474
+ * {
475
+ * "and": [
476
+ * "dns.record.read",
477
+ * "dns.record.update"
478
+ * ]
479
+ * },
480
+ * "admin"
481
+ * ]
482
+ * }
483
+ */
484
+ permissions?: Record<string, never>;
485
+ };
486
+ ratelimit?: {
487
+ /**
488
+ * @description Override how many tokens are deducted during the ratelimit operation.
489
+ * @default 1
490
+ */
491
+ cost?: number;
492
+ };
493
+ };
494
+ };
495
+ responses: never;
496
+ parameters: {
497
+ };
498
+ requestBodies: never;
499
+ headers: never;
500
+ pathItems: never;
501
+ }
502
+
503
+ interface operations {
504
+
505
+ "v1.liveness": {
506
+ responses: {
507
+ /** @description The configured services and their status */
508
+ 200: {
509
+ content: {
510
+ "application/json": {
511
+ /** @description The status of the server */
512
+ status: string;
513
+ services: {
514
+ /**
515
+ * @description The name of the connected metrics service
516
+ * @example AxiomMetrics
517
+ */
518
+ metrics: string;
519
+ /**
520
+ * @description The name of the connected logger service
521
+ * @example AxiomLogger or ConsoleLogger
522
+ */
523
+ logger: string;
524
+ /** @description The name of the connected ratelimit service */
525
+ ratelimit: string;
526
+ /** @description The name of the connected usagelimit service */
527
+ usagelimit: string;
528
+ /** @description The name of the connected analytics service */
529
+ analytics: string;
38
530
  };
39
531
  };
40
532
  };
41
- /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
42
- 400: {
43
- content: {
44
- "application/json": components["schemas"]["ErrBadRequest"];
45
- };
533
+ };
534
+ /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
535
+ 400: {
536
+ content: {
537
+ "application/json": components["schemas"]["ErrBadRequest"];
46
538
  };
47
- /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
48
- 401: {
49
- content: {
50
- "application/json": components["schemas"]["ErrUnauthorized"];
51
- };
539
+ };
540
+ /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
541
+ 401: {
542
+ content: {
543
+ "application/json": components["schemas"]["ErrUnauthorized"];
52
544
  };
53
- /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
54
- 403: {
55
- content: {
56
- "application/json": components["schemas"]["ErrForbidden"];
57
- };
545
+ };
546
+ /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
547
+ 403: {
548
+ content: {
549
+ "application/json": components["schemas"]["ErrForbidden"];
58
550
  };
59
- /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
60
- 404: {
61
- content: {
62
- "application/json": components["schemas"]["ErrNotFound"];
63
- };
551
+ };
552
+ /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
553
+ 404: {
554
+ content: {
555
+ "application/json": components["schemas"]["ErrNotFound"];
64
556
  };
65
- /** @description This response is sent when a request conflicts with the current state of the server. */
66
- 409: {
67
- content: {
68
- "application/json": components["schemas"]["ErrConflict"];
69
- };
557
+ };
558
+ /** @description This response is sent when a request conflicts with the current state of the server. */
559
+ 409: {
560
+ content: {
561
+ "application/json": components["schemas"]["ErrConflict"];
70
562
  };
71
- /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
72
- 429: {
73
- content: {
74
- "application/json": components["schemas"]["ErrTooManyRequests"];
75
- };
563
+ };
564
+ /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
565
+ 429: {
566
+ content: {
567
+ "application/json": components["schemas"]["ErrTooManyRequests"];
76
568
  };
77
- /** @description The server has encountered a situation it does not know how to handle. */
78
- 500: {
79
- content: {
80
- "application/json": components["schemas"]["ErrInternalServerError"];
81
- };
569
+ };
570
+ /** @description The server has encountered a situation it does not know how to handle. */
571
+ 500: {
572
+ content: {
573
+ "application/json": components["schemas"]["ErrInternalServerError"];
82
574
  };
83
575
  };
84
576
  };
85
577
  };
86
- "/v1/keys.getKey": {
87
- get: {
88
- parameters: {
89
- query: {
90
- keyId: string;
91
- };
578
+ getKey: {
579
+ parameters: {
580
+ query: {
581
+ keyId: string;
92
582
  };
93
- responses: {
94
- /** @description The configuration for a single key */
95
- 200: {
96
- content: {
97
- "application/json": components["schemas"]["Key"];
98
- };
583
+ };
584
+ responses: {
585
+ /** @description The configuration for a single key */
586
+ 200: {
587
+ content: {
588
+ "application/json": components["schemas"]["Key"];
99
589
  };
100
- /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
101
- 400: {
102
- content: {
103
- "application/json": components["schemas"]["ErrBadRequest"];
104
- };
590
+ };
591
+ /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
592
+ 400: {
593
+ content: {
594
+ "application/json": components["schemas"]["ErrBadRequest"];
105
595
  };
106
- /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
107
- 401: {
108
- content: {
109
- "application/json": components["schemas"]["ErrUnauthorized"];
110
- };
596
+ };
597
+ /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
598
+ 401: {
599
+ content: {
600
+ "application/json": components["schemas"]["ErrUnauthorized"];
111
601
  };
112
- /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
113
- 403: {
114
- content: {
115
- "application/json": components["schemas"]["ErrForbidden"];
116
- };
602
+ };
603
+ /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
604
+ 403: {
605
+ content: {
606
+ "application/json": components["schemas"]["ErrForbidden"];
117
607
  };
118
- /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
119
- 404: {
120
- content: {
121
- "application/json": components["schemas"]["ErrNotFound"];
122
- };
608
+ };
609
+ /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
610
+ 404: {
611
+ content: {
612
+ "application/json": components["schemas"]["ErrNotFound"];
123
613
  };
124
- /** @description This response is sent when a request conflicts with the current state of the server. */
125
- 409: {
126
- content: {
127
- "application/json": components["schemas"]["ErrConflict"];
128
- };
614
+ };
615
+ /** @description This response is sent when a request conflicts with the current state of the server. */
616
+ 409: {
617
+ content: {
618
+ "application/json": components["schemas"]["ErrConflict"];
129
619
  };
130
- /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
131
- 429: {
132
- content: {
133
- "application/json": components["schemas"]["ErrTooManyRequests"];
134
- };
620
+ };
621
+ /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
622
+ 429: {
623
+ content: {
624
+ "application/json": components["schemas"]["ErrTooManyRequests"];
135
625
  };
136
- /** @description The server has encountered a situation it does not know how to handle. */
137
- 500: {
138
- content: {
139
- "application/json": components["schemas"]["ErrInternalServerError"];
140
- };
626
+ };
627
+ /** @description The server has encountered a situation it does not know how to handle. */
628
+ 500: {
629
+ content: {
630
+ "application/json": components["schemas"]["ErrInternalServerError"];
141
631
  };
142
632
  };
143
633
  };
144
634
  };
145
- "/v1/keys.deleteKey": {
146
- post: {
147
- requestBody: {
148
- content: {
149
- "application/json": {
150
- /**
151
- * @description The id of the key to revoke
152
- * @example key_1234
153
- */
154
- keyId: string;
155
- };
635
+ deleteKey: {
636
+ requestBody: {
637
+ content: {
638
+ "application/json": {
639
+ /**
640
+ * @description The id of the key to revoke
641
+ * @example key_1234
642
+ */
643
+ keyId: string;
156
644
  };
157
645
  };
158
- responses: {
159
- /** @description The key was successfully revoked, it may take up to 30s for this to take effect in all regions */
160
- 200: {
161
- content: {
162
- "application/json": Record<string, never>;
163
- };
646
+ };
647
+ responses: {
648
+ /** @description The key was successfully revoked, it may take up to 30s for this to take effect in all regions */
649
+ 200: {
650
+ content: {
651
+ "application/json": Record<string, never>;
164
652
  };
165
- /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
166
- 400: {
167
- content: {
168
- "application/json": components["schemas"]["ErrBadRequest"];
169
- };
653
+ };
654
+ /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
655
+ 400: {
656
+ content: {
657
+ "application/json": components["schemas"]["ErrBadRequest"];
170
658
  };
171
- /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
172
- 401: {
173
- content: {
174
- "application/json": components["schemas"]["ErrUnauthorized"];
175
- };
659
+ };
660
+ /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
661
+ 401: {
662
+ content: {
663
+ "application/json": components["schemas"]["ErrUnauthorized"];
176
664
  };
177
- /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
178
- 403: {
179
- content: {
180
- "application/json": components["schemas"]["ErrForbidden"];
181
- };
665
+ };
666
+ /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
667
+ 403: {
668
+ content: {
669
+ "application/json": components["schemas"]["ErrForbidden"];
182
670
  };
183
- /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
184
- 404: {
185
- content: {
186
- "application/json": components["schemas"]["ErrNotFound"];
187
- };
671
+ };
672
+ /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
673
+ 404: {
674
+ content: {
675
+ "application/json": components["schemas"]["ErrNotFound"];
188
676
  };
189
- /** @description This response is sent when a request conflicts with the current state of the server. */
190
- 409: {
191
- content: {
192
- "application/json": components["schemas"]["ErrConflict"];
193
- };
677
+ };
678
+ /** @description This response is sent when a request conflicts with the current state of the server. */
679
+ 409: {
680
+ content: {
681
+ "application/json": components["schemas"]["ErrConflict"];
194
682
  };
195
- /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
196
- 429: {
197
- content: {
198
- "application/json": components["schemas"]["ErrTooManyRequests"];
199
- };
683
+ };
684
+ /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
685
+ 429: {
686
+ content: {
687
+ "application/json": components["schemas"]["ErrTooManyRequests"];
200
688
  };
201
- /** @description The server has encountered a situation it does not know how to handle. */
202
- 500: {
203
- content: {
204
- "application/json": components["schemas"]["ErrInternalServerError"];
205
- };
689
+ };
690
+ /** @description The server has encountered a situation it does not know how to handle. */
691
+ 500: {
692
+ content: {
693
+ "application/json": components["schemas"]["ErrInternalServerError"];
206
694
  };
207
695
  };
208
696
  };
209
697
  };
210
- "/v1/keys.createKey": {
211
- post: {
212
- requestBody: {
213
- content: {
214
- "application/json": {
215
- /**
216
- * @description Choose an `API` where this key should be created.
217
- * @example api_123
218
- */
219
- apiId: string;
220
- /**
221
- * @description To make it easier for your users to understand which product an api key belongs to, you can add prefix them.
222
- *
223
- * For example Stripe famously prefixes their customer ids with cus_ or their api keys with sk_live_.
224
- *
225
- * The underscore is automatically added if you are defining a prefix, for example: "prefix": "abc" will result in a key like abc_xxxxxxxxx
226
- */
227
- prefix?: string;
228
- /**
229
- * @description The name for your Key. This is not customer facing.
230
- * @example my key
231
- */
232
- name?: string;
233
- /**
234
- * @description The byte length used to generate your key determines its entropy as well as its length. Higher is better, but keys become longer and more annoying to handle. The default is 16 bytes, or 2^^128 possible combinations.
235
- * @default 16
236
- */
237
- byteLength?: number;
238
- /**
239
- * @description Your user’s Id. This will provide a link between Unkey and your customer record.
240
- * When validating a key, we will return this back to you, so you can clearly identify your user from their api key.
241
- * @example team_123
242
- */
243
- ownerId?: string;
244
- /**
245
- * @description This is a place for dynamic meta data, anything that feels useful for you should go here
246
- * @example {
247
- * "billingTier": "PRO",
248
- * "trialEnds": "2023-06-16T17:16:37.161Z"
249
- * }
250
- */
251
- meta?: {
252
- [key: string]: unknown;
253
- };
254
- /**
255
- * @description A list of roles that this key should have. If the role does not exist, an error is thrown
256
- * @example [
257
- * "admin",
258
- * "finance"
259
- * ]
260
- */
261
- roles?: string[];
262
- /**
263
- * @description You can auto expire keys by providing a unix timestamp in milliseconds. Once Keys expire they will automatically be disabled and are no longer valid unless you enable them again.
264
- * @example 1623869797161
265
- */
266
- expires?: number;
267
- /**
268
- * @description You can limit the number of requests a key can make. Once a key reaches 0 remaining requests, it will automatically be disabled and is no longer valid unless you update it.
269
- * @example 1000
270
- */
271
- remaining?: number;
698
+ createKey: {
699
+ requestBody: {
700
+ content: {
701
+ "application/json": {
702
+ /**
703
+ * @description Choose an `API` where this key should be created.
704
+ * @example api_123
705
+ */
706
+ apiId: string;
707
+ /**
708
+ * @description To make it easier for your users to understand which product an api key belongs to, you can add prefix them.
709
+ *
710
+ * For example Stripe famously prefixes their customer ids with cus_ or their api keys with sk_live_.
711
+ *
712
+ * The underscore is automatically added if you are defining a prefix, for example: "prefix": "abc" will result in a key like abc_xxxxxxxxx
713
+ */
714
+ prefix?: string;
715
+ /**
716
+ * @description The name for your Key. This is not customer facing.
717
+ * @example my key
718
+ */
719
+ name?: string;
720
+ /**
721
+ * @description The byte length used to generate your key determines its entropy as well as its length. Higher is better, but keys become longer and more annoying to handle. The default is 16 bytes, or 2^^128 possible combinations.
722
+ * @default 16
723
+ */
724
+ byteLength?: number;
725
+ /**
726
+ * @description Your user’s Id. This will provide a link between Unkey and your customer record.
727
+ * When validating a key, we will return this back to you, so you can clearly identify your user from their api key.
728
+ * @example team_123
729
+ */
730
+ ownerId?: string;
731
+ /**
732
+ * @description This is a place for dynamic meta data, anything that feels useful for you should go here
733
+ * @example {
734
+ * "billingTier": "PRO",
735
+ * "trialEnds": "2023-06-16T17:16:37.161Z"
736
+ * }
737
+ */
738
+ meta?: {
739
+ [key: string]: unknown;
740
+ };
741
+ /**
742
+ * @description A list of roles that this key should have. If the role does not exist, an error is thrown
743
+ * @example [
744
+ * "admin",
745
+ * "finance"
746
+ * ]
747
+ */
748
+ roles?: string[];
749
+ /**
750
+ * @description You can auto expire keys by providing a unix timestamp in milliseconds. Once Keys expire they will automatically be disabled and are no longer valid unless you enable them again.
751
+ * @example 1623869797161
752
+ */
753
+ expires?: number;
754
+ /**
755
+ * @description You can limit the number of requests a key can make. Once a key reaches 0 remaining requests, it will automatically be disabled and is no longer valid unless you update it.
756
+ * @example 1000
757
+ */
758
+ remaining?: number;
759
+ /**
760
+ * @description Unkey enables you to refill verifications for each key at regular intervals.
761
+ * @example {
762
+ * "interval": "daily",
763
+ * "amount": 100
764
+ * }
765
+ */
766
+ refill?: {
272
767
  /**
273
- * @description Unkey enables you to refill verifications for each key at regular intervals.
274
- * @example {
275
- * "interval": "daily",
276
- * "amount": 100
277
- * }
768
+ * @description Unkey will automatically refill verifications at the set interval.
769
+ * @enum {string}
278
770
  */
279
- refill?: {
280
- /**
281
- * @description Unkey will automatically refill verifications at the set interval.
282
- * @enum {string}
283
- */
284
- interval: "daily" | "monthly";
285
- /** @description The number of verifications to refill for each occurrence is determined individually for each key. */
286
- amount: number;
287
- };
771
+ interval: "daily" | "monthly";
772
+ /** @description The number of verifications to refill for each occurrence is determined individually for each key. */
773
+ amount: number;
774
+ };
775
+ /**
776
+ * @description Unkey comes with per-key ratelimiting out of the box.
777
+ * @example {
778
+ * "type": "fast",
779
+ * "limit": 10,
780
+ * "refillRate": 1,
781
+ * "refillInterval": 60
782
+ * }
783
+ */
784
+ ratelimit?: {
288
785
  /**
289
- * @description Unkey comes with per-key ratelimiting out of the box.
290
- * @example {
291
- * "type": "fast",
292
- * "limit": 10,
293
- * "refillRate": 1,
294
- * "refillInterval": 60
295
- * }
786
+ * @description Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate.
787
+ * @default fast
788
+ * @enum {string}
296
789
  */
297
- ratelimit?: {
298
- /**
299
- * @description Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate.
300
- * @default fast
301
- * @enum {string}
302
- */
303
- type?: "fast" | "consistent";
304
- /** @description The total amount of burstable requests. */
305
- limit: number;
306
- /** @description How many tokens to refill during each refillInterval. */
307
- refillRate: number;
308
- /** @description Determines the speed at which tokens are refilled, in milliseconds. */
309
- refillInterval: number;
310
- };
790
+ type?: "fast" | "consistent";
791
+ /** @description The total amount of burstable requests. */
792
+ limit: number;
793
+ /** @description How many tokens to refill during each refillInterval. */
794
+ refillRate: number;
795
+ /** @description Determines the speed at which tokens are refilled, in milliseconds. */
796
+ refillInterval: number;
797
+ };
798
+ /**
799
+ * @description Sets if key is enabled or disabled. Disabled keys are not valid.
800
+ * @default true
801
+ * @example false
802
+ */
803
+ enabled?: boolean;
804
+ /**
805
+ * @description Environments allow you to divide your keyspace.
806
+ *
807
+ * Some applications like Stripe, Clerk, WorkOS and others have a concept of "live" and "test" keys to
808
+ * give the developer a way to develop their own application without the risk of modifying real world
809
+ * resources.
810
+ *
811
+ * When you set an environment, we will return it back to you when validating the key, so you can
812
+ * handle it correctly.
813
+ */
814
+ environment?: string;
815
+ };
816
+ };
817
+ };
818
+ responses: {
819
+ /** @description The configuration for an api */
820
+ 200: {
821
+ content: {
822
+ "application/json": {
311
823
  /**
312
- * @description Sets if key is enabled or disabled. Disabled keys are not valid.
313
- * @default true
314
- * @example false
824
+ * @description The id of the key. This is not a secret and can be stored as a reference if you wish. You need the keyId to update or delete a key later.
825
+ * @example key_123
315
826
  */
316
- enabled?: boolean;
827
+ keyId: string;
317
828
  /**
318
- * @description Environments allow you to divide your keyspace.
319
- *
320
- * Some applications like Stripe, Clerk, WorkOS and others have a concept of "live" and "test" keys to
321
- * give the developer a way to develop their own application without the risk of modifying real world
322
- * resources.
323
- *
324
- * When you set an environment, we will return it back to you when validating the key, so you can
325
- * handle it correctly.
829
+ * @description The newly created api key, do not store this on your own system but pass it along to your user.
830
+ * @example prefix_xxxxxxxxx
326
831
  */
327
- environment?: string;
832
+ key: string;
328
833
  };
329
834
  };
330
835
  };
331
- responses: {
332
- /** @description The configuration for an api */
333
- 200: {
334
- content: {
335
- "application/json": {
336
- /**
337
- * @description The id of the key. This is not a secret and can be stored as a reference if you wish. You need the keyId to update or delete a key later.
338
- * @example key_123
339
- */
340
- keyId: string;
341
- /**
342
- * @description The newly created api key, do not store this on your own system but pass it along to your user.
343
- * @example prefix_xxxxxxxxx
344
- */
345
- key: string;
346
- };
347
- };
348
- };
349
- /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
350
- 400: {
351
- content: {
352
- "application/json": components["schemas"]["ErrBadRequest"];
353
- };
836
+ /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
837
+ 400: {
838
+ content: {
839
+ "application/json": components["schemas"]["ErrBadRequest"];
354
840
  };
355
- /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
356
- 401: {
357
- content: {
358
- "application/json": components["schemas"]["ErrUnauthorized"];
359
- };
841
+ };
842
+ /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
843
+ 401: {
844
+ content: {
845
+ "application/json": components["schemas"]["ErrUnauthorized"];
360
846
  };
361
- /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
362
- 403: {
363
- content: {
364
- "application/json": components["schemas"]["ErrForbidden"];
365
- };
847
+ };
848
+ /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
849
+ 403: {
850
+ content: {
851
+ "application/json": components["schemas"]["ErrForbidden"];
366
852
  };
367
- /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
368
- 404: {
369
- content: {
370
- "application/json": components["schemas"]["ErrNotFound"];
371
- };
853
+ };
854
+ /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
855
+ 404: {
856
+ content: {
857
+ "application/json": components["schemas"]["ErrNotFound"];
372
858
  };
373
- /** @description This response is sent when a request conflicts with the current state of the server. */
374
- 409: {
375
- content: {
376
- "application/json": components["schemas"]["ErrConflict"];
377
- };
859
+ };
860
+ /** @description This response is sent when a request conflicts with the current state of the server. */
861
+ 409: {
862
+ content: {
863
+ "application/json": components["schemas"]["ErrConflict"];
378
864
  };
379
- /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
380
- 429: {
381
- content: {
382
- "application/json": components["schemas"]["ErrTooManyRequests"];
383
- };
865
+ };
866
+ /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
867
+ 429: {
868
+ content: {
869
+ "application/json": components["schemas"]["ErrTooManyRequests"];
384
870
  };
385
- /** @description The server has encountered a situation it does not know how to handle. */
386
- 500: {
387
- content: {
388
- "application/json": components["schemas"]["ErrInternalServerError"];
389
- };
871
+ };
872
+ /** @description The server has encountered a situation it does not know how to handle. */
873
+ 500: {
874
+ content: {
875
+ "application/json": components["schemas"]["ErrInternalServerError"];
390
876
  };
391
877
  };
392
878
  };
393
879
  };
394
- "/v1/keys.verifyKey": {
395
- post: {
396
- requestBody: {
880
+ verifyKey: {
881
+ requestBody: {
882
+ content: {
883
+ "application/json": components["schemas"]["V1KeysVerifyKeyRequest"];
884
+ };
885
+ };
886
+ responses: {
887
+ /** @description The verification result */
888
+ 200: {
397
889
  content: {
398
- "application/json": components["schemas"]["V1KeysVerifyKeyRequest"];
890
+ "application/json": components["schemas"]["V1KeysVerifyKeyResponse"];
399
891
  };
400
892
  };
401
- responses: {
402
- /** @description The verification result */
403
- 200: {
404
- content: {
405
- "application/json": components["schemas"]["V1KeysVerifyKeyResponse"];
406
- };
407
- };
408
- /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
409
- 400: {
410
- content: {
411
- "application/json": components["schemas"]["ErrBadRequest"];
412
- };
893
+ /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
894
+ 400: {
895
+ content: {
896
+ "application/json": components["schemas"]["ErrBadRequest"];
413
897
  };
414
- /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
415
- 401: {
416
- content: {
417
- "application/json": components["schemas"]["ErrUnauthorized"];
418
- };
898
+ };
899
+ /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
900
+ 401: {
901
+ content: {
902
+ "application/json": components["schemas"]["ErrUnauthorized"];
419
903
  };
420
- /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
421
- 403: {
422
- content: {
423
- "application/json": components["schemas"]["ErrForbidden"];
424
- };
904
+ };
905
+ /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
906
+ 403: {
907
+ content: {
908
+ "application/json": components["schemas"]["ErrForbidden"];
425
909
  };
426
- /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
427
- 404: {
428
- content: {
429
- "application/json": components["schemas"]["ErrNotFound"];
430
- };
910
+ };
911
+ /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
912
+ 404: {
913
+ content: {
914
+ "application/json": components["schemas"]["ErrNotFound"];
431
915
  };
432
- /** @description This response is sent when a request conflicts with the current state of the server. */
433
- 409: {
434
- content: {
435
- "application/json": components["schemas"]["ErrConflict"];
436
- };
916
+ };
917
+ /** @description This response is sent when a request conflicts with the current state of the server. */
918
+ 409: {
919
+ content: {
920
+ "application/json": components["schemas"]["ErrConflict"];
437
921
  };
438
- /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
439
- 429: {
440
- content: {
441
- "application/json": components["schemas"]["ErrTooManyRequests"];
442
- };
922
+ };
923
+ /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
924
+ 429: {
925
+ content: {
926
+ "application/json": components["schemas"]["ErrTooManyRequests"];
443
927
  };
444
- /** @description The server has encountered a situation it does not know how to handle. */
445
- 500: {
446
- content: {
447
- "application/json": components["schemas"]["ErrInternalServerError"];
448
- };
928
+ };
929
+ /** @description The server has encountered a situation it does not know how to handle. */
930
+ 500: {
931
+ content: {
932
+ "application/json": components["schemas"]["ErrInternalServerError"];
449
933
  };
450
934
  };
451
935
  };
452
936
  };
453
- "/v1/keys.updateKey": {
454
- post: {
455
- requestBody: {
456
- content: {
457
- "application/json": {
458
- /**
459
- * @description The id of the key you want to modify
460
- * @example key_123
461
- */
462
- keyId: string;
463
- /**
464
- * @description The name of the key
465
- * @example Customer X
466
- */
467
- name?: string | null;
468
- /**
469
- * @description The id of the tenant associated with this key. Use whatever reference you have in your system to identify the tenant. When verifying the key, we will send this field back to you, so you know who is accessing your API.
470
- * @example user_123
471
- */
472
- ownerId?: string | null;
473
- /**
474
- * @description Any additional metadata you want to store with the key
475
- * @example {
476
- * "roles": [
477
- * "admin",
478
- * "user"
479
- * ],
480
- * "stripeCustomerId": "cus_1234"
481
- * }
482
- */
483
- meta?: {
484
- [key: string]: unknown;
485
- } | null;
486
- /**
487
- * @description The unix timestamp in milliseconds when the key will expire. If this field is null or undefined, the key is not expiring.
488
- * @example 0
489
- */
490
- expires?: number | null;
491
- /**
492
- * @description Unkey comes with per-key ratelimiting out of the box. Set `null` to disable.
493
- * @example {
494
- * "type": "fast",
495
- * "limit": 10,
496
- * "refillRate": 1,
497
- * "refillInterval": 60
498
- * }
499
- */
500
- ratelimit?: ({
501
- /**
502
- * @description Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate.
503
- * @enum {string}
504
- */
505
- type: "fast" | "consistent";
506
- /** @description The total amount of burstable requests. */
507
- limit: number;
508
- /** @description How many tokens to refill during each refillInterval. */
509
- refillRate: number;
510
- /** @description Determines the speed at which tokens are refilled, in milliseconds. */
511
- refillInterval: number;
512
- }) | null;
513
- /**
514
- * @description The number of requests that can be made with this key before it becomes invalid. Set `null` to disable.
515
- * @example 1000
516
- */
517
- remaining?: number | null;
937
+ updateKey: {
938
+ requestBody: {
939
+ content: {
940
+ "application/json": {
941
+ /**
942
+ * @description The id of the key you want to modify
943
+ * @example key_123
944
+ */
945
+ keyId: string;
946
+ /**
947
+ * @description The name of the key
948
+ * @example Customer X
949
+ */
950
+ name?: string | null;
951
+ /**
952
+ * @description The id of the tenant associated with this key. Use whatever reference you have in your system to identify the tenant. When verifying the key, we will send this field back to you, so you know who is accessing your API.
953
+ * @example user_123
954
+ */
955
+ ownerId?: string | null;
956
+ /**
957
+ * @description Any additional metadata you want to store with the key
958
+ * @example {
959
+ * "roles": [
960
+ * "admin",
961
+ * "user"
962
+ * ],
963
+ * "stripeCustomerId": "cus_1234"
964
+ * }
965
+ */
966
+ meta?: {
967
+ [key: string]: unknown;
968
+ } | null;
969
+ /**
970
+ * @description The unix timestamp in milliseconds when the key will expire. If this field is null or undefined, the key is not expiring.
971
+ * @example 0
972
+ */
973
+ expires?: number | null;
974
+ /**
975
+ * @description Unkey comes with per-key ratelimiting out of the box. Set `null` to disable.
976
+ * @example {
977
+ * "type": "fast",
978
+ * "limit": 10,
979
+ * "refillRate": 1,
980
+ * "refillInterval": 60
981
+ * }
982
+ */
983
+ ratelimit?: ({
518
984
  /**
519
- * @description Unkey enables you to refill verifications for each key at regular intervals.
520
- * @example {
521
- * "interval": "daily",
522
- * "amount": 100
523
- * }
985
+ * @description Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate.
986
+ * @enum {string}
524
987
  */
525
- refill?: ({
526
- /**
527
- * @description Unkey will automatically refill verifications at the set interval. If null is used the refill functionality will be removed from the key.
528
- * @enum {string}
529
- */
530
- interval: "daily" | "monthly";
531
- /** @description The amount of verifications to refill for each occurrence is determined individually for each key. */
532
- amount: number;
533
- }) | null;
988
+ type: "fast" | "consistent";
989
+ /** @description The total amount of burstable requests. */
990
+ limit: number;
991
+ /** @description How many tokens to refill during each refillInterval. */
992
+ refillRate: number;
993
+ /** @description Determines the speed at which tokens are refilled, in milliseconds. */
994
+ refillInterval: number;
995
+ }) | null;
996
+ /**
997
+ * @description The number of requests that can be made with this key before it becomes invalid. Set `null` to disable.
998
+ * @example 1000
999
+ */
1000
+ remaining?: number | null;
1001
+ /**
1002
+ * @description Unkey enables you to refill verifications for each key at regular intervals.
1003
+ * @example {
1004
+ * "interval": "daily",
1005
+ * "amount": 100
1006
+ * }
1007
+ */
1008
+ refill?: ({
534
1009
  /**
535
- * @description Set if key is enabled or disabled. If disabled, the key cannot be used to verify.
536
- * @example true
1010
+ * @description Unkey will automatically refill verifications at the set interval. If null is used the refill functionality will be removed from the key.
1011
+ * @enum {string}
537
1012
  */
538
- enabled?: boolean;
539
- };
1013
+ interval: "daily" | "monthly";
1014
+ /** @description The amount of verifications to refill for each occurrence is determined individually for each key. */
1015
+ amount: number;
1016
+ }) | null;
1017
+ /**
1018
+ * @description Set if key is enabled or disabled. If disabled, the key cannot be used to verify.
1019
+ * @example true
1020
+ */
1021
+ enabled?: boolean;
540
1022
  };
541
1023
  };
542
- responses: {
543
- /** @description The key was successfully updated, it may take up to 30s for this to take effect in all regions */
544
- 200: {
545
- content: {
546
- "application/json": Record<string, never>;
547
- };
1024
+ };
1025
+ responses: {
1026
+ /** @description The key was successfully updated, it may take up to 30s for this to take effect in all regions */
1027
+ 200: {
1028
+ content: {
1029
+ "application/json": Record<string, never>;
548
1030
  };
549
- /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
550
- 400: {
551
- content: {
552
- "application/json": components["schemas"]["ErrBadRequest"];
553
- };
1031
+ };
1032
+ /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
1033
+ 400: {
1034
+ content: {
1035
+ "application/json": components["schemas"]["ErrBadRequest"];
554
1036
  };
555
- /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
556
- 401: {
557
- content: {
558
- "application/json": components["schemas"]["ErrUnauthorized"];
559
- };
1037
+ };
1038
+ /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
1039
+ 401: {
1040
+ content: {
1041
+ "application/json": components["schemas"]["ErrUnauthorized"];
560
1042
  };
561
- /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
562
- 403: {
563
- content: {
564
- "application/json": components["schemas"]["ErrForbidden"];
565
- };
1043
+ };
1044
+ /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
1045
+ 403: {
1046
+ content: {
1047
+ "application/json": components["schemas"]["ErrForbidden"];
566
1048
  };
567
- /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
568
- 404: {
569
- content: {
570
- "application/json": components["schemas"]["ErrNotFound"];
571
- };
1049
+ };
1050
+ /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
1051
+ 404: {
1052
+ content: {
1053
+ "application/json": components["schemas"]["ErrNotFound"];
572
1054
  };
573
- /** @description This response is sent when a request conflicts with the current state of the server. */
574
- 409: {
575
- content: {
576
- "application/json": components["schemas"]["ErrConflict"];
577
- };
1055
+ };
1056
+ /** @description This response is sent when a request conflicts with the current state of the server. */
1057
+ 409: {
1058
+ content: {
1059
+ "application/json": components["schemas"]["ErrConflict"];
578
1060
  };
579
- /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
580
- 429: {
581
- content: {
582
- "application/json": components["schemas"]["ErrTooManyRequests"];
583
- };
1061
+ };
1062
+ /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
1063
+ 429: {
1064
+ content: {
1065
+ "application/json": components["schemas"]["ErrTooManyRequests"];
584
1066
  };
585
- /** @description The server has encountered a situation it does not know how to handle. */
586
- 500: {
587
- content: {
588
- "application/json": components["schemas"]["ErrInternalServerError"];
589
- };
1067
+ };
1068
+ /** @description The server has encountered a situation it does not know how to handle. */
1069
+ 500: {
1070
+ content: {
1071
+ "application/json": components["schemas"]["ErrInternalServerError"];
590
1072
  };
591
1073
  };
592
1074
  };
593
1075
  };
594
- "/v1/keys.updateRemaining": {
595
- post: {
596
- requestBody: {
1076
+ updateRemaining: {
1077
+ requestBody: {
1078
+ content: {
1079
+ "application/json": {
1080
+ /**
1081
+ * @description The id of the key you want to modify
1082
+ * @example key_123
1083
+ */
1084
+ keyId: string;
1085
+ /**
1086
+ * @description The operation you want to perform on the remaining count
1087
+ * @enum {string}
1088
+ */
1089
+ op: "increment" | "decrement" | "set";
1090
+ /**
1091
+ * @description The value you want to set, add or subtract the remaining count by
1092
+ * @example 1
1093
+ */
1094
+ value: number | null;
1095
+ };
1096
+ };
1097
+ };
1098
+ responses: {
1099
+ /** @description The configuration for an api */
1100
+ 200: {
597
1101
  content: {
598
1102
  "application/json": {
599
1103
  /**
600
- * @description The id of the key you want to modify
601
- * @example key_123
602
- */
603
- keyId: string;
604
- /**
605
- * @description The operation you want to perform on the remaining count
606
- * @enum {string}
607
- */
608
- op: "increment" | "decrement" | "set";
609
- /**
610
- * @description The value you want to set, add or subtract the remaining count by
611
- * @example 1
1104
+ * @description The number of remaining requests for this key after updating it. `null` means unlimited.
1105
+ * @example 100
612
1106
  */
613
- value: number | null;
1107
+ remaining: number | null;
614
1108
  };
615
1109
  };
616
1110
  };
617
- responses: {
618
- /** @description The configuration for an api */
619
- 200: {
620
- content: {
621
- "application/json": {
622
- /**
623
- * @description The number of remaining requests for this key after updating it. `null` means unlimited.
624
- * @example 100
625
- */
626
- remaining: number | null;
627
- };
628
- };
629
- };
630
- /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
631
- 400: {
632
- content: {
633
- "application/json": components["schemas"]["ErrBadRequest"];
634
- };
1111
+ /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
1112
+ 400: {
1113
+ content: {
1114
+ "application/json": components["schemas"]["ErrBadRequest"];
635
1115
  };
636
- /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
637
- 401: {
638
- content: {
639
- "application/json": components["schemas"]["ErrUnauthorized"];
640
- };
1116
+ };
1117
+ /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
1118
+ 401: {
1119
+ content: {
1120
+ "application/json": components["schemas"]["ErrUnauthorized"];
641
1121
  };
642
- /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
643
- 403: {
644
- content: {
645
- "application/json": components["schemas"]["ErrForbidden"];
646
- };
1122
+ };
1123
+ /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
1124
+ 403: {
1125
+ content: {
1126
+ "application/json": components["schemas"]["ErrForbidden"];
647
1127
  };
648
- /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
649
- 404: {
650
- content: {
651
- "application/json": components["schemas"]["ErrNotFound"];
652
- };
1128
+ };
1129
+ /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
1130
+ 404: {
1131
+ content: {
1132
+ "application/json": components["schemas"]["ErrNotFound"];
653
1133
  };
654
- /** @description This response is sent when a request conflicts with the current state of the server. */
655
- 409: {
656
- content: {
657
- "application/json": components["schemas"]["ErrConflict"];
658
- };
1134
+ };
1135
+ /** @description This response is sent when a request conflicts with the current state of the server. */
1136
+ 409: {
1137
+ content: {
1138
+ "application/json": components["schemas"]["ErrConflict"];
659
1139
  };
660
- /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
661
- 429: {
662
- content: {
663
- "application/json": components["schemas"]["ErrTooManyRequests"];
664
- };
1140
+ };
1141
+ /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
1142
+ 429: {
1143
+ content: {
1144
+ "application/json": components["schemas"]["ErrTooManyRequests"];
665
1145
  };
666
- /** @description The server has encountered a situation it does not know how to handle. */
667
- 500: {
668
- content: {
669
- "application/json": components["schemas"]["ErrInternalServerError"];
670
- };
1146
+ };
1147
+ /** @description The server has encountered a situation it does not know how to handle. */
1148
+ 500: {
1149
+ content: {
1150
+ "application/json": components["schemas"]["ErrInternalServerError"];
671
1151
  };
672
1152
  };
673
1153
  };
674
1154
  };
675
- "/v1/keys.getVerifications": {
676
- get: {
677
- parameters: {
678
- query?: {
679
- keyId?: string;
680
- ownerId?: string;
681
- start?: number | null;
682
- end?: number | null;
683
- granularity?: "day";
684
- };
685
- };
686
- responses: {
687
- /** @description Usage numbers over time */
688
- 200: {
689
- content: {
690
- "application/json": {
691
- verifications: {
692
- /**
693
- * @description The timestamp of the usage data
694
- * @example 1620000000000
695
- */
696
- time: number;
697
- /**
698
- * @description The number of successful requests
699
- * @example 100
700
- */
701
- success: number;
702
- /**
703
- * @description The number of requests that were rate limited
704
- * @example 10
705
- */
706
- rateLimited: number;
707
- /**
708
- * @description The number of requests that exceeded the usage limit
709
- * @example 0
710
- */
711
- usageExceeded: number;
712
- }[];
713
- };
1155
+ getVerifications: {
1156
+ parameters: {
1157
+ query?: {
1158
+ keyId?: string;
1159
+ ownerId?: string;
1160
+ start?: number | null;
1161
+ end?: number | null;
1162
+ granularity?: "day";
1163
+ };
1164
+ };
1165
+ responses: {
1166
+ /** @description Usage numbers over time */
1167
+ 200: {
1168
+ content: {
1169
+ "application/json": {
1170
+ verifications: {
1171
+ /**
1172
+ * @description The timestamp of the usage data
1173
+ * @example 1620000000000
1174
+ */
1175
+ time: number;
1176
+ /**
1177
+ * @description The number of successful requests
1178
+ * @example 100
1179
+ */
1180
+ success: number;
1181
+ /**
1182
+ * @description The number of requests that were rate limited
1183
+ * @example 10
1184
+ */
1185
+ rateLimited: number;
1186
+ /**
1187
+ * @description The number of requests that exceeded the usage limit
1188
+ * @example 0
1189
+ */
1190
+ usageExceeded: number;
1191
+ }[];
714
1192
  };
715
1193
  };
716
- /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
717
- 400: {
718
- content: {
719
- "application/json": components["schemas"]["ErrBadRequest"];
720
- };
1194
+ };
1195
+ /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
1196
+ 400: {
1197
+ content: {
1198
+ "application/json": components["schemas"]["ErrBadRequest"];
721
1199
  };
722
- /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
723
- 401: {
724
- content: {
725
- "application/json": components["schemas"]["ErrUnauthorized"];
726
- };
1200
+ };
1201
+ /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
1202
+ 401: {
1203
+ content: {
1204
+ "application/json": components["schemas"]["ErrUnauthorized"];
727
1205
  };
728
- /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
729
- 403: {
730
- content: {
731
- "application/json": components["schemas"]["ErrForbidden"];
732
- };
1206
+ };
1207
+ /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
1208
+ 403: {
1209
+ content: {
1210
+ "application/json": components["schemas"]["ErrForbidden"];
733
1211
  };
734
- /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
735
- 404: {
736
- content: {
737
- "application/json": components["schemas"]["ErrNotFound"];
738
- };
1212
+ };
1213
+ /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
1214
+ 404: {
1215
+ content: {
1216
+ "application/json": components["schemas"]["ErrNotFound"];
739
1217
  };
740
- /** @description This response is sent when a request conflicts with the current state of the server. */
741
- 409: {
742
- content: {
743
- "application/json": components["schemas"]["ErrConflict"];
744
- };
1218
+ };
1219
+ /** @description This response is sent when a request conflicts with the current state of the server. */
1220
+ 409: {
1221
+ content: {
1222
+ "application/json": components["schemas"]["ErrConflict"];
745
1223
  };
746
- /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
747
- 429: {
748
- content: {
749
- "application/json": components["schemas"]["ErrTooManyRequests"];
750
- };
1224
+ };
1225
+ /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
1226
+ 429: {
1227
+ content: {
1228
+ "application/json": components["schemas"]["ErrTooManyRequests"];
751
1229
  };
752
- /** @description The server has encountered a situation it does not know how to handle. */
753
- 500: {
754
- content: {
755
- "application/json": components["schemas"]["ErrInternalServerError"];
756
- };
1230
+ };
1231
+ /** @description The server has encountered a situation it does not know how to handle. */
1232
+ 500: {
1233
+ content: {
1234
+ "application/json": components["schemas"]["ErrInternalServerError"];
757
1235
  };
758
1236
  };
759
1237
  };
760
1238
  };
761
- "/v1/apis.getApi": {
762
- get: {
763
- parameters: {
764
- query: {
765
- apiId: string;
766
- };
1239
+ getApi: {
1240
+ parameters: {
1241
+ query: {
1242
+ apiId: string;
767
1243
  };
768
- responses: {
769
- /** @description The configuration for an api */
770
- 200: {
771
- content: {
772
- "application/json": {
773
- /**
774
- * @description The id of the key
775
- * @example key_1234
776
- */
777
- id: string;
778
- /**
779
- * @description The id of the workspace that owns the api
780
- * @example ws_1234
781
- */
782
- workspaceId: string;
783
- /**
784
- * @description The name of the api. This is internal and your users will not see this.
785
- * @example Unkey - Production
786
- */
787
- name?: string;
788
- };
1244
+ };
1245
+ responses: {
1246
+ /** @description The configuration for an api */
1247
+ 200: {
1248
+ content: {
1249
+ "application/json": {
1250
+ /**
1251
+ * @description The id of the key
1252
+ * @example key_1234
1253
+ */
1254
+ id: string;
1255
+ /**
1256
+ * @description The id of the workspace that owns the api
1257
+ * @example ws_1234
1258
+ */
1259
+ workspaceId: string;
1260
+ /**
1261
+ * @description The name of the api. This is internal and your users will not see this.
1262
+ * @example Unkey - Production
1263
+ */
1264
+ name?: string;
789
1265
  };
790
1266
  };
791
- /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
792
- 400: {
793
- content: {
794
- "application/json": components["schemas"]["ErrBadRequest"];
795
- };
1267
+ };
1268
+ /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
1269
+ 400: {
1270
+ content: {
1271
+ "application/json": components["schemas"]["ErrBadRequest"];
796
1272
  };
797
- /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
798
- 401: {
799
- content: {
800
- "application/json": components["schemas"]["ErrUnauthorized"];
801
- };
1273
+ };
1274
+ /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
1275
+ 401: {
1276
+ content: {
1277
+ "application/json": components["schemas"]["ErrUnauthorized"];
802
1278
  };
803
- /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
804
- 403: {
805
- content: {
806
- "application/json": components["schemas"]["ErrForbidden"];
807
- };
1279
+ };
1280
+ /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
1281
+ 403: {
1282
+ content: {
1283
+ "application/json": components["schemas"]["ErrForbidden"];
808
1284
  };
809
- /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
810
- 404: {
811
- content: {
812
- "application/json": components["schemas"]["ErrNotFound"];
813
- };
1285
+ };
1286
+ /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
1287
+ 404: {
1288
+ content: {
1289
+ "application/json": components["schemas"]["ErrNotFound"];
814
1290
  };
815
- /** @description This response is sent when a request conflicts with the current state of the server. */
816
- 409: {
817
- content: {
818
- "application/json": components["schemas"]["ErrConflict"];
819
- };
1291
+ };
1292
+ /** @description This response is sent when a request conflicts with the current state of the server. */
1293
+ 409: {
1294
+ content: {
1295
+ "application/json": components["schemas"]["ErrConflict"];
820
1296
  };
821
- /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
822
- 429: {
823
- content: {
824
- "application/json": components["schemas"]["ErrTooManyRequests"];
825
- };
1297
+ };
1298
+ /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
1299
+ 429: {
1300
+ content: {
1301
+ "application/json": components["schemas"]["ErrTooManyRequests"];
826
1302
  };
827
- /** @description The server has encountered a situation it does not know how to handle. */
828
- 500: {
829
- content: {
830
- "application/json": components["schemas"]["ErrInternalServerError"];
831
- };
1303
+ };
1304
+ /** @description The server has encountered a situation it does not know how to handle. */
1305
+ 500: {
1306
+ content: {
1307
+ "application/json": components["schemas"]["ErrInternalServerError"];
832
1308
  };
833
1309
  };
834
1310
  };
835
1311
  };
836
- "/v1/apis.createApi": {
837
- post: {
838
- requestBody: {
1312
+ createApi: {
1313
+ requestBody: {
1314
+ content: {
1315
+ "application/json": {
1316
+ /**
1317
+ * @description The name for your API. This is not customer facing.
1318
+ * @example my-api
1319
+ */
1320
+ name: string;
1321
+ };
1322
+ };
1323
+ };
1324
+ responses: {
1325
+ /** @description The configuration for an api */
1326
+ 200: {
839
1327
  content: {
840
1328
  "application/json": {
841
1329
  /**
842
- * @description The name for your API. This is not customer facing.
843
- * @example my-api
1330
+ * @description The id of the api
1331
+ * @example api_134
844
1332
  */
845
- name: string;
1333
+ apiId: string;
846
1334
  };
847
1335
  };
848
1336
  };
849
- responses: {
850
- /** @description The configuration for an api */
851
- 200: {
852
- content: {
853
- "application/json": {
854
- /**
855
- * @description The id of the api
856
- * @example api_134
857
- */
858
- apiId: string;
859
- };
860
- };
861
- };
862
- /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
863
- 400: {
864
- content: {
865
- "application/json": components["schemas"]["ErrBadRequest"];
866
- };
1337
+ /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
1338
+ 400: {
1339
+ content: {
1340
+ "application/json": components["schemas"]["ErrBadRequest"];
867
1341
  };
868
- /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
869
- 401: {
870
- content: {
871
- "application/json": components["schemas"]["ErrUnauthorized"];
872
- };
1342
+ };
1343
+ /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
1344
+ 401: {
1345
+ content: {
1346
+ "application/json": components["schemas"]["ErrUnauthorized"];
873
1347
  };
874
- /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
875
- 403: {
876
- content: {
877
- "application/json": components["schemas"]["ErrForbidden"];
878
- };
1348
+ };
1349
+ /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
1350
+ 403: {
1351
+ content: {
1352
+ "application/json": components["schemas"]["ErrForbidden"];
879
1353
  };
880
- /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
881
- 404: {
882
- content: {
883
- "application/json": components["schemas"]["ErrNotFound"];
884
- };
1354
+ };
1355
+ /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
1356
+ 404: {
1357
+ content: {
1358
+ "application/json": components["schemas"]["ErrNotFound"];
885
1359
  };
886
- /** @description This response is sent when a request conflicts with the current state of the server. */
887
- 409: {
888
- content: {
889
- "application/json": components["schemas"]["ErrConflict"];
890
- };
1360
+ };
1361
+ /** @description This response is sent when a request conflicts with the current state of the server. */
1362
+ 409: {
1363
+ content: {
1364
+ "application/json": components["schemas"]["ErrConflict"];
891
1365
  };
892
- /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
893
- 429: {
894
- content: {
895
- "application/json": components["schemas"]["ErrTooManyRequests"];
896
- };
1366
+ };
1367
+ /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
1368
+ 429: {
1369
+ content: {
1370
+ "application/json": components["schemas"]["ErrTooManyRequests"];
897
1371
  };
898
- /** @description The server has encountered a situation it does not know how to handle. */
899
- 500: {
900
- content: {
901
- "application/json": components["schemas"]["ErrInternalServerError"];
902
- };
1372
+ };
1373
+ /** @description The server has encountered a situation it does not know how to handle. */
1374
+ 500: {
1375
+ content: {
1376
+ "application/json": components["schemas"]["ErrInternalServerError"];
903
1377
  };
904
1378
  };
905
1379
  };
906
1380
  };
907
- "/v1/apis.listKeys": {
908
- get: {
909
- parameters: {
910
- query: {
911
- apiId: string;
912
- limit?: number;
913
- cursor?: string;
914
- ownerId?: string;
915
- };
1381
+ listKeys: {
1382
+ parameters: {
1383
+ query: {
1384
+ apiId: string;
1385
+ limit?: number;
1386
+ cursor?: string;
1387
+ ownerId?: string;
916
1388
  };
917
- responses: {
918
- /** @description The configuration for an api */
919
- 200: {
920
- content: {
921
- "application/json": {
922
- keys: components["schemas"]["Key"][];
923
- /**
924
- * @description The cursor to use for the next page of results, if no cursor is returned, there are no more results
925
- * @example eyJrZXkiOiJrZXlfMTIzNCJ9
926
- */
927
- cursor?: string;
928
- /** @description The total number of keys for this api */
929
- total: number;
930
- };
1389
+ };
1390
+ responses: {
1391
+ /** @description The configuration for an api */
1392
+ 200: {
1393
+ content: {
1394
+ "application/json": {
1395
+ keys: components["schemas"]["Key"][];
1396
+ /**
1397
+ * @description The cursor to use for the next page of results, if no cursor is returned, there are no more results
1398
+ * @example eyJrZXkiOiJrZXlfMTIzNCJ9
1399
+ */
1400
+ cursor?: string;
1401
+ /** @description The total number of keys for this api */
1402
+ total: number;
931
1403
  };
932
1404
  };
933
- /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
934
- 400: {
935
- content: {
936
- "application/json": components["schemas"]["ErrBadRequest"];
937
- };
1405
+ };
1406
+ /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
1407
+ 400: {
1408
+ content: {
1409
+ "application/json": components["schemas"]["ErrBadRequest"];
938
1410
  };
939
- /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
940
- 401: {
941
- content: {
942
- "application/json": components["schemas"]["ErrUnauthorized"];
943
- };
1411
+ };
1412
+ /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
1413
+ 401: {
1414
+ content: {
1415
+ "application/json": components["schemas"]["ErrUnauthorized"];
944
1416
  };
945
- /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
946
- 403: {
947
- content: {
948
- "application/json": components["schemas"]["ErrForbidden"];
949
- };
1417
+ };
1418
+ /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
1419
+ 403: {
1420
+ content: {
1421
+ "application/json": components["schemas"]["ErrForbidden"];
950
1422
  };
951
- /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
952
- 404: {
953
- content: {
954
- "application/json": components["schemas"]["ErrNotFound"];
955
- };
1423
+ };
1424
+ /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
1425
+ 404: {
1426
+ content: {
1427
+ "application/json": components["schemas"]["ErrNotFound"];
956
1428
  };
957
- /** @description This response is sent when a request conflicts with the current state of the server. */
958
- 409: {
959
- content: {
960
- "application/json": components["schemas"]["ErrConflict"];
961
- };
1429
+ };
1430
+ /** @description This response is sent when a request conflicts with the current state of the server. */
1431
+ 409: {
1432
+ content: {
1433
+ "application/json": components["schemas"]["ErrConflict"];
962
1434
  };
963
- /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
964
- 429: {
965
- content: {
966
- "application/json": components["schemas"]["ErrTooManyRequests"];
967
- };
1435
+ };
1436
+ /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
1437
+ 429: {
1438
+ content: {
1439
+ "application/json": components["schemas"]["ErrTooManyRequests"];
968
1440
  };
969
- /** @description The server has encountered a situation it does not know how to handle. */
970
- 500: {
971
- content: {
972
- "application/json": components["schemas"]["ErrInternalServerError"];
973
- };
1441
+ };
1442
+ /** @description The server has encountered a situation it does not know how to handle. */
1443
+ 500: {
1444
+ content: {
1445
+ "application/json": components["schemas"]["ErrInternalServerError"];
974
1446
  };
975
1447
  };
976
1448
  };
977
1449
  };
978
- "/v1/apis.deleteApi": {
979
- post: {
980
- requestBody: {
981
- content: {
982
- "application/json": {
983
- /**
984
- * @description The id of the api to delete
985
- * @example api_1234
986
- */
987
- apiId: string;
988
- };
1450
+ deleteApi: {
1451
+ requestBody: {
1452
+ content: {
1453
+ "application/json": {
1454
+ /**
1455
+ * @description The id of the api to delete
1456
+ * @example api_1234
1457
+ */
1458
+ apiId: string;
989
1459
  };
990
1460
  };
991
- responses: {
992
- /** @description The api was successfully deleted, it may take up to 30s for this to take effect in all regions */
993
- 200: {
994
- content: {
995
- "application/json": Record<string, never>;
996
- };
1461
+ };
1462
+ responses: {
1463
+ /** @description The api was successfully deleted, it may take up to 30s for this to take effect in all regions */
1464
+ 200: {
1465
+ content: {
1466
+ "application/json": Record<string, never>;
997
1467
  };
998
- /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
999
- 400: {
1000
- content: {
1001
- "application/json": components["schemas"]["ErrBadRequest"];
1002
- };
1468
+ };
1469
+ /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
1470
+ 400: {
1471
+ content: {
1472
+ "application/json": components["schemas"]["ErrBadRequest"];
1003
1473
  };
1004
- /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
1005
- 401: {
1006
- content: {
1007
- "application/json": components["schemas"]["ErrUnauthorized"];
1008
- };
1474
+ };
1475
+ /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
1476
+ 401: {
1477
+ content: {
1478
+ "application/json": components["schemas"]["ErrUnauthorized"];
1009
1479
  };
1010
- /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
1011
- 403: {
1012
- content: {
1013
- "application/json": components["schemas"]["ErrForbidden"];
1014
- };
1480
+ };
1481
+ /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
1482
+ 403: {
1483
+ content: {
1484
+ "application/json": components["schemas"]["ErrForbidden"];
1015
1485
  };
1016
- /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
1017
- 404: {
1018
- content: {
1019
- "application/json": components["schemas"]["ErrNotFound"];
1020
- };
1486
+ };
1487
+ /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
1488
+ 404: {
1489
+ content: {
1490
+ "application/json": components["schemas"]["ErrNotFound"];
1021
1491
  };
1022
- /** @description This response is sent when a request conflicts with the current state of the server. */
1023
- 409: {
1024
- content: {
1025
- "application/json": components["schemas"]["ErrConflict"];
1026
- };
1492
+ };
1493
+ /** @description This response is sent when a request conflicts with the current state of the server. */
1494
+ 409: {
1495
+ content: {
1496
+ "application/json": components["schemas"]["ErrConflict"];
1027
1497
  };
1028
- /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
1029
- 429: {
1030
- content: {
1031
- "application/json": components["schemas"]["ErrTooManyRequests"];
1032
- };
1498
+ };
1499
+ /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
1500
+ 429: {
1501
+ content: {
1502
+ "application/json": components["schemas"]["ErrTooManyRequests"];
1033
1503
  };
1034
- /** @description The server has encountered a situation it does not know how to handle. */
1035
- 500: {
1036
- content: {
1037
- "application/json": components["schemas"]["ErrInternalServerError"];
1038
- };
1504
+ };
1505
+ /** @description The server has encountered a situation it does not know how to handle. */
1506
+ 500: {
1507
+ content: {
1508
+ "application/json": components["schemas"]["ErrInternalServerError"];
1039
1509
  };
1040
1510
  };
1041
1511
  };
1042
1512
  };
1043
- "/v1/ratelimits.limit": {
1044
- post: {
1045
- requestBody: {
1513
+ limit: {
1514
+ requestBody: {
1515
+ content: {
1516
+ "application/json": {
1517
+ /**
1518
+ * @description Namespaces group different limits together for better analytics. You might have a namespace for your public API and one for internal tRPC routes.
1519
+ * @default default
1520
+ * @example email.outbound
1521
+ */
1522
+ namespace?: string;
1523
+ /**
1524
+ * @description Identifier of your user, this can be their userId, an email, an ip or anything else.
1525
+ * @example user_123
1526
+ */
1527
+ identifier: string;
1528
+ /**
1529
+ * @description How many requests may pass in a given window.
1530
+ * @example 10
1531
+ */
1532
+ limit: number;
1533
+ /**
1534
+ * @description The window duration in milliseconds
1535
+ * @example 60000
1536
+ */
1537
+ duration: number;
1538
+ /**
1539
+ * @description Expensive requests may use up more tokens. You can specify a cost to the request here and we'll deduct this many tokens in the current window. If there are not enough tokens left, the request is denied.
1540
+ * @default 1
1541
+ * @example 2
1542
+ */
1543
+ cost?: number;
1544
+ /**
1545
+ * @description Async will return a response immediately, lowering latency at the cost of accuracy.
1546
+ * @default false
1547
+ */
1548
+ async?: boolean;
1549
+ /** @description Attach any metadata to this request */
1550
+ meta?: {
1551
+ [key: string]: unknown;
1552
+ };
1553
+ /**
1554
+ * @description Resources that are about to be accessed by the user
1555
+ * @example [
1556
+ * {
1557
+ * "type": "project",
1558
+ * "id": "p_123",
1559
+ * "name": "dub"
1560
+ * }
1561
+ * ]
1562
+ */
1563
+ resources?: {
1564
+ /**
1565
+ * @description The type of resource
1566
+ * @example organization
1567
+ */
1568
+ type: string;
1569
+ /**
1570
+ * @description The unique identifier for the resource
1571
+ * @example org_123
1572
+ */
1573
+ id: string;
1574
+ /**
1575
+ * @description A human readable name for this resource
1576
+ * @example unkey
1577
+ */
1578
+ name?: string;
1579
+ /** @description Attach any metadata to this resources */
1580
+ meta?: {
1581
+ [key: string]: unknown;
1582
+ };
1583
+ }[];
1584
+ };
1585
+ };
1586
+ };
1587
+ responses: {
1588
+ 200: {
1046
1589
  content: {
1047
1590
  "application/json": {
1048
1591
  /**
1049
- * @description Namespaces group different limits together for better analytics. You might have a namespace for your public API and one for internal tRPC routes.
1050
- * @default default
1051
- * @example email.outbound
1052
- */
1053
- namespace?: string;
1054
- /**
1055
- * @description Identifier of your user, this can be their userId, an email, an ip or anything else.
1056
- * @example user_123
1592
+ * @description Returns true if the request should be processed, false if it was rejected.
1593
+ * @example true
1057
1594
  */
1058
- identifier: string;
1595
+ success: boolean;
1059
1596
  /**
1060
- * @description How many requests may pass in a given window.
1597
+ * @description How many requests are allowed within a window.
1061
1598
  * @example 10
1062
1599
  */
1063
1600
  limit: number;
1064
1601
  /**
1065
- * @description The window duration in milliseconds
1066
- * @example 60000
1067
- */
1068
- duration: number;
1069
- /**
1070
- * @description Expensive requests may use up more tokens. You can specify a cost to the request here and we'll deduct this many tokens in the current window. If there are not enough tokens left, the request is denied.
1071
- * @default 1
1072
- * @example 2
1073
- */
1074
- cost?: number;
1075
- /**
1076
- * @description Async will return a response immediately, lowering latency at the cost of accuracy.
1077
- * @default false
1602
+ * @description How many requests can still be made in the current window.
1603
+ * @example 9
1078
1604
  */
1079
- async?: boolean;
1080
- /** @description Attach any metadata to this request */
1081
- meta?: {
1082
- [key: string]: unknown;
1083
- };
1605
+ remaining: number;
1084
1606
  /**
1085
- * @description Resources that are about to be accessed by the user
1086
- * @example [
1087
- * {
1088
- * "type": "project",
1089
- * "id": "p_123",
1090
- * "name": "dub"
1091
- * }
1092
- * ]
1607
+ * @description A unix millisecond timestamp when the limits reset.
1608
+ * @example 1709804263654
1093
1609
  */
1094
- resources?: {
1095
- /**
1096
- * @description The type of resource
1097
- * @example organization
1098
- */
1099
- type: string;
1100
- /**
1101
- * @description The unique identifier for the resource
1102
- * @example org_123
1103
- */
1104
- id: string;
1105
- /**
1106
- * @description A human readable name for this resource
1107
- * @example unkey
1108
- */
1109
- name?: string;
1110
- /** @description Attach any metadata to this resources */
1111
- meta?: {
1112
- [key: string]: unknown;
1113
- };
1114
- }[];
1610
+ reset: number;
1115
1611
  };
1116
1612
  };
1117
1613
  };
1118
- responses: {
1119
- 200: {
1120
- content: {
1121
- "application/json": {
1122
- /**
1123
- * @description Returns true if the request should be processed, false if it was rejected.
1124
- * @example true
1125
- */
1126
- success: boolean;
1127
- /**
1128
- * @description How many requests are allowed within a window.
1129
- * @example 10
1130
- */
1131
- limit: number;
1132
- /**
1133
- * @description How many requests can still be made in the current window.
1134
- * @example 9
1135
- */
1136
- remaining: number;
1137
- /**
1138
- * @description A unix millisecond timestamp when the limits reset.
1139
- * @example 1709804263654
1140
- */
1141
- reset: number;
1142
- };
1143
- };
1144
- };
1145
- /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
1146
- 400: {
1147
- content: {
1148
- "application/json": components["schemas"]["ErrBadRequest"];
1149
- };
1614
+ /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
1615
+ 400: {
1616
+ content: {
1617
+ "application/json": components["schemas"]["ErrBadRequest"];
1150
1618
  };
1151
- /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
1152
- 401: {
1153
- content: {
1154
- "application/json": components["schemas"]["ErrUnauthorized"];
1155
- };
1619
+ };
1620
+ /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
1621
+ 401: {
1622
+ content: {
1623
+ "application/json": components["schemas"]["ErrUnauthorized"];
1156
1624
  };
1157
- /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
1158
- 403: {
1159
- content: {
1160
- "application/json": components["schemas"]["ErrForbidden"];
1161
- };
1625
+ };
1626
+ /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
1627
+ 403: {
1628
+ content: {
1629
+ "application/json": components["schemas"]["ErrForbidden"];
1162
1630
  };
1163
- /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
1164
- 404: {
1165
- content: {
1166
- "application/json": components["schemas"]["ErrNotFound"];
1167
- };
1631
+ };
1632
+ /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
1633
+ 404: {
1634
+ content: {
1635
+ "application/json": components["schemas"]["ErrNotFound"];
1168
1636
  };
1169
- /** @description This response is sent when a request conflicts with the current state of the server. */
1170
- 409: {
1171
- content: {
1172
- "application/json": components["schemas"]["ErrConflict"];
1173
- };
1637
+ };
1638
+ /** @description This response is sent when a request conflicts with the current state of the server. */
1639
+ 409: {
1640
+ content: {
1641
+ "application/json": components["schemas"]["ErrConflict"];
1174
1642
  };
1175
- /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
1176
- 429: {
1177
- content: {
1178
- "application/json": components["schemas"]["ErrTooManyRequests"];
1179
- };
1643
+ };
1644
+ /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
1645
+ 429: {
1646
+ content: {
1647
+ "application/json": components["schemas"]["ErrTooManyRequests"];
1180
1648
  };
1181
- /** @description The server has encountered a situation it does not know how to handle. */
1182
- 500: {
1183
- content: {
1184
- "application/json": components["schemas"]["ErrInternalServerError"];
1185
- };
1649
+ };
1650
+ /** @description The server has encountered a situation it does not know how to handle. */
1651
+ 500: {
1652
+ content: {
1653
+ "application/json": components["schemas"]["ErrInternalServerError"];
1186
1654
  };
1187
1655
  };
1188
1656
  };
1189
1657
  };
1190
- "/v1/keys": {
1191
- post: {
1192
- requestBody: {
1193
- content: {
1194
- "application/json": {
1658
+ "v1.migrations.createKeys": {
1659
+ requestBody: {
1660
+ content: {
1661
+ "application/json": ({
1195
1662
  /**
1196
1663
  * @description Choose an `API` where this key should be created.
1197
1664
  * @example api_123
@@ -1210,11 +1677,21 @@ interface paths {
1210
1677
  * @example my key
1211
1678
  */
1212
1679
  name?: string;
1680
+ hash: {
1681
+ /** @description The hashed and encoded key */
1682
+ value: string;
1683
+ /**
1684
+ * @description The algorithm for hashing and encoding, currently only sha256 and base64 are supported
1685
+ * @enum {string}
1686
+ */
1687
+ variant: "sha256_base64";
1688
+ };
1213
1689
  /**
1214
- * @description The byte length used to generate your key determines its entropy as well as its length. Higher is better, but keys become longer and more annoying to handle. The default is 16 bytes, or 2^^128 possible combinations.
1215
- * @default 16
1690
+ * @description The first 4 characters of the key. If a prefix is used, it should be the prefix plus 4 characters.
1691
+ * @default
1692
+ * @example unkey_32kq
1216
1693
  */
1217
- byteLength?: number;
1694
+ start?: string;
1218
1695
  /**
1219
1696
  * @description Your user’s Id. This will provide a link between Unkey and your customer record.
1220
1697
  * When validating a key, we will return this back to you, so you can clearly identify your user from their api key.
@@ -1231,6 +1708,14 @@ interface paths {
1231
1708
  meta?: {
1232
1709
  [key: string]: unknown;
1233
1710
  };
1711
+ /**
1712
+ * @description A list of roles that this key should have. If the role does not exist, an error is thrown
1713
+ * @example [
1714
+ * "admin",
1715
+ * "finance"
1716
+ * ]
1717
+ */
1718
+ roles?: string[];
1234
1719
  /**
1235
1720
  * @description You can auto expire keys by providing a unix timestamp in milliseconds. Once Keys expire they will automatically be disabled and are no longer valid unless you enable them again.
1236
1721
  * @example 1623869797161
@@ -1241,6 +1726,22 @@ interface paths {
1241
1726
  * @example 1000
1242
1727
  */
1243
1728
  remaining?: number;
1729
+ /**
1730
+ * @description Unkey enables you to refill verifications for each key at regular intervals.
1731
+ * @example {
1732
+ * "interval": "daily",
1733
+ * "amount": 100
1734
+ * }
1735
+ */
1736
+ refill?: {
1737
+ /**
1738
+ * @description Unkey will automatically refill verifications at the set interval.
1739
+ * @enum {string}
1740
+ */
1741
+ interval: "daily" | "monthly";
1742
+ /** @description The number of verifications to refill for each occurrence is determined individually for each key. */
1743
+ amount: number;
1744
+ };
1244
1745
  /**
1245
1746
  * @description Unkey comes with per-key ratelimiting out of the box.
1246
1747
  * @example {
@@ -1264,735 +1765,456 @@ interface paths {
1264
1765
  /** @description Determines the speed at which tokens are refilled, in milliseconds. */
1265
1766
  refillInterval: number;
1266
1767
  };
1768
+ /**
1769
+ * @description Sets if key is enabled or disabled. Disabled keys are not valid.
1770
+ * @default true
1771
+ * @example false
1772
+ */
1773
+ enabled?: boolean;
1774
+ /**
1775
+ * @description Environments allow you to divide your keyspace.
1776
+ *
1777
+ * Some applications like Stripe, Clerk, WorkOS and others have a concept of "live" and "test" keys to
1778
+ * give the developer a way to develop their own application without the risk of modifying real world
1779
+ * resources.
1780
+ *
1781
+ * When you set an environment, we will return it back to you when validating the key, so you can
1782
+ * handle it correctly.
1783
+ */
1784
+ environment?: string;
1785
+ })[];
1786
+ };
1787
+ };
1788
+ responses: {
1789
+ /** @description The key ids of all created keys */
1790
+ 200: {
1791
+ content: {
1792
+ "application/json": {
1793
+ /**
1794
+ * @description The ids of the keys. This is not a secret and can be stored as a reference if you wish. You need the keyId to update or delete a key later.
1795
+ * @example [
1796
+ * "key_123",
1797
+ * "key_456"
1798
+ * ]
1799
+ */
1800
+ keyIds: string[];
1267
1801
  };
1268
1802
  };
1269
1803
  };
1270
- responses: {
1271
- /** @description The configuration for an api */
1272
- 200: {
1273
- content: {
1274
- "application/json": {
1275
- /**
1276
- * @description The id of the key. This is not a secret and can be stored as a reference if you wish. You need the keyId to update or delete a key later.
1277
- * @example key_123
1278
- */
1279
- keyId: string;
1280
- /**
1281
- * @description The newly created api key, do not store this on your own system but pass it along to your user.
1282
- * @example prefix_xxxxxxxxx
1283
- */
1284
- key: string;
1285
- };
1286
- };
1804
+ /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
1805
+ 400: {
1806
+ content: {
1807
+ "application/json": components["schemas"]["ErrBadRequest"];
1287
1808
  };
1288
- /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
1289
- 400: {
1290
- content: {
1291
- "application/json": components["schemas"]["ErrBadRequest"];
1292
- };
1809
+ };
1810
+ /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
1811
+ 401: {
1812
+ content: {
1813
+ "application/json": components["schemas"]["ErrUnauthorized"];
1293
1814
  };
1294
- /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
1295
- 401: {
1296
- content: {
1297
- "application/json": components["schemas"]["ErrUnauthorized"];
1298
- };
1815
+ };
1816
+ /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
1817
+ 403: {
1818
+ content: {
1819
+ "application/json": components["schemas"]["ErrForbidden"];
1299
1820
  };
1300
- /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
1301
- 403: {
1302
- content: {
1303
- "application/json": components["schemas"]["ErrForbidden"];
1304
- };
1821
+ };
1822
+ /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
1823
+ 404: {
1824
+ content: {
1825
+ "application/json": components["schemas"]["ErrNotFound"];
1305
1826
  };
1306
- /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
1307
- 404: {
1308
- content: {
1309
- "application/json": components["schemas"]["ErrNotFound"];
1310
- };
1827
+ };
1828
+ /** @description This response is sent when a request conflicts with the current state of the server. */
1829
+ 409: {
1830
+ content: {
1831
+ "application/json": components["schemas"]["ErrConflict"];
1311
1832
  };
1312
- /** @description This response is sent when a request conflicts with the current state of the server. */
1313
- 409: {
1314
- content: {
1315
- "application/json": components["schemas"]["ErrConflict"];
1316
- };
1833
+ };
1834
+ /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
1835
+ 429: {
1836
+ content: {
1837
+ "application/json": components["schemas"]["ErrTooManyRequests"];
1317
1838
  };
1318
- /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
1319
- 429: {
1320
- content: {
1321
- "application/json": components["schemas"]["ErrTooManyRequests"];
1322
- };
1839
+ };
1840
+ /** @description The server has encountered a situation it does not know how to handle. */
1841
+ 500: {
1842
+ content: {
1843
+ "application/json": components["schemas"]["ErrInternalServerError"];
1323
1844
  };
1324
- /** @description The server has encountered a situation it does not know how to handle. */
1325
- 500: {
1326
- content: {
1327
- "application/json": components["schemas"]["ErrInternalServerError"];
1845
+ };
1846
+ };
1847
+ };
1848
+ "deprecated.createKey": {
1849
+ requestBody: {
1850
+ content: {
1851
+ "application/json": {
1852
+ /**
1853
+ * @description Choose an `API` where this key should be created.
1854
+ * @example api_123
1855
+ */
1856
+ apiId: string;
1857
+ /**
1858
+ * @description To make it easier for your users to understand which product an api key belongs to, you can add prefix them.
1859
+ *
1860
+ * For example Stripe famously prefixes their customer ids with cus_ or their api keys with sk_live_.
1861
+ *
1862
+ * The underscore is automatically added if you are defining a prefix, for example: "prefix": "abc" will result in a key like abc_xxxxxxxxx
1863
+ */
1864
+ prefix?: string;
1865
+ /**
1866
+ * @description The name for your Key. This is not customer facing.
1867
+ * @example my key
1868
+ */
1869
+ name?: string;
1870
+ /**
1871
+ * @description The byte length used to generate your key determines its entropy as well as its length. Higher is better, but keys become longer and more annoying to handle. The default is 16 bytes, or 2^^128 possible combinations.
1872
+ * @default 16
1873
+ */
1874
+ byteLength?: number;
1875
+ /**
1876
+ * @description Your user’s Id. This will provide a link between Unkey and your customer record.
1877
+ * When validating a key, we will return this back to you, so you can clearly identify your user from their api key.
1878
+ * @example team_123
1879
+ */
1880
+ ownerId?: string;
1881
+ /**
1882
+ * @description This is a place for dynamic meta data, anything that feels useful for you should go here
1883
+ * @example {
1884
+ * "billingTier": "PRO",
1885
+ * "trialEnds": "2023-06-16T17:16:37.161Z"
1886
+ * }
1887
+ */
1888
+ meta?: {
1889
+ [key: string]: unknown;
1890
+ };
1891
+ /**
1892
+ * @description You can auto expire keys by providing a unix timestamp in milliseconds. Once Keys expire they will automatically be disabled and are no longer valid unless you enable them again.
1893
+ * @example 1623869797161
1894
+ */
1895
+ expires?: number;
1896
+ /**
1897
+ * @description You can limit the number of requests a key can make. Once a key reaches 0 remaining requests, it will automatically be disabled and is no longer valid unless you update it.
1898
+ * @example 1000
1899
+ */
1900
+ remaining?: number;
1901
+ /**
1902
+ * @description Unkey comes with per-key ratelimiting out of the box.
1903
+ * @example {
1904
+ * "type": "fast",
1905
+ * "limit": 10,
1906
+ * "refillRate": 1,
1907
+ * "refillInterval": 60
1908
+ * }
1909
+ */
1910
+ ratelimit?: {
1911
+ /**
1912
+ * @description Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate.
1913
+ * @default fast
1914
+ * @enum {string}
1915
+ */
1916
+ type?: "fast" | "consistent";
1917
+ /** @description The total amount of burstable requests. */
1918
+ limit: number;
1919
+ /** @description How many tokens to refill during each refillInterval. */
1920
+ refillRate: number;
1921
+ /** @description Determines the speed at which tokens are refilled, in milliseconds. */
1922
+ refillInterval: number;
1328
1923
  };
1329
1924
  };
1330
1925
  };
1331
1926
  };
1332
- };
1333
- "/v1/keys/verify": {
1334
- post: {
1335
- requestBody: {
1927
+ responses: {
1928
+ /** @description The configuration for an api */
1929
+ 200: {
1336
1930
  content: {
1337
1931
  "application/json": {
1338
1932
  /**
1339
- * @description The id of the api where the key belongs to. This is optional for now but will be required soon.
1340
- * The key will be verified against the api's configuration. If the key does not belong to the api, the verification will fail.
1341
- * @example api_1234
1933
+ * @description The id of the key. This is not a secret and can be stored as a reference if you wish. You need the keyId to update or delete a key later.
1934
+ * @example key_123
1342
1935
  */
1343
- apiId?: string;
1936
+ keyId: string;
1344
1937
  /**
1345
- * @description The key to verify
1346
- * @example sk_1234
1938
+ * @description The newly created api key, do not store this on your own system but pass it along to your user.
1939
+ * @example prefix_xxxxxxxxx
1347
1940
  */
1348
1941
  key: string;
1349
1942
  };
1350
1943
  };
1351
1944
  };
1352
- responses: {
1353
- /** @description The verification result */
1354
- 200: {
1355
- content: {
1356
- "application/json": {
1357
- /**
1358
- * @description The id of the key
1359
- * @example key_1234
1360
- */
1361
- keyId?: string;
1362
- /**
1363
- * @description Whether the key is valid or not.
1364
- * A key could be invalid for a number of reasons, for example if it has expired, has no more verifications left or if it has been deleted.
1365
- * @example true
1366
- */
1367
- valid: boolean;
1368
- /**
1369
- * @description The name of the key, give keys a name to easily identifiy their purpose
1370
- * @example Customer X
1371
- */
1372
- name?: string;
1373
- /**
1374
- * @description The id of the tenant associated with this key. Use whatever reference you have in your system to identify the tenant. When verifying the key, we will send this field back to you, so you know who is accessing your API.
1375
- * @example user_123
1376
- */
1377
- ownerId?: string;
1378
- /**
1379
- * @description Any additional metadata you want to store with the key
1380
- * @example {
1381
- * "roles": [
1382
- * "admin",
1383
- * "user"
1384
- * ],
1385
- * "stripeCustomerId": "cus_1234"
1386
- * }
1387
- */
1388
- meta?: {
1389
- [key: string]: unknown;
1390
- };
1391
- /**
1392
- * @description The unix timestamp in milliseconds when the key was created
1393
- * @example 0
1394
- */
1395
- createdAt?: number;
1396
- /**
1397
- * @description The unix timestamp in milliseconds when the key was deleted. We don't delete the key outright, you can restore it later.
1398
- * @example 0
1399
- */
1400
- deletedAt?: number;
1401
- /**
1402
- * @description The unix timestamp in milliseconds when the key will expire. If this field is null or undefined, the key is not expiring.
1403
- * @example 123
1404
- */
1405
- expires?: number;
1945
+ /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
1946
+ 400: {
1947
+ content: {
1948
+ "application/json": components["schemas"]["ErrBadRequest"];
1949
+ };
1950
+ };
1951
+ /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
1952
+ 401: {
1953
+ content: {
1954
+ "application/json": components["schemas"]["ErrUnauthorized"];
1955
+ };
1956
+ };
1957
+ /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
1958
+ 403: {
1959
+ content: {
1960
+ "application/json": components["schemas"]["ErrForbidden"];
1961
+ };
1962
+ };
1963
+ /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
1964
+ 404: {
1965
+ content: {
1966
+ "application/json": components["schemas"]["ErrNotFound"];
1967
+ };
1968
+ };
1969
+ /** @description This response is sent when a request conflicts with the current state of the server. */
1970
+ 409: {
1971
+ content: {
1972
+ "application/json": components["schemas"]["ErrConflict"];
1973
+ };
1974
+ };
1975
+ /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
1976
+ 429: {
1977
+ content: {
1978
+ "application/json": components["schemas"]["ErrTooManyRequests"];
1979
+ };
1980
+ };
1981
+ /** @description The server has encountered a situation it does not know how to handle. */
1982
+ 500: {
1983
+ content: {
1984
+ "application/json": components["schemas"]["ErrInternalServerError"];
1985
+ };
1986
+ };
1987
+ };
1988
+ };
1989
+ /** @deprecated */
1990
+ "deprecated.verifyKey": {
1991
+ requestBody: {
1992
+ content: {
1993
+ "application/json": {
1994
+ /**
1995
+ * @description The id of the api where the key belongs to. This is optional for now but will be required soon.
1996
+ * The key will be verified against the api's configuration. If the key does not belong to the api, the verification will fail.
1997
+ * @example api_1234
1998
+ */
1999
+ apiId?: string;
2000
+ /**
2001
+ * @description The key to verify
2002
+ * @example sk_1234
2003
+ */
2004
+ key: string;
2005
+ };
2006
+ };
2007
+ };
2008
+ responses: {
2009
+ /** @description The verification result */
2010
+ 200: {
2011
+ content: {
2012
+ "application/json": {
2013
+ /**
2014
+ * @description The id of the key
2015
+ * @example key_1234
2016
+ */
2017
+ keyId?: string;
2018
+ /**
2019
+ * @description Whether the key is valid or not.
2020
+ * A key could be invalid for a number of reasons, for example if it has expired, has no more verifications left or if it has been deleted.
2021
+ * @example true
2022
+ */
2023
+ valid: boolean;
2024
+ /**
2025
+ * @description The name of the key, give keys a name to easily identifiy their purpose
2026
+ * @example Customer X
2027
+ */
2028
+ name?: string;
2029
+ /**
2030
+ * @description The id of the tenant associated with this key. Use whatever reference you have in your system to identify the tenant. When verifying the key, we will send this field back to you, so you know who is accessing your API.
2031
+ * @example user_123
2032
+ */
2033
+ ownerId?: string;
2034
+ /**
2035
+ * @description Any additional metadata you want to store with the key
2036
+ * @example {
2037
+ * "roles": [
2038
+ * "admin",
2039
+ * "user"
2040
+ * ],
2041
+ * "stripeCustomerId": "cus_1234"
2042
+ * }
2043
+ */
2044
+ meta?: {
2045
+ [key: string]: unknown;
2046
+ };
2047
+ /**
2048
+ * @description The unix timestamp in milliseconds when the key was created
2049
+ * @example 0
2050
+ */
2051
+ createdAt?: number;
2052
+ /**
2053
+ * @description The unix timestamp in milliseconds when the key was deleted. We don't delete the key outright, you can restore it later.
2054
+ * @example 0
2055
+ */
2056
+ deletedAt?: number;
2057
+ /**
2058
+ * @description The unix timestamp in milliseconds when the key will expire. If this field is null or undefined, the key is not expiring.
2059
+ * @example 123
2060
+ */
2061
+ expires?: number;
2062
+ /**
2063
+ * @description The ratelimit configuration for this key. If this field is null or undefined, the key has no ratelimit.
2064
+ * @example {
2065
+ * "limit": 10,
2066
+ * "remaining": 9,
2067
+ * "reset": 3600000
2068
+ * }
2069
+ */
2070
+ ratelimit?: {
1406
2071
  /**
1407
- * @description The ratelimit configuration for this key. If this field is null or undefined, the key has no ratelimit.
1408
- * @example {
1409
- * "limit": 10,
1410
- * "remaining": 9,
1411
- * "reset": 3600000
1412
- * }
2072
+ * @description Maximum number of requests that can be made inside a window
2073
+ * @example 10
1413
2074
  */
1414
- ratelimit?: {
1415
- /**
1416
- * @description Maximum number of requests that can be made inside a window
1417
- * @example 10
1418
- */
1419
- limit: number;
1420
- /**
1421
- * @description Remaining requests after this verification
1422
- * @example 9
1423
- */
1424
- remaining: number;
1425
- /**
1426
- * @description Unix timestamp in milliseconds when the ratelimit will reset
1427
- * @example 3600000
1428
- */
1429
- reset: number;
1430
- };
2075
+ limit: number;
1431
2076
  /**
1432
- * @description The number of requests that can be made with this key before it becomes invalid. If this field is null or undefined, the key has no request limit.
1433
- * @example 1000
2077
+ * @description Remaining requests after this verification
2078
+ * @example 9
1434
2079
  */
1435
- remaining?: number;
2080
+ remaining: number;
1436
2081
  /**
1437
- * @description If the key is invalid this field will be set to the reason why it is invalid.
1438
- * Possible values are:
1439
- * - NOT_FOUND: the key does not exist or has expired
1440
- * - FORBIDDEN: the key is not allowed to access the api
1441
- * - USAGE_EXCEEDED: the key has exceeded its request limit
1442
- * - RATE_LIMITED: the key has been ratelimited,
1443
- * - INSUFFICIENT_PERMISSIONS: you do not have the required permissions to perform this action
1444
- *
1445
- * @example NOT_FOUND
1446
- * @enum {string}
2082
+ * @description Unix timestamp in milliseconds when the ratelimit will reset
2083
+ * @example 3600000
1447
2084
  */
1448
- code?: "NOT_FOUND" | "FORBIDDEN" | "USAGE_EXCEEDED" | "RATE_LIMITED" | "UNAUTHORIZED" | "DISABLED" | "INSUFFICIENT_PERMISSIONS";
2085
+ reset: number;
1449
2086
  };
1450
- };
1451
- };
1452
- /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
1453
- 400: {
1454
- content: {
1455
- "application/json": components["schemas"]["ErrBadRequest"];
1456
- };
1457
- };
1458
- /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
1459
- 401: {
1460
- content: {
1461
- "application/json": components["schemas"]["ErrUnauthorized"];
1462
- };
1463
- };
1464
- /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
1465
- 403: {
1466
- content: {
1467
- "application/json": components["schemas"]["ErrForbidden"];
1468
- };
1469
- };
1470
- /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
1471
- 404: {
1472
- content: {
1473
- "application/json": components["schemas"]["ErrNotFound"];
1474
- };
1475
- };
1476
- /** @description This response is sent when a request conflicts with the current state of the server. */
1477
- 409: {
1478
- content: {
1479
- "application/json": components["schemas"]["ErrConflict"];
1480
- };
1481
- };
1482
- /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
1483
- 429: {
1484
- content: {
1485
- "application/json": components["schemas"]["ErrTooManyRequests"];
1486
- };
1487
- };
1488
- /** @description The server has encountered a situation it does not know how to handle. */
1489
- 500: {
1490
- content: {
1491
- "application/json": components["schemas"]["ErrInternalServerError"];
2087
+ /**
2088
+ * @description The number of requests that can be made with this key before it becomes invalid. If this field is null or undefined, the key has no request limit.
2089
+ * @example 1000
2090
+ */
2091
+ remaining?: number;
2092
+ /**
2093
+ * @description If the key is invalid this field will be set to the reason why it is invalid.
2094
+ * Possible values are:
2095
+ * - NOT_FOUND: the key does not exist or has expired
2096
+ * - FORBIDDEN: the key is not allowed to access the api
2097
+ * - USAGE_EXCEEDED: the key has exceeded its request limit
2098
+ * - RATE_LIMITED: the key has been ratelimited,
2099
+ * - INSUFFICIENT_PERMISSIONS: you do not have the required permissions to perform this action
2100
+ *
2101
+ * @example NOT_FOUND
2102
+ * @enum {string}
2103
+ */
2104
+ code?: "NOT_FOUND" | "FORBIDDEN" | "USAGE_EXCEEDED" | "RATE_LIMITED" | "UNAUTHORIZED" | "DISABLED" | "INSUFFICIENT_PERMISSIONS";
1492
2105
  };
1493
2106
  };
1494
2107
  };
1495
- };
1496
- };
1497
- "/v1/apis/{apiId}/keys": {
1498
- get: {
1499
- parameters: {
1500
- query?: {
1501
- limit?: number;
1502
- offset?: number | null;
1503
- ownerId?: string;
1504
- };
1505
- path: {
1506
- apiId: string;
2108
+ /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
2109
+ 400: {
2110
+ content: {
2111
+ "application/json": components["schemas"]["ErrBadRequest"];
1507
2112
  };
1508
2113
  };
1509
- responses: {
1510
- /** @description Keys belonging to the api */
1511
- 200: {
1512
- content: {
1513
- "application/json": {
1514
- keys: components["schemas"]["Key"][];
1515
- /** @description The total number of keys for this api */
1516
- total: number;
1517
- };
1518
- };
1519
- };
1520
- /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
1521
- 400: {
1522
- content: {
1523
- "application/json": components["schemas"]["ErrBadRequest"];
1524
- };
1525
- };
1526
- /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
1527
- 401: {
1528
- content: {
1529
- "application/json": components["schemas"]["ErrUnauthorized"];
1530
- };
1531
- };
1532
- /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
1533
- 403: {
1534
- content: {
1535
- "application/json": components["schemas"]["ErrForbidden"];
1536
- };
1537
- };
1538
- /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
1539
- 404: {
1540
- content: {
1541
- "application/json": components["schemas"]["ErrNotFound"];
1542
- };
1543
- };
1544
- /** @description This response is sent when a request conflicts with the current state of the server. */
1545
- 409: {
1546
- content: {
1547
- "application/json": components["schemas"]["ErrConflict"];
1548
- };
1549
- };
1550
- /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
1551
- 429: {
1552
- content: {
1553
- "application/json": components["schemas"]["ErrTooManyRequests"];
1554
- };
1555
- };
1556
- /** @description The server has encountered a situation it does not know how to handle. */
1557
- 500: {
1558
- content: {
1559
- "application/json": components["schemas"]["ErrInternalServerError"];
1560
- };
2114
+ /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
2115
+ 401: {
2116
+ content: {
2117
+ "application/json": components["schemas"]["ErrUnauthorized"];
1561
2118
  };
1562
2119
  };
1563
- };
1564
- };
1565
- }
1566
-
1567
- interface components {
1568
- schemas: {
1569
- ErrBadRequest: {
1570
- error: {
1571
- /**
1572
- * @description A machine readable error code.
1573
- * @example BAD_REQUEST
1574
- * @enum {string}
1575
- */
1576
- code: "BAD_REQUEST";
1577
- /**
1578
- * @description A link to our documentation with more details about this error code
1579
- * @example https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST
1580
- */
1581
- docs: string;
1582
- /** @description A human readable explanation of what went wrong */
1583
- message: string;
1584
- /**
1585
- * @description Please always include the requestId in your error report
1586
- * @example req_1234
1587
- */
1588
- requestId: string;
1589
- };
1590
- };
1591
- ErrUnauthorized: {
1592
- error: {
1593
- /**
1594
- * @description A machine readable error code.
1595
- * @example UNAUTHORIZED
1596
- * @enum {string}
1597
- */
1598
- code: "UNAUTHORIZED";
1599
- /**
1600
- * @description A link to our documentation with more details about this error code
1601
- * @example https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED
1602
- */
1603
- docs: string;
1604
- /** @description A human readable explanation of what went wrong */
1605
- message: string;
1606
- /**
1607
- * @description Please always include the requestId in your error report
1608
- * @example req_1234
1609
- */
1610
- requestId: string;
1611
- };
1612
- };
1613
- ErrForbidden: {
1614
- error: {
1615
- /**
1616
- * @description A machine readable error code.
1617
- * @example FORBIDDEN
1618
- * @enum {string}
1619
- */
1620
- code: "FORBIDDEN";
1621
- /**
1622
- * @description A link to our documentation with more details about this error code
1623
- * @example https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN
1624
- */
1625
- docs: string;
1626
- /** @description A human readable explanation of what went wrong */
1627
- message: string;
1628
- /**
1629
- * @description Please always include the requestId in your error report
1630
- * @example req_1234
1631
- */
1632
- requestId: string;
1633
- };
1634
- };
1635
- ErrNotFound: {
1636
- error: {
1637
- /**
1638
- * @description A machine readable error code.
1639
- * @example NOT_FOUND
1640
- * @enum {string}
1641
- */
1642
- code: "NOT_FOUND";
1643
- /**
1644
- * @description A link to our documentation with more details about this error code
1645
- * @example https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND
1646
- */
1647
- docs: string;
1648
- /** @description A human readable explanation of what went wrong */
1649
- message: string;
1650
- /**
1651
- * @description Please always include the requestId in your error report
1652
- * @example req_1234
1653
- */
1654
- requestId: string;
1655
- };
1656
- };
1657
- ErrConflict: {
1658
- error: {
1659
- /**
1660
- * @description A machine readable error code.
1661
- * @example CONFLICT
1662
- * @enum {string}
1663
- */
1664
- code: "CONFLICT";
1665
- /**
1666
- * @description A link to our documentation with more details about this error code
1667
- * @example https://unkey.dev/docs/api-reference/errors/code/CONFLICT
1668
- */
1669
- docs: string;
1670
- /** @description A human readable explanation of what went wrong */
1671
- message: string;
1672
- /**
1673
- * @description Please always include the requestId in your error report
1674
- * @example req_1234
1675
- */
1676
- requestId: string;
1677
- };
1678
- };
1679
- ErrTooManyRequests: {
1680
- error: {
1681
- /**
1682
- * @description A machine readable error code.
1683
- * @example TOO_MANY_REQUESTS
1684
- * @enum {string}
1685
- */
1686
- code: "TOO_MANY_REQUESTS";
1687
- /**
1688
- * @description A link to our documentation with more details about this error code
1689
- * @example https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS
1690
- */
1691
- docs: string;
1692
- /** @description A human readable explanation of what went wrong */
1693
- message: string;
1694
- /**
1695
- * @description Please always include the requestId in your error report
1696
- * @example req_1234
1697
- */
1698
- requestId: string;
1699
- };
1700
- };
1701
- ErrInternalServerError: {
1702
- error: {
1703
- /**
1704
- * @description A machine readable error code.
1705
- * @example INTERNAL_SERVER_ERROR
1706
- * @enum {string}
1707
- */
1708
- code: "INTERNAL_SERVER_ERROR";
1709
- /**
1710
- * @description A link to our documentation with more details about this error code
1711
- * @example https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR
1712
- */
1713
- docs: string;
1714
- /** @description A human readable explanation of what went wrong */
1715
- message: string;
1716
- /**
1717
- * @description Please always include the requestId in your error report
1718
- * @example req_1234
1719
- */
1720
- requestId: string;
2120
+ /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
2121
+ 403: {
2122
+ content: {
2123
+ "application/json": components["schemas"]["ErrForbidden"];
2124
+ };
1721
2125
  };
1722
- };
1723
- Key: {
1724
- /**
1725
- * @description The id of the key
1726
- * @example key_1234
1727
- */
1728
- id: string;
1729
- /**
1730
- * @description The first few characters of the key to visually identify it
1731
- * @example sk_5j1
1732
- */
1733
- start: string;
1734
- /**
1735
- * @description The id of the workspace that owns the key
1736
- * @example ws_1234
1737
- */
1738
- workspaceId: string;
1739
- /**
1740
- * @description The id of the api that this key is for
1741
- * @example api_1234
1742
- */
1743
- apiId?: string;
1744
- /**
1745
- * @description The name of the key, give keys a name to easily identify their purpose
1746
- * @example Customer X
1747
- */
1748
- name?: string;
1749
- /**
1750
- * @description The id of the tenant associated with this key. Use whatever reference you have in your system to identify the tenant. When verifying the key, we will send this field back to you, so you know who is accessing your API.
1751
- * @example user_123
1752
- */
1753
- ownerId?: string;
1754
- /**
1755
- * @description Any additional metadata you want to store with the key
1756
- * @example {
1757
- * "roles": [
1758
- * "admin",
1759
- * "user"
1760
- * ],
1761
- * "stripeCustomerId": "cus_1234"
1762
- * }
1763
- */
1764
- meta?: {
1765
- [key: string]: unknown;
2126
+ /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
2127
+ 404: {
2128
+ content: {
2129
+ "application/json": components["schemas"]["ErrNotFound"];
2130
+ };
1766
2131
  };
1767
- /**
1768
- * @description The unix timestamp in milliseconds when the key was created
1769
- * @example 0
1770
- */
1771
- createdAt?: number;
1772
- /**
1773
- * @description The unix timestamp in milliseconds when the key was deleted. We don't delete the key outright, you can restore it later.
1774
- * @example 0
1775
- */
1776
- deletedAt?: number;
1777
- /**
1778
- * @description The unix timestamp in milliseconds when the key will expire. If this field is null or undefined, the key is not expiring.
1779
- * @example 0
1780
- */
1781
- expires?: number;
1782
- /**
1783
- * @description The number of requests that can be made with this key before it becomes invalid. If this field is null or undefined, the key has no request limit.
1784
- * @example 1000
1785
- */
1786
- remaining?: number;
1787
- /**
1788
- * @description Unkey allows you to refill remaining verifications on a key on a regular interval.
1789
- * @example {
1790
- * "interval": "daily",
1791
- * "amount": 10
1792
- * }
1793
- */
1794
- refill?: {
1795
- /**
1796
- * @description Determines the rate at which verifications will be refilled.
1797
- * @example daily
1798
- * @enum {string}
1799
- */
1800
- interval: "daily" | "monthly";
1801
- /**
1802
- * @description Resets `remaining` to this value every interval.
1803
- * @example 100
1804
- */
1805
- amount: number;
1806
- /**
1807
- * @description The unix timestamp in miliseconds when the key was last refilled.
1808
- * @example 100
1809
- */
1810
- lastRefillAt?: number;
2132
+ /** @description This response is sent when a request conflicts with the current state of the server. */
2133
+ 409: {
2134
+ content: {
2135
+ "application/json": components["schemas"]["ErrConflict"];
2136
+ };
1811
2137
  };
1812
- /**
1813
- * @description Unkey comes with per-key ratelimiting out of the box.
1814
- * @example {
1815
- * "type": "fast",
1816
- * "limit": 10,
1817
- * "refillRate": 1,
1818
- * "refillInterval": 60
1819
- * }
1820
- */
1821
- ratelimit?: {
1822
- /**
1823
- * @description Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate.
1824
- * @default fast
1825
- * @enum {string}
1826
- */
1827
- type?: "fast" | "consistent";
1828
- /** @description The total amount of burstable requests. */
1829
- limit: number;
1830
- /** @description How many tokens to refill during each refillInterval. */
1831
- refillRate: number;
1832
- /** @description Determines the speed at which tokens are refilled, in milliseconds. */
1833
- refillInterval: number;
2138
+ /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
2139
+ 429: {
2140
+ content: {
2141
+ "application/json": components["schemas"]["ErrTooManyRequests"];
2142
+ };
2143
+ };
2144
+ /** @description The server has encountered a situation it does not know how to handle. */
2145
+ 500: {
2146
+ content: {
2147
+ "application/json": components["schemas"]["ErrInternalServerError"];
2148
+ };
1834
2149
  };
1835
- /**
1836
- * @description All roles this key belongs to
1837
- * @example [
1838
- * "admin",
1839
- * "finance"
1840
- * ]
1841
- */
1842
- roles?: string[];
1843
- /**
1844
- * @description All permissions this key has
1845
- * @example [
1846
- * "domain.dns.create_record",
1847
- * "finance.read_receipt"
1848
- * ]
1849
- */
1850
- permissions?: string[];
1851
- /**
1852
- * @description Sets if key is enabled or disabled. Disabled keys are not valid.
1853
- * @example true
1854
- */
1855
- enabled?: boolean;
1856
2150
  };
1857
- V1KeysVerifyKeyResponse: {
1858
- /**
1859
- * @description The id of the key
1860
- * @example key_1234
1861
- */
1862
- keyId?: string;
1863
- /**
1864
- * @description Whether the key is valid or not.
1865
- * A key could be invalid for a number of reasons, for example if it has expired, has no more verifications left or if it has been deleted.
1866
- * @example true
1867
- */
1868
- valid: boolean;
1869
- /**
1870
- * @description The name of the key, give keys a name to easily identifiy their purpose
1871
- * @example Customer X
1872
- */
1873
- name?: string;
1874
- /**
1875
- * @description The id of the tenant associated with this key. Use whatever reference you have in your system to identify the tenant. When verifying the key, we will send this field back to you, so you know who is accessing your API.
1876
- * @example user_123
1877
- */
1878
- ownerId?: string;
1879
- /**
1880
- * @description Any additional metadata you want to store with the key
1881
- * @example {
1882
- * "roles": [
1883
- * "admin",
1884
- * "user"
1885
- * ],
1886
- * "stripeCustomerId": "cus_1234"
1887
- * }
1888
- */
1889
- meta?: {
1890
- [key: string]: unknown;
2151
+ };
2152
+ "deprecated.listKeys": {
2153
+ parameters: {
2154
+ query?: {
2155
+ limit?: number;
2156
+ offset?: number | null;
2157
+ ownerId?: string;
1891
2158
  };
1892
- /**
1893
- * @description The unix timestamp in milliseconds when the key will expire. If this field is null or undefined, the key is not expiring.
1894
- * @example 123
1895
- */
1896
- expires?: number;
1897
- /**
1898
- * @description The ratelimit configuration for this key. If this field is null or undefined, the key has no ratelimit.
1899
- * @example {
1900
- * "limit": 10,
1901
- * "remaining": 9,
1902
- * "reset": 3600000
1903
- * }
1904
- */
1905
- ratelimit?: {
1906
- /**
1907
- * @description Maximum number of requests that can be made inside a window
1908
- * @example 10
1909
- */
1910
- limit: number;
1911
- /**
1912
- * @description Remaining requests after this verification
1913
- * @example 9
1914
- */
1915
- remaining: number;
1916
- /**
1917
- * @description Unix timestamp in milliseconds when the ratelimit will reset
1918
- * @example 3600000
1919
- */
1920
- reset: number;
2159
+ path: {
2160
+ apiId: string;
1921
2161
  };
1922
- /**
1923
- * @description The number of requests that can be made with this key before it becomes invalid. If this field is null or undefined, the key has no request limit.
1924
- * @example 1000
1925
- */
1926
- remaining?: number;
1927
- /**
1928
- * @description A machine readable code why the key is not valid.
1929
- * Possible values are:
1930
- * - VALID: the key is valid and you should proceed
1931
- * - NOT_FOUND: the key does not exist or has expired
1932
- * - FORBIDDEN: the key is not allowed to access the api
1933
- * - USAGE_EXCEEDED: the key has exceeded its request limit
1934
- * - RATE_LIMITED: the key has been ratelimited
1935
- * - UNAUTHORIZED: the key is not authorized
1936
- * - DISABLED: the key is disabled
1937
- * - INSUFFICIENT_PERMISSIONS: you do not have the required permissions to perform this action
1938
- *
1939
- * @enum {string}
1940
- */
1941
- code: "VALID" | "NOT_FOUND" | "FORBIDDEN" | "USAGE_EXCEEDED" | "RATE_LIMITED" | "UNAUTHORIZED" | "DISABLED" | "INSUFFICIENT_PERMISSIONS";
1942
- /** @description Sets the key to be enabled or disabled. Disabled keys will not verify. */
1943
- enabled?: boolean;
1944
- /**
1945
- * @description A list of all the permissions this key is connected to.
1946
- * @example [
1947
- * "dns.record.update",
1948
- * "dns.record.delete"
1949
- * ]
1950
- */
1951
- permissions?: string[];
1952
- /**
1953
- * @description The environment of the key, this is what what you set when you crated the key
1954
- * @example test
1955
- */
1956
- environment?: string;
1957
2162
  };
1958
- V1KeysVerifyKeyRequest: {
1959
- /**
1960
- * @description The id of the api where the key belongs to. This is optional for now but will be required soon.
1961
- * The key will be verified against the api's configuration. If the key does not belong to the api, the verification will fail.
1962
- * @example api_1234
1963
- */
1964
- apiId?: string;
1965
- /**
1966
- * @description The key to verify
1967
- * @example sk_1234
1968
- */
1969
- key: string;
1970
- /** @description Perform RBAC checks */
1971
- authorization?: {
1972
- /**
1973
- * @description A query for which permissions you require
1974
- * @example {
1975
- * "or": [
1976
- * {
1977
- * "and": [
1978
- * "dns.record.read",
1979
- * "dns.record.update"
1980
- * ]
1981
- * },
1982
- * "admin"
1983
- * ]
1984
- * }
1985
- */
1986
- permissions?: Record<string, never>;
2163
+ responses: {
2164
+ /** @description Keys belonging to the api */
2165
+ 200: {
2166
+ content: {
2167
+ "application/json": {
2168
+ keys: components["schemas"]["Key"][];
2169
+ /** @description The total number of keys for this api */
2170
+ total: number;
2171
+ };
2172
+ };
2173
+ };
2174
+ /** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
2175
+ 400: {
2176
+ content: {
2177
+ "application/json": components["schemas"]["ErrBadRequest"];
2178
+ };
2179
+ };
2180
+ /** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
2181
+ 401: {
2182
+ content: {
2183
+ "application/json": components["schemas"]["ErrUnauthorized"];
2184
+ };
2185
+ };
2186
+ /** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
2187
+ 403: {
2188
+ content: {
2189
+ "application/json": components["schemas"]["ErrForbidden"];
2190
+ };
2191
+ };
2192
+ /** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
2193
+ 404: {
2194
+ content: {
2195
+ "application/json": components["schemas"]["ErrNotFound"];
2196
+ };
2197
+ };
2198
+ /** @description This response is sent when a request conflicts with the current state of the server. */
2199
+ 409: {
2200
+ content: {
2201
+ "application/json": components["schemas"]["ErrConflict"];
2202
+ };
2203
+ };
2204
+ /** @description The user has sent too many requests in a given amount of time ("rate limiting") */
2205
+ 429: {
2206
+ content: {
2207
+ "application/json": components["schemas"]["ErrTooManyRequests"];
2208
+ };
2209
+ };
2210
+ /** @description The server has encountered a situation it does not know how to handle. */
2211
+ 500: {
2212
+ content: {
2213
+ "application/json": components["schemas"]["ErrInternalServerError"];
2214
+ };
1987
2215
  };
1988
2216
  };
1989
2217
  };
1990
- responses: never;
1991
- parameters: {
1992
- };
1993
- requestBodies: never;
1994
- headers: never;
1995
- pathItems: never;
1996
2218
  }
1997
2219
 
1998
2220
  type ErrorResponse = paths["/v1/liveness"]["get"]["responses"]["500"]["content"]["application/json"];
@@ -2087,6 +2309,9 @@ declare class Unkey {
2087
2309
  authorization?: {
2088
2310
  permissions?: Record<string, never> | undefined;
2089
2311
  } | undefined;
2312
+ ratelimit?: {
2313
+ cost?: number | undefined;
2314
+ } | undefined;
2090
2315
  }, "authorization"> & {
2091
2316
  authorization?: {
2092
2317
  permissions: PermissionQuery<TPermission>;