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. Swaps

Creation of a cross-chain exchange

PreviousCommission token formationNextRecurring payments

Last updated 1 year ago

The method allows you to create a cross-chain exchange. Cross-chain exchange allows you to exchange one asset for another

Creation of a cross-chain exchange

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
advancedBalanceIdstringRequired

Identifier of the upfront balance specified when creating the commission token

Example: 2db11a99-a1cb-44f1-ba3b-ee41d80f53be
clientIdstringOptional

Unique exchange identifier in the merchant system (to prevent duplicate requests)

Example: merchant_unique_id
addressFromIdstringRequired

Identifier of the outgoing address from which the specified amount will be debited

Example: e5b79674-72aa-46c5-9bc0-6c71176bbd61
addressToIdstringRequired

Identifier of the destination address where the coins will be credited after the swap

Example: 5681c552-2aff-4818-9f80-a20f7181b7ff
feeTokenstringRequired

Commission Token

Example: U2FsdGVkX1+mY2BlP3aKDL0b35LbOiDYeg3h8m9wel0IFhsqGIE1CD+3I0vIrppzQ2ZMpJhEZElBlW100tF/46ReHvSbTeUFnjxFkNdo2lFf6xQbpPgilPQM+Vw5pNSVdWtPrrOGbExHqRrqJipBdy+55h5+xN1vZ8j216zR0KQoH4hsK5oGW4xkEjkwZCio7jrqKQaF17hus9vl8ofKfQ==
webhookUrlstringOptional

URL address for notifying about the change in the status of the swap operation

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

{
  "advancedBalanceId": "2db11a99-a1cb-44f1-ba3b-ee41d80f53be",
  "clientId": "merchant_unique_id",
  "addressFromId": "e5b79674-72aa-46c5-9bc0-6c71176bbd61",
  "addressToId": "5681c552-2aff-4818-9f80-a20f7181b7ff",
  "feeToken": "U2FsdGVkX1+mY2BlP3aKDL0b35LbOiDYeg3h8m9wel0IFhsqGIE1CD+3I0vIrppzQ2ZMpJhEZElBlW100tF/46ReHvSbTeUFnjxFkNdo2lFf6xQbpPgilPQM+Vw5pNSVdWtPrrOGbExHqRrqJipBdy+55h5+xN1vZ8j216zR0KQoH4hsK5oGW4xkEjkwZCio7jrqKQaF17hus9vl8ofKfQ==",
  "webhookUrl": "https://merchant.domain/webhooks/swap"
}
200Success
{
  "success": true,
  "response": {
    "id": "62809beb-ce35-4861-a9e9-1e75f068f46f",
    "clientId": "merchant_unique_id",
    "advancedBalanceId": "2db11a99-a1cb-44f1-ba3b-ee41d80f53be",
    "addressFromId": "e5b79674-72aa-46c5-9bc0-6c71176bbd61",
    "addressToId": "5681c552-2aff-4818-9f80-a20f7181b7ff",
    "currencyFrom": "USDT",
    "currencyTo": "USDC",
    "networkFrom": "ethereum",
    "networkTo": "tron",
    "status": "PENDING",
    "rejectMessage": "null",
    "amountFrom": "200",
    "amountTo": "200",
    "price": "1",
    "serviceBlockchainFeeSource": "ADVANCE",
    "serviceBlockchainFee": "2",
    "serviceBlockchainFeeUSD": "2",
    "providerBlockchainFeeSource": "AMOUNT",
    "providerBlockchainFee": "2",
    "providerBlockchainFeeUSD": "2",
    "serviceFeeSource": "ADVANCE",
    "serviceFee": "2",
    "serviceFeeUSD": "2",
    "webhookUrl": "https://merchant.domain/webhooks/swap",
    "createdAt": "2025-05-14T13:39:50.470Z"
  }
}