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

# Cancel payment link


`POST /v1/payment_links/{payment_link_id}/cancel`

Stops the link accepting payment. Terminal — mint a new link rather than reopening this one. Cancelling a link that has already been paid is refused with `409` `PAYMENT_LINK_ALREADY_PAID`, and so is one whose earlier payment has since gone through (the link is marked paid). While a payment on the link is in progress the answer is `409` `CONCURRENT_MODIFICATION`: retry shortly. While one is still being confirmed (`pendingConfirmation` is present), or came back authorized but never captured, it is `409` `PAYMENT_PENDING_CONFIRMATION`: cancel once that payment is resolved.

Auth: a secret key with the `paymentLinks.cancel` permission. Returns `200` with Payment link.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `paymentLinkId` | path | string | Yes | The payment link id in the request path. |

## Request

**curl**

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

**Node**

```node
const res = await fetch("https://payments-api-sandbox.merchantservicedepot.com/v1/payment_links/{payment_link_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/payment_links/{payment_link_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 payment link identifier. |
| `object` | "payment_link" | Stable resource discriminator. |
| `status` | string | One of active, paid or cancelled. There is no expired status — expiry is decided by comparing expiresAt when the page is opened. |
| `amount` | integer | Amount to collect, in minor units. |
| `currency` | string | Three-letter ISO currency code. |
| `url` | string | The page to send the payer to. Hosted on a Myela domain — never a provider's. |
| `description` | string | What the payer is paying for. Shown on the page. |
| `expiresAt` | string | When the link stops accepting payment. Always present. |
| `paidAt` | string | When the link was paid. Present once it has been. |
| `paymentId` | string | The payment that settled this link. |
| `pendingConfirmation` | object | Present only while a charge on this link is unresolved. The link still reports active; every further attempt is refused, and so is cancelling it (409, `details.code` `PAYMENT_PENDING_CONFIRMATION`), until the named payment is reconciled, and still afterwards if it resolved as authorized but never captured. |
| `createdAt` | string | When the link was created. |

```json
{
  "id": "plink_01JEXAMPLE",
  "object": "payment_link",
  "status": "active",
  "amount": 2500,
  "currency": "USD",
  "url": "https://example.com/pay/9Yb3xK1t0QWEs7vLzR2mNc4h",
  "description": "Deposit",
  "expiresAt": "2026-12-01T00:00:00.000Z",
  "paidAt": "2026-09-14T18:04:11.000Z",
  "paymentId": "pay_01JEXAMPLE",
  "pendingConfirmation": {
    "paymentId": "pay_01JEXAMPLE",
    "since": "2026-09-14T18:04:11.000Z"
  },
  "createdAt": "2026-09-01T12:00:00.000Z"
}
```

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