API Documentation
English
English
  • Authorization
  • Request signing
  • List of error codes
  • Webhooks
  • IFrame order
  • Payment acceptance widget
  • Telegram MiniApp
  • API Reference
    • Base actions
      • Check x-api-signature
      • Fetch available currencies
      • Current price request
      • Search for operations by TX hash
      • Check address format
      • Get transaction history
    • Advanced account
      • Get advanced balances of user
      • Get advanced balance by id
      • Get payment address for advanced balance top-up
    • Blockchain addresses
      • Search by id
      • Transactions tracking
      • Search by address
      • Meta-data
      • Address Transactions
      • Last transaction of the address
      • Getting a list of PayIn addresses
      • Getting a list of business addresses
      • Get recurrent addresses
      • Getting a list of PayOut addresses
      • Creating a new business wallet address
      • Creating a new PayOut wallet address
    • Personal addresses
      • User creation
      • Getting an address
      • Getting a list of addresses
      • Get user
      • Adding a trusted address
      • Getting a list of trusted addresses
      • Deleting a trusted address
    • Orders
      • Creating an order
      • Getting information about an order
      • Getting a list of orders
    • Withdraws
      • Getting a commission for making a withdrawal
      • Sync withdraw
      • Async withdrawal
      • Receiving withdrawal information
    • Invoices
      • Create an invoice for payment
      • Invoice information request
      • Getting a list of invoices
    • Auto swaps
      • Create auto-swap
      • Find auto-swap by ID
    • Withdrawals 2.0
      • Create auto-withdrawal
      • Find auto-withdrawal by ID
      • Additional confirmation of the withdrawal
    • Bridge
      • Getting limits for cross-chain transfer
      • Getting information about cross-chain transfer
      • Commission token formation
      • Creating a cross-chain translation
    • Swaps
      • Getting limits for cross-chain exchange
      • Getting information about cross-chain exchange
      • Commission token formation
      • Creation of a cross-chain exchange
    • Recurring payments
      • Creating a payment link
      • Get a payment link
      • Get payment links by user
      • Disabling the payment link
      • Create a subscription
      • Getting a subscription
      • Cancel Subscription
      • Creating a payment
    • KYT
      • Check transaction risks
      • Check withdrawal risks
      • Check withdrawal risks for provided address
    • Partners API
      • Create user
      • Get user
      • Get all users
      • Creating an organization
      • Getting a list of organizations
      • Getting the user's advance balances
      • Replenishment of the user's advance balance
      • Get general tariffs
      • Create/update individual tariff
      • Get individual tariffs
      • Create API key
      • Get API keys
      • Delete API key
    • Webhooks
      • Get webhook
      • Get webhook (extended)
    • Orphan transactions
      • Get a transaction
      • Get a list of transactions
      • Get a commission token
      • Withdrawal
    • Address book
      • Add an address
      • Delete an address
      • Update the address
      • Get a list of addresses
Powered by GitBook
On this page
  1. API Reference
  2. Auto swaps

Create auto-swap

The method create auto-swap 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

Description of the response parameters

Parameter
Type
Description

id

string

Auto-swap ID

organizationId

string

Organization ID

status

enum

Status

currencyFrom

string

Outgoing coin of the address selected for auto-swap

networkFrom

string

Outgoing network of the address selected for auto-swap

currencyTo

string

The final coin to be sent to the client

networkTo

string

The final network to be sent to the client

amountFrom

string

The amount spent for the operation

amountFromUSD

string

The amount spent for the operation in terms of USD

amountTo

string

The final amount after the swap

amountToUSD

string

The final amount after the swap in terms of USD

amountToReceive

string

The amount that the client will receive

rate

string

Swap rate

blockchainFeeFrom

string

The network's commission for sending coins to the provider for making a swap

blockchainFeeFromUSD

string

The network's commission for sending coins to the provider for making a swap in terms of USD

blockchainFeeTo

string

The network's commission for sending coins from the provider to the client's address

blockchainFeeToUSD

string

The network's commission for sending coins from the provider to the client's address in terms of USD

serviceFee

string

Service commission for the operation

webhookUrl

string

URL for sending status change notification

createdAt

string

Date of creation of the auto-exchange

updatedAt

string

Date of the last update of the change

Statuses:

Status
Description

PENDING

In processing

WITHDRAWING

Waiting to be sent to the destination address

PROCESSED

Successfully

REJECTED

Rejected

ERROR

Processing error

PreviousAuto swapsNextFind auto-swap by ID

Last updated 7 months ago

  • Description of the request parameters
  • Include the network's commission in the swap amount
  • Description of the response parameters
  • POSTCreate auto-swap

Create auto-swap

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-swaps/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": "f5927a97-28e7-4022-ab53-3c3281ef7e9a",
    "organizationId": "44a43dbb-e24e-4380-8ba8-c4197a959d8f",
    "status": "PENDING",
    "message": null,
    "addressRiskLevel": "Low",
    "currencyFrom": "USDT",
    "networkFrom": "bsc",
    "currencyTo": "BTC",
    "networkTo": "bitcoin",
    "amountFrom": "1000",
    "amountFromUSD": "1000",
    "amountTo": "0.1",
    "amountToUSD": "990",
    "amountToReceive": "0.999",
    "rate": "10000",
    "blockchainFeeFrom": "0.34",
    "blockchainFeeFromUSD": "0.34",
    "blockchainFeeTo": "0.001",
    "blockchainFeeToUSD": "10",
    "serviceFee": "10",
    "webhookUrl": "https://merchant.domain/webhooks/...",
    "createdAt": "2025-05-14T13:39:50.451Z",
    "updatedAt": "2025-05-14T13:39:50.451Z"
  }
}