> ## 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.

# Issuing a Payment Refund

> Learn how to initiate a refund for a previously completed payment using the SynchPay API.

## Overview

If a payment was previously completed using SynchPay, you can issue a partial or full refund using the `/payment/refund` endpoint. This enables you to return funds to the consumer in cases such as cancellations, overcharges, or customer service resolutions.

## How It Works

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

  <Step title="Identify the Payment">
    Make sure you have the `PaymentRequestId` of the transaction you want to
    refund. This ID was returned during the original payment request and is also
    included in the payment confirmation webhook.
  </Step>

  <Step title="Submit a Refund Request">
    With the access token and payment ID in hand, make a `POST` request to the
    `/payment/refund` endpoint. You can specify the amount to be refunded,
    an optional description, and a PDF attachment to provide documentation.
  </Step>

  <Step title="Receive Refund Confirmation">
    If the refund is accepted, the API responds with a `HTTP 200`.
  </Step>
</Steps>

## Issuing a Refund

The `/payment/refund` endpoint allows you to refund all or part of a previously completed payment by referencing its `PaymentRequestId`.

### Endpoint

* **URL**: `https://api.synchpay.com/payment/refund?paymentRequestId=<GUID>`
* **Method**: `POST`
* **Authorization**: `Bearer <AccessToken>`\
  *Note*: Obtain the access token from `/auth/token` using your `ClientId` and `ClientSecret`.

### Query Parameter

| Parameter          | Type   | Description                                                     | Required |
| ------------------ | ------ | --------------------------------------------------------------- | -------- |
| `paymentRequestId` | string | The unique identifier of the original payment request to refund | Yes      |

### Request Body

The JSON payload sent to the endpoint must include:

| Parameter     | Type   | Description                                                                                 | Required |
| ------------- | ------ | ------------------------------------------------------------------------------------------- | -------- |
| `Amount`      | int    | The refund amount in cents. For example, \$20.00 should be submitted as `2000`.             | Yes      |
| `Description` | string | (Optional) Reason for the refund. This will appear in consumer communications if supported. | No       |
| `Attachment`  | object | (Optional) PDF file with additional refund documentation.                                   | No       |

#### Attachment Object

If included, the `Attachment` object must contain:

| Field      | Type   | Description                             | Required |
| ---------- | ------ | --------------------------------------- | -------- |
| `FileName` | string | Name of the PDF file (e.g. `note.pdf`)  | Yes      |
| `FileData` | string | Base64-encoded PDF file content         | Yes      |
| `FileType` | string | MIME type (must be `"application/pdf"`) | Yes      |

### Example Request

```json theme={null}
{
  "Amount": 2000,
  "Description": "Customer cancelled the service.",
  "Attachment": {
    "FileName": "refund_note.pdf",
    "FileData": "JVBERi0xLjQKJc...",
    "FileType": "application/pdf"
  }
}
```
