WSA
WebSocket API Spec
This document defines the specification for a WebSocket-based API protocol. It applies to production environments, using compressed formats.
From
- Must be either
"server"or a specificclient_id - If
fromisserver, it's the only global server - If not, it must be a valid
client_id
To
-
Can be:
"server": for messages directed to the server"client_id": when directed from a client to another client (via server proxy)"client": broadcast message to all clients (only allowed from server)
Rules
clientcan be the target (to) if the message originates from theserver, or is routed via the server from another client- A client may send a message with
to: "client", but it must be relayed through the server, which will handle authentication and authorization.
Type
Only three values are allowed:
"request""response""event"
ID
-
Message
idis chosen by the sender -
It should be the ISO8601 timestamp at the moment of sending, e.g.:
"2025-05-14T11:27:31.536370717+08:00"
This feature may be cancelled in the next version. At that time, it will be changed to a string of [a-z0-9]{5}, msg_id.
-
For
responsetype messages:idmust match the originalrequestoreventmessage's IDresponsemessages must not use a new unique ID
Request Message Structure
method: target service and versioned endpoint (e.g.auth@v1/login)params: arguments passed to backend service function
Response Message Structure
Event Message Structure
Production Format (Compressed)
Message Structure
Payload for Request/Event
Payload for Successful Response
Payload for Failure Response
This format is optimized for bandwidth-sensitive environments by shortening keys and values. It is strongly recommended to use the verbose version during development and the compact version in production deployments.