Create Withdrawal

HTTP Method: POST
Endpoint URL: /v2/withdrawal
Description: Creates a new withdrawal request that requires approval before processing.
Security: Requires both API-KEY and X-HMAC headers.

Request Headers

  • Content-Type: application/json
  • API-KEY: your_account_api_key
  • X-HMAC: your_hmac_signature (calculated from all request body fields)

Request Body (JSON)

{
  "amount": "10",
  "asset": {
    "short": "USDT",
    "network": "tron"
  },
  "addressTo": "TPSMckmxoQBQWfUcasbUs2cRUdh2EMQu4n",
  "customer": {
    "id": 1,
    "name": "Customer Name",
    "email": "customer-email@email.com"
  },
  "destTag": "",
  "invoice": "your-system-invoice-id"
}

Required Fields

  • amount (string) — Withdrawal amount as a decimal string with up to 8 decimal places
  • asset (object) — Cryptocurrency asset:
    • short — Asset ticker symbol, e.g. USDT
    • network — Blockchain network API value, e.g. tron
  • addressTo (string) — Destination wallet address

Optional Fields

  • customer (object) — Customer information. If omitted, the withdrawal is stored with id: 0 and empty name / email:
    • id — Your internal customer identifier (integer)
    • name — Customer name
    • email — Customer email address
  • destTag (string | null) — Destination tag/memo; omit, or pass an empty string or null, if the destination does not need one
  • invoice (string) — Your internal invoice/order ID for transaction tracking. Must be unique among your OPEN and APPROVED withdrawals (see 409 Conflict). If omitted, invoice is null in the response
  • addressFrom (string) — Source wallet address for withdraw-direct mode. Must be provided together with clientId. See Withdraw-Direct section below.
  • clientId (string) — Client identifier for address ownership validation. Must be provided together with addressFrom. See Client ID documentation for details.
  • transferAll (boolean) — When true, withdraws the entire balance from the source address instead of the specified amount. Used with withdraw-direct mode.

Validation: addressFrom and clientId must both be provided together. Sending only one will return a 400 Bad Request error.

Supported Asset Combinations

Withdrawals are available for every asset and network listed on the Available Assets page. Use the API value of the network (e.g. tron, ethereum, bsc, base, solana, ton, bitcoin). An unsupported short + network combination returns 400 Bad Request.

For networks that use a memo (e.g. ton), pass it in destTag when the destination requires one, such as an exchange deposit account.

Example cURL

curl https://api.alppay.io/v2/withdrawal \
  -X POST \
  -H "Content-Type: application/json" \
  -H "API-KEY: ak_live_1234567890abcdef" \
  -H "X-HMAC: your_calculated_signature" \
  -d '{
    "amount": "10",
    "asset": {
      "short": "USDT",
      "network": "tron"
    },
    "addressTo": "TPSMckmxoQBQWfUcasbUs2cRUdh2EMQu4n",
    "customer": {
      "id": 1,
      "name": "Customer Name",
      "email": "customer-email@email.com"
    },
    "destTag": "",
    "invoice": "your-system-invoice-id"
  }'

Successful Response (200 OK)

{
  "id": "5f5a8ced-5c6a-4038-9d73-662441242fd3",
  "txnId": "",
  "amount": "10",
  "receivedAmount": "0",
  "asset": {
    "short": "USDT",
    "name": "Tether",
    "logoUrl": "https://cryptologos.cc/logos/tether-usdt-logo.png",
    "network": "tron"
  },
  "addressFrom": "",
  "addressTo": "TPSMckmxoQBQWfUcasbUs2cRUdh2EMQu4n",
  "destTag": null,
  "status": "OPEN",
  "customer": {
    "id": 1,
    "name": "Customer Name",
    "email": "customer-email@email.com"
  },
  "merchant": {
    "id": 1,
    "name": "TestMerchant",
    "email": "test-merchant@test.com",
    "siteUrl": "",
    "logoUrl": ""
  },
  "invoice": "your-system-invoice-id",
  "createdAt": "2025-08-07T09:08:58.780375195Z",
  "updatedAt": "2025-08-07T09:08:58.780375285Z",
  "timeToApprove": null
}

Response Field Descriptions

  • id — Unique UUID identifier of the withdrawal request
  • txnId — Transaction ID on blockchain (empty until processing)
  • amount — Requested withdrawal amount as decimal string
  • receivedAmount — Amount actually sent as decimal string (0 until processed)
  • asset — Asset details object including name and logo URL
  • addressFrom — Source address (empty until processing)
  • addressTo — Destination wallet address
  • destTag — Destination tag if applicable, otherwise null
  • status — Current status: OPEN, APPROVED, CANCELLED, or COMPLETE
  • customer — Customer information object
  • merchant — Merchant account details object
  • invoice — Your internal invoice ID
  • createdAt — ISO 8601 timestamp of withdrawal creation
  • updatedAt — ISO 8601 timestamp of last update
  • timeToApprove — ISO 8601 timestamp when withdrawal will be auto-approved by the system (null if manual approval required)

Withdrawal Status Flow

  1. OPEN - Initial status after creation, awaiting approval
  2. APPROVED - Withdrawal approved (manually or automatically after timeToApprove)
  3. COMPLETE - Withdrawal successfully processed on blockchain
  4. CANCELLED - Withdrawal cancelled before processing

Important Notes

  • Approval Required: All withdrawals require approval before processing. This can happen:

    • Manually through the dashboard
    • Automatically after the time specified in timeToApprove
  • HMAC Signature: The X-HMAC header must be calculated using ALL fields sent in the request body

  • Customer ID: The customer.id field should be your internal customer identifier to maintain linkage between your system and the payment gateway

  • Invoice Field: Use the invoice field to store your internal transaction reference. This helps recover transaction links if the withdrawal ID is lost

  • Webhooks: Status change notifications are sent automatically to your configured webhook URL. See the Withdrawal Webhooks documentation for details

Withdraw-Direct Mode

When you provide addressFrom and clientId together, the withdrawal operates in withdraw-direct mode — funds are sent directly from the specified deposit address rather than from the merchant's pooled balance.

Withdraw-Direct Request Example

{
  "amount": "10",
  "asset": {
    "short": "USDT",
    "network": "tron"
  },
  "addressTo": "TPSMckmxoQBQWfUcasbUs2cRUdh2EMQu4n",
  "addressFrom": "TXkFpL3HmzE9KPpXGWNXdCbNcDYYn73U4C",
  "clientId": "client-12345",
  "transferAll": true,
  "customer": {
    "id": 1,
    "name": "Customer Name",
    "email": "customer-email@email.com"
  },
  "destTag": "",
  "invoice": "your-system-invoice-id"
}

Key Points

  • addressFrom must belong to the authenticated merchant and the specified clientId
  • If addressFrom does not match ownership, a 403 Forbidden error is returned
  • The merchant's Withdrawal to whitelist setting must be enabled; otherwise the request returns 400 Bad Request with withdrawal to whitelist is disabled for this merchant
  • addressTo must be on the merchant's whitelist for the asset and network; otherwise the request returns 400 Bad Request with addressTo is not whitelisted for this merchant
  • transferAll: true ignores the amount field and transfers the full address balance

Error Responses

400 Bad Request

Returned when request validation fails (invalid email, unsupported asset/network combination, etc.). For withdraw-direct also when the Withdrawal to whitelist setting is disabled or addressTo is not whitelisted (see Withdraw-Direct Mode).

401 Unauthorized

Missing or invalid API-KEY header, or a missing / invalid X-HMAC signature.

{
  "code": "unauthorized",
  "message": "Invalid HMAC signature"
}

403 Forbidden

The API key is valid but the request is not allowed: the request IP is not in the merchant's IP whitelist ("Blocked by IP"), or the merchant account is frozen or deactivated. For withdraw-direct, 403 is also returned when addressFrom is not linked to clientId or the wallet is blocked.

409 Conflict

A withdrawal with the same invoice already exists in OPEN or APPROVED status. Once that withdrawal is COMPLETE or CANCELLED, the invoice can be reused.

{
  "code": 409,
  "message": "a withdrawal with this invoice already exists in OPEN or APPROVED status"
}

500 Internal Server Error

Server-side error occurred. If it happened while checking the whitelist or the source address (withdraw-direct), no withdrawal was created and the request can be retried.