Skip to content
Returning.AIDocs

Broker Integrations

Returning.AI integrations have two jobs: identify the trader securely when the widget opens, then keep the loyalty engine fed with the broker events and trading facts that drive rewards.

Recommended baseline

Use Widget SDK + Access Key for the portal experience, Workflow Webhooks for identity and lifecycle events, and SQS/data-ingest for trading facts, aggregates, tier snapshots, and backfills. Read-only DB or API pull is a fallback only when the broker cannot push data.

Source of truth model

LayerOwnsTypical key
Broker portal / CRMTrader identity, account state, KYC, deposit statuscustomer_id
Trading platformMT4/MT5 login, deals, lots, symbols, PnL, account groupstrading_account_id / login
Returning.AIRewards, tiers, missions, coins, redemptions, widget statereturning_user_id plus broker identifiers

Integration options

PathUse whenTimingNotes
Widget SDK + Access KeyLogged-in client portals where the broker has a backendOn page load and every token refreshServer signs userIdentifiers into a 15-minute embed token. Browser receives only embed-token.
Workflow WebhooksRegistration, KYC, FTD, account-state events, redemptionsNear real timeHandshake first, then send the main webhook with x-session-token.
SQS Data FeedHigh-volume trading facts, backfills, hourly aggregates, CSV manifestsQueued batch or streamingUse AWS Simple Queue Service when payloads need buffering, chunking, or retry isolation.
Broker DB or API PullFallback for brokers that cannot push trading factsScheduled syncUse only when SQS/data-ingest is not available and the broker can expose a stable read-only source.
MetaTraderMT5 deal/history data or MT4 data through a broker-hosted bridgeScheduled cursor-based syncMT5 is a viable source when server access and commands are confirmed. MT4 usually needs Manager API or an export bridge.

Build order

  1. 1. Pick the trader identifier. Prefer a stable broker-owned customer ID. Map it to trading account logins separately instead of using email as the primary key.
  2. 2. Register or sync the trader. Use Workflow Webhooks for signup, KYC, FTD, and account-state events.
  3. 3. Render the widget. Mint an Access Key embed token server-side with matching userIdentifiers and put only the returned embed-token on the custom element.
  4. 4. Feed trading activity. Use SQS/data-ingest for broker-pushed trading facts, aggregates, tier snapshots, and backfills. Use read-only API/database pull only as a fallback when the broker cannot push reliably.