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

# Abonnement kündigen

> Das aktive Abonnement zum Ende der laufenden Abrechnungsperiode kündigen.

## Überblick

Kündigt das Abonnement des Nutzers. Es bleibt bis zum Ende der aktuellen Abrechnungsperiode aktiv und verlängert sich nicht. Erfordert Sitzungsauthentifizierung (JWT-Access-Token).

<Note>
  **Für Drittanbieter-Integrationen:** Verwenden Sie `POST /subscriptions/cancel/api` mit API-Schlüssel-Authentifizierung.
</Note>

<Warning>
  Die Kündigung wird zum Periodenende wirksam. Der Zugang bleibt bis `currentPeriodEnd` bestehen. Für eine sofortige Beendigung nutzen Sie das Abrechnungsportal.
</Warning>

## Authentifizierung

<ParamField header="Authorization" type="string" required>
  JWT-Access-Token. Format: `Bearer YOUR_ACCESS_TOKEN`
</ParamField>

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

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.llmgenerator.com/api/v1/subscriptions/cancel', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
    }
  });

  const data = await response.json();
  if (data.success) {
    console.log('Subscription will end on:', data.cancellationDate);
  }
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://api.llmgenerator.com/api/v1/subscriptions/cancel',
      headers={'Authorization': 'Bearer YOUR_ACCESS_TOKEN'}
  )
  data = response.json()
  if data['success']:
      print(f"Subscription will end on: {data['cancellationDate']}")
  ```
</RequestExample>

<ResponseExample>
  ```json Erfolg theme={null}
  {
    "success": true,
    "message": "Subscription cancelled successfully",
    "cancellationDate": "2024-02-15T00:00:00Z"
  }
  ```

  ```json Kein aktives Abonnement theme={null}
  {
    "message": "No active subscription to cancel"
  }
  ```
</ResponseExample>

## Antwortfelder

<ResponseField name="success" type="boolean">
  Ob die Kündigung erfolgreich geplant wurde.
</ResponseField>

<ResponseField name="message" type="string">
  Für Menschen lesbare Statusmeldung.
</ResponseField>

<ResponseField name="cancellationDate" type="string">
  ISO-8601-Zeitpunkt des Abonnementendes (nur bei Erfolg).
</ResponseField>

## Fehlerantworten

<ResponseField name="400">
  Ungültige Anfrage – Kein aktives Abonnement oder Kündigung per API nicht möglich.
</ResponseField>

<ResponseField name="401">
  Nicht autorisiert – Ungültiges oder fehlendes Token.
</ResponseField>

## Verhalten bei der Kündigung

| Szenario                   | Verhalten                                 |
| -------------------------- | ----------------------------------------- |
| Aktives Abonnement         | Zur Kündigung zum Periodenende vorgemerkt |
| Bereits gekündigt          | Fehler                                    |
| Kein Abonnement            | Fehler                                    |
| Keine Stripe-Abonnement-ID | Fehler (Kündigung per API nicht möglich)  |

## Reaktivierung

Nutzer können:

1. Das Abrechnungsportal (`/subscriptions/portal`) nutzen
2. Nach Ende des aktuellen Abonnements ein neues abschließen

## Bewährte Praktiken

* **Bestätigungsdialog**: Vor der Kündigung immer bestätigen lassen
* **Grund erfassen**: Feedback einholen, warum gekündigt wird
* **Retention**: Rabatt oder Pausenoption erwägen
* **Klare Kommunikation**: Ende des Zugangs transparent angeben

***

## POST /subscriptions/cancel/api

Kündigt das Abonnement mit API-Schlüssel-Authentifizierung. Geeignet für Drittanbieter-Integrationen.

### Authentifizierung

API-Schlüssel erforderlich. Übergeben Sie ihn im Header `Authorization`:

```
Authorization: Bearer llmgen_your_api_key_here
```

### Antwort

Wie bei `/subscriptions/cancel` oben.

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

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.llmgenerator.com/api/v1/subscriptions/cancel/api', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer llmgen_your_api_key_here'
    }
  });

  const data = await response.json();
  if (data.success) {
    console.log('Subscription will end on:', data.cancellationDate);
  }
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://api.llmgenerator.com/api/v1/subscriptions/cancel/api',
      headers={'Authorization': 'Bearer llmgen_your_api_key_here'}
  )
  data = response.json()
  if data['success']:
      print(f"Subscription will end on: {data['cancellationDate']}")
  ```
</RequestExample>
