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

# Rotate API key

> Rotate the secret key for an environment.

Generates a new secret key for the given environment and invalidates the previous one. The old secret stops working immediately.

## Body

<ParamField body="environment" type="string" required>
  Environment to rotate. One of `sandbox` or `live`.
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.vouchmark.com/v1/developers/api-keys/rotate \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"environment":"live"}'
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "success": true,
    "data": {
      "id": "...",
      "environment": "live",
      "publicKey": "live_pk_...",
      "secretPrefix": "live_sk_xxxx",
      "secretSuffix": "abc",
      "secretKey": "live_sk_...",
      "rotatedAt": "...",
      "createdAt": "..."
    }
  }
  ```
</ResponseExample>

Returns `201 Created`.

## Response fields

<ResponseField name="success" type="boolean" />

<ResponseField name="data" type="object">
  <Expandable title="rotatedKey">
    <ResponseField name="id" type="string" />

    <ResponseField name="environment" type="string">
      One of `sandbox` or `live`.
    </ResponseField>

    <ResponseField name="publicKey" type="string">
      Full public key. Prefixed `live_pk_` (live) or `test_pk_` (sandbox).
    </ResponseField>

    <ResponseField name="secretPrefix" type="string">
      First 12 characters of the new secret.
    </ResponseField>

    <ResponseField name="secretSuffix" type="string | null">
      Last 3 characters of the new secret. May be `null`.
    </ResponseField>

    <ResponseField name="secretKey" type="string">
      The full new secret key. Returned **only in this response** — copy it now and store it securely.
    </ResponseField>

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

    <ResponseField name="createdAt" type="string" />
  </Expandable>
</ResponseField>

<Warning>
  The `secretKey` is shown in full **only once**, in this response. It is masked in [List API keys](/api-reference/developers/list-api-keys) thereafter.
</Warning>
