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

# Rotate Api Key

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

## Request

- Base URL: `https://api.fettle.sh` (the document declares no server; this is the origin it was published from)
- URL: `https://api.fettle.sh/v1/api-keys/{api_key_id}/rotate`
- Auth: API key in header `Authorization`

Replace this key's secret.

The previous secret keeps working for a short grace window so in-flight
clients have time to switch. The new secret is returned once, here, and
cannot be retrieved again.

## Path parameters

- `api_key_id` string, uuid, required

## Headers

- `X-Organization-Id` string, uuid, nullable

## Response `200`

Successful Response

- ApiKeyCreateResponse: The one and only time the secret leaves the server.
  - `api_key` string, required
  - `key` ApiKeyRead, required: Key metadata. Never carries the secret.
    - `id` string, uuid, required
    - `name` string, required
    - `prefix` string, required
    - `scopes` ApiScope[], required
    - `status` 'ACTIVE' | 'REVOKED' | 'EXPIRED', required: Derived lifecycle state of a key. Never stored — see ``ApiKeyService.get_status``.
    - `allowed_cidrs` string[], nullable, required
    - `expires_at` string, date-time, nullable, required
    - `revoked_at` string, date-time, nullable, required
    - `last_used_at` string, date-time, nullable, required
    - `rotation_grace_expires_at` string, date-time, nullable, required
    - `created_by_user_id` string, uuid, required
    - `created_at` string, date-time, required

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/fettle/apis/fettle-sh.md) · [All operations](https://skmtc.dev/fettle/apis/fettle-sh/llms.txt) · [OpenAPI document](https://skmtc.dev/fettle/apis/fettle-sh/revisions/f32c8a18606f?raw)
