Pass your key as a query parameter
Browsers don’t let client code set a customAuthorization header on a WebSocket handshake, so the key travels in the URL instead. Other market-data WebSocket APIs take the same approach:
What happens on a bad key
If the key is missing, invalid, revoked, or restricted, the server rejects the handshake with a normal HTTP status code and a JSON error body, then closes the connection. It never accepts the WebSocket and disconnects you afterward:- The key has to be present and valid, or you get
MISSING_API_KEYorINVALID_API_KEY. - If your key has an IP allowlist configured, the connecting IP has to match it, exactly like REST. Otherwise you get
IP_NOT_ALLOWED. Keys with no allowlist entries accept connections from any IP. - The key’s plan has to meet the channel’s requirement. Every plan, including Free, can open WebSocket connections today, so this check doesn’t actually block anyone right now.
PLAN_REQUIREDis there for if that changes later.
Key checks run once, at connection time. Revoking a key from your developer dashboard immediately blocks any new connection attempt with it, same as REST. But a connection already open when you revoke stays open until it disconnects on its own, whether you close it or the network drops it.If a key is compromised and you need its open connections cut right away, close them yourself from wherever you opened them, right after revoking.