API ReferenceWithdraws
List Withdraws
Returns a paginated list of withdraws. Withdraws are returned sorted by creation date (most recent first) by default.
Endpoint
GET /api/v1/withdraws
Authentication
This endpoint requires HMAC Integration Authentication.
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
page | number | No | Page number (default: 1, minimum: 1) |
limit | number | No | Number of withdraws per page (default: 10, minimum: 1, maximum: 100) |
status | string | No | Filter by withdraw status (see status values below) |
destinationType | string | No | Filter by destination type: "bank_account" or "wallet" |
dateFrom | string | No | Filter withdraws created after this date (ISO 8601 format) |
dateTo | string | No | Filter withdraws created before this date (ISO 8601 format) |
sortBy | string | No | Sort field: "amount", "status", "createdAt", "paidAt", "referenceId" |
sortOrder | string | No | Sort order: "asc" or "desc" (default: "desc") |
Status Filter Values
pendingprocessingpaidfailedcanceled
Example Request
import crypto from 'crypto';
const API_KEY = process.env.PAYMENT_API_KEY!;
const API_SECRET = process.env.PAYMENT_API_SECRET!;
async function listWithdraws(page = 1, limit = 10, filters = {}) {
const queryParams = new URLSearchParams({
page: page.toString(),
limit: limit.toString(),
...(filters.status && { status: filters.status }),
...(filters.destinationType && { destinationType: filters.destinationType }),
...(filters.sortBy && { sortBy: filters.sortBy }),
...(filters.sortOrder && { sortOrder: filters.sortOrder }),
});
const method = 'GET';
const path = `/api/v1/withdraws?${queryParams.toString()}`;
const body = '';
const timestamp = Date.now().toString();
const message = `${timestamp}.${body}`;
const signature = crypto
.createHmac('sha256', API_SECRET)
.update(message)
.digest('hex');
const response = await fetch(`https://api.example.com${path}`, {
method,
headers: {
'X-API-Key': API_KEY,
'X-Timestamp': timestamp,
'X-Signature': `sha256=${signature}`,
},
});
const result = await response.json();
if (result.success) {
console.log(`Total withdraws: ${result.data.total}`);
console.log(`Page ${result.data.page} of ${result.data.totalPages}`);
console.log(`Withdraws:`, result.data.data);
return result.data;
} else {
console.error('Error:', result.error);
throw new Error(result.error.message);
}
}
// List all withdraws
const withdraws = await listWithdraws();
// List paid withdraws
const paidWithdraws = await listWithdraws(1, 20, {
status: 'paid',
});Response
Success Response (200 OK)
{
"success": true,
"data": {
"data": [
{
"id": "660e8400-e29b-41d4-a716-446655440001",
"amount": "1000.00",
"currency": "THB",
"status": "paid",
"referenceId": "payout-12345",
"destinationType": "bank_account",
"bankAccountNumber": "1234****7890",
"bankAccountName": "John Doe",
"bankCode": "004",
"destinationId": null,
"description": "Payout for order #12345",
"metadata": {
"order_id": "12345"
},
"paidAt": "2024-01-01T00:05:00.000Z",
"canceledAt": null,
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:05:00.000Z"
}
],
"total": 1,
"page": 1,
"limit": 10,
"totalPages": 1
}
}Pagination
The response includes pagination metadata:
| Field | Type | Description |
|---|---|---|
data | array | Array of withdraw objects |
total | number | Total number of withdraws |
page | number | Current page number |
limit | number | Number of withdraws per page |
totalPages | number | Total number of pages |
Filtering
By Status
Filter withdraws by their current status:
# Get only paid withdraws
GET /api/v1/withdraws?status=paid
# Get only pending withdraws
GET /api/v1/withdraws?status=pending
# Get failed withdraws
GET /api/v1/withdraws?status=failedBy Destination Type
Filter withdraws by destination type:
# Get only bank account withdraws
GET /api/v1/withdraws?destinationType=bank_accountBy Date Range
Filter withdraws by creation date:
# Get withdraws from January 2024
GET /api/v1/withdraws?dateFrom=2024-01-01T00:00:00Z&dateTo=2024-01-31T23:59:59Z
# Get withdraws created after a specific date
GET /api/v1/withdraws?dateFrom=2024-01-01T00:00:00ZSorting
Sort Fields
You can sort by the following fields:
amount- Withdraw amountstatus- Withdraw statuscreatedAt- Creation date (default)paidAt- Paid datereferenceId- Reference ID
Sort Order
asc- Ascending orderdesc- Descending order (default)