Create auto-withdrawal

The method create auto-withdrawal request

Amount limits apply to creation:

  • the amount must be more than $20 in equivalent

  • the amount must be twice the commission of the network of the final coin/network (see the method of obtaining available coins)

Description of the request parameters

Parameter
Type
Required
Description

address

string

yes

Destination address

currency

string

yes

The coin you want to receive

network

string

yes

The network where you want to receive coins

amountFrom

string

no

Outgoing amount

amountTo

string

no

The final amount

feeInAmount

boolean

no

Include the network commission in the swap amount

webhookUrl

string

no

URL for sending notifications when the status changes

It is necessary to send one of the parameters: amountFrom or amountTo When specifying two parameters, the priority will be amountFrom

Include the network's commission in the swap amount

By specifying the feeInAmount parameter in the value true, the specified amount + network commission will be debited from the address

  • If you specify amountFrom, the final amount amountTo may slip (it may differ from the one specified after the creation request)

  • If you specify amountTo, the estimated amount of the debit from the address will be blocked + a percentage to cover the insurance of slippage. After the exchange is completed, the amount will be corrected to the amount that was spent for the swap. There may be a slight slippage (≈ 0.1%) of the final amount due to the imposition of swap filters on the amount to be received

Additional confirmation

When creating a withdrawal from the payment acceptance widget, a webhook will be sent to the URL specified for withdrawal confirmation when creating the widget.

The webhook body will indicate the user who requested the withdrawal, the requested amount, the requested coins, and the conversion to the coin selected for withdrawal.

You can confirm or reject the withdrawal by sending the corresponding value in the request

Additional fields in the response body:

Name
Description

approveUrl

URL for sending the webhook for confirmation

approveResult

Confirmation data

approveResult.apiKey

API key data

approveResult.apiKey.public

Public part of the API key from which the confirmation came

approveResult.request

Request data

approveResult.request.ip

IP address from which the request came

approveResult.request.userAgent

User-Agent from which the request came

approveResult.approve

Approved or rejected

approveResult.time

Request time

requestedClientId

User ID in the merchant system who requested the withdrawal

requestedCurrency

Requested coin when creating the withdrawal

requestedAmount

Requested amount when creating the withdrawal

Create auto-withdrawal

post
Header parameters
x-api-public-keystringOptional

Public API-key

x-api-signaturestringOptional

Signing the request body with a private API-key

Content-typestringOptional

Request content type

Example: application/json
Body
addressstringRequired

The address to receive

Example: 1CGuTUAx7icKniPVKGiyiT7QLycpkxULLP
currencystringRequired

The coin you want to receive

Example: BTC
networkstringRequired

The network where you want to receive coins

Example: bitcoin
amountFromstringOptional

Outgoing amount

Example: 1000
amountTostringOptional

The final amount

Example: 0.1
feeInAmountbooleanOptional

To include the network commission in the amount to swap, when specifying this parameter, the amountTo will be equal to the amount that the address will receive

webhookUrlstringOptional

URL for sending a status change notification

Example: https://merchant.domain/webhooks/...
Responses
200Success
application/json
post
POST /api-gateway/auto-withdrawals/create HTTP/1.1
Host: ocp.onchainpay.io
Content-Type: application/json
Accept: */*
Content-Length: 193

{
  "address": "1CGuTUAx7icKniPVKGiyiT7QLycpkxULLP",
  "currency": "BTC",
  "network": "bitcoin",
  "amountFrom": "1000",
  "amountTo": "0.1",
  "feeInAmount": true,
  "webhookUrl": "https://merchant.domain/webhooks/..."
}
200Success
{
  "success": true,
  "response": {
    "id": "d2de09da-cec1-46b7-86d9-a344f4579df7",
    "organizationId": "da2fa0f7-3ac9-493e-b240-7e37555b1cfb",
    "type": "WITHDRAWAL",
    "status": "PENDING",
    "message": null,
    "addressRiskLevel": "Low",
    "currencyFrom": "USDT",
    "networkFrom": "bsc",
    "currencyTo": "BTC",
    "networkTo": "bitcoin",
    "addressFromId": "25a8de42-a359-47f1-bb82-bc9f6c20f1b9",
    "addressFrom": "0xD65D24ABCd85165a243C33Cf8133ffBaaa98255D",
    "addressTo": "0x22aECc7ff5b435E38be5457C8538256918783F67",
    "amountFrom": "1000",
    "amountFromUSD": "1000",
    "amountTo": "0.1",
    "amountToUSD": "990",
    "amountToReceive": "0.999",
    "rate": "10000",
    "blockchainFeeFrom": "0.34",
    "blockchainFeeFromUSD": "0.34",
    "blockchainFeeToSource": "ADVANCED",
    "blockchainFeeTo": "0.001",
    "blockchainFeeToUSD": "10",
    "serviceFee": "10",
    "txId": "0xadcc95b8bcd123e41612c46b057df889e32a73297e973c21e8b38046ac04130a",
    "webhookUrl": "https://merchant.domain/webhooks/...",
    "approveUrl": "https://merchant.domain/webhooks/...",
    "approveResult": {
      "apiKey": {
        "id": "9d22fec0-c979-46a2-9a71-264e0c4cb75c",
        "public": "c9jeO7OJcJb7cnBTVXrgtRzazf60W4Lbsz3/wOYM1m2EsJyZz5wGfbIIuoJ4Ugs6HMowQj8zlv2jf8Vt1ra4Fw=="
      },
      "request": {
        "ip": "123.231.123.100",
        "userAgent": "axios/1.6.0"
      },
      "approve": true,
      "time": "2025-06-09T13:18:11.513Z"
    },
    "requestedClientId": "c2e0461d-344c-45ef-9418-456a678a9a5f",
    "requestedCurrency": "EUR",
    "requestedAmount": "5500",
    "createdAt": "2025-06-09T13:18:11.513Z",
    "updatedAt": "2025-06-09T13:18:11.513Z"
  }
}

Last updated