Attaches a payment source to a flow. Supports three source types: wallet, exchange, and deposit_address. Returns the updated flow and a session token that authenticates all subsequent calls for this flow.
Call attachFlowSource only when executionState is initiated, source_attached, quoted, or signing. Re-attaching before broadcast lets the user change the source and rotates the flow session token.Before restoring or retrying a flow, call getFlow and check its current state.
Do not call attachFlowSource after broadcasted or source_confirmed.
Poll the existing flow instead. If the flow is cancelled, expired, or
failed, create a new flow for another attempt. Reusing a confirmed flow
returns 409 because source_confirmed → source_attached is not a valid
execution-state transition.
User pays from a CEX balance (e.g. Coinbase). The response includes an exchange buy URL to redirect the user to. No sanctions screening: the exchange KYCs the funder.
A unique deposit address is generated for the flow. The user sends funds directly to it: no wallet connection required. Works for BTC, SOL, EVM, and TRON. Call getFlowQuote after attaching to get the depositAddress, which you can display as a QR code or copy string.
Parameter
Type
Description
flowId
string
The flow ID.
sourceType
'deposit_address'
Indicates a deposit address source.
fromChainName
Chain
Chain family the user will send from: 'EVM', 'SOL', 'BTC', 'TRON'.
fromChainId
string
Network ID for the origin chain (e.g., '1' for BTC, '101' for SOL, '8453' for Base).
refundAddress
string
Where to return funds if the transfer fails.
Do not pass fromAddress with sourceType: 'deposit_address': the API returns 400.
import type { Flow } from '@dynamic-labs-sdk/client';type FlowSourceResponse = { flow: Flow; sessionToken: string; sessionExpiresAt: string; // ISO 8601 — when the session token expires};
No wallet connection or signing required. After attaching the source, call getFlowQuote to get the deposit address to show the user.
import { attachFlowSource, getFlowQuote } from '@dynamic-labs-sdk/client';await attachFlowSource({ flowId: 'your-flow-id', sourceType: 'deposit_address', fromChainId: '1', fromChainName: 'BTC', refundAddress: 'bc1q...', // where to return funds if the transfer fails});const quoted = await getFlowQuote({ flowId: 'your-flow-id' });const depositAddress = quoted.depositAddress;// Show depositAddress to the user — they send funds to it from any wallet or exchange