@unkey/api
Version:
Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@unkey/api* API.
67 lines • 3.25 kB
TypeScript
import * as z from "zod/v3";
import { KeysVerifyKeyCredits, KeysVerifyKeyCredits$Outbound } from "./keysverifykeycredits.js";
import { KeysVerifyKeyRatelimit, KeysVerifyKeyRatelimit$Outbound } from "./keysverifykeyratelimit.js";
export type V2KeysVerifyKeyRequestBody = {
/**
* The API key to verify, exactly as provided by your user.
*
* @remarks
* Include any prefix - even small changes will cause verification to fail.
*/
key: string;
/**
* Attaches metadata tags for analytics and monitoring without affecting verification outcomes.
*
* @remarks
* Enables segmentation of API usage in dashboards by endpoint, client version, region, or custom dimensions.
* Use 'key=value' format for compatibility with most analytics tools and clear categorization.
* Avoid including sensitive data in tags as they may appear in logs and analytics reports.
*/
tags?: Array<string> | undefined;
/**
* Checks if the key has the specified permission(s) using a query syntax.
*
* @remarks
* Supports single permissions, logical operators (AND, OR), and parentheses for grouping.
* Examples:
* - Single permission: "documents.read"
* - Multiple permissions: "documents.read AND documents.write"
* - Complex queries: "(documents.read OR documents.write) AND users.view"
* Verification fails if the key lacks the required permissions through direct assignment or role inheritance.
*/
permissions?: string | undefined;
/**
* Controls credit consumption for usage-based billing and quota enforcement.
*
* @remarks
* Omitting this field uses the default cost of 1 credit per verification.
* Credits provide globally consistent usage tracking, essential for paid APIs with strict quotas.
*/
credits?: KeysVerifyKeyCredits | undefined;
/**
* Enforces time-based rate limiting during verification to prevent abuse and ensure fair usage.
*
* @remarks
* Omitting this field skips rate limit checks entirely, relying only on configured key rate limits.
* Multiple rate limits can be checked simultaneously, each with different costs and temporary overrides.
* Rate limit checks are optimized for performance but may allow brief bursts during high concurrency.
*/
ratelimits?: Array<KeysVerifyKeyRatelimit> | undefined;
/**
* Migrate keys on demand from your previous system. Reach out for migration support at support@unkey.dev
*/
migrationId?: string | undefined;
};
/** @internal */
export type V2KeysVerifyKeyRequestBody$Outbound = {
key: string;
tags?: Array<string> | undefined;
permissions?: string | undefined;
credits?: KeysVerifyKeyCredits$Outbound | undefined;
ratelimits?: Array<KeysVerifyKeyRatelimit$Outbound> | undefined;
migrationId?: string | undefined;
};
/** @internal */
export declare const V2KeysVerifyKeyRequestBody$outboundSchema: z.ZodType<V2KeysVerifyKeyRequestBody$Outbound, z.ZodTypeDef, V2KeysVerifyKeyRequestBody>;
export declare function v2KeysVerifyKeyRequestBodyToJSON(v2KeysVerifyKeyRequestBody: V2KeysVerifyKeyRequestBody): string;
//# sourceMappingURL=v2keysverifykeyrequestbody.d.ts.map