# Subscription Cancellation Endpoint

## Overview

The Subscription Cancellation API allows merchants to terminate an active subscription before its scheduled end date. Once cancelled, no further charges will be processed for that subscription.

## Endpoint

<mark style="color:red;background-color:red;">**DELETE**</mark> `https://api-stg.onekeypayments.com/v3/subscriptions/`**`{subscription_id}`**

Where `{subscription_id}` is the unique numeric identifier of the subscription you wish to cancel.

{% openapi src="<https://1595349702-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7aIgg5dys0yN8otrASQq%2Fuploads%2FtjURgHfp9kR0tlIYvOR5%2Fokpsubs-delete-v3.yml?alt=media&token=0c04b4f7-7f40-4b58-8ab1-052caca84e59>" path="/v3/subscriptions/{subscription\_id}" method="delete" %}
[okpsubs-delete-v3.yml](https://1595349702-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7aIgg5dys0yN8otrASQq%2Fuploads%2FtjURgHfp9kR0tlIYvOR5%2Fokpsubs-delete-v3.yml?alt=media\&token=0c04b4f7-7f40-4b58-8ab1-052caca84e59)
{% endopenapi %}

### Request Parameters

This endpoint uses only a path parameter to identify the subscription:

<table><thead><tr><th width="168">Parameter</th><th width="123">Type</th><th width="127">Required</th><th>Description</th></tr></thead><tbody><tr><td>id</td><td>integer</td><td>Yes</td><td>Unique numeric identifier of the subscription to cancel.</td></tr></tbody></table>

### Request Body

The request body should be empty for this endpoint.

```
{}
```

### Response

#### Success Response

A successful cancellation returns an **HTTP 200** status code :white\_check\_mark:.

### Error Responses

The API may return the following errors:

#### &#x20;  **Subscription Already Cancelled (421)**

Returned when attempting to cancel a subscription that has already been cancelled:

```json
{
  "code": 421,
  "description": "Subscription was already cancelled.",
  "type": "SUBSCRIPTION_ALREADY_CANCELLED"
}
```

#### &#x20;  **Subscription Not Found (420)**

Returned when the specified subscription ID does not exist:

```json
{
  "code": 420,
  "description": "Subscription does not exist.",
  "type": "SUBSCRIPTION_NOT_FOUND"
}
```

#### &#x20;  **Subscription Terminated (426)**

Returned when attempting to cancel a subscription that has already been terminated (completed its lifecycle):

```json
{
  "code": 426,
  "description": "Subscription is terminated and cannot be cancelled.",
  "type": "SUBSCRIPTION_IS_TERMINATED"
}
```

#### &#x20;  **Generic Error (501)**

Returned when an unexpected error occurs:

```json
{
  "code": 501,
  "description": "Generic Error",
  "type": "GENERIC_ERROR"
}
```

### Cancellation Effects

When a subscription is cancelled:

1. The subscription status is immediately changed to `CANCELLED`
2. All scheduled future charges are removed
3. The cancellation is recorded in the subscription history

### Important Notes

1. **Cancellation vs. Refund**: Cancelling a subscription only prevents future charges. It does not refund any previous charges. To process refunds for previous transactions, use the separate Refund API.
2. **Reactivation**: Once a subscription is cancelled, it cannot be reactivated. A new subscription must be created if the customer wishes to resume the service.
3. **Timing**: Cancellation takes effect immediately, regardless of the subscription's billing cycle.
