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
}Swap
Swap
Build an unsigned swap transaction from a quote.
Visibility modes:
visibility: "public"(default) — pure pass-through to the Jupiter/Metis upstream. The returned transaction is whatever the upstream produces.visibility: "private"— the server forces Jupiter’s output into a program-owned stash ATA (deterministically derived from(userPublicKey, quoteResponse.outputMint)), prepends an idempotent ATA-create, and appends aschedule_private_transferinstruction that registers a one-shot Hydra crank. When the crank fires, it self-CPIs into the on-chain private-transfer flow to deliver the swapped tokens todestinationwith the requested delay/split policy. The returned transaction is a v0VersionedTransactionthat is still unsigned — the client signs and submits.
When visibility = "private", the fields destination, minDelayMs, maxDelayMs, and split are required. clientRefId and validator are optional. Explicitly setting destinationTokenAccount to anything other than the server-derived stash ATA returns 400.
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
Response
Swap transaction
Was this page helpful?

