Skip to content

WebSocket

Zlikord uses WebSocket for real-time messaging, presence, and voice signaling.

WS /api/ws?token=<jwt_token>

Pass your JWT token as the token query parameter. On successful connection, you will receive a READY event:

{ "type": "READY" }

Send JSON messages to the server with an op field.

Subscribe to events for a room (channel or DM thread).

{
"op": "SUBSCRIBE",
"room": "channel:42"
}

Room format:

  • channel:<id> — a guild text or voice channel
  • dm:<id> — a direct message thread

Response:

{ "type": "SUBSCRIBED", "room": "channel:42" }

If you lack access:

{ "type": "ERROR", "data": "forbidden room" }
{
"op": "UNSUBSCRIBE",
"room": "channel:42"
}

Response:

{ "type": "UNSUBSCRIBED", "room": "channel:42" }

Forward a WebRTC signaling payload to other users in a voice channel.

{
"op": "VOICE_SIGNAL",
"room": "channel:5",
"data": {
"type": "offer",
"sdp": "..."
}
}

The server broadcasts a VOICE_SIGNAL event to all other clients in the room, tagged with the sender’s user ID.

Events are broadcast by the server to subscribed clients.

A new message was sent in a subscribed channel.

{
"type": "MESSAGE_CREATE",
"room": "channel:42",
"data": {
"id": 101,
"channel_id": 42,
"author_id": 1,
"content": "Hello!",
"created_at": "2026-01-15T12:01:00Z"
}
}

A new direct message was received.

{
"type": "DIRECT_MESSAGE_CREATE",
"data": {
"id": 51,
"direct_thread_id": 1,
"author_id": 2,
"content": "Hey!",
"created_at": "2026-01-15T12:01:00Z"
}
}

A WebRTC signaling message from another user.

{
"type": "VOICE_SIGNAL",
"room": "channel:5",
"data": {
"from_user_id": 2,
"signal": {
"type": "answer",
"sdp": "..."
}
}
}

A user’s voice state changed (joined/left a voice channel).

{
"type": "VOICE_STATE_UPDATE",
"room": "channel:5",
"data": {
"channel_id": 5,
"joined": true,
"member_user_ids": [1, 2],
"member_states": [
{ "user_id": 1, "muted": false, "deafened": false }
]
}
}

An error occurred processing a command.

{ "type": "ERROR", "data": "unknown op" }