# Refund a transaction

API to refund payments of approved transaction or partial refund transaction with available balance to refund.

This endpoint automaticlly detects if void or refund operation is required.

### API Interface

## Refund approved transaction object

<mark style="color:green;">`POST`</mark> `https://api.sensepass.com/api/transactions/refund`

#### Request Body

<table><thead><tr><th width="284">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>transactionNumber<mark style="color:red;">*</mark></td><td>string</td><td>The Transaction Number To Be Refunded - Required</td></tr><tr><td>isPartial</td><td>boolean</td><td>true for partial refund transaction, requires "refundAmount" field for partial amount</td></tr><tr><td>refundAmount</td><td>number</td><td>The refund amount - for partial refund only, see "isPartial" flag</td></tr></tbody></table>

**Authentication Request Body fields**

[See here our Authentication page](/sensepay/transaction-api/authentication.md)

{% tabs %}
{% tab title="200: OK OK" %}
**errorCode = 0 indicating successful refund operation.**

**On error see "errorMessage" field which describes the error cause.**

```json
{
  "errorMessage": null,
  "errorCode": 0,
  "refundConfirmation": "063-LlgKAzfRL",
  "approvedBy": "PayPal",
  "refundBy": "PayPal",
  "dateApproval": "2019-12-19T09:47:59.105Z",
  "result": "Approved",
  "providerId": "z+n1opZ+RFn50fstklvWoOsovKIY5AUfsrVdGsO653c=",
  "transaction": {
    "TransactionNumber": "14a4334a32c852aeb0cfae52cbff1314649da7f175a8e140b35c147c",
    "date": "2019-12-19T09:47:59.105Z",
    "amount": 1234.56,
    "currency": "USD",
    "status": 0,
    "businessId": 144
  }
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid Input" %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="500: Internal Server Error Internal Error" %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

### Example of Successful Refund

```json
{
  "errorMessage": null,
  "errorCode": 0,
  "refundConfirmation": "063-LlgKAzfRL",
  "approvedBy": "PayPal",
  "refundBy": "PayPal",
  "dateApproval": "2019-12-19T09:47:59.105Z",
  "result": "Approved",
  "providerId": "z+n1opZ+RFn50fstklvWoOsovKIY5AUfsrVdGsO653c=",
  "transaction": {
    "TransactionNumber": "14a4334a32c852aeb0cfae52cbff1314649da7f175a8e140b35c147c",
    "date": "2019-12-19T09:47:59.105Z",
    "amount": 1234.56,
    "currency": "USD",
    "status": 0,
    "businessId": 144
  }
}
```

### Example of Unsuccessful Refund

```json
{
    "errorMessage": "refund operation declined by Processor",
    "errorCode": 22,
    "transaction": null,
    "refundConfirmation": null,
    "dateApproval": null,
    "result": "Declined",
    "providerId": null,
    "approvedBy": null,
    "refundBy": null,
    "amount": null
}
```

### Refund Request Examples

Basic request example to refund a new transaction using Device ID:

```json
{
  "transactionNumber": "14a4334a32c852aeb0cfae52cbff1314649da7f175a8e140b35c147c",
  "deviceId": "2ooeww5ufzg3nkuf8a10gu5n695yolixlbgb042o03to9bxfkr7t815i5epu8o58jv1rznif3o1tr6xsb1rm"
}
```

Basic request example to refund a new transaction using Location API Key or Merchant API key:

```json
{
  "transactionNumber": "14a4334a32c852aeb0cfae52cbff1314649da7f175a8e140b35c147c",
  "apiKey": "2ooeww5ufzg3nkuf8a10gu5n695yolixlbgb042o038o58jv1rznif3o1tr6xsb1rm"
}
```

### Flow Chart

[See our payment flow chart here](/sensepay/transaction-api/flow-charts/payment-flow.md)

### Transaction Status Flow

[See our transaction status flow here](/sensepay/transaction-api/flow-charts/transaction-status-flow.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sensepass.com/sensepay/transaction-api/payment-flows/refund-a-transaction.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
