> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stateset.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rotate Api Key V1

> Issue a new plaintext secret for an existing key, in place. Preserves the row's id, name, scopes, rate limit, and expiration — only the secret (and therefore…

Issue a new plaintext secret for an existing key, in place.

Preserves the row's id, name, scopes, rate limit, and expiration —
only the secret (and therefore key\_hash + key\_prefix) changes. The
old plaintext stops working the instant this commits, so callers
should orchestrate the cutover: deploy the new value before calling
rotate, OR have a brief outage if you can tolerate it.

A key can rotate itself; the response carries the new plaintext, but
the caller must update their auth header on the next request.

### Path parameters

<ParamField path="key_id" type="string (uuid)" required />

### Response

`CreateAPIKeyResponse`

<ResponseField name="id" type="string" required />

<ResponseField name="name" type="string" required />

<ResponseField name="key" type="string" required>
  Plaintext API key — store it now. The platform only retains the SHA-256 hash; this is the one and only time the secret is exposed.
</ResponseField>

<ResponseField name="key_prefix" type="string" required />

<ResponseField name="scopes" type="string[]" required />

<ResponseField name="rate_limit_per_minute" type="integer" required />

<ResponseField name="created_at" type="string" required />

### Status codes

| Code  | Meaning             |
| ----- | ------------------- |
| `200` | Successful Response |
| `422` | Validation Error    |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.computer.stateset.app/api/v1/keys/{key_id}/rotate' \
    --header 'X-API-Key: YOUR_API_KEY'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "name": "Two-Person Tent",
    "key": "string",
    "key_prefix": "string",
    "scopes": [
      "string"
    ],
    "rate_limit_per_minute": 8,
    "created_at": "2026-08-31T14:22:05Z"
  }
  ```
</ResponseExample>
