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."
]
}
}
}Initiate a swap transaction between two stablecoin assets.
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."
]
}
}
}Service key for API authentication
x >= 0base: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 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 Webhook URL to receive transaction status updates.