Skip to main content
Identities let you connect multiple API keys to a single entity — a user, an organization, a service account, or any logical grouping in your system. Once connected, keys can share configuration, metadata, and most importantly, rate limits.

The Problem Identities Solve

Without identities, each API key is an island. If a user has 3 keys, you need to:
  • Update rate limits on each key separately
  • Piece together analytics from multiple sources
  • Track usage per-key instead of per-user
  • Allow users to bypass limits by creating more keys
With identities:

Real-World Example

Imagine you’re building a developer platform like Stripe. Each customer has:
  • A test key for development
  • A production key for live traffic
  • Multiple restricted keys for different microservices
All these keys belong to the same customer. With identities:
Now:
  • All 3 keys share the 1000 req/min limit
  • Updating the identity’s plan metadata updates it for all keys
  • Analytics aggregate across all keys
  • Customer can’t bypass limits by using different keys

Use Cases

Shared rate limits

Enforce a single rate limit across all of a user’s keys. Prevents bypass through multiple keys.

Aggregate analytics

See total usage per customer instead of piecing together data from individual keys.

Centralized configuration

Store plan tier, feature flags, or custom limits once. All keys inherit the configuration.

Multi-tenant organizations

Map identities to organizations. Team members and services share the org’s identity and limits.

Service accounts

Group keys for different microservices under a single service account identity.

User management

Track all keys belonging to a user. Revoke all keys when user leaves or account is suspended.

Creating Identities

Identity Data Model

string
required
Unkey’s internal identifier for this identity. Use this in API calls that reference the identity.
string
required
Your identifier for this entity. This links the Unkey identity to your system — typically a user ID, org ID, or customer ID.If you use Clerk, Auth0, WorkOS, or similar: use their user/org ID as the externalId.
json
Arbitrary JSON metadata. Store anything useful: plan tier, feature flags, company name, billing info.
array
Rate limits that apply to all keys linked to this identity:

Linking Keys to Identities

Create keys that automatically link to an identity using the externalId field:

Shared Rate Limits

The killer feature: enforce a single rate limit across all of a user’s keys.

The Problem

Without shared limits, rate limits apply per-key:

The Solution

Create an identity with rate limits, then link all keys to it:

Implementation

1

Create identity with rate limits

2

Create keys linked to identity

3

Verify — limits enforced automatically

Multiple Rate Limits

Apply different limits to different resource types:
Check specific limits during verification:
If any specified limit is exceeded, verification fails.

Accessing Identity Data

When you verify a key linked to an identity, you get the identity info:

Updating Identities

Update identity metadata or rate limits — changes apply to all linked keys:

Managing Keys per Identity

List all keys belonging to an identity:

Revoke All Keys for an Identity

When a user leaves or account is suspended:

Common Patterns

Link Unkey identities to Clerk, Auth0, or WorkOS:
Use organization IDs as externalIds for team-based rate limiting:
Different plans get different limits:
Production and staging keys for the same user:

Analytics & Insights

Identities enable powerful analytics:
  • Per-customer usage: See total API usage per customer instead of per-key
  • Churn prediction: Identify customers with declining usage
  • Upsell opportunities: Find users hitting rate limits who might upgrade
  • Cost attribution: Track API costs per customer for accurate billing
Analytics are automatically aggregated by identity. View in the Unkey dashboard under Analytics → filter by externalId.

Best Practices

Use meaningful external IDs

Use your existing user/org IDs as externalId. Makes it easy to join Unkey data with your database.

Store plan tier in metadata

Keep plan information in identity metadata for easy access during verification without extra DB queries.

One identity per customer

Even if users have multiple projects, use one identity per user. Use key metadata for project scoping.

Set rate limits on identities

Always set rate limits on the identity, not individual keys, to prevent bypass through multiple keys.

Update identities on upgrades

When users upgrade plans, update the identity’s rate limits and metadata immediately.

Clean up on churn

Delete identities and all associated keys when users churn to keep your workspace clean.

Next Steps

API Keys

Learn about creating and managing API keys

Rate Limiting

Deep dive into rate limiting strategies

Analytics

Track usage patterns per identity

API Reference

Complete identity API documentation