A successful response returns the following fields:
curl --request POST \
--url https://api.turnkey.com/public/v1/submit/execute_swap \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header "X-Stamp: <string> (see Authorizations)" \
--data '{
"type": "ACTIVITY_TYPE_EXECUTE_SWAP_V4",
"timestampMs": "<string> (e.g. 1746736509954)",
"organizationId": "<string> (Your Organization ID)",
"parameters": {
"inputToken": "<string>",
"inputAmount": "<string>",
"outputToken": "<string>",
"sponsor": "<boolean>",
"destinationAddress": "<string>",
"evmNonce": "<string>",
"recentBlockhash": "<string>",
"gasStationNonce": "<string>",
"boundQuote": {
"quoteId": "<string>",
"quotedOutputAmount": "<string>",
"minOutputAmount": "<string>"
},
"market": {
"signWith": "<string>",
"slippageBps": "<string>",
"minOutputAmount": "<string>",
"feeSponsorship": "<boolean>",
"fixedRate": "<boolean>"
}
}
}'
import { Turnkey } from "@turnkey/sdk-server";
const turnkeyClient = new Turnkey({
apiBaseUrl: "https://api.turnkey.com",
apiPublicKey: process.env.API_PUBLIC_KEY!,
apiPrivateKey: process.env.API_PRIVATE_KEY!,
defaultOrganizationId: process.env.ORGANIZATION_ID!,
});
const response = await turnkeyClient.apiClient().executeSwap({
inputToken: "<string> (CAIP-19 asset ID for the input asset.)",
inputAmount: "<string> (Exact base-unit amount of the input asset.)",
outputToken: "<string> (CAIP-19 asset ID for the output asset.)",
sponsor: true // Whether the swap transaction is gas sponsored.,
destinationAddress: "<string> (Raw public address that receives the output asset. Required for cross-protocol swaps and rejected otherwise. The address must match the output token protocol. Wallet account IDs, private key IDs, and CAIP account or asset identifiers are not supported.)",
evmNonce: "<string> (Exact EVM sender (EOA account) nonce. Valid only for a non-sponsored EVM swap. Honored for already-delegated (Type-2) batch swaps and single-call swaps; ignored for not-yet-delegated EIP-7702 (Type-4) batches where the outer nonce is derived from the authorization. Prefer gas_station_nonce for batch replay protection and use the nonces endpoint to fetch it. Omit to auto-fetch.)",
recentBlockhash: "<string> (Exact Solana recent blockhash. Valid only for a Solana swap, including sponsored swaps. Omit to auto-fetch.)",
gasStationNonce: "<string> (Exact gas station delegate contract nonce used in the BatchExecution EIP-712 message. Valid for sponsored EVM swaps and non-sponsored EVM swaps that execute as a multi-call batch (for example ERC-20 approve + swap). This is the replay-protection nonce for gas-station batches; use the nonces endpoint to fetch it. Omit to auto-fetch.)",
boundQuote: { // boundQuote field,
quoteId: "<string> (Quote identifier returned by create_swap_quote. Execution is bound to this quote; the signer is derived from the quote and must not be resupplied.)",
quotedOutputAmount: "<string> (Exact quoted base-unit output amount committed by the quote.)",
minOutputAmount: "<string> (Exact minimum base-unit output committed by the quote.)",
},
market: { // market field,
signWith: "<string> (Wallet account address that sends the input asset. Private Key identifiers are not supported.)",
slippageBps: "<string> (Maximum allowed slippage in basis points, at most 5000. When omitted, the provider chooses the slippage. The swap executes at the provider's price when the activity is approved, so the slippage and min_output_amount are its only price protection.)",
minOutputAmount: "<string> (Optional price floor in base units of the output asset. When set, the swap fails unless the provider's minimum output after slippage is at least this amount.)",
feeSponsorship: true // When true, Turnkey pays the execution costs for this swap and invoices them to the billing parent organization as Swap Execution. Requires the FEATURE_NAME_SWAP_FEE_SPONSORSHIP organization feature. Defaults to false.,
fixedRate: true // When true, requests a 1:1 conversion before fees between supported stablecoins. Requires the FEATURE_NAME_SWAP_FIXED_RATE organization feature. Defaults to false.,
}
});
{
"activity": {
"id": "<activity-id>",
"status": "ACTIVITY_STATUS_COMPLETED",
"type": "ACTIVITY_TYPE_EXECUTE_SWAP_V4",
"organizationId": "<organization-id>",
"timestampMs": "<timestamp> (e.g. 1746736509954)",
"result": {
"activity": {
"id": "<string>",
"organizationId": "<string>",
"status": "<string>",
"type": "<string>",
"intent": {
"executeSwapIntentV4": {
"inputToken": "<string>",
"inputAmount": "<string>",
"outputToken": "<string>",
"sponsor": "<boolean>",
"destinationAddress": "<string>",
"evmNonce": "<string>",
"recentBlockhash": "<string>",
"gasStationNonce": "<string>",
"boundQuote": {
"quoteId": "<string>",
"quotedOutputAmount": "<string>",
"minOutputAmount": "<string>"
},
"market": {
"signWith": "<string>",
"slippageBps": "<string>",
"minOutputAmount": "<string>",
"feeSponsorship": "<boolean>",
"fixedRate": "<boolean>"
}
}
},
"result": {
"executeSwapResult": {
"swapRequestId": "<string>",
"provider": "<string>",
"quoteId": "<string>",
"outputAmount": "<string>",
"minOutputAmount": "<string>",
"feeSponsorship": "<boolean>",
"fixedRate": "<boolean>",
"estimatedCharges": {
"executionUsd": "<string>",
"turnkeyFeeUsd": "<string>",
"fixedRateAdjustmentUsd": "<string>"
}
}
},
"votes": "<array>",
"fingerprint": "<string>",
"canApprove": "<boolean>",
"canReject": "<boolean>",
"createdAt": "<string>",
"updatedAt": "<string>"
}
}
}
}