Returns & Reversals API
The Returns module handles customer product returns (Sales Returns) and vendor product reversals (Purchase Returns).
Every return processed through the Tracepos API triggers an automated reconciliation cycle:
- Restocks or Deducts Inventory: Adjusts physical warehouse on-hand levels.
- Updates Party Ledgers: Reduces customer debt (A/R) or supplier liability (A/P).
- Posts Balanced Accounting Reversals: Posts contra-revenue or contra-expense entries to the general ledger.
1. Sales Returns (Customer Refunds & Restock)
Process merchandise returned by a retail or wholesale customer.
List Sales Returns
GET
/api/v1/public/sales-returnsResponse (200 OK)
{
"status": "success",
"data": {
"current_page": 1,
"data": [
{
"id": 25,
"unique_id": "ord_sret_89410ef",
"invoice_number": "SRET-00012",
"order_type": "sales-returns",
"order_date": "2026-09-29",
"total": "2750.00",
"due_amount": "2750.00",
"notes": "Wrong size purchased by customer",
"user": {
"id": 105,
"name": "Adeola Adeleke"
}
}
],
"total": 6
}
}
Record Sales Return
Record items returned by a customer. This automatically increments physical warehouse stock and updates customer debt.
POST
/api/v1/public/sales-returnsRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
user_id | Integer / String | Yes | Customer ID (e.g. 105) |
order_date | Date (YYYY-MM-DD) | Yes | Return transaction date |
items | Array | Yes | Returned items array (minimum 1 item) |
items[].product_id | Integer / String | Yes | Product ID or hash ID |
items[].quantity | Numeric | Yes | Quantity returned (min: 0.01) |
items[].unit_price | Numeric | Yes | Refund price per unit |
notes | String | No | Reason for return |
invoice_number | String | No | Original sale invoice reference (e.g. SAL-00451) |
Code Examples
:::: code-group ::: code-group-item cURL
curl -X POST "https://api.tracepos.com/api/v1/public/sales-returns" \
-H "X-Tracepos-Public-Key: tp_pub_live_7f8a9c2d1e" \
-H "X-Tracepos-Secret-Key: tp_sec_live_9b3e1f7a4c" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"user_id": 105,
"order_date": "2026-09-30",
"invoice_number": "SAL-00451",
"notes": "Customer returned unopened carton",
"items": [
{
"product_id": 45,
"quantity": 1,
"unit_price": 2750.00
}
]
}'
::: ::: code-group-item Node.js (Axios)
const axios = require('axios');
async function processSalesReturn(returnData) {
const response = await axios.post(
'https://api.tracepos.com/api/v1/public/sales-returns',
returnData,
{
headers: {
'X-Tracepos-Public-Key': process.env.TRACEPOS_PUBLIC_KEY,
'X-Tracepos-Secret-Key': process.env.TRACEPOS_SECRET_KEY,
'Content-Type': 'application/json',
'Accept': 'application/json'
}
}
);
return response.data;
}
::: ::: code-group-item Python (Requests)
import os
import requests
headers = {
"X-Tracepos-Public-Key": os.getenv("TRACEPOS_PUBLIC_KEY"),
"X-Tracepos-Secret-Key": os.getenv("TRACEPOS_SECRET_KEY"),
"Content-Type": "application/json",
"Accept": "application/json"
}
payload = {
"user_id": 105,
"order_date": "2026-09-30",
"invoice_number": "SAL-00451",
"items": [
{"product_id": 45, "quantity": 1, "unit_price": 2750.00}
]
}
response = requests.post(
"https://api.tracepos.com/api/v1/public/sales-returns",
json=payload,
headers=headers
)
result = response.json()
::: ::: code-group-item PHP (Guzzle)
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://api.tracepos.com/api/v1/public/']);
$response = $client->post('sales-returns', [
'headers' => [
'X-Tracepos-Public-Key' => getenv('TRACEPOS_PUBLIC_KEY'),
'X-Tracepos-Secret-Key' => getenv('TRACEPOS_SECRET_KEY'),
'Content-Type' => 'application/json',
'Accept' => 'application/json'
],
'json' => [
'user_id' => 105,
'order_date' => '2026-09-30',
'invoice_number' => 'SAL-00451',
'items' => [
['product_id' => 45, 'quantity' => 1, 'unit_price' => 2750.00]
]
]
]);
$result = json_decode($response->getBody()->getContents(), true);
::: ::::
Response (200 OK)
{
"status": "success",
"return_id": 26,
"invoice_number": "SRET-00013"
}
2. Purchase Returns (Supplier Stock Return)
Return substandard, damaged, or excess inventory back to a vendor. This decrements warehouse stock and credits your accounts payable ledger.
POST
/api/v1/public/purchase-returnsRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
user_id | Integer / String | Yes | Supplier ID (e.g. 201) |
order_date | Date (YYYY-MM-DD) | Yes | Return dispatch date |
items | Array | Yes | Returned stock array |
items[].product_id | Integer / String | Yes | Product ID |
items[].quantity | Numeric | Yes | Quantity returned to supplier |
items[].unit_price | Numeric | Yes | Credit cost price agreed with vendor |
Request Payload
{
"user_id": 201,
"order_date": "2026-09-30",
"items": [
{
"product_id": 12,
"quantity": 10,
"unit_price": 2500.00
}
]
}
Response (200 OK)
{
"status": "success",
"return_id": 18,
"invoice_number": "PRET-00008"
}
Return Ledger Rules
- Sales Return Accounting:
- Debit:
41200Sales Returns (Contra-Revenue) - Credit:
11500Accounts Receivable (or Cash drawer if immediately refunded) - Inventory Restock: Stock is incremented in
product_detailsfor the receiving warehouse.
- Debit:
- Purchase Return Accounting:
- Debit:
21100Accounts Payable (reducing supplier debt) - Credit:
11700Inventory Asset (or51200Purchase Returns) - Stock Reduction: Stock is decremented in
product_detailsfor the dispatching warehouse.
- Debit:
