# Cancellations

Customers cannot directly cancel a subscription but they must request the cancellation to the vendor. When the cancellation request is received by the vendor, he will perform one last billing to account for the remaining unpaid period and the subscription will be immediately cancelled. A subscription can be terminated (forcefully cancelled) anytime by plan’s admin or operational accounts, using the web app or the 8Pay Javascript library.

## Get cancellations of a plan

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/plans/:planId/cancellations`

#### Path Parameters

| Name  | Type   | Description                                                   |
| ----- | ------ | ------------------------------------------------------------- |
| id    | string | ID of the plan                                                |
| chain | string | [chain identifier](https://docs.8pay.network/overview#chains) |

#### Query Parameters

| Name        | Type   | Description                                           |
| ----------- | ------ | ----------------------------------------------------- |
| triggeredBy | string | filter by the user who triggered the billing          |
| from        | number | filter by `timestamp` (default 0)                     |
| to          | number | filter by `timestamp` (default current timestamp)     |
| sort        | string | `asc` or `desc` based on `timestamp` (default `desc`) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

{% tabs %}
{% tab title="200 " %}

```
{
    "data": [
        {
            "subscriptionId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "timestamp": 1571686335,
            "forced": false,
            "triggeredBy": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "transactionHash": "0x9ed2fdc68aa1253d206b954ea065a38a6332bd1732d0992e9bcb7056e720e381",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get cancellation for a subscription

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/subscriptions/:subscriptionId/cancellation`

#### Path Parameters

| Name  | Type   | Description                                                   |
| ----- | ------ | ------------------------------------------------------------- |
| id    | string | ID of the subscription                                        |
| chain | string | [chain identifier](https://docs.8pay.network/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

{% tabs %}
{% tab title="200 " %}

```
{
    "subscriptionId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
    "timestamp": 1571646052,
    "forced": false,
    "triggeredBy": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
    "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
    "transactionStatus": "confirmed"
}
```

{% endtab %}
{% endtabs %}
