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

# Terminate a subscription

> You can terminate a subscription at any time, whether it's active or pending.

## Terminate an active subscription

<Info>
  Subscriptions in the `incomplete` state are held by an [activation rule](/guide/subscriptions/activation-rules). They cancel on their own if the rule fails or its timeout is reached, and you can also [cancel them on demand](#cancel-an-incomplete-subscription).
</Info>

<Tabs>
  <Tab title="Dashboard">
    To terminate an active subscription through the user interface:

    1. Access the **"Customers"** section via the side menu;
    2. Select a customer from the list;
    3. In the **"Overview"** tab, select an active subscription; and
    4. Click **"Terminate subscription"**.
  </Tab>

  <Tab title="API">
    <CodeGroup>
      ```bash Terminate an active subscription theme={"dark"}
        LAGO_URL="https://api.getlago.com"
        API_KEY="__YOUR_API_KEY__"
        EXTERNAL_ID="__YOUR_SUBSCRIPTION_ID__"

        curl --location --request DELETE "$LAGO_URL/api/v1/subscriptions/$EXTERNAL_ID" \
          --header "Authorization: Bearer $API_KEY"

      ```
    </CodeGroup>
  </Tab>
</Tabs>

### Generate a closing invoice at subscription termination

By default, Lago automatically generates a closing invoice for any **outstanding usage-based charges** or **pay-in-arrears subscription fees** that haven’t yet been invoiced.
If you don’t want to generate an invoice at termination:

<Tabs>
  <Tab title="Dashboard">
    In the Termination dialog, simply switch off the **Generate final invoice** option.
  </Tab>

  <Tab title="API">
    <CodeGroup>
      ```bash Terminate a subscription without closing invoice theme={"dark"}
        LAGO_URL="https://api.getlago.com"
        API_KEY="__YOUR_API_KEY__"
        EXTERNAL_ID="__YOUR_SUBSCRIPTION_ID__"

        curl --location --request DELETE "$LAGO_URL/api/v1/subscriptions/$EXTERNAL_ID?on_termination_invoice=skip" \
          --header "Authorization: Bearer $API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

### Generate a closing credit note at subscription termination

If the subscription fee has been **paid in advance**, Lago automatically issues a credit note for the **unused days**.
At termination, you can :

<Tabs>
  <Tab title="Dashboard">
    In the Termination dialog, you can choose how to handle unused amounts:

    * **Skip** – Don’t generate a credit note.
    * **Offset** — The unused due amount is offset against the invoice, reducing the remaining amount due.
    * **Refund** – If the invoice is paid or partially paid, the unused paid amount is refunded; any unpaid unused amount is credited back to the customer.
    * **Credit** (default) – The unused amount is credited back to the customer.

    <Frame caption="Termination options">
      <img src="https://mintcdn.com/lago/Qjm2ad-IYGtRgG7r/guide/subscriptions/images/terminate-subscription-options.png?fit=max&auto=format&n=Qjm2ad-IYGtRgG7r&q=85&s=1c18ad5e6b5cae8765e1b522d558a6cc" alt="" width="3456" height="2161" data-path="guide/subscriptions/images/terminate-subscription-options.png" />
    </Frame>
  </Tab>

  <Tab title="API">
    <CodeGroup>
      ```bash Terminate a subscription without closing credit note theme={"dark"}
        LAGO_URL="https://api.getlago.com"
        API_KEY="__YOUR_API_KEY__"
        EXTERNAL_ID="__YOUR_SUBSCRIPTION_ID__"

        curl --location --request DELETE "$LAGO_URL/api/v1/subscriptions/$EXTERNAL_ID?on_termination_credit_note=skip" \
          --header "Authorization: Bearer $API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## Terminate a pending subscription

<Tabs>
  <Tab title="Dashboard">
    To terminate a pending subscription through the user interface:

    1. Access the **"Customers"** section via the side menu;
    2. Select a customer from the list;
    3. In the **"Overview"** tab, select a pending subscription (subscription set in the future or pending downgrade); and
    4. Click **"Terminate subscription"** to cancel a pending subscription.
  </Tab>

  <Tab title="API">
    <CodeGroup>
      ```bash Terminate a pending subscription theme={"dark"}
          LAGO_URL="https://api.getlago.com"
          API_KEY="__YOUR_API_KEY__"
          EXTERNAL_ID="__YOUR_SUBSCRIPTION_ID__"

          curl --location --request DELETE "$LAGO_URL/api/v1/subscriptions/$EXTERNAL_ID?status=pending" \
            --header "Authorization: Bearer $API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

<Warning>
  To ensure the termination of a pending subscription, it is crucial to include the `?status=pending` filter in your endpoint.
  Neglecting to do so will render any termination attempts ineffective.
</Warning>

## Cancel an incomplete subscription

A subscription held `incomplete` by a payment [activation rule](/guide/subscriptions/activation-rules) (waiting for its first payment) can be canceled on demand, instead of waiting for the rule's timeout. This is useful when the payment clearly won't complete, for example when the customer abandons a 3D Secure challenge and you want to let them start over.

<Tabs>
  <Tab title="Dashboard">
    To cancel an incomplete subscription through the user interface:

    1. Access the **"Customers"** section via the side menu;
    2. Select a customer from the list;
    3. In the **"Overview"** tab, select the incomplete subscription; and
    4. Click **"Cancel subscription"**.
  </Tab>

  <Tab title="API">
    <CodeGroup>
      ```bash Cancel an incomplete subscription theme={"dark"}
        LAGO_URL="https://api.getlago.com"
        API_KEY="__YOUR_API_KEY__"
        EXTERNAL_ID="__YOUR_SUBSCRIPTION_ID__"

        curl --location --request DELETE "$LAGO_URL/api/v1/subscriptions/$EXTERNAL_ID?status=incomplete" \
          --header "Authorization: Bearer $API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

The subscription becomes `canceled` with `cancellation_reason: manual`. Its draft invoice is closed (nothing is billed), and any applied coupons, credit notes and wallet credits are recredited. Any pending payment is canceled with the payment provider on a best-effort basis — some payment statuses can't be canceled, so a payment may still succeed later as a late payment. Termination options (`on_termination_credit_note`, `on_termination_invoice`) are ignored, since an incomplete subscription has never been billed.

<Warning>
  Include the `?status=incomplete` filter. Without it the endpoint targets the `active` subscription for that `external_id` and returns a not-found error for an incomplete one.
</Warning>
