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

# Rotate an API key

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

## Request

- Base URL: `https://api.hyperresearch.ai`
- URL: `https://api.hyperresearch.ai/v1/keys/{id}/rotate`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `hr_session`

Creates a new key with the same scopes and sets the old key to expire in 24 hours (overlap window).

## Path parameters

- `id` string, required

## Response `201`

Rotated

- RotatedApiKey
  - `created` CreatedApiKey, required
    - `id` string, required
    - `name` string, nullable, required
    - `prefix` 'hr_live_' | 'hr_test_' | 'hr_chat_', required
    - `masked` string, required
    - `scopes` string[], required
    - `last_used_at` string, nullable, required
    - `expires_at` string, nullable, required
    - `revoked_at` string, nullable, required
    - `created_at` string, required
    - `ip_allowlist` string[], required
    - `rotate_by` string, nullable, required
    - `rotation_due` boolean, required
    - `secret` string, required
  - `rotated` object, required: the previous key, now expiring after the 24 h overlap window
    - `id` string, required
    - `name` string, nullable, required
    - `prefix` 'hr_live_' | 'hr_test_' | 'hr_chat_', required
    - `masked` string, required
    - `scopes` string[], required
    - `last_used_at` string, nullable, required
    - `expires_at` string, nullable, required
    - `revoked_at` string, nullable, required
    - `created_at` string, required
    - `ip_allowlist` string[], required
    - `rotate_by` string, nullable, required
    - `rotation_due` boolean, required

## Other responses

- `400`: Invalid request
- `401`: Authentication failed
- `403`: Insufficient scope or plan
- `404`: Not found
- `429`: Rate limited or over quota
- `500`: Internal error

---

[API](https://skmtc.dev/hyperresearch/apis/hyperresearch-cloud-api.md) · [All operations](https://skmtc.dev/hyperresearch/apis/hyperresearch-cloud-api/llms.txt) · [OpenAPI document](https://skmtc.dev/hyperresearch/apis/hyperresearch-cloud-api/revisions/726ef831ebf4?raw)
