Skip to main content
Every connection must authenticate before the gateway routes any command. Include the credential keys in your first command, which must be subscribe, unsubscribe, or list_subscriptions. Any other first command fails authentication. You do not need to send credentials on later commands. Authentication lasts for the life of the connection. If the connection drops, reconnect, authenticate again, and resubscribe.

Authentication

Keys are required (Y), optional (N), or conditionally required (C). Conditional keys are required based on the presence or value of other keys.
Example authenticated first command, using the test values from Signature example:
The credential keys sit at the top level of the command object, next to id, cmd, and params. See Command keys.

Signature

  1. Concatenate these strings without delimiters: time + key + "CPM_WEB_MARKETDATA" + passphrase. Use the exact time, key, and passphrase values you send.
  2. Do not trim or Unicode-normalize the API key or passphrase.
  3. Encode the concatenated text once as UTF-8.
  4. Decode your signing secret with standard Base64.
  5. Compute HMAC-SHA256 over the UTF-8 bytes, keyed with the decoded secret.
  6. Encode the 32-byte result with standard padded Base64 and send it as signature.
The command’s id, cmd, and params are not signed. The signature authenticates the whole connection.
time must be within 30 seconds of the server’s clock, inclusive, in either direction: server_time - 30 to server_time + 30.

Signature example

These are test values only. The signing secret a2V5 is the Base64 encoding of the text key. Use it only to check your signing code, and never share your real secret. Example in Python:

Authorization

Authentication succeeds when all of the following are true:
  • The signature is valid for the API key and passphrase.
  • The API key exists.
  • The API key’s user is active and has the MARKET_DATA permission.
  • The user’s Firm or FCM is active.
If authentication fails, the server sends an error with code 7 and text Unable to authenticate, then closes the WebSocket with close code 3000 and reason Unauthorized User. Open a new connection with a fresh time and signature to retry. See Errors. Example authentication failure:
A newly created or rotated API key may take up to 5 seconds to become usable.

Commands sent while authentication is pending

You can send more commands before authentication completes. The server queues them and runs them in order after authentication succeeds. See Limits for the queue size and the authentication timeout.