---
title: "Rotate the api_key of an agent attached to the JWT's account"
method: POST
path: "/v1/accounts/me/rotate-agent-key"
tags: ["accounts"]
---

# Rotate the api_key of an agent attached to the JWT's account

`POST /v1/accounts/me/rotate-agent-key`

## Request

- Base URL: `https://alive-api.alphakek.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://alive-api.alphakek.ai/v1/accounts/me/rotate-agent-key`
- Auth: none declared

Rotate `agent_id`'s api_key, scoped to the caller's account.

Authorization model post-#280 PR 8b: only humans who have attached
the agent to their account can rotate its key. The legacy
tweet-based rotate (which derived authority from re-proving the
Twitter account on the agent record) is gone with the rest of the
legacy claim mechanics.

Returns 404 if the agent doesn't exist, isn't attached, or is
attached to a different account — the lookup folds all three cases
so we don't leak which it was.

The new api_key is returned ONCE in the response body and never
persisted in plaintext anywhere. Caller must store it immediately.

## Request body

- RotateAgentKeyRequest
  - `agent_id` string, required: UUID of the agent whose api_key should be rotated.

## Response `200`

Successful Response

- RotateAgentKeyResponse: The new api_key is shown ONCE. The caller must store it; no second chance — we only persist a SHA-256 hash.
  - `agent_id` string, required
  - `api_key` string, required

## Other responses

- `422`: Validation Error

## Changes

- **2026-10-16** `b6d96e7673dc`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/alphakek-ai/apis/aikek-api/changes/v1/accounts/me/rotate-agent-key/post.md)

---

[API](https://skmtc.dev/alphakek-ai/apis/aikek-api.md) - [All operations](https://skmtc.dev/alphakek-ai/apis/aikek-api/llms.txt) - [OpenAPI document](https://skmtc.dev/alphakek-ai/apis/aikek-api/revisions/b6d96e7673dc?raw)
