Async withdrawal

The method allows you to create a request to withdraw coins from an address and get the execution result to the specified webhookUrl

Async withdrawal

POSThttps://ocp.onchainpay.io/api-gateway/make-withdrawal-async
Header parameters
Body
advancedBalanceId*string

Identifier of the advance balance for writing off commissions

Example: "abeb285e-0e04-4fb4-90cb-69ad4b89f212"
addressId*string

Identifier of the address from which the coins should be withdrawn

Example: "98a8fd1c-cb2d-46b4-90b9-43f948ca66f0"
address*string

Address for sending coins

Example: "0x00000005707bf50efa35a2db020ede9ac08ae226"
tagstringnull

Tag (memo) address (relevant for networks that support the tag, such as Ripple)

amount*string

Withdrawal amount

Example: "123.12"
feeToken*string

Fee token that was not created when requesting /request-fee

Example: "U2FsdGVkX19yWh6k7PjIN0f7IBX10I8r1IKR6enmejPDQnS0uMsWmCfSUBdMv/VkLfqHVsWjR16+GXm3BM+7zjLAOhvv5ejX8rxd/xQYwxW+5ZTcf4KACfy+XXOHkY4q1d0N+ejdIPZBATv29h9Cb6agWlRj/bB+iq6IhCJf4uc="
feeInAmountboolean

(Relevant for withdrawing coins) Deduct the network commission from the withdrawal amount or from the payer's funds. By default, the network commission is deducted from the withdrawal amount.

webhookUrlstring

URL to send webhook when output status changes

Example: "https://merchant.domain/webhooks/withdraw"
Response
Body
success*boolean

Request success indicator

response*MakeAsyncWithdrawResponse (object)

The body of the response to the request to generate output

Request
const response = await fetch('https://ocp.onchainpay.io/api-gateway/make-withdrawal-async', {
    method: 'POST',
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "advancedBalanceId": "abeb285e-0e04-4fb4-90cb-69ad4b89f212",
      "addressId": "98a8fd1c-cb2d-46b4-90b9-43f948ca66f0",
      "address": "0x00000005707bf50efa35a2db020ede9ac08ae226",
      "amount": "123.12",
      "feeToken": "U2FsdGVkX19yWh6k7PjIN0f7IBX10I8r1IKR6enmejPDQnS0uMsWmCfSUBdMv/VkLfqHVsWjR16+GXm3BM+7zjLAOhvv5ejX8rxd/xQYwxW+5ZTcf4KACfy+XXOHkY4q1d0N+ejdIPZBATv29h9Cb6agWlRj/bB+iq6IhCJf4uc="
    }),
});
const data = await response.json();
Response
{
  "success": false,
  "response": {
    "id": "59390a4f-2469-4a04-b32d-1f9e9145af37",
    "advancedBalanceId": "abeb285e-0e04-4fb4-90cb-69ad4b89f212",
    "addressId": "98a8fd1c-cb2d-46b4-90b9-43f948ca66f0",
    "currency": "USDT",
    "network": "ethereum",
    "tx": "null",
    "status": "pending",
    "address": "0x00000005707bf50efa35a2db020ede9ac08ae226",
    "tag": null,
    "amount": "123.12",
    "feeCurrency": "0x00000005707Bf50EfA35a2db020eDe9Ac0780b9f",
    "feeSource": "advanced_balance",
    "feeAmount": "1.12",
    "webhookUrl": "https://merchant.domain/webhooks/withdraw",
    "createdAt": "2024-09-19T14:20:34.027Z"
  }
}

Last updated