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

# Rotate Api Key

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

Rotate an API key: invalidate the old secret and issue a new one atomically,
preserving the key's id, name, and scopes.

The new plaintext key is returned **once** in this response.

## Path parameters

- `key_id` string, required

## Response `200`

Successful Response

- RotateApiKeyResponse — Response model for rotating an API key. Returns the new plaintext once.
  - `api_key` string, required
  - `key` ApiKeyMetadata, required — Non-sensitive metadata for an API key. Never includes the key value.
    - `id` string, required
    - `prefix` string, required
    - `name` string, nullable
    - `scopes` ApiKeyScope[]
    - `created_at` string, date-time, nullable
    - `expires_at` string, date-time, nullable
    - `last_used_at` string, date-time, nullable
    - `legacy` boolean
    - `created_by_email` string, nullable
  - `message` string

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/neosapien/apis/neocore.md) · [All operations](https://skmtc.dev/neosapien/apis/neocore/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/neosapien/neocore/revisions/db4791891204/schema)
