Skip to main content
POST
/
v1
/
swap
/
swap
curl --request POST \ --url https://payments.magicblock.app/v1/swap/swap \ --header 'Content-Type: application/json' \ --data ' { "userPublicKey": "3rXKwQ1kpjBd5tdcco32qsvqUh1BnZjcYnS5kYrP7AYE", "quoteResponse": { "inputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "inAmount": "1000000", "outputMint": "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", "outAmount": "999519", "otherAmountThreshold": "994522", "swapMode": "ExactIn", "slippageBps": 50, "priceImpactPct": "0", "routePlan": [] } } '
{ "swapTransaction": "AQABA...base64...", "lastValidBlockHeight": 318120000 }

Body

application/json
userPublicKey
string
required

Public key of the wallet that will sign the swap transaction.

Example:

"3rXKwQ1kpjBd5tdcco32qsvqUh1BnZjcYnS5kYrP7AYE"

quoteResponse
object
required

Quote response from GET /v1/swap/quote.

payer
string

Optional fee payer for transaction fees and rent.

Example:

"3rXKwQ1kpjBd5tdcco32qsvqUh1BnZjcYnS5kYrP7AYE"

wrapAndUnwrapSol
boolean

Automatically wrap and unwrap native SOL when needed.

Example:

true

useSharedAccounts
boolean

Allow shared accounts for intermediate routing state.

Example:

true

feeAccount
string

Optional initialized token account used to collect platform fees.

trackingAccount
string

Optional public key used for downstream transaction tracking.

prioritizationFeeLamports

Optional priority fee configuration or fixed lamport amount.

Required range: x >= 0
asLegacyTransaction
boolean

Build a legacy transaction instead of a versioned one. Not allowed when visibility = "private".

destinationTokenAccount
string

Optional destination token account for the output mint. When visibility = "private", this is server-controlled and must match the derived stash ATA.

nativeDestinationAccount
string

Optional destination account for native SOL output. Not supported when visibility = "private".

dynamicComputeUnitLimit
boolean

Estimate compute usage and set the compute unit limit automatically.

skipUserAccountsRpcCalls
boolean

Skip extra RPC checks for required user accounts.

dynamicSlippage
boolean

Let the upstream swap builder overwrite slippage on the transaction.

computeUnitPriceMicroLamports
integer

Optional exact compute unit price in micro-lamports.

Required range: x >= 0
blockhashSlotsToExpiry
integer

Optional transaction expiry window in slots.

Required range: x >= 0
positiveSlippage
object

Optional positive slippage collection settings.

visibility
enum<string>

public (default) proxies Jupiter/Metis as-is. private routes the output through a scheduled private transfer.

Available options:
public,
private
Example:

"public"

destination
string

Final private-transfer recipient (wallet pubkey). Required when visibility = "private".

minDelayMs
string

Earliest (ms) the queued transfer may settle. Required when visibility = "private".

Pattern: ^\d+$
Example:

"0"

maxDelayMs
string

Latest (ms) the queued transfer may settle. Required when visibility = "private". Must be >= minDelayMs and <= 600000 (10 minutes).

Pattern: ^\d+$
Example:

"60000"

split
integer

Number of queue entries to split the transfer across. Required when visibility = "private". Must be between 1 and 14.

Required range: 1 <= x <= 14
clientRefId
string

Optional u64 client correlation id attached to each queued split.

Pattern: ^\d+$
validator
string

Optional validator pubkey for the transfer-queue PDA. Defaults to the well-known MagicBlock validator (MAS1Dt9qreoRMQ14YQuhg8UTZMMzDdKhmkZMECCzk57).

Response

Swap transaction

swapTransaction
string
required

Base64-encoded unsigned transaction.

lastValidBlockHeight
integer
Required range: x >= 0
prioritizationFeeLamports
integer
Required range: x >= 0
privateTransfer
object

Present only when visibility = "private". Diagnostic metadata about the appended schedule_private_transfer instruction.