execute_swap returns a poll handle. Query get_swap_status with that handle to observe the full lifecycle. Same-chain and cross-chain swaps share the same endpoint and the same response shape. The endpoint normalizes provider-specific state machines to three states: PENDING, COMPLETED, FAILED.
Lifecycle model
Turnkey normalizes swap lifecycle to three states across same-chain and cross-chain routes:- PENDING: still in flight. Broadcast pending, origin transaction not yet included, or (cross-chain) destination-side execution not yet settled.
- COMPLETED: the user received the destination asset. Terminal, happy path.
- FAILED: the swap will not fill as intended. Reported only when Turnkey knows what the user holds. Terminal.
bridge_pending, delayed, submitted, and so on) collapse into PENDING on purpose. Every state maps to exactly one customer action: PENDING means wait, COMPLETED means you got the output, FAILED means look at what you hold and consider re-swapping.
Query get_swap_status
string
required
Unique identifier of the sub-organization that executed the swap.
string
required
The poll handle returned from
execute_swap.cURL
JavaScript
Response fields
status: normalized state.PENDING,COMPLETED, orFAILED.swapKind:SAME_CHAINorCROSS_CHAIN. Set at execute time; does not change.provider: the provider that executed the swap. Present when known.inputToken,outputToken,inputAmount: echoed from the execute intent.originTxHash: origin-chain transaction hash. Present once the swap is broadcast, for both same-chain and cross-chain routes.destinationTxHash: destination-chain transaction onCOMPLETED. Cross-chain only.outputAmount: actual amount received, onCOMPLETED. May lag thestatustransition by seconds while the monitor fetches the final settled amount.settledAsset,settledAmount,settlementTxHash: onFAILED. See What FAILED means.providerStatus: raw provider status passthrough for UI use. Cross-chain only. Not normative.updatedAt: last observed state change, as a Unix timestamp in milliseconds (stringified).
Same-chain vs. cross-chain differences
The response shape is identical. Only two behaviors differ in practice:- Timing. Same-chain reaches a terminal state within one block time. Cross-chain can take tens of seconds to several minutes depending on the route and bridge.
- Field population.
destinationTxHashandproviderStatusare cross-chain only. On same-chainFAILED, the settled triple derives directly from the origin transaction:settledAsset = inputToken,settledAmount = inputAmount,settlementTxHash = <revert hash>(nothing moved on-chain in a swap sense).
swapKind in the response to branch client-side handling only when it matters.
What FAILED means
FAILED is reported only when Turnkey knows what the user holds. A bridge failure with a refund still in flight stays PENDING until the refund lands (or is confirmed impossible).
On FAILED, three fields describe the outcome:
settledAsset(CAIP-19): the asset the user ended up with.settledAmount: raw on-chain amount of that asset.settlementTxHash: the on-chain transaction that settled the funds.
- Provider refunded on the origin chain:
settledAssetis the origin-chain refund token. It may differ from the original input token if the route included an origin-side swap. - Funds never left the user (e.g., origin transaction reverted):
settledAssetequalsinputToken,settledAmountequalsinputAmount,settlementTxHashis the origin transaction hash. - Nothing was recoverable:
settledAssetisnull. Internal alerts fire on this state.
settledAsset is non-null, you can call execute_swap again with the settled asset as the new input to re-attempt. Caveats worth surfacing to end users:
- The refunded amount is reduced by refund gas and any origin-side swap losses.
- A re-swap pays its own fees and slippage.
- If the refund landed on the origin chain and the original destination was on a different chain, the re-swap is again cross-chain.
Polling cadence
- Same-chain: poll every ~1 second while
PENDING. Typically settles within one block time. - Cross-chain: poll every 5 to 10 seconds while
PENDING. Settlement can take from tens of seconds to several minutes depending on route.
Next steps
- End-to-end example: full flow from enable to confirmation.
- Execute a swap: request semantics that generate the poll handle.