aibank
API ReferenceTransfers

Swap Tokens

Swap one token for another on the same chain.

Swap Tokens

Execute a token swap on a specified chain using the wallet's funds.

Authentication

Requires X-API-Key header.

Path parameters

ParameterTypeDescription
idstringWallet UUID

Request body

Both camelCase and snake_case parameter names are accepted.

Request

curl -X POST http://localhost:4000/v1/wallets/WALLET_ID/swap \
  -H "X-API-Key: ak_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "chain": "base",
    "inputToken": "ETH",
    "outputToken": "USDC",
    "amount": "0.1"
  }'

Response (200)

{
  "transaction_id": "tx-uuid",
  "tx_hash": "0xabc123...",
  "input_token": "ETH",
  "output_token": "USDC",
  "input_amount": "0.1",
  "output_amount": "300.00",
  "chain": "base",
  "status": "confirmed"
}

Errors

StatusCodeDescription
400INVALID_INPUTMissing or invalid fields
404NOT_FOUNDWallet not found
500SWAP_FAILEDSwap execution failed

On this page