@unkey/api
Version:
Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@unkey/api* API.
30 lines • 2.39 kB
TypeScript
import { UnkeyCore } from "../core.js";
import { RequestOptions } from "../lib/sdks.js";
import * as components from "../models/components/index.js";
import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/httpclienterrors.js";
import * as errors from "../models/errors/index.js";
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
import { UnkeyError } from "../models/errors/unkeyerror.js";
import { APIPromise } from "../types/async.js";
import { Result } from "../types/fp.js";
/**
* Apply rate limiting
*
* @remarks
* Check and enforce rate limits for any identifier (user ID, IP address, API client, etc.).
*
* 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.
*
* **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. A 429 may be returned if the workspace exceeds its API rate limit. Other 4xx responses indicate auth, namespace existence/deletion, or validation errors (e.g., 410 Gone for deleted namespaces). 5xx responses indicate server errors.
*
* **Required Permissions**
*
* Your root key must have one of the following permissions:
* - `ratelimit.*.limit` (to check limits in any namespace)
* - `ratelimit.<namespace_id>.limit` (to check limits in a specific namespace)
*
* If set, this operation will use {@link Security.rootKey} from the global security.
*/
export declare function ratelimitLimit(client: UnkeyCore, request: components.V2RatelimitLimitRequestBody, options?: RequestOptions): APIPromise<Result<components.V2RatelimitLimitResponseBody, errors.BadRequestErrorResponse | errors.UnauthorizedErrorResponse | errors.ForbiddenErrorResponse | errors.NotFoundErrorResponse | errors.GoneErrorResponse | errors.TooManyRequestsErrorResponse | errors.InternalServerErrorResponse | UnkeyError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
//# sourceMappingURL=ratelimitLimit.d.ts.map