Skip to content

Rotate Agent Key

POST
/api/agents/{agent_id}/rotate
curl --request POST \
--url https://example.com/api/agents/example/rotate \
--header 'Authorization: Bearer <token>'

Replace an agent’s key. The old key stops working now; the new one is shown once. Admin keys only.

Rotating your own key is allowed: the replacement comes back in this response, so it hands your access over rather than taking it away. That is the only way to get a readable copy of your own key again — Studio stores a hash, never the key. A browser signed in with the cookie gets the cookie rewritten to the new key here, so the tab that rotated stays signed in.

agent_id
required
Agent Id
string

Successful Response

Media typeapplication/json
AgentKeyResponse
object
agent
required
AgentRecord

An API key’s identity and scope. The key itself is never stored or returned again.

object
id
required
Id
string
name
required
Name
string
enabled
required
Enabled
boolean
is_admin
required
Is Admin
boolean
allowed_characters
required
Allowed Characters
Array<string>
allowed_workflows
required
Allowed Workflows
Array<string>
max_concurrent_jobs
required
Any of:
integer
created_at
required
Created At
string format: date-time
last_used_at
required
Any of:
string format: date-time
avatar
Any of:
string
bio
Any of:
string
key
required
Key

Shown once. Only its hash is stored.

string
Examplegenerated
{
"agent": {
"id": "example",
"name": "example",
"enabled": true,
"is_admin": true,
"allowed_characters": [
"example"
],
"allowed_workflows": [
"example"
],
"max_concurrent_jobs": 1,
"created_at": "2026-04-15T12:00:00Z",
"last_used_at": "2026-04-15T12:00:00Z",
"avatar": "example",
"bio": "example"
},
"key": "example"
}

Validation Error

Media typeapplication/json
HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
Examplegenerated
{
"detail": [
{
"loc": [
"example"
],
"msg": "example",
"type": "example"
}
]
}