> ## Documentation Index
> Fetch the complete documentation index at: https://apidocs.synchpay.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Canceling a Payment Request

> Cancel an outstanding payment request before it is paid.

## Overview

If a payment request no longer needs to be collected, you can cancel it through the `/Payment/{paymentRequestId}/Cancel` endpoint. Canceling a request stops the payer from completing that payment and moves the payment request to the `Canceled` status.

Use this endpoint for payment requests that are still outstanding, such as requests that are pending payer action, scheduled for a future date, or otherwise not yet completed.

## How It Works

<Steps>
  <Step title="Obtain an Access Token">
    Before calling the cancel endpoint, secure an access token by making a `POST` request to `/auth/token` using your `ClientId` and `ClientSecret`.
  </Step>

  <Step title="Identify the Payment Request">
    Use the `PaymentRequestId` returned when the payment request was created, or the ID received in a payment status webhook.
  </Step>

  <Step title="Submit the Cancellation">
    Send a `PUT` request to `/Payment/{paymentRequestId}/Cancel` with the payment request ID in the path.
  </Step>

  <Step title="Track the Updated Status">
    After cancellation, the payment request status becomes `Canceled`. You can use payment status webhooks to keep your system in sync.
  </Step>
</Steps>

## Canceling the Payment Request

The `/Payment/{paymentRequestId}/Cancel` endpoint cancels an existing payment request by referencing its `PaymentRequestId`.

### Endpoint

* **URL**: `https://api.synchpay.com/Payment/{paymentRequestId}/Cancel`
* **Method**: `PUT`
* **Authorization**: `Bearer <AccessToken>`

### Path Parameters

| Parameter          | Type   | Description                                        | Required |
| ------------------ | ------ | -------------------------------------------------- | -------- |
| `paymentRequestId` | string | Unique identifier of the payment request to cancel | Yes      |

### Request Body

This endpoint does not require a request body.

### Example Request

```http theme={null}
PUT /Payment/ce0e3549-a83e-4cf6-bb5c-1d50a21d8af7/Cancel HTTP/1.1
Host: api.synchpay.com
Authorization: Bearer eyJhbGciOi...
```

### Response

A successful request returns `200 OK` with no response body.

### Error Responses

| Status code | Cause                                                           |
| ----------- | --------------------------------------------------------------- |
| `400`       | The payment request cannot be canceled from its current status. |
| `401`       | Missing or invalid access token.                                |
| `404`       | The payment request was not found.                              |

## When to Use This Endpoint

Use the cancel endpoint when you want to:

* Stop an unpaid payment request before the payer completes it.
* Cancel a scheduled payment request before it is processed.
* Prevent a duplicate or incorrect request from being paid.

## Payment Status

After a successful cancellation, the payment request moves to `Canceled`, which is a final state. See [payment statuses](/synchpay/make-payment#payment-statuses) for the full status transition table.
