---
title: "POST /api-keys/{id}/rotate"
method: POST
path: "/api-keys/{id}/rotate"
---

# POST /api-keys/{id}/rotate

`POST /api-keys/{id}/rotate`

## Request

- Base URL: `https://api.useanima.sh/v1`
- URL: `https://api.useanima.sh/v1/api-keys/{id}/rotate`
- Auth: one of:
  - HTTP bearer
  - API key in header `X-API-Key`

## Path parameters

- `id` string, required: Unique identifier of the API key to rotate

## Request body

- object: Request body for rotating an API key, which revokes the old key and issues a new one

## Response `200`

OK

- object: API key resource including the secret value, returned only on creation
  - `id` string, required: Unique identifier for the API key
  - `orgId` string, required: Organization that owns this API key
  - `agentId` string, nullable, required: Agent this key is restricted to, null if unrestricted
  - `name` string, nullable, required: Human-readable label for the API key
  - `prefix` string, required: Non-secret prefix of the key for identification
  - `mode` 'LIVE' | 'TEST', required: Environment mode of the key
  - `scopes` string[], required: Permission scopes granted to this key
  - `revoked` boolean, required: Whether the key has been revoked
  - `createdAt` string, date-time, required: ISO 8601 timestamp when the key was created
  - `lastUsedAt` string, date-time, nullable, required: ISO 8601 timestamp when the key was last used, null if never used
  - `expiresAt` string, date-time, nullable, required: ISO 8601 timestamp when the key expires, null if no expiration
  - `createdBy` string, nullable, required: User ID of the key creator, null if created by system
  - `extension` object, nullable: Extension-token settings surfaced from metadata. Present only for extension:bridge keys.
    - `authPolicy` 'session' | 'pre_approved' | 'prompt_owner', required
    - `tokenTtl` '15m' | '1h' | 'session', required
  - `key` string, required: Full secret API key value, only returned once at creation time

---

[API](https://skmtc.dev/useanima/apis/anima-api.md) · [All operations](https://skmtc.dev/useanima/apis/anima-api/llms.txt) · [OpenAPI document](https://skmtc.dev/useanima/apis/anima-api/revisions/aaa148188980?raw)
