This guide gets you from zero to a working API key verification as fast as possible. We’ll create a key, then verify it using your preferred method.Documentation Index
Fetch the complete documentation index at: https://unkey.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Need an account? Sign up free, takes 30 seconds.
1. Create an API
An API in Unkey is a container for your keys. Head to your dashboard and create one, or use one you already have. Copy your API ID, it looks likeapi_xxxx.
2. Create a root key
Root keys authenticate your requests to the Unkey API (for creating and managing keys).- Go to Workspace Settings → Root Keys
- Click Create New Root Key
- Give it a name and select the permissions you need
- Copy the key, you won’t see it again
3. Create an API key
Now let’s create a key that your users would use to authenticate:key value, that’s what you’ll verify in the next step.
4. Verify the key
This is what you’ll do on every API request to check if a key is valid:What’s in the verification response?
Thedata object contains everything you need to make authorization decisions:
| Field | Type | Description |
|---|---|---|
valid | boolean | Whether the key passed all checks |
code | string | Status code (VALID, NOT_FOUND, RATE_LIMITED, etc.) |
keyId | string | The key’s unique identifier |
name | string? | Human-readable name of the key |
meta | object? | Custom metadata associated with the key |
expires | number? | Unix timestamp (in milliseconds) when the key will expire. (if set) |
credits | number? | Remaining uses (if usage limits set) |
enabled | boolean | Whether the key is enabled |
roles | string[]? | Permissions attached to the key |
permissions | string[]? | Permissions attached to the key |
identity | object? | Identity info if externalId was set when creating the key |
ratelimits | object[]? | Rate limit states (if rate limiting configured) |
Fields marked with
? are optional and only included when relevant (e.g.,
remaining only appears if you set a usage limit).Next steps
Now integrate Unkey into your actual application:Next.js
Protect API routes with middleware
Express
Add key verification to Express routes
Bun
Fast verification with Bun’s native server
Hono
Globally distributed API key verification
Add rate limiting
Protect endpoints from abuse
Set usage limits
Cap requests per key for billing tiers
Add permissions
Fine-grained access control
SDK Reference
Full TypeScript SDK docs

