Skip to main content
POST
/
swap
/
initiate
Initiate
curl --request POST \
  --url https://api.onswitch.xyz/swap/initiate \
  --header 'Content-Type: application/json' \
  --header 'x-service-key: <api-key>' \
  --data '
{
  "amount": 100,
  "from_asset": "base:usdc",
  "to_asset": "solana:usdt",
  "beneficiary": {
    "wallet_address": "0x1234567890123456789012345678901234567890"
  },
  "exact_output": false,
  "callback_url": "https://your-app.com/webhook",
  "reference": "550e8400-e29b-41d4-a716-446655440000"
}
'
{
  "success": true,
  "message": "Swap initiated successfully",
  "timestamp": "2024-01-01T00:00:00.000Z",
  "data": {
    "status": "AWAITING_DEPOSIT",
    "type": "SWAP",
    "reference": "550e8400-e29b-41d4-a716-446655440000",
    "rate": 1,
    "fee": {
      "total": 0.5,
      "platform": 0.45,
      "developer": 0.05,
      "currency": "USDC"
    },
    "source": {
      "amount": 100,
      "currency": "USDC"
    },
    "destination": {
      "amount": 99.5,
      "currency": "USDT"
    },
    "deposit": {
      "amount": 100,
      "address": "0x1234567890123456789012345678901234567890",
      "asset": "base:usdc",
      "note": [
        "Kindly send the exact amount to the wallet address to complete the transaction.",
        "This dynamic wallet address has a 30 minutes expiry window and can only be used once."
      ]
    }
  }
}

Authorizations

x-service-key
string
header
required

Service key for API authentication

Body

application/json
amount
number
required
Required range: x >= 0
from_asset
enum<string>
required
Available options:
base:usdc,
solana:usdc,
solana:usdt,
ethereum:usdc,
ethereum:usdt,
polygon:usdc,
polygon:usdt,
bsc:usdc,
bsc:usdt,
arbitrum:usdc,
optimism:usdc,
gnosis:usdc,
gnosis:usdt,
arbitrum:usdt,
avalanche:usdc,
monad:usdc,
optimism:usdt,
monad:usdt,
plasma:usdt,
avalanche:usdt,
tron:usdt,
linea:usdt,
mantle:usdt,
hyperevm:usdt,
berachain:usdt,
linea:usdc,
berachain:usdc,
sonic:usdc,
base:cngn,
bsc:cngn
to_asset
enum<string>
required
Available options:
base:usdc,
solana:usdc,
solana:usdt,
ethereum:usdc,
ethereum:usdt,
polygon:usdc,
polygon:usdt,
bsc:usdc,
bsc:usdt,
arbitrum:usdc,
optimism:usdc,
gnosis:usdc,
gnosis:usdt,
arbitrum:usdt,
avalanche:usdc,
monad:usdc,
optimism:usdt,
monad:usdt,
plasma:usdt,
avalanche:usdt,
tron:usdt,
linea:usdt,
mantle:usdt,
hyperevm:usdt,
berachain:usdt,
linea:usdc,
berachain:usdc,
sonic:usdc,
base:cngn,
bsc:cngn
beneficiary
object
required
exact_output
boolean
default:false
callback_url
string<uri>

Webhook URL to receive transaction status updates.

reference
string<uuid>

Response

Successfully initiated swap transaction

success
boolean
required
message
string
required
timestamp
string<date-time>
required
data
any | null
required

Response data