Swaps
Swap Tokens
Execute a token swap within a wallet.
post/v1/wallets/{wallet_id}/swap
Path parameters
wallet_idstring required
ID of the wallet.
Headers
privy-app-idstring required
ID of your Privy app.
privy-authorization-signaturestring
Request authorization signature. If multiple signatures are required, they should be comma separated.
privy-request-expirystring
Request expiry. Value is a Unix timestamp in milliseconds representing the deadline by which the request must be processed.
privy-idempotency-keystring
Idempotency keys ensure API requests are executed only once within a 24-hour window.
Request body
Example request
{
"amount_type": "exact_input",
"base_amount": "1000000000000000000",
"destination": {
"asset_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"caip2": "eip155:1"
},
"slippage_bps": 50,
"source": {
"asset_address": "native",
"caip2": "eip155:1"
}
}Response
Swap initiated successfully.
Example response
{
"estimated_fees": [
{
"amount": "0.20",
"recipient": "0x1234567890abcdef1234567890abcdef12345678",
"type": "relayer"
}
],
"estimated_gas": {
"amount": "0.0001",
"base_amount": "100000000000000",
"gas_asset": "ETH"
},
"fees": [
{
"amount": "0.20",
"recipient": "0x1234567890abcdef1234567890abcdef12345678",
"type": "relayer"
}
],
"gas": {
"amount": "0.0001",
"base_amount": "100000000000000",
"gas_asset": "ETH"
}
}