Verify API key
Verify an API key's validity and permissions for request authentication.
Use this endpoint on every incoming request to your protected resources. It checks key validity, permissions, rate limits, and usage quotas in a single call.
Important: Returns HTTP 200 for all verification outcomes — check the 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 credential needs one of:
- api.*.verify_key (verify keys in any API)
- api.<api_id>.verify_key (verify keys in specific API)
- unkey:v1:<workspace_id>:keyspaces/*/keys/*#verify_key (verify keys in any keyspace)
- unkey:v1:<workspace_id>:keyspaces/<keyspace_id>/keys/*#verify_key (verify keys in a specific keyspace)
- unkey:v1:<workspace_id>:keyspaces/<keyspace_id>/keys/<key_id>#verify_key (verify a specific key)
Note: If your credential has no verify permissions at all, you will receive a 403 Forbidden error. If your credential has verify permissions for a different API or keyspace than the key you're verifying, you will receive a 200 response with code: NOT_FOUND to avoid leaking key existence.
Request body
Example request
{
"key": "sk_1234abcdef",
"tags": [
"endpoint=/users/profile",
"method=GET",
"region=us-east-1",
"clientVersion=2.3.0",
"feature=premium"
],
"permissions": "documents.read AND users.view",
"credits": {
"cost": 5
},
"ratelimits": [
{
"name": "tokens",
"cost": 2,
"limit": 50,
"duration": 600000
}
],
"migrationId": "m_1234abcd"
}Response
Key verification process completed. This endpoint always returns HTTP 200 regardless of whether the key passed or failed verification. You must check the valid field in the response data to determine the actual verification result.
When verification succeeds, the response includes comprehensive information about the key including its current status, remaining credits, expiration time, associated permissions and roles, metadata, and any rate limiting information. This data enables your application to make informed authorization decisions and provide appropriate user experiences.
When verification fails, the response indicates the specific reason through the code field while setting valid to false. The failure codes help you handle different scenarios appropriately, such as directing users to renew expired keys, upgrade for more credits, or contact support for disabled keys.
The response also includes identity information when the key is associated with an identity, providing additional context about the key holder and any identity-specific rate limits or metadata that may apply to the verification.
Example response
{
"meta": {
"requestId": "req_123"
},
"data": {
"identity": {
"ratelimits": [
{
"id": "rl_1234567890abcdef",
"name": "api_requests",
"limit": 1000,
"duration": 3600000,
"autoApply": true
}
]
},
"ratelimits": [
{
"id": "rl_1234567890abcdef",
"name": "api_requests",
"limit": 1000,
"duration": 3600000,
"reset": 3600000,
"remaining": 999,
"autoApply": true
}
]
}
}