---
title: "Create swap transaction"
method: POST
path: "/trade/swap"
tags: ["Trade"]
---

# Create swap transaction

`POST /trade/swap`

Create a swap transaction from a trade quote. The transaction is ready to be signed and sent.

## Request body

- SwapTransactionRequest
  - `quoteResponse` TradeQuoteResponse, required
    - `requestId` string, required — Unique identifier for the quote request
    - `contextSlot` number, required — The slot at which the quote was generated
    - `inAmount` string, required — Input amount
    - `inputMint` string, required — Input token mint public key
    - `outAmount` string, required — Expected output amount
    - `outputMint` string, required — Output token mint public key
    - `minOutAmount` string, required — Minimum output amount considering slippage
    - `otherAmountThreshold` string, required — Other amount threshold for the swap
    - `priceImpactPct` string, required — Price impact percentage
    - `slippageBps` number, required — Slippage tolerance in basis points
    - `routePlan` RoutePlanLeg[], required — Array of route legs showing the swap path
      - `venue` string, required — Name of the DEX or venue
      - `inAmount` string, required — Input amount for this leg
      - `outAmount` string, required — Output amount for this leg
      - `inputMint` string, required — Input token mint for this leg
      - `outputMint` string, required — Output token mint for this leg
      - `inputMintDecimals` number, required — Decimals of the input token mint
      - `outputMintDecimals` number, required — Decimals of the output token mint
      - `marketKey` string, required — Market key for this leg
      - `data` string, required — Additional data for this leg
    - `platformFee` PlatformFee
      - `amount` string, required — Platform fee amount
      - `feeBps` number, required — Platform fee in basis points
      - `feeAccount` string, required — Public key of the fee account
      - `segmenterFeeAmount` string, required — Segmenter fee amount
      - `segmenterFeePct` number, required — Segmenter fee percentage
    - `outTransferFee` string, nullable — Output transfer fee if applicable
    - `simulatedComputeUnits` number, nullable — Simulated compute units for the swap transaction
  - `userPublicKey` string, required — Public key of the user's wallet

## Response `200`

Successfully created swap transaction

- object
  - `success` boolean, required
  - `response` object
    - `swapTransaction` string, required — Base58 encoded serialized VersionedTransaction
    - `computeUnitLimit` number, required — Compute unit limit for the transaction
    - `lastValidBlockHeight` number, required — Last valid block height for the transaction
    - `prioritizationFeeLamports` number, required — Prioritization fee in lamports

## Other responses

- `400` — Bad request - Invalid quote or parameters
- `401` — Unauthorized - Invalid or missing API key
- `500` — Internal server error

---

[API](https://skmtc.net/bags/apis/bags-public-api-v2.md) · [All operations](https://skmtc.net/bags/apis/bags-public-api-v2/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/bags/bags-public-api-v2/revisions/4a14b82cd39d/schema)
