@unkey/api 0.20.0 → 0.20.2

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