Logo
API ReferenceWithdraws

Retrieve Withdraw

Retrieves the details of an existing withdraw by its ID.

Endpoint

GET /api/v1/withdraws/{withdraw_id}

Authentication

This endpoint requires HMAC Integration Authentication.

Path Parameters

ParameterTypeRequiredDescription
withdraw_idstringYesThe UUID of the withdraw to retrieve

Example Request

import crypto from 'crypto';

const API_KEY = process.env.PAYMENT_API_KEY!;
const API_SECRET = process.env.PAYMENT_API_SECRET!;

async function getWithdraw(withdrawId: string) {
  const method = 'GET';
  const path = `/api/v1/withdraws/${withdrawId}`;
  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('Withdraw status:', result.data.status);
    console.log('Withdraw amount:', result.data.amount);
    return result.data;
  } else {
    console.error('Error:', result.error);
    throw new Error(result.error.message);
  }
}

// Get withdraw
const withdraw = await getWithdraw('660e8400-e29b-41d4-a716-446655440001');

Response

Success Response (200 OK)

{
  "success": true,
  "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"
  }
}

Error Response (404 Not Found)

{
  "success": false,
  "error": {
    "code": "RESOURCE_NOT_FOUND",
    "message": "Withdraw not found"
  }
}

Withdraw Status

Withdraws can be in one of the following statuses:

StatusDescription
pendingWithdraw created, waiting to be processed
processingWithdraw is being processed by provider
paidWithdraw completed successfully
failedWithdraw failed (e.g., insufficient balance)
canceledWithdraw was cancelled

Response Fields

FieldTypeDescription
idstringWithdraw UUID
amountstringAmount as decimal string
currencystringCurrency code (THB)
statusstringCurrent withdraw status
referenceIdstringYour reference ID
destinationTypestringDestination type (bank_account or wallet)
bankAccountNumberstringMasked bank account number (or null)
bankAccountNamestringBank account name (or null)
bankCodestringBank code (or null)
destinationIdstringDestination ID (or null)
descriptionstringWithdraw description (or null)
metadataobjectAdditional metadata (or null)
paidAtstringISO timestamp when withdraw was paid (or null)
canceledAtstringISO timestamp when withdraw was canceled (or null)
createdAtstringISO timestamp when withdraw was created
updatedAtstringISO timestamp when withdraw was last updated

On this page