Connecting
| Environment | URL |
|---|---|
| Production | wss://ws.templedigitalgroup.com/v1/stream |
| Development | wss://ws-dev.templedigitalgroup.com/v1/stream |
Pass your API key in the X-API-Key header when connecting. Authentication happens automatically on the WebSocket handshake.
X-API-Key: your-api-key-here
Connections without a valid API key are rejected with HTTP 401.
API key rules
API keys follow the same rules as the REST API. A valid key is still refused when:
- the account is locked or suspended (
ACCOUNT_LOCKED) - the account is restricted to withdraw-only access (
ACCOUNT_WITHDRAW_ONLY) - the account has an IP allowlist and your IP is not on it (
IP_ALLOWLIST_DENIED) - trading is halted for maintenance (
MAINTENANCE_MODE) - the key lacks the
readscope (INSUFFICIENT_SCOPE). A key with no scopes stored hasreadandwrite;writeincludesread.
These apply to streaming as well as to orders: if you use an IP allowlist, every system that connects must be on it. A refusal at connect is remembered for 5 seconds per key and IP address, so a retry within that time gets the same answer, even if the account was just unlocked.
Placing and cancelling orders also needs the write scope. See Placing and cancelling orders.
Handshake errors
Rejections during the handshake are plain-text HTTP responses:
| Status | Body | What to do |
|---|---|---|
| 401 | Authentication required | Check your API key. Repeated 401s lead to 429. |
| 403 | <CODE>: <message>, for example ACCOUNT_LOCKED: Account is locked or suspended | The key is valid but not allowed (see API key rules). Does not count as a failed attempt. |
| 403 | Forbidden | An Origin header that is not one of ours, sent by a browser page on another site. Clients that send no Origin (bots, servers) are not affected. Counts as a failed attempt. |
| 503 | MAINTENANCE_MODE: ... | Trading is halted. Retry after the Retry-After seconds. |
| 429 | Too many connections from this IP | Close connections you do not need, then retry. |
| 429 | Too many failed connection attempts | Wait for the Retry-After seconds before trying again. |
After 5 failed attempts from one IP address, only one attempt is allowed every 30 seconds. See Rate limits.
Credential expiry and revocation
Open connections are re-checked against their credential about once a minute, and the API key rules above are applied again each time. When the credential is no longer valid or allowed (API key revoked or regenerated, account locked, and so on), the server sends an auth_expired message with a reason, then closes the connection with close code 4008 and the reason as close text. Reconnect with a valid credential. Private user events stop at that point.
{"type":"auth_expired","reason":"api_key_revoked","message":"API key revoked or regenerated, please re-authenticate"}reason | Meaning |
|---|---|
api_key_revoked | The API key was revoked or regenerated. |
credential_check_failed | The credential could not be verified for three consecutive checks. |
account_locked | The account was locked or suspended. |
withdraw_only | The account was restricted to withdraw-only access. |
ip_allowlist | The account's IP allowlist no longer includes you. |
maintenance_mode | Trading was halted. |
insufficient_scope | The key no longer has the scope the connection needs. |
Connections authenticated with a web-app login (JWT) can also get token_expired and session_revoked.
Re-authenticating on an open connection
This is usually not needed, because the X-API-Key header authenticates the connection. To re-authenticate an existing connection, send:
{"type":"auth","api_key":"your-api-key-here"}If the key is valid but not allowed, the server sends an error with the refusal code (for example ACCOUNT_LOCKED), then closes the connection with close code 1008.
Updated 3 days ago

