---
title: "Rotate an API key by id: revoke it and issue a new token with the same name and environment, atomically"
method: POST
path: "/v1/account/api-keys/{id}/rotate"
---

# Rotate an API key by id: revoke it and issue a new token with the same name and environment, atomically

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

## Request

- Base URL: `https://api.roveapi.com`
- URL: `https://api.roveapi.com/v1/account/api-keys/{id}/rotate`
- Auth: API key in cookie `rove_session`

## Path parameters

- `id` string, uuid, required

## Response `201`

Successful response (Cache-Control: no-store)

- object
  - `key` object, required
    - `id` string, uuid, required
    - `name` string, nullable, required
    - `environment` 'live' | 'test', required
    - `key_id_fingerprint` string, required: The viewer's API key ID: first 8 hex of SHA-256 of the key id.
    - `created_at` string, date-time, required
    - `last_used_at` string, date-time, nullable, required
    - `revoked_at` string, date-time, nullable, required
    - `kind` 'key' | 'oauth', required: 'oauth' for the dedicated key of a connected app's grant; such a key has no token and cannot be rotated.
    - `connected_app` object, nullable, required: null for every kind 'key' row.
      - `grant_id` string, uuid, required
      - `client_name` string, required: The app's display name: its asserted name, else its redirect host, else 'an app on this computer'. Not verified by Rove.
      - `grant_active` boolean, required
  - `token` string, required: Shown once; never returned again.
  - `revoked_key_id` string, uuid, required

## Other responses

- `401`: RFC 7807 owner-session-required: sign in
- `403`: RFC 7807 owner-origin-refused (mutations only)
- `404`: RFC 7807 key-not-found: re-read the key list
- `409`: RFC 7807 key-revoked; or oauth-key-not-rotatable for a connected app's key (AR-01)
- `429`: RFC 7807 key-create-rate-limited: 20 creates and rotates per account per trailing hour; Retry-After and retry_after_seconds
- `503`: RFC 7807 account-service-unavailable; Retry-After: 30

---

[API](https://skmtc.dev/roveapi/apis/rove-api.md) · [All operations](https://skmtc.dev/roveapi/apis/rove-api/llms.txt) · [OpenAPI document](https://skmtc.dev/roveapi/apis/rove-api/revisions/0e5d69bde586?raw)
