--expiration. Set it to 0 to revoke immediately, or use a positive value to allow a graceful overlap period for key rotation.
Important: Analytics and usage metrics are tracked at both the key level AND identity level. If the original key has an identity, the new key will inherit it, allowing you to track usage across both individual keys and the overall identity.
Required permissions:
api.*.create_keyorapi.<api_id>.create_keyapi.*.encrypt_keyorapi.<api_id>.encrypt_key(only when the original key is recoverable)
See the API reference for the full HTTP endpoint documentation.
Usage
Flags
The database identifier of the key to reroll. This is the unique ID returned when creating or listing keys, NOT the actual API key token. You can find this ID in the response from
keys.createKey, key verification responses, the Unkey dashboard, or API key listing endpoints.Duration in milliseconds until the original key is revoked, starting from now. Set to
0 to revoke the original key immediately. Positive values keep the original key active for the specified duration, allowing graceful migration by giving users time to update their credentials. Common overlap periods: 1 hour (3600000), 24 hours (86400000), 7 days (604800000), 30 days (2592000000).Global Flags
| Flag | Type | Description |
|---|---|---|
--root-key | string | Override root key ($UNKEY_ROOT_KEY) |
--api-url | string | Override API base URL (default: https://api.unkey.com) |
--config | string | Path to config file (default: ~/.unkey/config.toml) |
--output | string | Output format — use json for raw JSON |
Examples
Output
Default output shows the request ID with latency, followed by the new key details:--output=json, the full response envelope is returned:

