> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.partnerpage.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.partnerpage.io/_mcp/server.

# Refund a sale

POST https://v1.api.partnerpage.io/api/deal-registration/private/v1alpha/tracking/refund/
Content-Type: application/json

Called by your server when a sale you reported is refunded. `amount` is the **total** refunded on the invoice so far, in the sale's minor unit; leave it out for the whole sale. A retry of the same total adds nothing and a higher total adds the difference. `taxAmount` is the total tax refunded so far; it is required for a partial refund of a sale with tax, and kept on the refund for your records only: the commission is reduced by the refunded share of the sale (`amount` over the sale's amount), whatever the tax split. An unpaid commission is reduced pro rata; a paid one becomes a recovery for you to review. Every call is real: try it on a test directory.

```bash
curl -X POST https://v1.api.partnerpage.io/api/deal-registration/private/v1alpha/tracking/refund/ \
  -H "Authorization: Token $PARTNERPAGE_API_KEY" -H "Content-Type: application/json" \
  -d '{"trackingId":"pp_trk_…","invoiceId":"inv_123","amount":5000}'
```

Reference: https://docs.partnerpage.io/api-reference/partner-tracking/refund-a-sale

## Authentication

- `Authorization` header (required) (prefixed with ` Token   `) — Your API key, sent as `Authorization: Token <your API key>`

## Request

### Body (application/json)

This endpoint expects a TrackingRefundRequest.

- `trackingId` (string, required) — The directory's Tracking ID, from Settings › Partner links (pp_trk_...).
- `invoiceId` (string, required) — The invoice ID of the sale.
- `amount` (long, optional, nullable) — The total refunded on the invoice so far, in the sale's minor unit; left out for the whole sale.
- `taxAmount` (long, optional, nullable) — The total tax refunded on the invoice so far, in the same unit. Required for a partial refund of a sale with tax; kept for your records, as the commission is reduced by the refunded share of the sale's amount whatever the tax split.

## Response

### 200

Refund recorded, or nothing new when the total was already recorded (`refundId` null)

- `saleId` (string, required)
- `invoiceId` (string, required)
- `refundedAmount` (integer, required)
- `refundId` (string, required, nullable)

## Errors

### 400 Bad Request Error

A field is missing or malformed, the body is not a JSON object, the total is more than the sale or not a multiple of 10 for a three-decimal currency, or the refunded tax is missing for a partial refund of a taxed sale, below what was already refunded, above the sale's tax or above the total refunded

- `any`

### 401 Unauthorized Error

The API key is missing or invalid; a dashboard login is refused

- `any`

### 403 Forbidden Error

The Tracking ID is another organisation's, the key lacks the decide permission on Partner leads, or Partner leads are off

- `any`

### 404 Not Found Error

No directory has this Tracking ID (`{"code": "unknown_tracking_id"}`), or no sale you reported carries this invoice ID (`{"code": "unknown_invoice"}`)

- `any`

### 409 Conflict Error

More than this total was already refunded (`refund_below_recorded`), or a payout to the partner is being sent (`payout_sending`); nothing was recorded

- `any`

### 429 Too Many Requests Error

Rate limit exceeded: up to 1,000 requests an hour per API key to each of the lead, sale and refund calls

- `any`

## Examples

**Request**

```json
{
  "trackingId": "pp_trk_4fQ9xZ2mK7pL1sV8nB3cR6tY",
  "invoiceId": "inv_123",
  "amount": 5000
}
```

**SDK Code**

```python Example request (application/json)
import requests

url = "https://v1.api.partnerpage.io/api/deal-registration/private/v1alpha/tracking/refund/"

payload = {
    "trackingId": "pp_trk_4fQ9xZ2mK7pL1sV8nB3cR6tY",
    "invoiceId": "inv_123",
    "amount": 5000
}
headers = {
    "Authorization": "Token  <apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Example request (application/json)
const url = 'https://v1.api.partnerpage.io/api/deal-registration/private/v1alpha/tracking/refund/';
const options = {
  method: 'POST',
  headers: {Authorization: 'Token  <apiKey>', 'Content-Type': 'application/json'},
  body: '{"trackingId":"pp_trk_4fQ9xZ2mK7pL1sV8nB3cR6tY","invoiceId":"inv_123","amount":5000}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```