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

# Rotate API Key

> Rotate an API key to get a new secret

<Note>
  This endpoint requires **Bearer authentication** with your Supabase JWT.
</Note>

Rotating a key generates a new secret while keeping the same key ID and configuration. The old key is immediately invalidated.

## Path Parameters

<ParamField path="id" type="string" required>
  Key ID to rotate
</ParamField>

## Response

<Warning>
  The new API key is only returned once. Store it securely!
</Warning>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://prod.api.unleeshed.ai/partner/v1/api-keys/key-abc-123/rotate" \
    -H "Authorization: Bearer YOUR_SUPABASE_JWT"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://prod.api.unleeshed.ai/partner/v1/api-keys/key-abc-123/rotate',
    {
      method: 'POST',
      headers: { 'Authorization': `Bearer ${supabaseJwt}` }
    }
  );
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "success": true,
    "data": {
      "id": "key-abc-123",
      "name": "Production Server",
      "full_key": "pk_live_new456xxxxxxxxxxxxxxxxxxxxxxxx",
      "key_prefix": "pk_live_new45",
      "rotated_at": "2026-01-30T16:00:00Z"
    }
  }
  ```
</ResponseExample>
