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.
Request body
Example request
{
"keyId": "key_2cGKbMxRyIzhCxo1Idjz8q",
"name": "Payment Service Production Key",
"externalId": "user_912a841d",
"meta": {
"plan": "enterprise",
"limits": {
"storage": "500GB",
"compute": "1000 minutes/month"
},
"features": [
"analytics",
"exports",
"webhooks"
],
"hasAcceptedTerms": true,
"billing": {
"cycle": "monthly",
"next_billing": "2024-01-15"
},
"preferences": {
"timezone": "UTC",
"notifications": true
},
"lastBillingDate": "2023-10-15"
},
"expires": 1704067200000,
"credits": {
"remaining": 1000,
"refill": {
"interval": "daily",
"amount": 1000,
"refillDay": 15
}
},
"ratelimits": [
{
"name": "api"
}
],
"enabled": true,
"roles": [
"api_admin",
"billing_reader"
],
"permissions": [
"documents.read",
"documents.write",
"settings.view"
]
}Response
Key updated successfully. Changes take effect immediately with up to 30-second edge propagation.
Example response
{
"meta": {
"requestId": "req_123"
}
}