Skip to main content
POST
/
v1
/
wallets
/
{wallet_id}
/
swap
Swap Tokens
curl --request POST \
  --url https://api.privy.io/v1/wallets/{wallet_id}/swap \
  --header 'Authorization: Basic <encoded-value>' \
  --header 'Content-Type: application/json' \
  --header 'privy-app-id: <privy-app-id>' \
  --data '
{
  "caip2": "eip155:1",
  "input_token": "native",
  "output_token": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
  "amount": "1000000000000000000",
  "amount_type": "exact_input",
  "slippage_bps": 50
}
'
{
  "id": "cm7oxq1el000e11o8iwp7d0d0",
  "status": "pending",
  "wallet_id": "fmfdj6yqly31huorjqzq38zc",
  "caip2": "eip155:1",
  "input_token": "native",
  "output_token": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
  "input_amount": "1000000000000000000"
}

Prerequisites


Privy automates token approvals and transaction submission. The response is a wallet action that starts in pending status and can be polled for confirmation.

Authorizations

Authorization
string
header
required

Basic Auth header with your app ID as the username and your app secret as the password.

Headers

privy-app-id
string
required

ID of your Privy app.

privy-authorization-signature
string

Request authorization signature. If multiple signatures are required, they should be comma separated.

privy-idempotency-key
string

Idempotency keys ensure API requests are executed only once within a 24-hour window.

Path Parameters

wallet_id
string
required

ID of the wallet.

Body

application/json

Input for executing a token swap.

caip2
string
required

Chain identifier (e.g., "eip155:1" for Ethereum mainnet).

input_token
string
required

Token address to sell, or "native" for the chain's native token.

output_token
string
required

Token address to buy, or "native" for the chain's native token.

amount
string
required

Amount in base units (e.g., wei for ETH).

amount_type
enum<string>
default:exact_input

Whether the amount refers to the input token (exact_input) or output token (exact_output).

Available options:
exact_input,
exact_output
slippage_bps
number

Maximum slippage tolerance in basis points (e.g., 50 for 0.5%).

recipient
string

Address to receive the output tokens. Defaults to the wallet address if not specified.

Response

200 - application/json

Swap initiated successfully.

Result of a token swap execution.

id
string | null
required

The ID of the wallet action.

status
enum<string>
required

The current status of the wallet action.

Available options:
pending,
succeeded,
rejected,
failed
wallet_id
string
required

The ID of the wallet involved in the action.

caip2
string
required

Chain identifier.

input_token
string
required

Token address being sold.

output_token
string
required

Token address being bought.

input_amount
string
required

Amount of input token in base units.

steps
(EVMTransactionWalletActionStep · object | EVMUserOperationWalletActionStep · object)[]

The steps of the wallet action. Only returned if ?include=action_steps is provided.

A wallet action step consisting of an EVM transaction.