valid field in response data to determine if the key is authorized. A 429 may be returned if the workspace exceeds its API rate limit.
Common Use Cases
- Authenticate API requests before processing
- Enforce permission-based access control
- Track usage and apply rate limits
Required Permissions
Your root key needs one of:api.*.verify_key(verify keys in any API)api.<api_id>.verify_key(verify keys in specific API)
403 Forbidden error. If your root key has verify permissions for a different API than the key you’re verifying, you will receive a 200 response with code: NOT_FOUND to avoid leaking key existence.
Request
The API key to verify, exactly as provided by your user. Include any prefix - even small changes will cause verification to fail.Length: 1-512 charactersExample:
sk_1234abcdefAttaches metadata tags for analytics and monitoring without affecting verification outcomes. 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.Example:
["endpoint=/users/profile", "method=GET", "region=us-east-1"]Checks if the key has the specified permission(s) using a query syntax. Supports single permissions, logical operators (AND, OR), and parentheses for grouping.Verification fails if the key lacks the required permissions through direct assignment or role inheritance.Examples:
- Single permission:
"documents.read" - Multiple permissions:
"documents.read AND documents.write" - Complex queries:
"(documents.read OR documents.write) AND users.view"
Controls credit consumption during verification.
Number of credits to deduct from the key’s remaining balance upon successful verification.
Enforces time-based rate limiting during verification to prevent abuse and ensure fair usage. 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.
Migrate keys on demand from your previous system. Reach out for migration support at [email protected]Length: Max 256 characters
Response
The primary verification result. If true, the key is valid and can be used. If false, check the ‘code’ field to understand why verification failed.Your application should always check this field first before proceeding.
A machine-readable code indicating the verification status or failure reason.Values:
VALID- Key is valid and passed all checksNOT_FOUND- Key doesn’t exist or belongs to wrong APIFORBIDDEN- Key lacks required permissionsINSUFFICIENT_PERMISSIONS- Key lacks specific required permissions for this requestUSAGE_EXCEEDED- Key has no remaining creditsRATE_LIMITED- Key exceeded rate limitsDISABLED- Key was explicitly disabledEXPIRED- Key has passed its expiration date
The unique identifier of the verified key in Unkey’s system. Use this ID for operations like updating or revoking the key.This field is returned for both valid and invalid keys (except when
code=NOT_FOUND).The human-readable name assigned to this key during creation. This is useful for displaying in logs or admin interfaces to identify the key’s purpose.
Custom metadata associated with the key. This can include any JSON-serializable data you stored with the key during creation or updates, such as plan information, feature flags, or user details.Use this to avoid additional database lookups for contextual information needed during API calls.
Unix timestamp (in milliseconds) when the key will expire. If omitted, the key has no expiration.You can use this to warn users about upcoming expirations or to understand the validity period.
The number of requests/credits remaining for this key. If omitted, the key has unlimited usage.This value decreases with each verification (based on the ‘cost’ parameter) unless explicit credit refills are configured.
Indicates if the key is currently enabled. Disabled keys will always fail verification with
code=DISABLED.This is useful for implementing temporary suspensions without deleting the key.A list of all permission names assigned to this key, either directly or through roles. These permissions determine what actions the key can perform.Only returned when permissions were checked during verification or when the key fails with
code=FORBIDDEN.A list of all role names assigned to this key. Roles are collections of permissions that grant access to specific functionality.Only returned when permissions were checked during verification.
Information about the identity associated with this key. Identities allow multiple keys to share resources (like rate limits) and represent the same user or entity across different applications or devices.
The identifier from your system that this key is associated with.
Custom metadata associated with the identity.
The rate limits that were checked during this verification, including current state and remaining capacity.