This is an old revision of the document!
Connecting and Authenticating
WebSocket Connection
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.
Heartbeat
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
Authentication
The first message you send must be a LoginRequest (wrapped in a ClientMessage). Authenticate with either method:
- API key — set
api_keyonly. - 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— aLoginResult. Anything other thanLOGIN_RESULT_SUCCESSmeans login failed; readerror_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.
Authentication Token
LoginResponse may include an authentication_token, and you can request a fresh one at any time:
- Send
AuthenticationTokenRequestwith arequest_id. - Receive
AuthenticationTokenwithtokenandexpire_time(orfail_message).
The token authenticates to T4 REST services. It does not resume a dropped WebSocket session — you re-authenticate on reconnect.
Reconnection & Session Handling
Sessions are not resumable. On any disconnect:
- Reconnect to the endpoint.
- Send
LoginRequestagain. - 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.