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

# Terminate a Subscription (Subnet / Service)

> End-to-end flow for terminating an active subscription (IPv4 subnet or other service) using the IPXO API.

# Terminate a Subscription (Subnet / Service)

This guide explains how to ***terminate an active subscription*** (for example, an IPv4 subnet lease) using the IPXO API.

A termination can be:

* **End of period** – service remains active until the current billing period ends
* **Immediate** – service is terminated right away (irreversible)

***

## Prerequisites

Before starting this flow, you need:

* A valid ***access token*** (`{access_token}`)
* Your ***tenant UUI*** (`{tenant_uuid}`)
* At least one ***active subscription***

***

## Flow overview

At a high level, terminating a subscription consists of:

1. Listing active subscriptions
2. Selecting a subscription to terminate
3. Creating a termination request
4. (Optional) Cancelling a pending termination

***

## 1) List active subscriptions

> [Try it](/api-reference/subscription/search-subscriptions)

Start by retrieving all active subscriptions for the tenant.

```bash theme={null}
curl 'https://apigw.ipxo.com/ecommerce/public/{tenant_uuid}/subscriptions/search' \
-X POST \
-H 'Authorization: Bearer {access_token}' \
-H 'Content-Type: application/json' \
--data-raw '{
    "filter": {
      "status": "active"
    },
    "per_page": "100"
  }'
```

### What this does

* Returns all ***currently active subscriptions***
* Each subscription represents a recurring service (e.g. subnet lease)

### What to save from the response

From the selected subscription:

* `uuid` → `{subscription_uuid}`

***

## 2) Terminate a subscription

> [Try it](/api-reference/subscription/terminate-subscription)

Create a termination request for the selected subscription.

```bash theme={null}
curl 'https://apigw.ipxo.com/ecommerce/public/{tenant_uuid}/subscriptions/{subscription_uuid}/terminate'   -X POST   -H 'Authorization: Bearer {access_token}' \
-H 'Content-Type: application/json' \
--data-raw '{
    "type": "end_of_period",
    "reason": "Pricing",
    "details": "Cancellation reason detailed explanation",
    "meta": {
      "use_again": false
    }
  }'
```

***

## Termination types

| Type            | Behavior                                                 |
| --------------- | -------------------------------------------------------- |
| `end_of_period` | Service remains active until current billing period ends |
| `immediate`     | Service is terminated immediately (cannot be undone)     |

> ⚠️ **Important:** Immediate terminations are irreversible.\
> End-of-period terminations can be cancelled before the period ends.

***

## Termination reason

There are more termination reasons available.\
For this API example, only one is provided (`Pricing`).

***

### What this does

* Creates a termination request
* Marks the subscription for termination
* Does ***not*** immediately delete the service (unless `immediate`)

### What to save from the response

* `uuid` → `{subscription_termination_uuid}`

***

## 3) (Optional) List termination requests

If you need to:

* Verify termination status
* Retrieve the termination UUID
* Check whether a termination can be cancelled

> [Try it](/api-reference/subscription/list-customer-termination-requests)

List pending termination requests for the subscription.

```bash theme={null}
curl 'https://apigw.ipxo.com/ecommerce/public/{tenant_uuid}/subscriptions/termination-requests?filter[status]=pending&filter[subscription_id]={subscription_uuid}' \
-X GET \
-H 'Authorization: Bearer {access_token}'
```

### When this is useful

* You didn’t store the termination UUID
* You want to check if termination is still pending
* You want to allow the user to undo termination

***

## 4) (Optional) Cancel a pending termination

> [Try it](/api-reference/subscription/cancel-termination-request)

If the termination type was `end_of_period`, it can be cancelled ***before it is executed***.

```bash theme={null}
curl 'https://apigw.ipxo.com/ecommerce/public/{tenant_uuid}/subscriptions/termination-requests/{subscription_termination_uuid}/cancel' \
-X POST \
-H 'Authorization: Bearer {access_token}' \
-H 'Content-Type: application/json' \
--data-raw '{}'
```

### What this does

* Cancels a pending termination request
* Keeps the subscription active
* Restores normal recurring billing

***

## Subscription lifecycle summary

```bash theme={null}
active
  │── terminate (end_of_period)
  │     │── pending
  │     │     `── cancel → active
  │     `── executed → terminated
  `── terminate (immediate)
        `── terminated (irreversible)
```

***

## Variables created in this flow

| Variable                          | Source                 | Purpose                       |
| --------------------------------- | ---------------------- | ----------------------------- |
| `{subscription_uuid}`             | List subscriptions     | Identify service to terminate |
| `{subscription_termination_uuid}` | Terminate subscription | Track / cancel termination    |
