developers:apiv2:connecting

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/v2
Simulator (Admin) wss://wssadmin-sim.t4login.com/v2
Live wss://wss.t4login.com/v2
Live (Admin) wss://wssadmin.t4login.com/v2

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

Authentication must be performed immediately after establishing a connection by sending a `LoginRequest` message. This API supports two authentication methods: - API Key Authentication (provide only the `apikey` field). - Username/Password Authentication (send `firm`, `username`, `password`, `appName`, and `appLicense`).

Example LoginRequest (API Key Authentication):

{
  "apiKey": "abc123-xyz789"
}

Example LoginRequest (Username/Password Authentication):

{
  "firm": "T4Futures",
  "username": "trader123",
  "password": "securepassword",
  "appName": "CustomTradingApp",
  "appLicense": "LICENSE-4567"
}

If authentication succeeds, the server will return a `LoginResponse` with a session ID and assigned roles.

Example Successful LoginResponse:

{
  "result": "LOGIN_SUCCESS",
  "sessionId": "sess-123456789",
  "userId": "user-456",
  "firmId": "firm-789",
  "roles": ["Trader", "RiskManager"]
}

If authentication fails, the server will return an error message. Some common reasons for failure include:

LoginResult Code Meaning
`LOGIN_FAILED` Invalid credentials.
`TWO_FACTOR_REQUIRED` Two-factor authentication is required.
`UNAUTHORIZED` API key or username/password is incorrect.
`PASSWORD_EXPIRED` The password must be changed before logging in.
`LOCKED_OUT` Too many failed login attempts.

For detailed message formats, refer to the Message Catalog page.

If the connection is lost, clients should reconnect automatically and re-authenticate as session resumption is not supported. Connections remain valid as long as heartbeats are exchanged.

The system undergoes scheduled maintenance every week, shutting down at midnight on Friday and resuming service on Sunday morning. During this period, all connections will be dropped.

Once authenticated, clients can:


💡 Tip: Test your WebSocket connection using tools like `wscat` or a sample SDK.

  • developers/apiv2/connecting.txt
  • Last modified: 2026/09/07 21:58
  • by chad