---
title: "Rotate Key"
method: POST
path: "/v1/keys/{key_id}/rotate"
tags: ["keys"]
---

# Rotate Key

`POST /v1/keys/{key_id}/rotate`

Rotate an API key's secret in place, within the caller's organization.

Requires master key authentication.

Generates a new secret for the same key row (id, user, name, expiry, and
metadata are preserved) and returns the new raw key once, using the same
response shape as key creation. The previous secret stops authenticating
immediately; there is no grace window.

## Path parameters

- `key_id` string, required

## Response `200`

Successful Response

- CreateKeyResponse — Response model for creating a new API key.
  - `allowed_models` string[], nullable, required
  - `capture_agent_telemetry` boolean, nullable, required
  - `created_at` string, required
  - `exclude_from_budget` boolean, required
  - `expires_at` string, nullable, required
  - `id` string, required
  - `is_active` boolean, required
  - `key` string, required
  - `key_name` string, nullable, required
  - `key_prefix` string, nullable, required
  - `metadata` object, required
  - `reject_user_mismatch` boolean, nullable, required
  - `user_id` string, nullable, required

## Other responses

- `422` — Validation Error

## Changes

- **2026-08-12** `4891ca15ef2b` — 1 info
  - added the required property `capture_agent_telemetry` to the response with the `200` status
- **2026-08-06** `f7875304ff05` — 1 info
  - added the required property `reject_user_mismatch` to the response with the `200` status
- **2026-07-23** `2a163c690f59` — 1 info
  - added the required property `exclude_from_budget` to the response with the `200` status
- **2026-07-20** `bcd0082085cb` — 2 info
  - added the required property `allowed_models` to the response with the `200` status
  - added the required property `key_prefix` to the response with the `200` status
- **2026-07-20** `d9a87177ce4a` — 1 info
  - the endpoint scheme security `XApiKeyAuth` was added to the API

[Full history](https://skmtc.dev/mozilla-ai/apis/otari/changes/v1/keys/:key_id/rotate/post.md)

---

[API](https://skmtc.dev/mozilla-ai/apis/otari.md) · [All operations](https://skmtc.dev/mozilla-ai/apis/otari/llms.txt) · [OpenAPI document](https://skmtc.dev/mozilla-ai/apis/otari/revisions/80c117c36f36?raw)
