Replace all permissions on a key with the specified set in a single atomic operation.
Use this to synchronize with external systems, reset permissions to a known state, or apply standardized permission templates. Permissions granted through roles 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 permission changes 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 permissions using the database identifier returned from keys.createKey.
Do not confuse this with the actual API key string that users include in requests.
3 - 255"key_2cGKbMxRyIzhCxo1Idjz8q"
The permissions to set for this key.
This is a complete replacement operation - it overwrites all existing direct permissions with this new set.
Key behaviors:
Any permissions that do not exist will be auto created if the root key has permissions, otherwise this operation will fail with a 403 error.
Specify the permission by its slug.
3Permissions set successfully. Returns all permissions 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 permissions now directly assigned to the key after the set operation has completed.
The response includes:
Important notes: