---
title: "Rotate API key"
method: POST
path: "/auth/keys/{id}/rotate"
tags: ["ApiKeys"]
---

# Rotate API key

`POST /auth/keys/{id}/rotate`

## Request

- Base URL: `https://api.crevio.co/v1`
- URL: `https://api.crevio.co/v1/auth/keys/{id}/rotate`
- Auth: API key in header `Authorization`

Issues a new secret for the key and revokes the old one at the same moment. The key keeps its id, name and scopes. The new secret (`token`) is in this response only. Called by Crevio's agent, a script or an MCP client, `token` is `null` and `token_secret_id` names the account secret that holds it.

## Path parameters

- `id` string, required

## Headers

- `Idempotency-Key` string

## Response `200`

The key with its new secret

- ApiKey
  - `object` string, required
  - `id` string, required
  - `name` string, nullable, required
  - `last4` string, required
  - `token_type` string, required
  - `kind` 'personal' | 'team', required: `personal` acts as the person who made it; `team` sees only what the whole account sees.
  - `scopes` string[], nullable, required: What the key may call. Null for a key made before scopes existed, which reaches everything.
  - `token` string, nullable, required
  - `last_used_at` string, nullable, required
  - `expires_at` string, nullable, required
  - `created_at` string, required

## Other responses

- `400`: Bad request
- `401`: Authentication required
- `403`: Forbidden
- `404`: Resource not found
- `429`: Rate limit exceeded — 600 requests per minute per owner on the free tier: every API key and OAuth token one person holds on an account shares one budget, and the account's team keys share another. Retry after the number of seconds in `Retry-After`.
- `500`: Internal server error

## Changes

- **2026-11-15** `56c22ab9b282`: 6 warning
  - added the new `idempotency_error` enum value to the `error/type` response property for the response status `400`
  - added the new `idempotency_error` enum value to the `error/type` response property for the response status `401`
  - added the new `idempotency_error` enum value to the `error/type` response property for the response status `403`
  - added the new `idempotency_error` enum value to the `error/type` response property for the response status `404`
  - …2 more
- **2026-10-23** `bf736a72ee9c`: 1 info
  - endpoint added

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

---

[API](https://skmtc.dev/crevio/apis/crevio-api-v1.md) - [All operations](https://skmtc.dev/crevio/apis/crevio-api-v1/llms.txt) - [OpenAPI document](https://skmtc.dev/crevio/apis/crevio-api-v1/revisions/ccbd8fcbd6d7?raw)
