POST /v2/identities.createIdentity
Create an identity to group multiple API keys under a single entity. Identities enable shared rate limits and metadata across all associated keys. Perfect for users with multiple devices, organizations with multiple API keys, or when you need unified rate limiting across different services.Required Permissions
Requiresidentity.*.create_identity permission
Request
Creates an identity using your system’s unique identifier for a user, organization, or entity. Must be stable and unique across your workspace - duplicate externalIds return CONFLICT errors.This identifier links Unkey identities to your authentication system, database records, or tenant structure. Avoid changing externalIds after creation as this breaks the link between your systems.
- Must be 1-255 characters long
- Can contain letters, numbers, underscores, dots, and hyphens
user_123Stores arbitrary JSON metadata returned during key verification for contextual information. Eliminates additional database lookups during verification, improving performance for stateless services.Important: Avoid storing sensitive data here as it’s returned in verification responses. Large metadata objects increase verification latency and should stay under 10KB total size.Use this for subscription details, feature flags, user preferences, and organization information.
- Maximum 100 properties
Defines shared rate limits that apply to all keys belonging to this identity. Prevents abuse by users with multiple keys by enforcing consistent limits across their entire key portfolio.Rate limit counters are shared across all keys with this identity, regardless of how many keys the user creates. During verification, specify which named limits to check for enforcement.
- Maximum 50 rate limits per identity
name- Named identifier for this rate limitlimit- Maximum operations allowedduration- Time window in milliseconds
Response
The unique identifier of the created identity. Use this ID to reference the identity in subsequent operations.Example:
id_1234567890abcdefExample
cURL
Response
Error Codes
400- Bad request (invalid parameters)401- Unauthorized (missing or invalid root key)403- Forbidden (insufficient permissions - requiresidentity.*.create_identity)409- Conflict (identity with this externalId already exists)429- Too many requests (rate limit exceeded)500- Internal server error