Logo
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

ParameterTypeRequiredDescription
pagenumberNoPage number (default: 1, minimum: 1)
limitnumberNoNumber of withdraws per page (default: 10, minimum: 1, maximum: 100)
statusstringNoFilter by withdraw status (see status values below)
destinationTypestringNoFilter by destination type: "bank_account" or "wallet"
dateFromstringNoFilter withdraws created after this date (ISO 8601 format)
dateTostringNoFilter withdraws created before this date (ISO 8601 format)
sortBystringNoSort field: "amount", "status", "createdAt", "paidAt", "referenceId"
sortOrderstringNoSort order: "asc" or "desc" (default: "desc")

Status Filter Values

  • pending
  • processing
  • paid
  • failed
  • canceled

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:

FieldTypeDescription
dataarrayArray of withdraw objects
totalnumberTotal number of withdraws
pagenumberCurrent page number
limitnumberNumber of withdraws per page
totalPagesnumberTotal 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=failed

By Destination Type

Filter withdraws by destination type:

# Get only bank account withdraws
GET /api/v1/withdraws?destinationType=bank_account

By 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:00Z

Sorting

Sort Fields

You can sort by the following fields:

  • amount - Withdraw amount
  • status - Withdraw status
  • createdAt - Creation date (default)
  • paidAt - Paid date
  • referenceId - Reference ID

Sort Order

  • asc - Ascending order
  • desc - Descending order (default)

On this page