---
title: "Swap or Bridge Tokens"
method: POST
path: "/v1/bridge/swap"
tags: ["Bridge"]
---

# Swap or Bridge Tokens

`POST /v1/bridge/swap`

Swap one token for another using the optimal route available. You can specify a tokenIn amount (if exact='input') or tokenOut amount (if exact='output'), but not both. The corresponding output or input amount will be returned as the quote.

**Authentication**: This endpoint requires project authentication and wallet authentication. For backend usage, use `x-secret-key` header. For frontend usage, use `x-client-id` + `Authorization: Bearer <jwt>` headers.

## Request body

- object — Request to swap tokens using the optimal route available. You can specify a tokenIn amount (if exact='input') or tokenOut amount (if exact='output'), but not both. The corresponding output or input amount will be returned as the quote.
  - `exact` 'input' | 'output' — Whether to swap the exact input or output amount
  - `tokenIn` object, required
    - `address` string, required — The input token address to swap (use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for native token)
    - `chainId` integer, required — The blockchain network where the token is located
    - `amount` string — The amount of the input token to swap in wei.
    - `maxAmount` string — The maximum amount of the input token to swap in wei.
  - `tokenOut` object, required
    - `address` string, required — The output token address to swap (use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for native token)
    - `chainId` integer, required — The blockchain network where the token is located
    - `amount` string — The amount of the output token to receive in wei.
    - `minAmount` string — The minimum amount of the output token to receive in wei.
  - `from` string — The wallet address or ENS name that will execute the swap. If omitted, the project wallet will be used if available.
  - `receiver` string — The wallet address that will receive the swapped tokens. Defaults to the sender address if not specified.
  - `slippageToleranceBps` number, nullable — The slippage tolerance in basis points. Will be automatically calculated by default.

## Response `200`

Swap completed successfully. Returns the transaction used for the swap.

- object — Successful token swap response containing executed transaction ID
  - `result` object, required
    - `transactionId` string, required — Payment transaction ID that was executed

## Other responses

- `400` — Invalid request parameters.
- `401` — Authentication required. For backend usage, include `x-secret-key` header. For frontend usage, include `x-client-id` + `Authorization: Bearer <jwt>` headers.
- `402` — Payment required. Insufficient wallet balance to complete the purchase.
- `500` — Internal server error. This may occur due to network connectivity issues, wallet creation failures, or transaction execution failures.

---

[API](https://skmtc.net/thirdweb/apis/thirdweb-api.md) · [All operations](https://skmtc.net/thirdweb/apis/thirdweb-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/thirdweb/thirdweb-api/versions/fb4cb67da1c7/schema)
