curl --request POST \
--url https://api.soroswap.finance/swap \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"assetIn": "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA",
"assetOut": "CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV",
"amount": "10000000",
"tradeType": "EXACT_IN",
"protocols": [
"soroswap",
"aqua",
"sdex"
],
"slippageBps": "50",
"from": "GBQJ4HBCQHJQKSKNT3JRKC5VKA3QJUXBVFWIVSMHKPQSJ7XP2IXTCAAK"
}
'{
"quote": {},
"xdr": "AAAAAgAAAAB8shYDi1JO9x2/3jMeVzK2IGtrsFVWLCL4uHRJf+YPyAAAA+gCzi7H...",
"action": "SIGN_TRANSACTION",
"message": "Sign the transaction with the user wallet and send the signed XDR to /send endpoint or your own rpc",
"actionData": {},
"simulated": false,
"prerequisites": [
{
"action": "CREATE_TRUSTLINE",
"xdr": "AAAAAgAAAABiSu3MsKtQvDuQO5i2b...",
"signer": "GBQJ4HBCQHJQKSKNT3JRKC5VKA3QJUXBVFWIVSMHKPQSJ7XP2IXTCAAK",
"assetCode": "USDC",
"assetIssuer": "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
"description": "<string>"
}
]
}Swap (all-in-one)
Quotes, builds and simulates a swap in a single call: the equivalent of calling /quote and then /quote/build.
Send the same parameters as /quote plus the wallet address (from, a G account or C contract). The response always includes the quote, plus an action field telling you what to do next:
- SIGN_TRANSACTION β
xdris the simulated swap transaction, ready to be signed and sent to /send or your own rpc. - CREATE_TRUSTLINE β the account is missing a trustline for the output asset.
xdris a changeTrust transaction: sign it, submit it, then call this endpoint again to get the swap XDR. Details (signer, assetCode, assetIssuer) come inactionData. - Other actions (e.g. RESTORE_BALANCE) follow the same pattern:
xdris the transaction that resolves the action.
π¦ Inline prerequisites
Pass inlinePrerequisites: true to always receive the swap XDR in a single call, even when a trustline is missing. Instead of a CREATE_TRUSTLINE action, the trustline transaction comes in a prerequisites array: sign and submit each prerequisite in order, then handle the swap XDR according to simulated:
simulated: true(SDEX routes) β the swap XDR is complete; sign it and send it.simulated: false(Soroban routes) β simulation cannot succeed until the trustline exists, so the swap XDR has no footprint, resource fees or auth entries. Re-simulate and assemble it (footprint, resources and auth entries are regenerated automatically), or override sequence and Soroban resources yourself, before signing and sending. Submitting it as-is will fail.
The swap XDRβs sequence number already accounts for the prerequisite transactions when they share the same source account. Only the missing-trustline case becomes a prerequisite; other actions (e.g. RESTORE_BALANCE) keep the action flow described above.
β‘ Gasless Trustline
Pass gaslessTrustline: "create" together with a sponsor address to get a single SDEX transaction that opens the trustline and swaps. The returned XDR must be signed by both the user and the sponsor.
Note: The two-step Soroban sponsored flow (user signature + fee bump) is not supported here β use /quote and /quote/build for that.
π° Fees
feeBps and referralId are accepted for compatibility and ignored: the fee comes from your authenticated principalβs partner rate, and fee destinations are no longer caller-supplied. The values you send are recorded so Soroswap can seed your profile and propose your payout address. The quote includes platformFee only when a partner rate applies.
curl --request POST \
--url https://api.soroswap.finance/swap \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"assetIn": "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA",
"assetOut": "CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV",
"amount": "10000000",
"tradeType": "EXACT_IN",
"protocols": [
"soroswap",
"aqua",
"sdex"
],
"slippageBps": "50",
"from": "GBQJ4HBCQHJQKSKNT3JRKC5VKA3QJUXBVFWIVSMHKPQSJ7XP2IXTCAAK"
}
'{
"quote": {},
"xdr": "AAAAAgAAAAB8shYDi1JO9x2/3jMeVzK2IGtrsFVWLCL4uHRJf+YPyAAAA+gCzi7H...",
"action": "SIGN_TRANSACTION",
"message": "Sign the transaction with the user wallet and send the signed XDR to /send endpoint or your own rpc",
"actionData": {},
"simulated": false,
"prerequisites": [
{
"action": "CREATE_TRUSTLINE",
"xdr": "AAAAAgAAAABiSu3MsKtQvDuQO5i2b...",
"signer": "GBQJ4HBCQHJQKSKNT3JRKC5VKA3QJUXBVFWIVSMHKPQSJ7XP2IXTCAAK",
"assetCode": "USDC",
"assetIssuer": "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
"description": "<string>"
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Query Parameters
Network on which the operation will be performed
testnet, mainnet Body
Data required to quote and build the swap
Input asset contract address
"CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA"
Output asset contract address
"CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75"
Expected input amount in stroops
"10000000"
Type of trade: EXACT_IN = input fixed; EXACT_OUT = output fixed
EXACT_IN, EXACT_OUT "EXACT_IN"
Array of protocols to aggregate liquidity from
["soroswap", "aqua"]
The wallet address (G account or C contract) that will send the funds and sign the transaction
"GBQJ4HBCQHJQKSKNT3JRKC5VKA3QJUXBVFWIVSMHKPQSJ7XP2IXTCAAK"
Number of route splits for optimization. Higher values improve price discovery but increase latency. Max: 1000..
10
Slippage tolerance in basis points (bps). 10000 = 100%, 100 = 1%, 50 = 0.5%. Default is 50 bps (0.5%)
"50"
Maximum number of hops to aggregate liquidity from
2
Restricts intermediate tokens to a specific list. Only useful for Soroban transactions (Router and Aggregator). Not useful for SDEX.
[
"SOROSWAP",
"STELLAR_EXPERT",
"AQUA",
"LOBSTR"
]
Ignored. Your fee rate lives in your partner profile (see GET /partner). Kept for wire compatibility; the value you send is recorded so Soroswap can seed your profile.
50
Whether to use gasless trustline swap. Only use this if you are sure that the user does not have a trustline for the output asset and if you have an sponsor account.
true
The wallet address that will receive the funds. Defaults to the from address. Must equal from when gaslessTrustline is enabled
Ignored. Fee destinations are no longer caller-supplied; the value you send is recorded so Soroswap can propose your payout address.
The wallet address that will sponsor the trustline. Only supported for the Gasless Trustline (SDEX) flow
When true and a trustline is missing, the response still contains the swap XDR: the trustline transaction is returned in a prerequisites array instead of replacing the swap. Prerequisites must be signed and submitted in order first. For Soroban routes the swap XDR is returned unsimulated (simulated: false) since simulation cannot succeed until the trustline exists β re-simulate it (or override sequence and Soroban resources) before submitting
true
Response
Quote and transaction (or required action) returned successfully
The quote for the swap, same schema as the /quote response
Unsigned transaction XDR: the swap when action is SIGN_TRANSACTION, or the transaction that resolves the required action (e.g. a changeTrust for CREATE_TRUSTLINE)
"AAAAAgAAAAB8shYDi1JO9x2/3jMeVzK2IGtrsFVWLCL4uHRJf+YPyAAAA+gCzi7H..."
What to do next with the returned XDR
SIGN_TRANSACTION, CREATE_TRUSTLINE, RESTORE_BALANCE, RESTORE_CONTRACT "SIGN_TRANSACTION"
Human-readable explanation of the required action
"Sign the transaction with the user wallet and send the signed XDR to /send endpoint or your own rpc"
Extra details when action is not SIGN_TRANSACTION (e.g. signer, assetCode, assetIssuer for CREATE_TRUSTLINE)
Only present in inline-prerequisites mode. false means the swap XDR was built without simulation (no footprint, resource fees or auth entries) and must be re-simulated and assembled before submission
false
Only present in inline-prerequisites mode: transactions to sign and submit, in order, before the swap XDR
Show child attributes
Show child attributes