Connect — integration guide
Onboard a user and have them link their accounts in a hosted flow. Execution endpoints are documented separately.
Before you start
You'll get three things from us when your organization is set up:
- An API key — your
X-API-Keyfor every server-to-server call. It carries thesub_accountsentitlement (the scope that powers Connect). Shown once at creation. - A webhook secret — to verify the signed events we send you (optional, if you use webhooks).
- Your return URL(s) registered — the hosted flow may only redirect users back to a URL on your allowlist.
We provision these for you — email james@openmarkets.ai. Base URL: https://api.openmarkets.ai.
X-API-Key: om_..._live_... every call (identifies your org)
X-OpenMarkets-Account: your-user-123 scopes the call to one of your usersHow it works
POST /flow/v1/connect/link-sessionsReturns a one-time hosted_url for this user.
connect.openmarkets.aiCredentials are entered and validated here — never through you.
verify X-OpenMarkets-SignatureMark the user connected.
GET /flow/v1/auth/account/partnersBalances & positions — or trade on their behalf.
Every authenticated call sends those two headers: X-API-Key (your org) and X-OpenMarkets-Account (your id for the user).
1 · Mint a link
POST /flow/v1/connect/link-sessions
X-API-Key: om_..._live_...
{ "external_user_id": "your-user-123",
"return_url": "https://app.yourco.com/openmarkets/done" }
→ { "hosted_url": "https://connect.openmarkets.ai/start?token=lt_live_..." }Redirect the user to hosted_url. The first call also provisions the user. Add "mode":"manage" for the limits / accounts screen.
2 · Webhook
POST {your webhook_url} · X-OpenMarkets-Signature: t=..,v1=<hmac>
{ "event": "user.partners_connected", "external_user_id": "your-user-123",
"connected_partners": ["kalshi"], "delivery_id": "evt_..." }Verify the HMAC, dedupe on delivery_id. Trust the webhook, not the redirect.
3 · Read accounts
GET /flow/v1/auth/account/partners
X-API-Key: om_..._live_... · X-OpenMarkets-Account: your-user-123Connected accounts + balances. 403 = not your user.
4 · Place a trade
POST /flow/v1/auth/orders/buy
X-API-Key: om_..._live_... · X-OpenMarkets-Account: your-user-123
{ "orders": [
{ "position_hash": "<from the liquidity / quote feed>",
"amount": 50, // stake in USD — or "shares": 100
"max_price": 0.42 } // won't fill above this
]}Name the position and a price ceiling. Omit partner_id and we route to the best venue (or pass it to pin one); add "mode":"paper" for a practice fill. Strict — any other field returns 400 unknown_parameter. Each leg comes back with its fill (filled_shares, filled_notional, avg_price) and a sor_decision_id for the audit trail.
Notes
- Identity is
(your org, external_user_id)— never email. Each org's users are fully isolated. - Users set their own limits, pause accounts, and disconnect — you're read-only there.
- Prefer typed SDKs?
@openmarketsai/connect-node(server) wraps every call here;@openmarketsai/connect-webis the drop-in account-linking launcher.