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

# API 키 재발급

> API 키 값을 재생성하는 엔드포인트입니다.

## POST /api-keys/{keyId}/regenerate

API 키를 재발급합니다. 이름·설명·권한 등 메타데이터는 유지하고 새 키 값을 발급하며, 이전 키는 즉시 무효화됩니다.

<Warning>
  새 API 키 값도 한 번만 표시됩니다. 기존 키는 즉시 사용할 수 없습니다.
</Warning>

<Note>
  현재 요청에 사용 중인 API 키는 재발급할 수 없습니다.
</Note>

### 경로 매개변수

<ParamField path="keyId" type="string" required>
  재발급할 API 키 ID입니다.
</ParamField>

### 응답

<ResponseField name="success" type="boolean">
  재발급 성공 여부입니다.
</ResponseField>

<ResponseField name="message" type="string">
  상태 메시지입니다.
</ResponseField>

<ResponseField name="apiKey" type="object">
  재발급된 API 키 정보입니다.

  <Expandable title="apiKey 속성">
    <ResponseField name="id" type="string">
      키 식별자입니다(변경 없음).
    </ResponseField>

    <ResponseField name="name" type="string">
      키 이름입니다(변경 없음).
    </ResponseField>

    <ResponseField name="key" type="string">
      새 API 키 값입니다(한 번만 표시).
    </ResponseField>

    <ResponseField name="regeneratedAt" type="string">
      재발급 시각(ISO 8601)입니다.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="warning" type="string">
  이전 키가 무효임을 안내하는 메시지입니다.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.llmgenerator.com/api/v1/api-keys/llm_1706123456_abc123def456/regenerate \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    'https://api.llmgenerator.com/api/v1/api-keys/llm_1706123456_abc123def456/regenerate',
    {
      method: 'POST',
      headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
    }
  );

  const data = await response.json();
  // Save data.apiKey.key securely!
  ```
</RequestExample>

<ResponseExample>
  ```json Success (200) theme={null}
  {
    "success": true,
    "message": "API key regenerated successfully",
    "apiKey": {
      "id": "llm_1706123456_abc123def456",
      "name": "Production Key",
      "key": "llm_1706456789_newvalue567xyz",
      "regeneratedAt": "2026-01-27T10:00:00.000Z"
    },
    "warning": "This is the only time the new API key will be shown. Please save it securely. The old key is now invalid."
  }
  ```

  ```json Cannot Regenerate Current Key (400) theme={null}
  {
    "message": "Cannot regenerate the API key currently being used"
  }
  ```

  ```json Not Found (404) theme={null}
  {
    "message": "API key not found"
  }
  ```
</ResponseExample>
