Update key settings
Update key properties in response to plan changes, subscription updates, or account status changes.
Use this for user upgrades/downgrades, role modifications, or administrative changes. Supports partial updates - only specify fields you want to change. Set fields to null to clear them.
Important: Permissions and roles are replaced entirely. Use dedicated add/remove endpoints for incremental changes.
Required Permissions
Your credential must have one of the following permissions:
api.*.update_key(to update keys in any API)api.<api_id>.update_key(to update keys in a specific API)unkey:v1:<workspace_id>:keyspaces/*/keys/*#update_key(to update keys in any keyspace)unkey:v1:<workspace_id>:keyspaces/<keyspace_id>/keys/*#update_key(to update keys in a specific keyspace)unkey:v1:<workspace_id>:keyspaces/<keyspace_id>/keys/<key_id>#update_key(to update a specific key)
Side Effects
If you specify an externalId that doesn't exist, a new identity will be automatically created and linked to the key. Permission updates will auto-create any permissions that don't exist in your workspace. Changes take effect immediately but may take up to 30 seconds to propagate to all edge regions due to cache invalidation.
Authorization
Body
application/jsonSpecifies which key to update using the database identifier returned from createKey.
Do not confuse this with the actual API key string that users include in requests.
Length: 3–255Pattern: ^[a-zA-Z0-9_]+$
Sets a human-readable name for internal organization and identification.
Omitting this field leaves the current name unchanged, while setting null removes it entirely.
Avoid generic names like "API Key" when managing multiple keys per user or service.
Length: 1–255
Links this key to a user or entity in your system for ownership tracking during verification.
Omitting this field preserves the current association, while setting null disconnects the key from any identity.
Essential for user-specific analytics, billing, and key management across multiple users.
Supports letters, numbers, underscores, dots, and hyphens for flexible identifier formats.
Length: 1–255Pattern: ^[a-zA-Z0-9_.-]+$
Stores arbitrary JSON metadata returned during key verification.
Omitting this field preserves existing metadata, while setting null removes all metadata entirely.
Avoid storing sensitive data here as it's returned in verification responses.
Large metadata objects increase verification latency and should stay under 10KB total size.
Sets when this key automatically expires as a Unix timestamp in milliseconds.
Verification fails with code=EXPIRED immediately after this time passes.
Omitting this field preserves the current expiration, while setting null makes the key permanent.
Avoid setting timestamps in the past as they immediately invalidate the key.
Keys expire based on server time, not client time, which prevents timezone-related issues.
Active sessions continue until their next verification attempt after expiry.
Range: 0–4102444800000
Show child attributesHide child attributes
Range: 0–9223372036854776000
Show child attributesHide child attributes
Range: 1–9223372036854776000
Day of the month for monthly refills (1-31).
Only required when interval is 'monthly'.
For days beyond the month's length, refill occurs on the last day of the month.
Range: 1–31
Defines time-based rate limits that protect against abuse by controlling request frequency.
Omitting this field preserves existing rate limits, while setting null removes all rate limits.
Unlike credits which track total usage, rate limits reset automatically after each window expires.
Multiple rate limits can control different operation types with separate thresholds and windows.
Items: max 50
Show child attributesHide child attributes
The name of this rate limit. This name is used to identify which limit to check during key verification.
Best practices for limit names:
- Use descriptive, semantic names like 'api_requests', 'heavy_operations', or 'downloads'
- Be consistent with naming conventions across your application
- Create separate limits for different resource types or operation costs
- Consider using namespaced names for better organization (e.g., 'files.downloads', 'compute.training')
You will reference this exact name when verifying keys to check against this specific limit.
Length: 3–128
The maximum number of operations allowed within the specified time window.
When this limit is reached, verification requests will fail with code=RATE_LIMITED until the window resets. The limit should reflect:
- Your infrastructure capacity and scaling limitations
- Fair usage expectations for your service
- Different tier levels for various user types
- The relative cost of the operations being limited
Higher values allow more frequent access but may impact service performance.
Range: >= 1
The duration for each ratelimit window in milliseconds.
This controls how long the rate limit counter accumulates before resetting. Common values include:
- 1000 (1 second): For strict per-second limits on high-frequency operations
- 60000 (1 minute): For moderate API usage control
- 3600000 (1 hour): For less frequent but costly operations
- 86400000 (24 hours): For daily quotas
Shorter windows provide more frequent resets but may allow large burst usage. Longer windows provide more consistent usage patterns but take longer to reset after limit exhaustion.
Range: >= 1000
Default: false
Controls whether the key is currently active for verification requests.
When set to false, all verification attempts fail with code=DISABLED regardless of other settings.
Omitting this field preserves the current enabled status.
Useful for temporarily suspending access during billing issues, security incidents, or maintenance windows without losing key configuration.
Items: max 100
Items: max 1000
Responses
requestId is particularly important when troubleshooting issues with the Unkey support team.Show child attributesHide child attributes
requestId is particularly important when troubleshooting issues with the Unkey support team.Show child attributesHide child attributes
Show child attributesHide child attributes
400 (Bad Request), 401 (Unauthorized), 403 (Forbidden), 404 (Not Found), 409 (Conflict), and 500 (Internal Server Error).Show child attributesHide child attributes
JSON path indicating exactly where in the request the error occurred. This helps pinpoint the problematic field or parameter. Examples include:
- 'body.name' (field in request body)
- 'body.items[3].tags' (nested array element)
- 'path.apiId' (path parameter)
- 'query.limit' (query parameter)
Use this location to identify exactly which part of your request needs correction.
requestId is particularly important when troubleshooting issues with the Unkey support team.Show child attributesHide child attributes
Show child attributesHide child attributes
400 (Bad Request), 401 (Unauthorized), 403 (Forbidden), 404 (Not Found), 409 (Conflict), and 500 (Internal Server Error).requestId is particularly important when troubleshooting issues with the Unkey support team.Show child attributesHide child attributes
Show child attributesHide child attributes
400 (Bad Request), 401 (Unauthorized), 403 (Forbidden), 404 (Not Found), 409 (Conflict), and 500 (Internal Server Error).requestId is particularly important when troubleshooting issues with the Unkey support team.Show child attributesHide child attributes
Show child attributesHide child attributes
400 (Bad Request), 401 (Unauthorized), 403 (Forbidden), 404 (Not Found), 409 (Conflict), and 500 (Internal Server Error).requestId is particularly important when troubleshooting issues with the Unkey support team.Show child attributesHide child attributes
Show child attributesHide child attributes
400 (Bad Request), 401 (Unauthorized), 403 (Forbidden), 404 (Not Found), 409 (Conflict), and 500 (Internal Server Error).requestId is particularly important when troubleshooting issues with the Unkey support team.Show child attributesHide child attributes
Show child attributesHide child attributes
400 (Bad Request), 401 (Unauthorized), 403 (Forbidden), 404 (Not Found), 409 (Conflict), and 500 (Internal Server Error).