AsyncAPI 2.6 description of Nakama's **realtime socket API**. Unlike the request/response REST surface (modeled in `openapi/nakama-openapi.yml`), Nakama exposes a genuine bidirectional **WebSocket** transport for realtime features: status presence, realtime chat channels, relayed and authoritative multiplayer matches, matchmaking, parties, and realtime notification delivery. The client opens the socket at `GET /ws` (upgraded to WebSocket), passing the JWT session token from an authenticate call as the `token` query parameter, an optional `format` query parameter (`json` or `protobuf`), and an optional `lang` parameter. Once connected, both sides exchange **envelope** messages. A client envelope that includes a `cid` (correlation id) receives a matching server envelope carrying the same `cid`; server- initiated messages (such as `match_data`, `channel_message`, `notifications`, `status_presence_event`, and `matchmaker_matched`) arrive without a `cid`. This document models a representative subset of the envelope message types. The authoritative set is defined by `realtime/realtime.proto` (the `Envelope` message) in the heroiclabs/nakama repository.
View SpecView on GitHubGamingGame BackendBackendRealtimeMultiplayerMatchmakingLeaderboardsSocialOpen SourceAsyncAPIWebhooksEvents
Channels
/ws
publishsendEnvelope
Client-to-server realtime messages.
The single Nakama realtime WebSocket channel. All realtime traffic flows as `Envelope` messages in both directions over this one connection. The `publish` operation below covers envelopes the client sends to the server; the `subscribe` operation covers envelopes the server sends to the client.
Messages
✉
ChannelJoin
Join a realtime chat channel
Client request to join a chat channel (room, direct message, or group).
✉
ChannelMessageSend
Send a chat message
Client request to send a message to a joined channel.
✉
MatchCreate
Create a relayed match
Client request to create a new client-relayed multiplayer match.
✉
MatchJoin
Join a match
Client request to join a match by id or by matchmaker token.
✉
MatchDataSend
Send match data
Client sends an opcode-tagged data frame to all or some match participants.
✉
MatchmakerAdd
Add to the matchmaker
Client request to enter the matchmaking pool with a query and constraints.
✉
StatusUpdate
Update status
Client updates its presence status string.
✉
Channel
Channel joined
Server reply describing a joined chat channel.
✉
ChannelMessage
Incoming chat message
Server-initiated delivery of a message on a joined channel.
✉
Match
Match state
Server reply describing a created or joined match, including presences.
✉
MatchData
Incoming match data
Server-initiated delivery of an opcode-tagged data frame from a match participant.
✉
MatchmakerMatched
Matchmaker matched
Server-initiated notification that a suitable set of opponents was found.
✉
StatusPresenceEvent
Status presence event
Server-initiated event describing users who came online or went offline.
✉
Notifications
Realtime notifications
Server-initiated delivery of one or more in-app notifications.
✉
Error
Error
Server error envelope, echoing the cid of the failed request when applicable.
Servers
ws
nakama127.0.0.1:7350
Default self-hosted Nakama socket endpoint. Connect to `/ws` and upgrade to WebSocket. Use `wss` against a TLS-terminated Heroic Cloud project URL in production.