Verify an API key's validity and permissions for request authentication.
Use this command 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.
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)
Note: If your root key has no verify permissions at all, you will receive a 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.
See the API reference for the full HTTP endpoint documentation.
Usage#
Flags#
The API key to verify, exactly as provided by your user. Include any prefix -- even small changes will cause verification to fail.
Permission query to check, supports AND/OR operators and parentheses for grouping. Examples: "documents.read", "documents.read AND documents.write", "(documents.read OR documents.write) AND users.view". Verification fails if the key lacks the required permissions through direct assignment or role inheritance.
JSON object for credit consumption configuration. Controls credit deduction for usage-based billing and quota enforcement. Omitting this field uses the default cost of 1 credit per verification.
Show credits fieldsHide credits fields
Sets how many credits to deduct for this verification request. Use 0 for read-only operations or free tier access, higher values for premium features. Credits are deducted after all security checks pass. Min: 0, max: 1000000000.
JSON array of rate limit checks to enforce during verification. 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.
Show ratelimits array item fieldsHide ratelimits array item fields
References an existing rate limit by its name. Key rate limits take precedence over identifier-based limits.
Optionally override how expensive this operation is and how many tokens are deducted from the current limit.
Default: 1
Optionally override the maximum number of requests allowed within the specified interval.
Optionally override the duration of the rate limit window in milliseconds.
Migration provider ID for on-demand key migration from your previous system. Reach out for migration support at support@unkey.com.
Global Flags#
| Flag | Type | Description |
|---|---|---|
--root-key | string | Override root key ($UNKEY_ROOT_KEY) |
--api-url | string | Override API base URL (default: https://api.unkey.com) |
--config | string | Path to config file (default: ~/.unkey/config.toml) |
--output | string | Output format. Use json for raw JSON |
--body | string | Send this JSON string as the request body. You cannot combine it with request-building flags. |
Examples#
Output#
Default output shows the request ID, followed by the verification result:
With --output=json, the full response envelope is returned:
When verification fails, the valid field is false and code indicates the reason:
Possible code values: VALID, NOT_FOUND, FORBIDDEN, INSUFFICIENT_PERMISSIONS, USAGE_EXCEEDED, RATE_LIMITED, DISABLED, EXPIRED.