Skip to content

Gateway Opcodes

Every Gateway message is a JSON object with op, d, s, t. The opcode (op) defines the message role. Directions:

  • C→S — client sends to server
  • S→C — server sends to client
  • C↔S — used both ways
CodeNameDirectionDescription
0DISPATCHS→CServer-to-client event. t holds the event type, d the payload.
1HEARTBEATC↔SHeartbeat. Client sends with the last s on the interval from HELLO. Server may also send one; reply immediately.
2IDENTIFYC→SStarts a new session. Sent after HELLO.
3PRESENCE_UPDATEC→SUpdate client status and activities.
4VOICE_STATE_UPDATEC→SJoin/leave a voice channel, mute, deafen.
6RESUMEC→SResume an interrupted session with the last s.
7RECONNECTS→CServer asks the client to reconnect and resume.
8REQUEST_GUILD_MEMBERSC→SRequest guild member list (for large guilds).
9INVALID_SESSIONS→CSession is invalid. d: true means resume is possible; false means re-identify.
10HELLOS→CFirst message after connect. d.heartbeat_interval is the ms between heartbeats.
11HEARTBEAT_ACKS→CHeartbeat acknowledgement. If missing, reconnect.
12GATEWAY_ERRORS→CGateway-level error with details in d.