Add roles to a key without affecting existing roles or permissions.
Use this for privilege upgrades, enabling new feature sets, or subscription changes that grant additional role-based capabilities. Direct permissions remain unchanged.
Important: Changes take effect immediately with up to 30-second edge propagation.
Required Permissions
Your root key must have one of the following permissions:
api.*.update_key (to update keys in any API)api.<api_id>.update_key (to update keys in a specific API)Side Effects
Invalidates the key cache for immediate effect, and makes role assignments available for verification within 30 seconds across all regions.
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_123Root 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:
Specifies which key receives the additional roles using the database identifier returned from createKey.
Do not confuse this with the actual API key string that users include in requests.
Added roles supplement existing roles and permissions without replacing them.
Role assignments take effect immediately but may take up to 30 seconds to propagate across all regions.
3 - 255"key_2cGKbMxRyIzhCxo1Idjz8q"
Assigns additional roles to the key through direct assignment to existing workspace roles. Operations are idempotent - adding existing roles has no effect and causes no errors.
All roles must already exist in the workspace - roles cannot be created automatically. Invalid roles cause the entire operation to fail atomically, ensuring consistent state.
1 - 100 elementsSpecify the role by name.
3 - 255Roles added 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 operation completes.
The response includes:
Important notes: