developers:apiv2:connecting

This is an old revision of the document!


Connecting and Authenticating

Clients must connect using WebSocket Secure (WSS) over SSL/TLS on port 443. Messages are encoded with Google Protocol Buffers.

Environment WebSocket URL
Simulator wss://wss-sim.t4login.com/v1
Simulator (Admin) wss://wssadmin-sim.t4login.com/v1
Live wss://wss.t4login.com/v1
Live (Admin) wss://wssadmin.t4login.com/v1

Develop and certify against the Simulator.

To maintain an active connection, both the client and server must send a heartbeat message every 20 seconds. If no other message is sent during that interval, the server will send a heartbeat automatically. If the server does not receive any message for 3 consecutive heartbeat intervals, it will terminate the connection.

// ClientMessage
heartbeat { timestamp: 1725600000000 }   // UTC epoch milliseconds

The first message you send must be a LoginRequest (wrapped in a ClientMessage). Authenticate with either method:

  • API key — set api_key only.
  • Username / password — set firm, username, password, app_name, app_license.

Optionally set price_format to choose how prices are formatted (see Pricing and Data Types).

// ClientMessage
login_request {
  api_key: "YOUR_API_KEY"
  price_format: PRICE_FORMAT_DECIMAL
}

The server replies with a LoginResponse:

  • result — a LoginResult. Anything other than LOGIN_RESULT_SUCCESS means login failed; read error_message.
  • session_id, user_id, firm_id, roles — session identity and permissions.
  • exchanges — the exchanges and market data you are entitled to.
  • accounts — the accounts you can view and trade.
  • authentication_token (optional) — a short-lived token for T4 REST services.

Order routing requires the appropriate role. Without it, market-data and account subscriptions still work, but order submissions are rejected.

LoginResponse may include an authentication_token, and you can request a fresh one at any time:

  • Send AuthenticationTokenRequest with a request_id.
  • Receive AuthenticationToken with token and expire_time (or fail_message).

The token authenticates to T4 REST services. It does not resume a dropped WebSocket session — you re-authenticate on reconnect.

Sessions are not resumable. On any disconnect:

  1. Reconnect to the endpoint.
  2. Send LoginRequest again.
  3. Re-subscribe to markets and accounts, and reconcile order state from the account snapshot.

Maintenance: connections are dropped for scheduled maintenance every week (shutting down at midnight on Friday), resuming Sunday morning. Build automatic reconnect-and-resubscribe into your client.

  • developers/apiv2/connecting.1788792912.txt.gz
  • Last modified: 2026/09/07 14:55
  • by chad