---
title: "POST /swap"
method: POST
path: "/swap"
---

# POST /swap

`POST /swap`

Returns a transaction that you can use from the quote you get from `/quote`.

## Request body

- SwapRequest
  - `userPublicKey` string, required — The user public key.
  - `wrapAndUnwrapSol` boolean — Default is true. If true, will automatically wrap/unwrap SOL. If false, it will use wSOL token account. Will be ignored if `destinationTokenAccount` is set because the `destinationTokenAccount` may belong to a different user that we have no authority to close.
  - `useSharedAccounts` boolean — Default is true. This enables the usage of shared program accountns. That means no intermediate token accounts or open orders accounts need to be created for the users. But it also means that the likelihood of hot accounts is higher.
  - `feeAccount` string — Fee token account, same as the output token for ExactIn and as the input token for ExactOut, it is derived using the seeds = ["referral_ata", referral_account, mint] and the `REFER4ZgmyYx9c6He5XfaTMiGfdLwRnkV4RPp9t9iF3` referral contract (only pass in if you set a feeBps and make sure that the feeAccount has been created).
  - `computeUnitPriceMicroLamports` union — The compute unit price to prioritize the transaction, the additional fee will be `computeUnitLimit (1400000) * computeUnitPriceMicroLamports`. If `auto` is used, Jupiter will automatically set a priority fee and it will be capped at 5,000,000 lamports / 0.005 SOL.
    - integer
    - 'auto'
  - `prioritizationFeeLamports` union — \* PriorityFeeWithMaxLamports is impossible to be typed. Prioritization fee lamports paid for the transaction in addition to the signatures fee. Mutually exclusive with compute_unit_price_micro_lamports. If `auto` is used, Jupiter will automatically set a priority fee and it will be capped at 5,000,000 lamports / 0.005 SOL.
    - integer
    - 'auto'
  - `asLegacyTransaction` boolean — Default is false. Request a legacy transaction rather than the default versioned transaction, needs to be paired with a quote using asLegacyTransaction otherwise the transaction might be too large.
  - `useTokenLedger` boolean — Default is false. This is useful when the instruction before the swap has a transfer that increases the input token amount. Then, the swap will just use the difference between the token ledger token amount and post token amount.
  - `destinationTokenAccount` string — Public key of the token account that will be used to receive the token out of the swap. If not provided, the user's ATA will be used. If provided, we assume that the token account is already initialized.
  - `dynamicComputeUnitLimit` boolean — When enabled, it will do a swap simulation to get the compute unit used and set it in ComputeBudget's compute unit limit. This will increase latency slightly since there will be one extra RPC call to simulate this. Default is `false`.
  - `skipUserAccountsRpcCalls` boolean — When enabled, it will not do any rpc calls check on user's accounts. Enable it only when you already setup all the accounts needed for the trasaction, like wrapping or unwrapping sol, destination account is already created.
  - `programAuthorityId` integer — The program authority id [0;7], load balanced across the available set by default
  - `allowOptimizedWrappedSolTokenAccount` boolean — Default is false. Enabling it would reduce use an optimized way to open WSOL that reduce compute unit.
  - `quoteResponse` QuoteResponse, required
    - `inputMint` string, required
    - `inAmount` string, required
    - `outputMint` string, required
    - `outAmount` string, required
    - `otherAmountThreshold` string, required
    - `swapMode` 'ExactIn' | 'ExactOut', required
    - `slippageBps` integer, required
    - `computedAutoSlippage` integer
    - `platformFee` PlatformFee
      - `amount` string
      - `feeBps` integer
    - `priceImpactPct` string, required
    - `routePlan` RoutePlanStep[], required
      - `swapInfo` SwapInfo, required
        - `ammKey` string, required
        - `label` string
        - `inputMint` string, required
        - `outputMint` string, required
        - `inAmount` string, required
        - `outAmount` string, required
        - `feeAmount` string, required
        - `feeMint` string, required
      - `percent` integer, required
    - `contextSlot` number
    - `timeTaken` number
  - `dynamicSlippage` object
    - `minBps` integer
    - `maxBps` integer
  - `blockhashSlotsToExpiry` number — Optional. When passed in, Swap object will be returned with your desired slots to epxiry.
  - `correctLastValidBlockHeight` boolean — Optional. Default to false. Request Swap object to be returned with the correct blockhash prior to Agave 2.0.

## Response `200`

Successful response

- SwapResponse
  - `swapTransaction` string, required
  - `lastValidBlockHeight` number, required
  - `prioritizationFeeLamports` number
  - `dynamicSlippageReport` object
    - `amplificationRatio` string
    - `otherAmount` integer
    - `simulatedIncurredSlippageBps` integer
    - `slippageBps` integer
    - `categoryName` 'stable' | 'lst' | 'bluechip' | 'verified'
    - `heuristicMaxSlippageBps` integer

## Changes

- **2024-11-08** `60b54df3a485` — 2 info
  - added the optional property `dynamicSlippageReport/categoryName` to the response with the `200` status
  - added the optional property `dynamicSlippageReport/heuristicMaxSlippageBps` to the response with the `200` status
- **2024-09-30** `0aa85ac2905b` — 1 info
  - added the new optional request property `correctLastValidBlockHeight`
- **2024-09-30** `53cb30422626` — 1 info
  - added the new optional request property `blockhashSlotsToExpiry`
- **2024-08-14** `6ba4cc1dd86f` — 2 info
  - added the new optional request property `dynamicSlippage`
  - added the optional property `dynamicSlippageReport` to the response with the `200` status
- **2024-08-08** `950ef4cf1592` — 1 info
  - added the new optional request property `allowOptimizedWrappedSolTokenAccount`

[Full history](https://skmtc.dev/jup-ag/apis/swap-api/changes/swap/post.md)

---

[API](https://skmtc.dev/jup-ag/apis/swap-api.md) · [All operations](https://skmtc.dev/jup-ag/apis/swap-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/jup-ag/swap-api/revisions/ea5cff499615/schema)
