Key Expiration (TTL)
KV supports automatic key expiration. Expired keys are automatically deleted and will return 404 on read.Setting Expiration
Two ways to expire keys:| Option | Description | Example |
|---|---|---|
expiration_ttl | Seconds from now until expiration (min: 60) | 3600 = 1 hour |
expiration | Unix timestamp when key expires | 1704067200 |
CLI Example
API Example
Use Cases for TTL
- Sessions — Expire after 24 hours of inactivity
- Cache — Expire after 5 minutes to ensure freshness
- Rate limiting — Expire counters after the rate limit window
- Temporary tokens — Auto-cleanup verification codes
Minimum TTL is 60 seconds. Keys with TTL less than 60 seconds will be rejected.
Metadata
Attach JSON metadata to keys for filtering, tagging, and context. Metadata is returned with the key on read.Setting Metadata
Reading Metadata
Metadata is returned with the value:Use Cases for Metadata
- Versioning — Track schema versions for migrations
- Tagging — Categorize keys by type, source, or owner
- Debugging — Store creation context (who, when, why)
- Filtering — Future: filter list operations by metadata
Metadata must be valid JSON and cannot exceed 1KB when serialized.