# Delete payment link

Source: <https://docs.gjold.com/v2/payment-links/delete>

Delete a payment link before it expires, so that it can no longer be paid: the payer sees the link as expired. Deleting is final.

## Request

**DELETE** `https://api.gjold.com/v2/{shopid}:pay:{payid}`

- `{payid}` is the link's `"id"`, from [Create payment link](https://docs.gjold.com/v2/payment-links/create#response), [Create subscriber](https://docs.gjold.com/v2/subscribers/create#response), or [Renew subscriber](https://docs.gjold.com/v2/subscribers/renew#response), whose links you delete the same way.

The request has no body. The key needs the `payid` [permission](https://docs.gjold.com/v2/authentication#permissions).

### Headers

- `Authorization`

  **Required.** Your API key, after `Basic` and base64-encoded. See [Authentication](https://docs.gjold.com/v2/authentication).

## Response

We answer `200 OK` with an empty object, `{}`, once the link can no longer be paid. Opening it then shows the payer that it has expired, and answers `404`, as a link that expired on its own does.

If the payer is paying the link at that moment, as while their bank asks them for 3-D Secure, the request waits for the bank's answer. If the bank authorizes the payment, the link was paid, and the request fails with `409 link is paid`; seq then returns the transaction, as for any paid link. Otherwise the link is deleted, and the payer sees it as expired.

## Errors

Besides the errors that any request can give, which [Errors](https://docs.gjold.com/v2/errors) lists:

| Status and message | Description |
|---|---|
| `404 link not found` | There is no such link: it expired, it was deleted already, it was paid more than 10 minutes ago, or the `{payid}` is wrong. A retry of a delete whose answer you lost gets this. So a `404` means that the link can't be paid, not that it never was: seq says whether it was. |
| `409 link is paid` | The payer has paid the link, or saved their card in a subscriber link. To undo it, [void](https://docs.gjold.com/v2/transactions/void) or [refund](https://docs.gjold.com/v2/transactions/refund) the transaction, or [delete](https://docs.gjold.com/v2/subscribers/delete) the subscriber. |

Delete is safe to send again: a link deleted by the first request is not found by the second.

## When to delete

Delete a link when paying it would be wrong: the payer paid another way, the order changed, or what it was for is gone. To change an order, delete its link, then create a new one. See [Orders and payment links](https://docs.gjold.com/notes/orders#a-link-that-must-not-be-paid).
