> Index of every page: https://docs.merchantservicedepot.com/llms.txt

# Cancel subscription


`POST /v1/subscriptions/{subscription_id}/cancel`

Cancels immediately.

Auth: a secret key with the `subscriptions.cancel` permission. Returns `200` with Subscription.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `subscriptionId` | path | string | Yes | The subscription id in the request path. |

## Request

**curl**

```curl
curl -X POST "https://payments-api-sandbox.merchantservicedepot.com/v1/subscriptions/{subscription_id}/cancel" \
  -H "Authorization: Bearer $MYELA_API_KEY"
```

**Node**

```node
const res = await fetch("https://payments-api-sandbox.merchantservicedepot.com/v1/subscriptions/{subscription_id}/cancel", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MYELA_API_KEY}`,
  },
});

if (!res.ok) {
  const { error } = await res.json();
  // Branch on error.code — never on error.message.
  throw new Error(error.code);
}
const data = await res.json();
```

**Python**

```python
import os
import requests

res = requests.post(
    "https://payments-api-sandbox.merchantservicedepot.com/v1/subscriptions/{subscription_id}/cancel",
    headers={
        "Authorization": f"Bearer {os.environ['MYELA_API_KEY']}",
    },
)

if not res.ok:
    # Branch on error["code"] — never on error["message"].
    raise RuntimeError(res.json()["error"]["code"])
data = res.json()
```

## Response

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Unique subscription identifier. |
| `object` | "subscription" | Stable resource discriminator. |
| `status` | string | Current subscription state. |
| `customerId` | string | Subscribed customer. |
| `planId` | string | Subscribed plan. |
| `paymentMethodId` | string | Stored payment method. |
| `nextBillingAt` | string | Next scheduled billing timestamp. |
| `createdAt` | string | ISO 8601 creation timestamp. |

```json
{
  "id": "sub_01JEXAMPLE",
  "object": "subscription",
  "status": "active",
  "customerId": "cus_01JEXAMPLE",
  "planId": "plan_01JEXAMPLE",
  "paymentMethodId": "pm_01JEXAMPLE",
  "nextBillingAt": "2026-09-01T13:00:00.000Z",
  "createdAt": "2026-08-10T20:49:51.653Z"
}
```

Source: https://docs.merchantservicedepot.com/api-reference/cancel-subscription/
