Skip to content

Protocol reference

Every message on the play WebSocket, the server's close codes, the shapes the messages carry and the quick-chat phrases, generated from the protocol's contract. The page is rebuilt from the platform's contracts each time the site is built, so it always matches what the server speaks. How to connect, and the order messages come in, are in the protocol's guide.

Each frame is a JSON text message holding one object, whose type says which message it is. A field's path is written from its message: a[].b is b in each item of the list a.

Client to server

subscribe

Type: object. Attach to a match and receive its snapshot.

FieldTypeDescription
type requiredexactly subscribe
match requiredstring

resume

Type: object. Attach after a reconnect and receive every delta after a version, read from the match's log, so a resume never needs a snapshot. A client that wants a fresh snapshot instead sends subscribe.

FieldTypeDescription
type requiredexactly resume
match requiredstring
version requiredintegerAt least 0.

submitMove

Type: object. A move for the caller's seat; idempotent by clientSeq.

FieldTypeDescription
type requiredexactly submitMove
match requiredstring
clientSeq requiredintegerAt least 1.
baseVersion requiredintegerAt least 0.
move requiredMove

ping

Type: object. Keep-alive and latency probe.

FieldTypeDescription
type requiredexactly ping
sentAtinteger

chat

Type: object. Send a quick-chat phrase to the match's other players. Refused with an error frame: chatOff (the game's policy, or a spectator), unknownPhrase, or tooFast (more than 3 in 10 seconds).

FieldTypeDescription
type requiredexactly chat
match requiredstring
phrase requiredone of hello, goodLuck, thanks, sorry, wellPlayed, goodGame, thinking, yourTurn, niceMove, oops

Server to client

snapshot

Type: object. The match as the seat sees it (the Player API's MatchView).

FieldTypeDescription
type requiredexactly snapshot
match requiredstring
snapshot requiredMatchView

delta

Type: object. One applied move, projected for the receiving seat (the Player API's Delta).

FieldTypeDescription
type requiredexactly delta
match requiredstring
delta requiredDelta

moveRejected

Type: object. The caller's move was rejected; codes as in the Player API.

FieldTypeDescription
type requiredexactly moveRejected
match requiredstring
clientSeq requiredinteger
code requiredstring
detailstring

pong

Type: object. The answer to a ping.

FieldTypeDescription
type requiredexactly pong
sentAtinteger

error

Type: object. A problem with the connection, a subscription or a chat (notFound, unauthenticated, chatOff, unknownPhrase, tooFast).

FieldTypeDescription
type requiredexactly error
matchstring
code requiredstring
detailstring

chatted

Type: object. A seat sent a quick-chat phrase. Only seated players receive it; spectators don't. The match also keeps its last 20 phrases, for up to 10 minutes and in memory only, and sends a seated player each one the game's policy allows, oldest first, when their connection subscribes or resumes, so a phrase sent before they connected still reaches them. A client that already has a phrase knows it by its id and shows it once.

FieldTypeDescription
type requiredexactly chatted
match requiredstring
idstringThe phrase's ID, a typed string (cht_…) unique to this sending: the same phrase sent live and again on a later subscribe has the same id. Matches ^cht_[0-9A-HJKMNP-TV-Z]{26}$.
seat requiredintegerAt least 0. At most 9.
phrase requiredone of hello, goodLuck, thanks, sorry, wellPlayed, goodGame, thinking, yourTurn, niceMove, oops
at requiredstring (date and time, RFC 3339)

seats

Type: object. Every seat as it is now (the Player API's SeatInfo): who drives it, whether its player is connected, and, while a bot may take an away player's seat over, when it will. Sent to a connection when it subscribes or resumes, and to every connection, players and spectators alike, when a player connects or goes, a grace period starts or a seat's controller changes. Not part of the log: it carries no version, and each one replaces the last.

FieldTypeDescription
type requiredexactly seats
match requiredstring
seats requiredlist of SeatInfo

Close codes

The WebSocket close codes the server ends a connection with, besides the standard ones (1000 when the client closed, 1009 for a frame that is too big). The socket's token is checked once, at the upgrade, so the server ends the connection when that token stops being good enough. The close frame's reason is the code's name.

CodeNameMeaning
4001tokenExpiredThe access token the socket was opened with has expired. The client gets a fresh token (refreshing it if it hasn't already) and reconnects at once, resuming each match from its last version; this is routine, every 15 minutes or so.
4003accountSuspendedThe player's account has been suspended since the token the socket was opened with was issued, while the socket was open or before it connected. The client doesn't reconnect with that token; refreshing it is refused while the account stays suspended.

Shapes

The Player API's shapes the messages carry, as its reference defines them. The Player API's match endpoints answer with the same shapes.

Move

Type: object. An engine move (the engine contract's Move); choices in order.

FieldTypeDescription
action requiredstring
choices requiredlist of object
choices[].step requiredstring
choices[].value requiredstring

MatchView

Type: object.

FieldTypeDescription
match requiredstring
status requiredone of created, running, paused, ended, aborted, abandoned
version requiredintegerAt least 0.
yourSeatintegerAbsent for a spectator, who sees the public view, a round behind in a game that hides anything. At least 0.
seats requiredlist of SeatInfo
view requiredobjectThe engine's projection for the seat (SeatView values)
legalActionslist of stringThe actions the caller's seat may take now.
stateHash requiredstringThe full state's hash, for confirming predictions.
outcomeOutcome
clockslist of ClockThe seats' clocks, for a timed match.
seedCommitmentstringThe SHA-256 of the match seed's eight bytes (big-endian), hex, published from the start.
seedstringThe seed, 16 hex digits, once the match has ended - unless the game keeps permanent secrets.
moveslist of LegalMoveThe seat's complete legal moves, with labels, when it can act - for clients that can't rebuild the state because the game hides information.
movesTruncatedbooleanPresent and true when the seat has more legal moves than the list holds (512)
quickChatlist of stringThe quick-chat phrases the seat may send; none for a spectator or when the game's policy is none.

SeatInfo

Type: object. A seat, who drives it, and whether its player is connected now; the play socket's seats frame sends the same shape whenever it changes.

FieldTypeDescription
seat requiredintegerAt least 0.
playerstringAbsent for a bot's seat. Matches ^ply_[0-9A-HJKMNP-TV-Z]{26}$.
controller requiredone of human, botWho drives the seat now: bot while a bot stands in for its away player.
connected requiredbooleanWhether the seat's player has a play socket open on the match now; always false for a bot's seat.
reconnectBystring (date and time, RFC 3339)While the seat's player is away and a bot may take the seat over: when the grace period ends and the bot takes it.

Outcome

Type: object.

FieldTypeDescription
winners requiredlist of integer
reason requiredstring

Clock

Type: object. One seat's clock when the message was sent; clients count down from it.

FieldTypeDescription
seat requiredintegerAt least 0.
remainingMs requiredintegerAt least 0.
running requiredboolean

Type: object.

FieldTypeDescription
action requiredstring
anytime requiredbooleanAn any-time action, such as resigning.
choices requiredlist of object
choices[].step requiredstring
choices[].value requiredstringWhat the move records.
choices[].label requiredstringHow to show it.
choices[].stepLabelstringThe rules' label for the step (its label in the DSL), absent when the rules give none; the builder's text, to head the step with when the presentation manifest has none, shown as text.

Delta

Type: object. One log entry - a move, or a change of who drives a seat, which leaves the state as it was.

FieldTypeDescription
version requiredintegerAt least 1.
seatintegerThe seat that moved or whose controller changed; absent for a system move. At least 0.
moveMove
controllerone of human, botFor a controller change only, instead of a move - a bot took the seat over after its player disconnected, or the player reclaimed it.
view requiredobjectThe projection after the move, for the receiving seat.
legalActionslist of string
stateHash requiredstring
outcomeOutcome
clockslist of ClockThe seats' clocks after the entry, for a timed match.
moveslist of LegalMoveThe receiving seat's complete legal moves after the latest entry, with labels.
movesTruncatedboolean

Quick-chat phrases

A chat frame sends a phrase by its ID, and clients show its text. A game whose rules limit communication allows only the courtesy phrases; one that allows none has no quick chat.

IDKindText
hellocourtesyHi!
goodLuckcourtesyGood luck!
thankscourtesyThanks!
sorrycourtesySorry!
wellPlayedcourtesyWell played
goodGamecourtesyGood game
thinkingplayThinking…
yourTurnplayYour turn!
niceMoveplayNice move!
oopsplayOops!