---
title: "Rotate an API key: issue a replacement, then revoke the old one"
method: POST
path: "/api/keys/rotate"
tags: ["API Keys"]
---

# Rotate an API key: issue a replacement, then revoke the old one

`POST /api/keys/rotate`

## Request

- Base URL: `https://www.oxfordledge.com` (the document declares no server; this is the origin it was published from)
- URL: `https://www.oxfordledge.com/api/keys/rotate`
- Auth: none declared

Rotate an API key — the leak-response action.

Issues a replacement key (same name), THEN revokes the old one, so a
failure mid-rotation can never leave you locked out. The new key is
shown once in this response. Trial keys cannot be rotated.

## Query parameters

- `key_id` integer, required

## Response `200`

Successful Response

- ApiKeysCreateResponse: `POST /api/keys` — generate a new API key. Run 19 F4 backfill 2026-05-12. Returns the freshly-generated key + metadata. The plaintext key is shown ONCE — clients must capture it on this response or revoke + reissue.
  - `status` string, nullable: 'ok' on success.
  - `key` string, nullable: Plaintext API key — shown exactly once.
  - `name` string, nullable: Human-readable label.
  - `id` integer, nullable: Key id (numeric).
  - `created_at` string, nullable: ISO timestamp.
  - `error` string, nullable: Failure message.

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/oxfordledge/apis/oxford-ledge-api.md) · [All operations](https://skmtc.dev/oxfordledge/apis/oxford-ledge-api/llms.txt) · [OpenAPI document](https://skmtc.dev/oxfordledge/apis/oxford-ledge-api/revisions/e832a1260f0b?raw)
