> ## 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-Schlüssel neu ausstellen

> Dieser Endpunkt stellt einen API-Schlüssel neu aus.

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

Dieser Endpunkt erzeugt einen neuen Schlüsselwert bei gleichbleibenden Metadaten (Name, Beschreibung, Berechtigungen). Der alte Schlüssel wird sofort ungültig.

<Warning>
  Der neue API-Schlüsselwert wird nur einmal angezeigt. Der alte Schlüssel funktioniert ab sofort nicht mehr.
</Warning>

<Note>
  Sie können nicht den API-Schlüssel neu ausstellen, mit dem die aktuelle Anfrage authentifiziert wird.
</Note>

### Pfadparameter

<ParamField path="keyId" type="string" required>
  Kennung des neu auszustellenden API-Schlüssels.
</ParamField>

### Antwort

<ResponseField name="success" type="boolean">
  Ob die Neuausstellung erfolgreich war.
</ResponseField>

<ResponseField name="message" type="string">
  Statusmeldung.
</ResponseField>

<ResponseField name="apiKey" type="object">
  Details des neu ausgestellten API-Schlüssels.

  <Expandable title="Eigenschaften von apiKey">
    <ResponseField name="id" type="string">
      Schlüsselkennung (unverändert).
    </ResponseField>

    <ResponseField name="name" type="string">
      Schlüsselname (unverändert).
    </ResponseField>

    <ResponseField name="key" type="string">
      Neuer API-Schlüsselwert (nur einmal sichtbar).
    </ResponseField>

    <ResponseField name="regeneratedAt" type="string">
      ISO-8601-Zeitstempel der Neuausstellung.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="warning" type="string">
  Hinweis, dass der alte Schlüssel nun ungültig ist.
</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>
