Create a new API key for user authentication and authorization.
Use this endpoint when users sign up, upgrade subscription tiers, or need additional keys. Keys are cryptographically secure and unique to the specified API namespace.
Important: The key is returned only once. Store it immediately and provide it to your user, as it cannot be retrieved later.
Common use cases:
Required Permissions
Your root key needs one of:
api.*.create_key
(create keys in any API)api.<api_id>.create_key
(create keys in specific API)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:
Successfully created a new API key. The response includes both the keyId (for reference in your system) and the full key string. IMPORTANT: This is the only time the complete key is available - it cannot be retrieved later. You must securely provide this key to your end user immediately.
The response is of type object
.