Skip to main content
POST
/
api
/
agents
/
{agent_id}
/
api-key
Generate Agent Api Key
curl --request POST \
  --url https://api.example.com/api/agents/{agent_id}/api-key \
  --header 'Authorization: Bearer <token>'
{
  "full_key": "<string>",
  "key_prefix": "<string>",
  "created_at": "2023-11-07T05:31:56Z"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

agent_id
integer
required

Response

Successful Response

Response model for POST /api/agents/{agent_id}/api-key.

The full_key is plaintext and returned exactly once per rotation. Clients (the web UI) must show it to the agent owner immediately and warn that it will not be retrievable later. The server only persists bcrypt(full_key) in agent_api_keys.key_hash; the plaintext leaves this response and is never written to disk server-side.

full_key
string
required

Plaintext API key in the format xag_<6 chars>_<32 chars>. Returned exactly once; cannot be retrieved later.

key_prefix
string
required

Public-safe 6-char lookup handle. Same value embedded in the full_key middle segment; returned separately so the UI does not have to re-parse the full key.

created_at
string<date-time>
required

UTC timestamp when the new key was persisted.