> ## 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 erstellen

> Dieser Endpunkt erstellt einen neuen API-Schlüssel.

## POST /api-keys

Dieser Endpunkt erstellt einen neuen API-Schlüssel für den authentifizierten Nutzer. Der vollständige Schlüsselwert wird nur einmal bei der Erstellung angezeigt – sicher speichern.

<Warning>
  Der vollständige API-Schlüssel wird nur bei der Erstellung zurückgegeben. Bewahren Sie ihn sicher auf; eine spätere Abfrage ist nicht möglich.
</Warning>

### Anfragetext

<ParamField body="name" type="string" required>
  Beschreibender Name für den API-Schlüssel (1–100 Zeichen).
</ParamField>

<ParamField body="description" type="string">
  Beschreibung der Verwendung des Schlüssels (max. 500 Zeichen).
</ParamField>

<ParamField body="permissions" type="array">
  Liste der Berechtigungen für den Schlüssel. Standardmäßig alle Berechtigungen.
</ParamField>

<ParamField body="expiresAt" type="string">
  Optionales Ablaufdatum im ISO-8601-Format.
</ParamField>

### Antwort

<ResponseField name="success" type="boolean">
  Ob der Schlüssel erfolgreich erstellt wurde.
</ResponseField>

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

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

  <Expandable title="Eigenschaften von apiKey">
    <ResponseField name="id" type="string">
      Eindeutige Kennung des API-Schlüssels.
    </ResponseField>

    <ResponseField name="name" type="string">
      Name des Schlüssels.
    </ResponseField>

    <ResponseField name="key" type="string">
      Vollständiger API-Schlüssel (nur einmal sichtbar).
    </ResponseField>

    <ResponseField name="isActive" type="boolean">
      Ob der Schlüssel aktiv ist.
    </ResponseField>

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

<ResponseField name="warning" type="string">
  Hinweis, den Schlüssel sicher zu speichern.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.llmgenerator.com/api/v1/api-keys \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Production API Key",
      "description": "For the main application"
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    'https://api.llmgenerator.com/api/v1/api-keys',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        name: 'Production API Key',
        description: 'For the main application'
      })
    }
  );

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

<ResponseExample>
  ```json Success (201) theme={null}
  {
    "success": true,
    "message": "API key created successfully",
    "apiKey": {
      "id": "llm_1706345678_newkey123abc",
      "name": "Production API Key",
      "description": "For the main application",
      "key": "llm_1706345678_newkey123abc",
      "permissions": [],
      "expiresAt": null,
      "createdAt": "2026-01-27T10:00:00.000Z",
      "isActive": true
    },
    "warning": "This is the only time the full API key will be shown. Please save it securely."
  }
  ```

  ```json Validation Error (400) theme={null}
  {
    "message": "Validation error: Name is required"
  }
  ```
</ResponseExample>
