code: INSUFFICIENT_PERMISSIONS.
Basic permission check
Pass a permission string to verify:Permission query syntax
Unkey supports logical operators for complex permission checks:Single permission
documents.read.
AND (all required)
OR (any required)
Complex queries with parentheses
admin OR have both documents.read and documents.write.
Real-world example
Response structure
Successful verification with permissions:Manual permission checking
Sometimes you need to check permissions after loading data from your database (e.g., checking if the user owns a resource). In these cases:Wildcard permissions
Permissions support wildcards for broader access:*— All permissions (use carefully!)documents.*— All document permissionsapi.v1.*— All v1 API permissions
Best practices
Use specific permissions, not broad ones
Use specific permissions, not broad ones
Instead of
admin, define specific permissions like users.delete, billing.manage. This gives you more control and better audit trails.Check permissions at the API layer
Check permissions at the API layer
Don’t just check in the UI — always verify permissions server-side during API requests.
Use roles for common access patterns
Use roles for common access patterns
Instead of attaching 10 permissions to every key, create a role and attach that. Easier to manage and update.

