Authorizations
Unkey uses API keys (root keys) for authentication. These keys authorize access to management operations in the API. To authenticate, include your root key in the Authorization header of each request:
Authorization: Bearer unkey_123
Root keys have specific permissions attached to them, controlling what operations they can perform. Key permissions follow a hierarchical structure with patterns like resource.resource_id.action
(e.g., apis.*.create_key
, apis.*.read_api
).
Security best practices:
- Keep root keys secure and never expose them in client-side code
- Use different root keys for different environments
- Rotate keys periodically, especially after team member departures
- Create keys with minimal necessary permissions following least privilege principle
- Monitor key usage with audit logs.
Body
Specifies which key loses the roles using the database identifier returned from createKey. Do not confuse this with the actual API key string that users include in requests. Removing roles only affects direct assignments, not permissions inherited from other sources. Role changes take effect immediately but may take up to 30 seconds to propagate across all regions.
3 - 255
"key_2cGKbMxRyIzhCxo1Idjz8q"
Removes direct role assignments from the key without affecting other role sources or permissions. Operations are idempotent - removing non-assigned roles has no effect and causes no errors.
After removal, the key loses access to permissions that were only granted through these roles. Invalid role references cause the entire operation to fail atomically, ensuring consistent state.
1 - 100
elementsSpecify the role by name.
Response
Roles removed successfully. Returns all roles currently assigned to the key.
Metadata object included in every API response. This provides context about the request and is essential for debugging, audit trails, and support inquiries. The requestId
is particularly important when troubleshooting issues with the Unkey support team.
Complete list of all roles directly assigned to the key after the removal operation completes.
The response includes:
- The remaining roles still assigned to the key (after removing the specified roles)
- Both ID and name for each role for easy reference
Important notes:
- The response reflects the current state after the removal operation
- An empty array indicates the key now has no roles assigned
- This only shows direct role assignments
- Role permissions are not expanded in this response - use keys.getKey for full details
- Changes take effect immediately for new verifications but cached sessions may retain old permissions briefly