---
title: "POST /api-keys/{id}/rotate"
method: POST
path: "/api-keys/{id}/rotate"
tags: ["API Keys"]
---

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

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

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/api-keys/{id}/rotate`
- Auth: HTTP bearer

## Path parameters

- `id` integer, required

## Response `200`

API key rotated successfully; the response contains the new plaintext secret, shown only once

- CreateApiKeyResponse
  - `api_key` string, required
  - `created_at` string, date-time, required
  - `environment_id` integer, nullable
  - `expires_at` string, date-time, nullable
  - `id` integer, required
  - `key_prefix` string, required
  - `name` string, required
  - `permissions` string[], nullable
  - `project_id` integer, nullable: Immutable optional deployment resource scope.
  - `role_type` string, required

## Other responses

- `401`: Unauthorized
- `403`: Forbidden
- `404`: Not found
- `428`: Recent MFA verification required
- `500`: Internal server error

## Changes

- **2026-11-16** `eb31063c55e2`: 2 info
  - added the optional property `environment_id` to the response with the `200` status
  - added the optional property `project_id` to the response with the `200` status
- **2026-08-04** `c647b6ab1d2c`: 1 info
  - added the non-success response with the status `428`
- **2026-07-27** `1b060c0a4ba3`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/api-keys/:id/rotate/post.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) - [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) - [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/3b040526eb43?raw)
