@unkey/api 2.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/README.md +2 -1
  2. package/bin/mcp-server.js +119 -22
  3. package/bin/mcp-server.js.map +17 -14
  4. package/dist/commonjs/funcs/identitiesListIdentities.js +3 -0
  5. package/dist/commonjs/funcs/identitiesListIdentities.js.map +1 -1
  6. package/dist/commonjs/funcs/ratelimitLimit.d.ts +2 -2
  7. package/dist/commonjs/funcs/ratelimitLimit.d.ts.map +1 -1
  8. package/dist/commonjs/funcs/ratelimitLimit.js +3 -3
  9. package/dist/commonjs/funcs/ratelimitLimit.js.map +1 -1
  10. package/dist/commonjs/lib/config.d.ts +3 -3
  11. package/dist/commonjs/lib/config.js +3 -3
  12. package/dist/commonjs/lib/security.d.ts.map +1 -1
  13. package/dist/commonjs/lib/security.js.map +1 -1
  14. package/dist/commonjs/mcp-server/mcp-server.js +1 -1
  15. package/dist/commonjs/mcp-server/server.js +1 -1
  16. package/dist/commonjs/mcp-server/tools/ratelimitLimit.js +1 -1
  17. package/dist/commonjs/models/components/index.d.ts +2 -0
  18. package/dist/commonjs/models/components/index.d.ts.map +1 -1
  19. package/dist/commonjs/models/components/index.js +2 -0
  20. package/dist/commonjs/models/components/index.js.map +1 -1
  21. package/dist/commonjs/models/components/keycreditsrefill.d.ts +8 -8
  22. package/dist/commonjs/models/components/keycreditsrefill.d.ts.map +1 -1
  23. package/dist/commonjs/models/components/keycreditsrefill.js +13 -14
  24. package/dist/commonjs/models/components/keycreditsrefill.js.map +1 -1
  25. package/dist/commonjs/models/components/updatekeycreditsdata.d.ts +41 -0
  26. package/dist/commonjs/models/components/updatekeycreditsdata.d.ts.map +1 -0
  27. package/dist/commonjs/models/components/updatekeycreditsdata.js +72 -0
  28. package/dist/commonjs/models/components/updatekeycreditsdata.js.map +1 -0
  29. package/dist/commonjs/models/components/updatekeycreditsrefill.d.ts +81 -0
  30. package/dist/commonjs/models/components/updatekeycreditsrefill.d.ts.map +1 -0
  31. package/dist/commonjs/models/components/updatekeycreditsrefill.js +95 -0
  32. package/dist/commonjs/models/components/updatekeycreditsrefill.js.map +1 -0
  33. package/dist/commonjs/models/components/v2keysupdatekeyrequestbody.d.ts +3 -3
  34. package/dist/commonjs/models/components/v2keysupdatekeyrequestbody.d.ts.map +1 -1
  35. package/dist/commonjs/models/components/v2keysupdatekeyrequestbody.js +3 -3
  36. package/dist/commonjs/models/components/v2keysupdatekeyrequestbody.js.map +1 -1
  37. package/dist/commonjs/models/errors/goneerrorresponse.d.ts +72 -0
  38. package/dist/commonjs/models/errors/goneerrorresponse.d.ts.map +1 -0
  39. package/dist/commonjs/models/errors/goneerrorresponse.js +99 -0
  40. package/dist/commonjs/models/errors/goneerrorresponse.js.map +1 -0
  41. package/dist/commonjs/models/errors/index.d.ts +1 -0
  42. package/dist/commonjs/models/errors/index.d.ts.map +1 -1
  43. package/dist/commonjs/models/errors/index.js +1 -0
  44. package/dist/commonjs/models/errors/index.js.map +1 -1
  45. package/dist/commonjs/sdk/ratelimit.d.ts +1 -1
  46. package/dist/commonjs/sdk/ratelimit.js +1 -1
  47. package/dist/esm/funcs/identitiesListIdentities.js +3 -0
  48. package/dist/esm/funcs/identitiesListIdentities.js.map +1 -1
  49. package/dist/esm/funcs/ratelimitLimit.d.ts +2 -2
  50. package/dist/esm/funcs/ratelimitLimit.d.ts.map +1 -1
  51. package/dist/esm/funcs/ratelimitLimit.js +3 -3
  52. package/dist/esm/funcs/ratelimitLimit.js.map +1 -1
  53. package/dist/esm/lib/config.d.ts +3 -3
  54. package/dist/esm/lib/config.js +3 -3
  55. package/dist/esm/lib/security.d.ts.map +1 -1
  56. package/dist/esm/lib/security.js.map +1 -1
  57. package/dist/esm/mcp-server/mcp-server.js +1 -1
  58. package/dist/esm/mcp-server/server.js +1 -1
  59. package/dist/esm/mcp-server/tools/ratelimitLimit.js +1 -1
  60. package/dist/esm/models/components/index.d.ts +2 -0
  61. package/dist/esm/models/components/index.d.ts.map +1 -1
  62. package/dist/esm/models/components/index.js +2 -0
  63. package/dist/esm/models/components/index.js.map +1 -1
  64. package/dist/esm/models/components/keycreditsrefill.d.ts +8 -8
  65. package/dist/esm/models/components/keycreditsrefill.d.ts.map +1 -1
  66. package/dist/esm/models/components/keycreditsrefill.js +12 -13
  67. package/dist/esm/models/components/keycreditsrefill.js.map +1 -1
  68. package/dist/esm/models/components/updatekeycreditsdata.d.ts +41 -0
  69. package/dist/esm/models/components/updatekeycreditsdata.d.ts.map +1 -0
  70. package/dist/esm/models/components/updatekeycreditsdata.js +34 -0
  71. package/dist/esm/models/components/updatekeycreditsdata.js.map +1 -0
  72. package/dist/esm/models/components/updatekeycreditsrefill.d.ts +81 -0
  73. package/dist/esm/models/components/updatekeycreditsrefill.d.ts.map +1 -0
  74. package/dist/esm/models/components/updatekeycreditsrefill.js +57 -0
  75. package/dist/esm/models/components/updatekeycreditsrefill.js.map +1 -0
  76. package/dist/esm/models/components/v2keysupdatekeyrequestbody.d.ts +3 -3
  77. package/dist/esm/models/components/v2keysupdatekeyrequestbody.d.ts.map +1 -1
  78. package/dist/esm/models/components/v2keysupdatekeyrequestbody.js +3 -3
  79. package/dist/esm/models/components/v2keysupdatekeyrequestbody.js.map +1 -1
  80. package/dist/esm/models/errors/goneerrorresponse.d.ts +72 -0
  81. package/dist/esm/models/errors/goneerrorresponse.d.ts.map +1 -0
  82. package/dist/esm/models/errors/goneerrorresponse.js +62 -0
  83. package/dist/esm/models/errors/goneerrorresponse.js.map +1 -0
  84. package/dist/esm/models/errors/index.d.ts +1 -0
  85. package/dist/esm/models/errors/index.d.ts.map +1 -1
  86. package/dist/esm/models/errors/index.js +1 -0
  87. package/dist/esm/models/errors/index.js.map +1 -1
  88. package/dist/esm/sdk/ratelimit.d.ts +1 -1
  89. package/dist/esm/sdk/ratelimit.js +1 -1
  90. package/docs/sdks/ratelimit/README.md +2 -1
  91. package/examples/apisCreateApi.example.ts +1 -1
  92. package/examples/package-lock.json +1 -1
  93. package/jsr.json +1 -1
  94. package/package.json +1 -1
  95. package/src/funcs/identitiesListIdentities.ts +3 -0
  96. package/src/funcs/ratelimitLimit.ts +6 -2
  97. package/src/lib/config.ts +3 -3
  98. package/src/lib/security.ts +4 -1
  99. package/src/mcp-server/mcp-server.ts +1 -1
  100. package/src/mcp-server/server.ts +1 -1
  101. package/src/mcp-server/tools/ratelimitLimit.ts +1 -1
  102. package/src/models/components/index.ts +2 -0
  103. package/src/models/components/keycreditsrefill.ts +18 -14
  104. package/src/models/components/updatekeycreditsdata.ts +85 -0
  105. package/src/models/components/updatekeycreditsrefill.ts +126 -0
  106. package/src/models/components/v2keysupdatekeyrequestbody.ts +10 -10
  107. package/src/models/errors/goneerrorresponse.ts +118 -0
  108. package/src/models/errors/index.ts +1 -0
  109. package/src/sdk/ratelimit.ts +1 -1
@@ -0,0 +1,62 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+ import * as z from "zod";
5
+ import * as components from "../components/index.js";
6
+ import { UnkeyError } from "./unkeyerror.js";
7
+ /**
8
+ * Error response when the requested resource has been soft-deleted and is no longer available. This occurs when:
9
+ *
10
+ * @remarks
11
+ * - The resource has been marked as deleted but still exists in the database
12
+ * - The resource is intentionally unavailable but could potentially be restored
13
+ * - The resource cannot be restored through the API or dashboard
14
+ *
15
+ * To resolve this error, contact support if you need the resource restored.
16
+ */
17
+ export class GoneErrorResponse extends UnkeyError {
18
+ constructor(err, httpMeta) {
19
+ const message = "message" in err && typeof err.message === "string"
20
+ ? err.message
21
+ : `API error occurred: ${JSON.stringify(err)}`;
22
+ super(message, httpMeta);
23
+ this.data$ = err;
24
+ this.meta = err.meta;
25
+ this.error = err.error;
26
+ this.name = "GoneErrorResponse";
27
+ }
28
+ }
29
+ /** @internal */
30
+ export const GoneErrorResponse$inboundSchema = z.object({
31
+ meta: components.Meta$inboundSchema,
32
+ error: components.BaseError$inboundSchema,
33
+ request$: z.instanceof(Request),
34
+ response$: z.instanceof(Response),
35
+ body$: z.string(),
36
+ })
37
+ .transform((v) => {
38
+ return new GoneErrorResponse(v, {
39
+ request: v.request$,
40
+ response: v.response$,
41
+ body: v.body$,
42
+ });
43
+ });
44
+ /** @internal */
45
+ export const GoneErrorResponse$outboundSchema = z.instanceof(GoneErrorResponse)
46
+ .transform(v => v.data$)
47
+ .pipe(z.object({
48
+ meta: components.Meta$outboundSchema,
49
+ error: components.BaseError$outboundSchema,
50
+ }));
51
+ /**
52
+ * @internal
53
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
54
+ */
55
+ export var GoneErrorResponse$;
56
+ (function (GoneErrorResponse$) {
57
+ /** @deprecated use `GoneErrorResponse$inboundSchema` instead. */
58
+ GoneErrorResponse$.inboundSchema = GoneErrorResponse$inboundSchema;
59
+ /** @deprecated use `GoneErrorResponse$outboundSchema` instead. */
60
+ GoneErrorResponse$.outboundSchema = GoneErrorResponse$outboundSchema;
61
+ })(GoneErrorResponse$ || (GoneErrorResponse$ = {}));
62
+ //# sourceMappingURL=goneerrorresponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"goneerrorresponse.js","sourceRoot":"","sources":["../../../../src/models/errors/goneerrorresponse.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAuB7C;;;;;;;;;GASG;AACH,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IAa/C,YACE,GAA0B,EAC1B,QAAgE;QAEhE,MAAM,OAAO,GAAG,SAAS,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ;YACjE,CAAC,CAAC,GAAG,CAAC,OAAO;YACb,CAAC,CAAC,uBAAuB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;QACjD,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;QAEvB,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED,gBAAgB;AAChB,MAAM,CAAC,MAAM,+BAA+B,GAIxC,CAAC,CAAC,MAAM,CAAC;IACX,IAAI,EAAE,UAAU,CAAC,kBAAkB;IACnC,KAAK,EAAE,UAAU,CAAC,uBAAuB;IACzC,QAAQ,EAAE,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC;IAC/B,SAAS,EAAE,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC;IACjC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;CAClB,CAAC;KACC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE;IACf,OAAO,IAAI,iBAAiB,CAAC,CAAC,EAAE;QAC9B,OAAO,EAAE,CAAC,CAAC,QAAQ;QACnB,QAAQ,EAAE,CAAC,CAAC,SAAS;QACrB,IAAI,EAAE,CAAC,CAAC,KAAK;KACd,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAQL,gBAAgB;AAChB,MAAM,CAAC,MAAM,gCAAgC,GAIzC,CAAC,CAAC,UAAU,CAAC,iBAAiB,CAAC;KAChC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;KACvB,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC,mBAAmB;IACpC,KAAK,EAAE,UAAU,CAAC,wBAAwB;CAC3C,CAAC,CAAC,CAAC;AAEN;;;GAGG;AACH,MAAM,KAAW,kBAAkB,CAOlC;AAPD,WAAiB,kBAAkB;IACjC,iEAAiE;IACpD,gCAAa,GAAG,+BAA+B,CAAC;IAC7D,kEAAkE;IACrD,iCAAc,GAAG,gCAAgC,CAAC;AAGjE,CAAC,EAPgB,kBAAkB,KAAlB,kBAAkB,QAOlC"}
@@ -2,6 +2,7 @@ export * from "./apierror.js";
2
2
  export * from "./badrequesterrorresponse.js";
3
3
  export * from "./conflicterrorresponse.js";
4
4
  export * from "./forbiddenerrorresponse.js";
5
+ export * from "./goneerrorresponse.js";
5
6
  export * from "./httpclienterrors.js";
6
7
  export * from "./internalservererrorresponse.js";
7
8
  export * from "./notfounderrorresponse.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/models/errors/index.ts"],"names":[],"mappings":"AAIA,cAAc,eAAe,CAAC;AAC9B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AACrD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/models/errors/index.ts"],"names":[],"mappings":"AAIA,cAAc,eAAe,CAAC;AAC9B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AACrD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC"}
@@ -5,6 +5,7 @@ export * from "./apierror.js";
5
5
  export * from "./badrequesterrorresponse.js";
6
6
  export * from "./conflicterrorresponse.js";
7
7
  export * from "./forbiddenerrorresponse.js";
8
+ export * from "./goneerrorresponse.js";
8
9
  export * from "./httpclienterrors.js";
9
10
  export * from "./internalservererrorresponse.js";
10
11
  export * from "./notfounderrorresponse.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/models/errors/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AACrD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/models/errors/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AACrD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC"}
@@ -35,7 +35,7 @@ export declare class Ratelimit extends ClientSDK {
35
35
  *
36
36
  * Use this for rate limiting beyond API keys - limit users by ID, IPs by address, or any custom identifier. Supports namespace organization, variable costs, and custom overrides.
37
37
  *
38
- * **Important**: Always returns HTTP 200. Check the `success` field to determine if the request should proceed.
38
+ * **Response Codes**: Rate limit checks return HTTP 200 regardless of whether the limit is exceeded - check the `success` field in the response to determine if the request should be allowed. 4xx responses indicate auth, namespace existence/deletion, or validation errors (e.g., 410 Gone for deleted namespaces). 5xx responses indicate server errors.
39
39
  *
40
40
  * **Required Permissions**
41
41
  *
@@ -47,7 +47,7 @@ export class Ratelimit extends ClientSDK {
47
47
  *
48
48
  * Use this for rate limiting beyond API keys - limit users by ID, IPs by address, or any custom identifier. Supports namespace organization, variable costs, and custom overrides.
49
49
  *
50
- * **Important**: Always returns HTTP 200. Check the `success` field to determine if the request should proceed.
50
+ * **Response Codes**: Rate limit checks return HTTP 200 regardless of whether the limit is exceeded - check the `success` field in the response to determine if the request should be allowed. 4xx responses indicate auth, namespace existence/deletion, or validation errors (e.g., 410 Gone for deleted namespaces). 5xx responses indicate server errors.
51
51
  *
52
52
  * **Required Permissions**
53
53
  *
@@ -193,7 +193,7 @@ Check and enforce rate limits for any identifier (user ID, IP address, API clien
193
193
 
194
194
  Use this for rate limiting beyond API keys - limit users by ID, IPs by address, or any custom identifier. Supports namespace organization, variable costs, and custom overrides.
195
195
 
196
- **Important**: Always returns HTTP 200. Check the `success` field to determine if the request should proceed.
196
+ **Response Codes**: Rate limit checks return HTTP 200 regardless of whether the limit is exceeded - check the `success` field in the response to determine if the request should be allowed. 4xx responses indicate auth, namespace existence/deletion, or validation errors (e.g., 410 Gone for deleted namespaces). 5xx responses indicate server errors.
197
197
 
198
198
  **Required Permissions**
199
199
 
@@ -285,6 +285,7 @@ run();
285
285
  | errors.UnauthorizedErrorResponse | 401 | application/json |
286
286
  | errors.ForbiddenErrorResponse | 403 | application/json |
287
287
  | errors.NotFoundErrorResponse | 404 | application/json |
288
+ | errors.GoneErrorResponse | 410 | application/json |
288
289
  | errors.InternalServerErrorResponse | 500 | application/json |
289
290
  | errors.APIError | 4XX, 5XX | \*/\* |
290
291
 
@@ -18,7 +18,7 @@ const unkey = new Unkey({
18
18
  });
19
19
 
20
20
  async function main() {
21
- const result = await unkey.createApi({
21
+ const result = await unkey.apis.createApi({
22
22
  name: "payment-service-production",
23
23
  });
24
24
 
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "..": {
20
20
  "name": "@unkey/api",
21
- "version": "2.0.4",
21
+ "version": "2.0.5",
22
22
  "dependencies": {
23
23
  "zod": "^3.20.0"
24
24
  },
package/jsr.json CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  {
4
4
  "name": "@unkey/api",
5
- "version": "2.0.4",
5
+ "version": "2.0.5",
6
6
  "exports": {
7
7
  ".": "./src/index.ts",
8
8
  "./models/errors": "./src/models/errors/index.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unkey/api",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "author": "Speakeasy",
5
5
  "type": "module",
6
6
  "bin": {
@@ -241,6 +241,9 @@ async function $do(
241
241
  if (typeof nextCursor !== "string") {
242
242
  return { next: () => null };
243
243
  }
244
+ if (nextCursor.trim() === "") {
245
+ return { next: () => null };
246
+ }
244
247
 
245
248
  const nextVal = () =>
246
249
  identitiesListIdentities(
@@ -33,7 +33,7 @@ import { Result } from "../types/fp.js";
33
33
  *
34
34
  * Use this for rate limiting beyond API keys - limit users by ID, IPs by address, or any custom identifier. Supports namespace organization, variable costs, and custom overrides.
35
35
  *
36
- * **Important**: Always returns HTTP 200. Check the `success` field to determine if the request should proceed.
36
+ * **Response Codes**: Rate limit checks return HTTP 200 regardless of whether the limit is exceeded - check the `success` field in the response to determine if the request should be allowed. 4xx responses indicate auth, namespace existence/deletion, or validation errors (e.g., 410 Gone for deleted namespaces). 5xx responses indicate server errors.
37
37
  *
38
38
  * **Required Permissions**
39
39
  *
@@ -56,6 +56,7 @@ export function ratelimitLimit(
56
56
  | errors.UnauthorizedErrorResponse
57
57
  | errors.ForbiddenErrorResponse
58
58
  | errors.NotFoundErrorResponse
59
+ | errors.GoneErrorResponse
59
60
  | errors.InternalServerErrorResponse
60
61
  | UnkeyError
61
62
  | ResponseValidationError
@@ -86,6 +87,7 @@ async function $do(
86
87
  | errors.UnauthorizedErrorResponse
87
88
  | errors.ForbiddenErrorResponse
88
89
  | errors.NotFoundErrorResponse
90
+ | errors.GoneErrorResponse
89
91
  | errors.InternalServerErrorResponse
90
92
  | UnkeyError
91
93
  | ResponseValidationError
@@ -164,7 +166,7 @@ async function $do(
164
166
 
165
167
  const doResult = await client._do(req, {
166
168
  context,
167
- errorCodes: ["400", "401", "403", "404", "4XX", "500", "5XX"],
169
+ errorCodes: ["400", "401", "403", "404", "410", "4XX", "500", "5XX"],
168
170
  retryConfig: context.retryConfig,
169
171
  retryCodes: context.retryCodes,
170
172
  });
@@ -183,6 +185,7 @@ async function $do(
183
185
  | errors.UnauthorizedErrorResponse
184
186
  | errors.ForbiddenErrorResponse
185
187
  | errors.NotFoundErrorResponse
188
+ | errors.GoneErrorResponse
186
189
  | errors.InternalServerErrorResponse
187
190
  | UnkeyError
188
191
  | ResponseValidationError
@@ -198,6 +201,7 @@ async function $do(
198
201
  M.jsonErr(401, errors.UnauthorizedErrorResponse$inboundSchema),
199
202
  M.jsonErr(403, errors.ForbiddenErrorResponse$inboundSchema),
200
203
  M.jsonErr(404, errors.NotFoundErrorResponse$inboundSchema),
204
+ M.jsonErr(410, errors.GoneErrorResponse$inboundSchema),
201
205
  M.jsonErr(500, errors.InternalServerErrorResponse$inboundSchema),
202
206
  M.fail("4XX"),
203
207
  M.fail("5XX"),
package/src/lib/config.ts CHANGED
@@ -58,7 +58,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
58
58
  export const SDK_METADATA = {
59
59
  language: "typescript",
60
60
  openapiDocVersion: "2.0.0",
61
- sdkVersion: "2.0.4",
62
- genVersion: "2.683.1",
63
- userAgent: "speakeasy-sdk/typescript 2.0.4 2.683.1 2.0.0 @unkey/api",
61
+ sdkVersion: "2.0.5",
62
+ genVersion: "2.698.4",
63
+ userAgent: "speakeasy-sdk/typescript 2.0.5 2.698.4 2.0.0 @unkey/api",
64
64
  } as const;
@@ -84,7 +84,10 @@ type SecurityInputOAuth2 = {
84
84
  type SecurityInputOAuth2ClientCredentials = {
85
85
  type: "oauth2:client_credentials";
86
86
  value:
87
- | { clientID?: string | undefined; clientSecret?: string | undefined }
87
+ | {
88
+ clientID?: string | undefined;
89
+ clientSecret?: string | undefined;
90
+ }
88
91
  | null
89
92
  | string
90
93
  | undefined;
@@ -19,7 +19,7 @@ const routes = buildRouteMap({
19
19
  export const app = buildApplication(routes, {
20
20
  name: "mcp",
21
21
  versionInfo: {
22
- currentVersion: "2.0.4",
22
+ currentVersion: "2.0.5",
23
23
  },
24
24
  });
25
25
 
@@ -60,7 +60,7 @@ export function createMCPServer(deps: {
60
60
  }) {
61
61
  const server = new McpServer({
62
62
  name: "Unkey",
63
- version: "2.0.4",
63
+ version: "2.0.5",
64
64
  });
65
65
 
66
66
  const client = new UnkeyCore({
@@ -18,7 +18,7 @@ Check and enforce rate limits for any identifier (user ID, IP address, API clien
18
18
 
19
19
  Use this for rate limiting beyond API keys - limit users by ID, IPs by address, or any custom identifier. Supports namespace organization, variable costs, and custom overrides.
20
20
 
21
- **Important**: Always returns HTTP 200. Check the \`success\` field to determine if the request should proceed.
21
+ **Response Codes**: Rate limit checks return HTTP 200 regardless of whether the limit is exceeded - check the \`success\` field in the response to determine if the request should be allowed. 4xx responses indicate auth, namespace existence/deletion, or validation errors (e.g., 410 Gone for deleted namespaces). 5xx responses indicate server errors.
22
22
 
23
23
  **Required Permissions**
24
24
 
@@ -19,6 +19,8 @@ export * from "./ratelimitrequest.js";
19
19
  export * from "./ratelimitresponse.js";
20
20
  export * from "./role.js";
21
21
  export * from "./security.js";
22
+ export * from "./updatekeycreditsdata.js";
23
+ export * from "./updatekeycreditsrefill.js";
22
24
  export * from "./v2apiscreateapirequestbody.js";
23
25
  export * from "./v2apiscreateapiresponsebody.js";
24
26
  export * from "./v2apiscreateapiresponsedata.js";
@@ -11,14 +11,16 @@ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
11
11
  /**
12
12
  * How often credits are automatically refilled.
13
13
  */
14
- export const Interval = {
14
+ export const KeyCreditsRefillInterval = {
15
15
  Daily: "daily",
16
16
  Monthly: "monthly",
17
17
  } as const;
18
18
  /**
19
19
  * How often credits are automatically refilled.
20
20
  */
21
- export type Interval = ClosedEnum<typeof Interval>;
21
+ export type KeyCreditsRefillInterval = ClosedEnum<
22
+ typeof KeyCreditsRefillInterval
23
+ >;
22
24
 
23
25
  /**
24
26
  * Configuration for automatic credit refill behavior.
@@ -27,7 +29,7 @@ export type KeyCreditsRefill = {
27
29
  /**
28
30
  * How often credits are automatically refilled.
29
31
  */
30
- interval: Interval;
32
+ interval: KeyCreditsRefillInterval;
31
33
  /**
32
34
  * Number of credits to add during each refill cycle.
33
35
  */
@@ -43,22 +45,24 @@ export type KeyCreditsRefill = {
43
45
  };
44
46
 
45
47
  /** @internal */
46
- export const Interval$inboundSchema: z.ZodNativeEnum<typeof Interval> = z
47
- .nativeEnum(Interval);
48
+ export const KeyCreditsRefillInterval$inboundSchema: z.ZodNativeEnum<
49
+ typeof KeyCreditsRefillInterval
50
+ > = z.nativeEnum(KeyCreditsRefillInterval);
48
51
 
49
52
  /** @internal */
50
- export const Interval$outboundSchema: z.ZodNativeEnum<typeof Interval> =
51
- Interval$inboundSchema;
53
+ export const KeyCreditsRefillInterval$outboundSchema: z.ZodNativeEnum<
54
+ typeof KeyCreditsRefillInterval
55
+ > = KeyCreditsRefillInterval$inboundSchema;
52
56
 
53
57
  /**
54
58
  * @internal
55
59
  * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
56
60
  */
57
- export namespace Interval$ {
58
- /** @deprecated use `Interval$inboundSchema` instead. */
59
- export const inboundSchema = Interval$inboundSchema;
60
- /** @deprecated use `Interval$outboundSchema` instead. */
61
- export const outboundSchema = Interval$outboundSchema;
61
+ export namespace KeyCreditsRefillInterval$ {
62
+ /** @deprecated use `KeyCreditsRefillInterval$inboundSchema` instead. */
63
+ export const inboundSchema = KeyCreditsRefillInterval$inboundSchema;
64
+ /** @deprecated use `KeyCreditsRefillInterval$outboundSchema` instead. */
65
+ export const outboundSchema = KeyCreditsRefillInterval$outboundSchema;
62
66
  }
63
67
 
64
68
  /** @internal */
@@ -67,7 +71,7 @@ export const KeyCreditsRefill$inboundSchema: z.ZodType<
67
71
  z.ZodTypeDef,
68
72
  unknown
69
73
  > = z.object({
70
- interval: Interval$inboundSchema,
74
+ interval: KeyCreditsRefillInterval$inboundSchema,
71
75
  amount: z.number().int(),
72
76
  refillDay: z.number().int().optional(),
73
77
  });
@@ -85,7 +89,7 @@ export const KeyCreditsRefill$outboundSchema: z.ZodType<
85
89
  z.ZodTypeDef,
86
90
  KeyCreditsRefill
87
91
  > = z.object({
88
- interval: Interval$outboundSchema,
92
+ interval: KeyCreditsRefillInterval$outboundSchema,
89
93
  amount: z.number().int(),
90
94
  refillDay: z.number().int().optional(),
91
95
  });
@@ -0,0 +1,85 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod";
6
+ import { safeParse } from "../../lib/schemas.js";
7
+ import { Result as SafeParseResult } from "../../types/fp.js";
8
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
9
+ import {
10
+ UpdateKeyCreditsRefill,
11
+ UpdateKeyCreditsRefill$inboundSchema,
12
+ UpdateKeyCreditsRefill$Outbound,
13
+ UpdateKeyCreditsRefill$outboundSchema,
14
+ } from "./updatekeycreditsrefill.js";
15
+
16
+ /**
17
+ * Credit configuration and remaining balance for this key.
18
+ */
19
+ export type UpdateKeyCreditsData = {
20
+ /**
21
+ * Number of credits remaining (null for unlimited). This also clears the refilling schedule.
22
+ */
23
+ remaining?: number | null | undefined;
24
+ /**
25
+ * Configuration for automatic credit refill behavior.
26
+ */
27
+ refill?: UpdateKeyCreditsRefill | null | undefined;
28
+ };
29
+
30
+ /** @internal */
31
+ export const UpdateKeyCreditsData$inboundSchema: z.ZodType<
32
+ UpdateKeyCreditsData,
33
+ z.ZodTypeDef,
34
+ unknown
35
+ > = z.object({
36
+ remaining: z.nullable(z.number().int()).optional(),
37
+ refill: z.nullable(UpdateKeyCreditsRefill$inboundSchema).optional(),
38
+ });
39
+
40
+ /** @internal */
41
+ export type UpdateKeyCreditsData$Outbound = {
42
+ remaining?: number | null | undefined;
43
+ refill?: UpdateKeyCreditsRefill$Outbound | null | undefined;
44
+ };
45
+
46
+ /** @internal */
47
+ export const UpdateKeyCreditsData$outboundSchema: z.ZodType<
48
+ UpdateKeyCreditsData$Outbound,
49
+ z.ZodTypeDef,
50
+ UpdateKeyCreditsData
51
+ > = z.object({
52
+ remaining: z.nullable(z.number().int()).optional(),
53
+ refill: z.nullable(UpdateKeyCreditsRefill$outboundSchema).optional(),
54
+ });
55
+
56
+ /**
57
+ * @internal
58
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
59
+ */
60
+ export namespace UpdateKeyCreditsData$ {
61
+ /** @deprecated use `UpdateKeyCreditsData$inboundSchema` instead. */
62
+ export const inboundSchema = UpdateKeyCreditsData$inboundSchema;
63
+ /** @deprecated use `UpdateKeyCreditsData$outboundSchema` instead. */
64
+ export const outboundSchema = UpdateKeyCreditsData$outboundSchema;
65
+ /** @deprecated use `UpdateKeyCreditsData$Outbound` instead. */
66
+ export type Outbound = UpdateKeyCreditsData$Outbound;
67
+ }
68
+
69
+ export function updateKeyCreditsDataToJSON(
70
+ updateKeyCreditsData: UpdateKeyCreditsData,
71
+ ): string {
72
+ return JSON.stringify(
73
+ UpdateKeyCreditsData$outboundSchema.parse(updateKeyCreditsData),
74
+ );
75
+ }
76
+
77
+ export function updateKeyCreditsDataFromJSON(
78
+ jsonString: string,
79
+ ): SafeParseResult<UpdateKeyCreditsData, SDKValidationError> {
80
+ return safeParse(
81
+ jsonString,
82
+ (x) => UpdateKeyCreditsData$inboundSchema.parse(JSON.parse(x)),
83
+ `Failed to parse 'UpdateKeyCreditsData' from JSON`,
84
+ );
85
+ }
@@ -0,0 +1,126 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod";
6
+ import { safeParse } from "../../lib/schemas.js";
7
+ import { ClosedEnum } from "../../types/enums.js";
8
+ import { Result as SafeParseResult } from "../../types/fp.js";
9
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
10
+
11
+ /**
12
+ * How often credits are automatically refilled.
13
+ */
14
+ export const UpdateKeyCreditsRefillInterval = {
15
+ Daily: "daily",
16
+ Monthly: "monthly",
17
+ } as const;
18
+ /**
19
+ * How often credits are automatically refilled.
20
+ */
21
+ export type UpdateKeyCreditsRefillInterval = ClosedEnum<
22
+ typeof UpdateKeyCreditsRefillInterval
23
+ >;
24
+
25
+ /**
26
+ * Configuration for automatic credit refill behavior.
27
+ */
28
+ export type UpdateKeyCreditsRefill = {
29
+ /**
30
+ * How often credits are automatically refilled.
31
+ */
32
+ interval: UpdateKeyCreditsRefillInterval;
33
+ /**
34
+ * Number of credits to add during each refill cycle.
35
+ */
36
+ amount: number;
37
+ /**
38
+ * Day of the month for monthly refills (1-31).
39
+ *
40
+ * @remarks
41
+ * Only required when interval is 'monthly'.
42
+ * For days beyond the month's length, refill occurs on the last day of the month.
43
+ */
44
+ refillDay?: number | undefined;
45
+ };
46
+
47
+ /** @internal */
48
+ export const UpdateKeyCreditsRefillInterval$inboundSchema: z.ZodNativeEnum<
49
+ typeof UpdateKeyCreditsRefillInterval
50
+ > = z.nativeEnum(UpdateKeyCreditsRefillInterval);
51
+
52
+ /** @internal */
53
+ export const UpdateKeyCreditsRefillInterval$outboundSchema: z.ZodNativeEnum<
54
+ typeof UpdateKeyCreditsRefillInterval
55
+ > = UpdateKeyCreditsRefillInterval$inboundSchema;
56
+
57
+ /**
58
+ * @internal
59
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
60
+ */
61
+ export namespace UpdateKeyCreditsRefillInterval$ {
62
+ /** @deprecated use `UpdateKeyCreditsRefillInterval$inboundSchema` instead. */
63
+ export const inboundSchema = UpdateKeyCreditsRefillInterval$inboundSchema;
64
+ /** @deprecated use `UpdateKeyCreditsRefillInterval$outboundSchema` instead. */
65
+ export const outboundSchema = UpdateKeyCreditsRefillInterval$outboundSchema;
66
+ }
67
+
68
+ /** @internal */
69
+ export const UpdateKeyCreditsRefill$inboundSchema: z.ZodType<
70
+ UpdateKeyCreditsRefill,
71
+ z.ZodTypeDef,
72
+ unknown
73
+ > = z.object({
74
+ interval: UpdateKeyCreditsRefillInterval$inboundSchema,
75
+ amount: z.number().int(),
76
+ refillDay: z.number().int().optional(),
77
+ });
78
+
79
+ /** @internal */
80
+ export type UpdateKeyCreditsRefill$Outbound = {
81
+ interval: string;
82
+ amount: number;
83
+ refillDay?: number | undefined;
84
+ };
85
+
86
+ /** @internal */
87
+ export const UpdateKeyCreditsRefill$outboundSchema: z.ZodType<
88
+ UpdateKeyCreditsRefill$Outbound,
89
+ z.ZodTypeDef,
90
+ UpdateKeyCreditsRefill
91
+ > = z.object({
92
+ interval: UpdateKeyCreditsRefillInterval$outboundSchema,
93
+ amount: z.number().int(),
94
+ refillDay: z.number().int().optional(),
95
+ });
96
+
97
+ /**
98
+ * @internal
99
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
100
+ */
101
+ export namespace UpdateKeyCreditsRefill$ {
102
+ /** @deprecated use `UpdateKeyCreditsRefill$inboundSchema` instead. */
103
+ export const inboundSchema = UpdateKeyCreditsRefill$inboundSchema;
104
+ /** @deprecated use `UpdateKeyCreditsRefill$outboundSchema` instead. */
105
+ export const outboundSchema = UpdateKeyCreditsRefill$outboundSchema;
106
+ /** @deprecated use `UpdateKeyCreditsRefill$Outbound` instead. */
107
+ export type Outbound = UpdateKeyCreditsRefill$Outbound;
108
+ }
109
+
110
+ export function updateKeyCreditsRefillToJSON(
111
+ updateKeyCreditsRefill: UpdateKeyCreditsRefill,
112
+ ): string {
113
+ return JSON.stringify(
114
+ UpdateKeyCreditsRefill$outboundSchema.parse(updateKeyCreditsRefill),
115
+ );
116
+ }
117
+
118
+ export function updateKeyCreditsRefillFromJSON(
119
+ jsonString: string,
120
+ ): SafeParseResult<UpdateKeyCreditsRefill, SDKValidationError> {
121
+ return safeParse(
122
+ jsonString,
123
+ (x) => UpdateKeyCreditsRefill$inboundSchema.parse(JSON.parse(x)),
124
+ `Failed to parse 'UpdateKeyCreditsRefill' from JSON`,
125
+ );
126
+ }
@@ -6,18 +6,18 @@ import * as z from "zod";
6
6
  import { safeParse } from "../../lib/schemas.js";
7
7
  import { Result as SafeParseResult } from "../../types/fp.js";
8
8
  import { SDKValidationError } from "../errors/sdkvalidationerror.js";
9
- import {
10
- KeyCreditsData,
11
- KeyCreditsData$inboundSchema,
12
- KeyCreditsData$Outbound,
13
- KeyCreditsData$outboundSchema,
14
- } from "./keycreditsdata.js";
15
9
  import {
16
10
  RatelimitRequest,
17
11
  RatelimitRequest$inboundSchema,
18
12
  RatelimitRequest$Outbound,
19
13
  RatelimitRequest$outboundSchema,
20
14
  } from "./ratelimitrequest.js";
15
+ import {
16
+ UpdateKeyCreditsData,
17
+ UpdateKeyCreditsData$inboundSchema,
18
+ UpdateKeyCreditsData$Outbound,
19
+ UpdateKeyCreditsData$outboundSchema,
20
+ } from "./updatekeycreditsdata.js";
21
21
 
22
22
  export type V2KeysUpdateKeyRequestBody = {
23
23
  /**
@@ -68,7 +68,7 @@ export type V2KeysUpdateKeyRequestBody = {
68
68
  /**
69
69
  * Credit configuration and remaining balance for this key.
70
70
  */
71
- credits?: KeyCreditsData | undefined;
71
+ credits?: UpdateKeyCreditsData | null | undefined;
72
72
  /**
73
73
  * Defines time-based rate limits that protect against abuse by controlling request frequency.
74
74
  *
@@ -102,7 +102,7 @@ export const V2KeysUpdateKeyRequestBody$inboundSchema: z.ZodType<
102
102
  externalId: z.nullable(z.string()).optional(),
103
103
  meta: z.nullable(z.record(z.any())).optional(),
104
104
  expires: z.nullable(z.number().int()).optional(),
105
- credits: KeyCreditsData$inboundSchema.optional(),
105
+ credits: z.nullable(UpdateKeyCreditsData$inboundSchema).optional(),
106
106
  ratelimits: z.array(RatelimitRequest$inboundSchema).optional(),
107
107
  enabled: z.boolean().optional(),
108
108
  roles: z.array(z.string()).optional(),
@@ -116,7 +116,7 @@ export type V2KeysUpdateKeyRequestBody$Outbound = {
116
116
  externalId?: string | null | undefined;
117
117
  meta?: { [k: string]: any } | null | undefined;
118
118
  expires?: number | null | undefined;
119
- credits?: KeyCreditsData$Outbound | undefined;
119
+ credits?: UpdateKeyCreditsData$Outbound | null | undefined;
120
120
  ratelimits?: Array<RatelimitRequest$Outbound> | undefined;
121
121
  enabled?: boolean | undefined;
122
122
  roles?: Array<string> | undefined;
@@ -134,7 +134,7 @@ export const V2KeysUpdateKeyRequestBody$outboundSchema: z.ZodType<
134
134
  externalId: z.nullable(z.string()).optional(),
135
135
  meta: z.nullable(z.record(z.any())).optional(),
136
136
  expires: z.nullable(z.number().int()).optional(),
137
- credits: KeyCreditsData$outboundSchema.optional(),
137
+ credits: z.nullable(UpdateKeyCreditsData$outboundSchema).optional(),
138
138
  ratelimits: z.array(RatelimitRequest$outboundSchema).optional(),
139
139
  enabled: z.boolean().optional(),
140
140
  roles: z.array(z.string()).optional(),