Integration flows
Each flow is the order in which a client calls the API for one job. Steps run top to bottom. A box's colour shows the transport — green for /info, blue for WebSocket, yellow for /exchange — and signed actions say which key signs them. See Signing for the two signing flows.
Set up an account
Every account completes these steps once, in this order, before its agent key can trade:
- Deposit USDC — see Deposit USDC below.
- Approve a builder code with the user's wallet —
approveBuilderFee. - Approve the agent with the user's wallet —
approveAgent.
Three one-time steps, in this order. The user’s wallet signs both approvals; the agent then signs every trade.
- USDC
Deposit USDCFund the account. On testnet,
POST /request-fundcredits test USDC to the perp account. - POST /exchangeAccount-signed
approveBuilderFeeSigned by the user’s wallet. Approves the builder you trade through, up to
maxFeeRate.Builder approved
- POST /exchangeAccount-signed
approveAgentSigned by the user’s wallet. Authorizes the agent key that signs trading actions.
Agent authorized
- Do all of these
Deposit USDC
Look up Bridge2, fund it one of three ways, then confirm the balance.
- Pick one of 3POST /infoAccount-signed
depositWithPermitUser has no ETH: sign an EIP-2612 permit and the API host submits it.
Place and track a perp order
With the account set up, the agent signs every order. Watch the order on the stream; reconcile from history.
- POST /exchangeAgent-signed
orderAgent-signed. One action can carry a batch of orders, applied in order.
One
successfor the whole action — the oid and fills come from the stream below - Do all of these
- POST /info
userFillsExecutions for history and reconciliation. Indexed, so it can lag the stream briefly.
Trade an Outcome market
Fund the Outcome sub-account, place the order, then follow two channels on two endpoints.
A successful order response can mean queued, not matched. Subscribe to both channels in step 4, or a rejected queue entry looks like an order that never filled.
- POST /exchangeAccount-signed
tokenSendMove USDC from
perptooutcome. Account-signed; an agent cannot move funds. - POST /exchangeAgent-signed
orderais theinstrument_id;b/rencode the leg (buy NO =b: false, r: false) andpis that leg's price. TIFGtc,Gtd, orAlo—Iocis rejected.Possibly an async acceptance with a
traceId - Do all of these
- POST /info
outcomePositionsPositions only — no margin summary. Use
clearinghouseStatewithaccountType=outcomefor that.
The Outcome Integration Guide walks through the same flow with request examples.
Withdraw funds
USDC to Arbitrum has its own action; everything else goes out through a TxRelay peg.
- Pick one of 2TxRelay
deposit-addressOther chains: request a peg address with
src_chain: "txflow", then send to it withtokenSend.
Earn builder fees
Each user approves a cap once; your orders carry the fee; you claim what accrues.
If the user has not approved you, or the fee exceeds the cap, the builder fee is silently ignored and the order still goes through.
- POST /exchangeAccount-signed
approveBuilderFeeSigned by the user’s account key, once per builder. Sets
maxFeeRate. - POST /exchangeAgent-signed
orderAdd the action-level
builderobject (baddress,ffee) besideorders.
See Builder Technical Documentation for fee caps and eligibility.