Skip to main content
API keys are the foundation of Unkey. They provide a simple, secure way to authenticate requests to your API while giving you fine-grained control over access, usage, and permissions.

Overview

Unkey handles the complete API key lifecycle — from creation to verification to revocation — so you can focus on building your API instead of managing authentication infrastructure.

Create keys

Generate API keys programmatically via API or dashboard with custom configuration

Verify instantly

Verify keys in ~50ms globally with automatic validation of limits, expiration, and permissions

Track usage

Monitor verification patterns, track remaining credits, and analyze usage per key

Revoke immediately

Disable or delete keys with global propagation in under 60 seconds

Key Creation

Create API keys through the dashboard or API with complete control over their configuration.

Key Configuration Options

Set an expiration timestamp (Unix milliseconds) to automatically invalidate keys after a certain time.
Keys return code: "EXPIRED" after expiration. Perfect for trials, temporary access, or forced rotation.
Limit total requests a key can make. Each verification decrements the counter.
When exhausted, verification returns code: "USAGE_EXCEEDED".
Automatically restore credits on a schedule:
Perfect for subscription models: “50,000 requests/month”.
Limit request frequency per key:
Multiple limits can be applied to different operation types.
Attach permissions for fine-grained access control:
Checked during verification to authorize specific actions.

Key Verification

Verify keys on every request to authenticate users and enforce limits.

Verification Response

When you verify a key, Unkey returns comprehensive information:
The credits field shows remaining credits after this verification. A value of 999 means the key can be used 999 more times.

Verification Status Codes

Metadata Management

Store arbitrary JSON data with each key for context and configuration.

Common Use Cases

User context

Plan information

Feature flags

Resource scoping

Update Metadata

Key Revocation

Revoke access immediately when keys are compromised or users churn.
Use when the key should never work again. Cannot be undone.
Deletion is permanent and cannot be reversed. The key cannot be recovered. If you might need to restore access, use disable instead.

Propagation Time

  • Delete: Up to 60 seconds for global invalidation
  • Disable: Up to 60 seconds for global propagation
  • Re-enable: Immediate

Advanced Features

Custom cost per request

Charge different amounts per operation type:

Permission checking

Verify permissions during authentication:

Key rerolling

Generate a new key while preserving configuration:

Update credits

Manually adjust credit balance:

Best Practices

API keys should only be transmitted over secure connections. Never send keys in URLs or query parameters.
Never commit keys to version control. Use environment variables or secret management services.
Regularly rotate keys for security. Use the reroll feature to generate new keys while maintaining configuration.
Give keys only the permissions they need. Create separate keys for different services or operations.
Watch for unusual activity — sudden spikes, failed verifications, or geographic anomalies.
Always check the code field to provide helpful error messages to users:
  • EXPIRED: “Your API key has expired. Please generate a new one.”
  • USAGE_EXCEEDED: “You’ve reached your request limit. Upgrade for more.”
  • RATE_LIMITED: “Too many requests. Please slow down.”

Next Steps

Rate Limiting

Protect your API from abuse with flexible rate limiting

Identities

Group multiple keys under users or organizations

Analytics

Track usage patterns and verification trends

API Reference

Complete API documentation for all endpoints