api.*.update_key(to update keys in any API)api.<api_id>.update_key(to update keys in a specific API)
See the API reference for the full HTTP endpoint documentation.
Usage
Flags
The ID of the key to update (begins with
key_). This is the database reference ID for the key, not the actual API key string that users authenticate with. This ID uniquely identifies which key’s credits will be updated.Defines how to modify the key’s remaining credits. Must be one of
set, increment, or decrement. Use set to replace current credits with a specific value or unlimited usage, increment to add credits for plan upgrades or credit purchases, and decrement to reduce credits for refunds or policy violations.The credit value to use with the specified operation. For
set, this becomes the new remaining credits value. For increment, this amount is added to current credits. For decrement, this amount is subtracted from current credits.Omit when using the set operation to make the key unlimited (removes usage restrictions entirely). When decrementing, if the result would be negative, remaining credits are automatically set to zero.Required when using increment or decrement operations. Optional for set operation (omitting creates unlimited usage).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 updated credit data:--output=json, the full response envelope is returned:

