Guides, route-group overviews, and live schema entry points for the Plexichat backend.
Gateway opcodes
The backend defines gateway opcodes in src/api/websocket/opcodes.py (GatewayOpcode). Clients send opcodes to the server; the server sends opcodes to clients.
Core lifecycle opcodes
These opcodes manage the connection lifecycle. See Connection for the full flow.
Value
Name
Direction
Purpose
0
DISPATCH
Server → client
Deliver a dispatch event (t and s fields).
1
HEARTBEAT
Client → server
Heartbeat with the last sequence number or null.
2
IDENTIFY
Client → server
Authenticate a new session with token, intents, and properties.
3
PRESENCE_UPDATE
Client → server
Update presence.
4
VOICE_STATE_UPDATE
Client → server
Update voice state.
6
RESUME
Client → server
Resume a prior session with token, session_id, and seq.
7
RECONNECT
Server → client
Request that the client reconnect and resume.
8
REQUEST_GUILD_MEMBERS
Client → server
Request guild member chunks.
9
INVALID_SESSION
Server → client
Session is not resumable as sent (d: false) or can be retried (d: true).
Artifacts are collaborative canvases such as whiteboards and live code editors. Sums are collaborative PlexiSum workbooks. Both families use the same subscribe, operation, and sync pattern. For close handling, see Close codes.
Value
Name
Purpose
60
ARTIFACT_SUBSCRIBE
Subscribe to an artifact's live updates.
61
ARTIFACT_UNSUBSCRIBE
Unsubscribe from an artifact.
62
ARTIFACT_OP
Apply an operation to an artifact.
63
ARTIFACT_SYNC
Request or receive full artifact state sync.
64
SUM_SUBSCRIBE
Subscribe to a PlexiSum workbook.
65
SUM_UNSUBSCRIBE
Unsubscribe from a workbook.
66
SUM_OP
Apply an operation to a workbook.
67
SUM_SYNC
Request or receive full workbook state sync.
68
ARTIFACT_OP_REJECTED
Server → client: a stale ARTIFACT_OP was refused. Re-fetch and re-base.
ARTIFACT_OP_REJECTED (68) is the only server-only fabric rejection
opcode. An edit operation (op: 62) whose rev is older than the
artifact's committed revision is not persisted and not relayed: a concurrent
write already landed, so relaying it would let peers re-apply superseded
full-content edits. The server sends this frame instead, echoing the rejected
operation so the client can match it against its own client_id.
Treat it as "discard my optimistic edit and reload": request an
ARTIFACT_SYNC (63) for the artifact, apply the returned snapshot and
rev, then re-apply the edit locally. Operations that carry no numeric rev
(strokes, cursors, transcription deltas) and the equal-rev echo of your own
just-committed write are never rejected.
How to use opcodes
As a client, you primarily send IDENTIFY, HEARTBEAT, RESUME, and optional state-change opcodes such as PRESENCE_UPDATE, TYPING_START, and fabric opcodes.
The server primarily sends HELLO, HEARTBEAT_ACK, RECONNECT, INVALID_SESSION, and DISPATCH.
Always check the opcode value against GatewayOpcode in src/api/websocket/opcodes.py before implementing custom handling. Unknown opcodes close the connection with 4001 UNKNOWN_OPCODE (resumable).