When to use this
Trial access
Give new users a 7-day trial key. It stops working automatically.
Time-limited integrations
Partner needs API access for a project? Key expires when the project ends.
Session-based access
Generate a key that lasts for a user’s session (e.g., 24 hours).
Security rotations
Force key rotation by having keys expire periodically.
How it works
- Create a key with an
expirestimestamp (Unix milliseconds) - Key works normally until the expiration time
- After expiration, verification returns
code: EXPIRED - Unkey automatically cleans up expired keys
Create a temporary key
Setexpires to a Unix timestamp in milliseconds:
Common expiration times
Verification response
When verifying an expired key:Extend or change expiration
Update the expiration time on an existing key:Remove expiration
Make a temporary key permanent by settingexpires to null:
Combining with other features
Temporary keys work with all other key features:Temporary vs usage-limited keys
Use both together for trial limits: “7 days OR 1000 requests, whichever comes first.”
Next steps
Usage limits
Cap total requests per key
Key rotation
Generate new keys while maintaining config