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

# Rotate Api Key

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

## Request

- Base URL: `https://www.gateco.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://www.gateco.ai/api/api-keys/{key_id}/rotate`
- Auth: OAuth 2 (password, token URL `/api/auth/login`)

Rotate an API key.

Creates a replacement key with the same name. The old key continues to
authenticate for a 24-hour grace period (its expires_at is set to now + 24h),
giving deployments time to roll the new credential.

Returns the new plaintext key exactly once.
Requires JWT authentication.

## Path parameters

- `key_id` string, uuid, required

## Response `200`

Successful Response

- CreateApiKeyResponse: Response for POST /api/api-keys — includes the plaintext key exactly once.
  - `id` string, required
  - `name` string, required
  - `prefix` string, required
  - `last_used_at` string, nullable, required
  - `expires_at` string, nullable, required
  - `created_at` string, required
  - `key` string, required: Full API key — display once and discard

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/gateco/apis/gateco-api.md) · [All operations](https://skmtc.dev/gateco/apis/gateco-api/llms.txt) · [OpenAPI document](https://skmtc.dev/gateco/apis/gateco-api/revisions/5debaf204950?raw)
