---
title: "Rotate API key"
method: POST
path: "/v1/api-keys/{keyId}/rotate"
tags: ["API Keys"]
---

# Rotate API key

`POST /v1/api-keys/{keyId}/rotate`

Rotates an API key and returns the new key plus the old key grace period.

## Path parameters

- `keyId` string, required — API key identifier.

## Headers

- `x-project-id` string — Selects the active project for this request. Required for session/dashboard callers. Ignored when authenticating with an API key, whose scope is fixed to the key's project.

## Request body

- object — Rotate API key request body.
  - `gracePeriodHours` number — Grace period for the old key before revocation.

## Response `201`

API key rotated

- object — Standard success response envelope.
  - `data` object, required — API key rotation response payload.
    - `apiKey` object, required — New API key details.
      - `id` string, required — API key identifier.
      - `name` string, required — API key name.
      - `key` string, required — Full API key. Only returned once.
      - `keyPrefix` string, required — API key prefix for display.
      - `role` 'api_admin' | 'api_developer' | 'api_readonly', required — API key role.
      - `environment` 'sandbox' | 'production', required — API key environment.
      - `expiresAt` string, date-time, nullable, required — Expiration timestamp, if set.
      - `createdAt` string, date-time, required — Creation timestamp.
    - `previousKey` object, required — Previous API key rotation metadata.
      - `id` string, required — API key identifier.
      - `rotationDeadline` string, date-time, required — Deadline for revoking the previous key.
  - `meta` object, required — Response metadata.
    - `requestId` string, required — Request identifier for tracing.
    - `timestamp` string, date-time, required — ISO 8601 timestamp.

## Other responses

- `400` — Error
- `401` — Error
- `403` — Error
- `404` — Error
- `500` — Error

---

[API](https://skmtc.net/solana/apis/solana-developer-platform-api.md) · [All operations](https://skmtc.net/solana/apis/solana-developer-platform-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/solana/solana-developer-platform-api/revisions/672b1916ba61/schema)
