Skip to main content
Prerequisites:
  • The parent organization must be Pay As You Go, Pro, or Enterprise.
  • ACTIVITY_TYPE_UPSERT_SWAP_CONFIG is optional. Without a swap configuration, quotes default to a client fee of 0.
  • The signing address (signWith) is a wallet account address or a private key address in the organization submitting the activity. Private key identifiers are not supported. Parent organization wallets and sub-organization wallets can both swap: the activity belongs to the organization that owns the wallet. In a delegated access setup, a delegate can submit the activity to the wallet owner’s organization or act as the second signer on an activity submitted by the wallet owner.

Call create_swap_quote

Quoting is an activity: submit an ACTIVITY_TYPE_CREATE_SWAP_QUOTE_V2 activity with the standard envelope (type, timestampMs, organizationId) and a parameters object.
string
required
The organization that owns the swapping wallet. Parent organizations and sub-organizations can both swap; the parent’s swap configuration applies in either case.
string
required
The wallet account address or private key address that will sign and fund the swap. Private key identifiers are not supported. Quotes are computed against this address, so balances and allowances are reflected accurately.
string
required
CAIP-19 identifier for the asset being sold, e.g. eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 (USDC on Base). The origin chain is derived from this identifier.
string
required
CAIP-19 identifier for the asset being bought. If its CAIP-2 prefix matches inputToken, the swap is same-chain. A different EVM chain is cross-chain. A different protocol (eip155 vs solana) is cross-protocol (EVM ↔ SVM). Native assets use slip44:, e.g. eip155:137/slip44:966 (POL).
string
required
In raw onchain units of the input asset, e.g. "1000000" for 1 USDC at 6 decimals.
string
Optional. Slippage tolerance in basis points as a stringified integer, e.g. "50" for 0.5%. Used to compute each quote’s minOutputAmount. If you omit it, the provider applies its default and the quote returns the effective total.
string
Required for EVM ↔ SVM. Raw public address that receives the output asset. It must match the output token protocol (a Solana address for a Solana output; an EVM address for an EVM output). Omit it for same-protocol routes. Wallet account IDs, private key IDs, and CAIP identifiers are not accepted.
cURL:
cURL
JavaScript:
JavaScript
Response:

Read the response

The result contains a quotes array. Each quote is executable as-is:
  • quoteId — identifies this quote. Pass it to ACTIVITY_TYPE_EXECUTE_SWAP_V3 to execute against this quote’s pricing; execution is pinned to the quote it references.
  • provider — the provider that produced the quote and will execute the swap.
  • outputAmount — expected output in raw onchain units, net of all fees. This is what the recipient receives if the swap fills at the quoted price.
  • minOutputAmount — the floor enforced at execution, derived from outputAmount and your slippage tolerance. If the swap cannot deliver at least this amount, it fails rather than filling worse.
  • slippageBps — optional. The effective total slippage tolerance for this quote, taken from the provider response when present. If the request omitted slippageBps, the provider can calculate this value.
  • clientFeeBps — your organization’s configured fee, for display or audit. Turnkey’s fee is baked into the quoted amounts and is not itemized. See Fees.
  • estimatedTimeSeconds — optional. Provider-estimated time to settlement, when available.
  • expiresAt — millisecond epoch after which the quote can no longer be executed.

Execution price semantics

Execution is pinned to the quote: ACTIVITY_TYPE_EXECUTE_SWAP_V3 references a quoteId, and the signed intent carries that quote’s quotedOutputAmount and minOutputAmount. The economics your user signs are the economics that execute. Within those bounds, the actual fill can move:
  • minOutputAmount is the enforced floor. If the swap cannot deliver at least this amount, it will fail — the user never receives less than the floor they signed.
  • outputAmount is the expected fill, not a guarantee. The settled amount can be higher or lower than quoted, bounded on the low side by minOutputAmount. The actual amount is reported as outputAmount in swap status on COMPLETED.
  • Quotes expire. A quote can only be executed before its expiresAt; after that, request a new quote. Quotes may still be technically valid while the route the quote describes is no longer available in the market due to price movements. In that situation, if the quote cannot be executed with the economic parameters, it will fail at execution time.
Important: Neither Turnkey nor the underlying DEX aggregator guarantees execution at any quoted price. Users bear the risk of adverse price movement between the time of quote and the time of execution.

Slippage

Slippage is the difference between the price reflected in a quote and the price at which the swap actually executes onchain. It occurs because prices can move between quoting and execution. Low-liquidity pairs, large trade sizes, and periods of high network activity can increase slippage. You can set your tolerance at quote time via slippageBps, in basis points (e.g. "50" for 0.5%). If you omit it, the provider applies its default. Each quote derives its minOutputAmount from the quoted outputAmount and the effective tolerance, and the signed execute intent carries that floor. If the swap would return less than minOutputAmount, it fails rather than filling worse. Choosing a tolerance is a tradeoff worth surfacing to your users:
  • A tighter slippage tolerance reduces the risk of an unfavorable fill but increases the chance the swap fails if the market moves.
  • A wider tolerance makes execution more likely but exposes the user to a worse price, down to the floor.
  • A swap that fails on the floor still incurs gas for the reverted origin transaction. If the swap is sponsored, that cost falls on your organization, not the user — slippage-driven reverts are a gas cost to budget for in sponsored flows.
Quotes expire at expiresAt; if a quote has expired before the user confirms, request a new one rather than executing stale economics. Quotes are more likely to succeed the closer they are generated to execution time.

How fees are applied

Every quote’s outputAmount and minOutputAmount already reflect all fees — Turnkey’s and yours. There is no fee math to do on your side: the amount you display to the user is the quote’s outputAmount, and the amount they receive is the settled outputAmount from swap status. Your fee configuration is applied when the quote is created. The fee baked into a quote travels with it: executing a quote settles at that quote’s economics, even if you change your fee configuration in between. Fee changes take effect for new quotes.

Same-chain vs. cross-chain quotes

Quote shape is identical for same-chain, cross-chain, and cross-protocol routes. The CAIP-2 prefixes of inputToken and outputToken decide the route. Matching prefixes are same-chain. Different EVM chains are cross-chain. eip155 paired with solana is cross-protocol (EVM ↔ SVM). For EVM ↔ SVM, set destinationAddress on the quote. Omit it for same-protocol routes. Same-protocol quotes that include destinationAddress fail. Cross-chain and cross-protocol quotes use the same freshness and slippage rules as same-chain quotes, but execution stays PENDING longer after broadcast. The swap stays PENDING until the destination leg settles, or it becomes FAILED. Refund details on a FAILED cross-chain or cross-protocol swap can arrive after the status flip. See Track swap status.

Next steps