Reference

Events and payloads

Consume Gateway dispatches predictably and design handlers that tolerate retries, gaps and new fields.

Dispatch envelope

Every Gateway frame has an op field. Dispatch events additionally carry d for the payload and a monotonically increasing s sequence within the current session. Store the latest sequence only after your handler has durably accepted the event.

json
{
  "op": "MESSAGE_CREATE",
  "s": 42,
  "d": {
    "id": "<message_id>",
    "channel_id": "<channel_id>",
    "content": "Hello"
  }
}

Common event families

FamilyExamplesIntent
Community structureGUILD_CREATE, GUILD_UPDATE, CHANNEL_CREATE, ROLE_UPDATEGUILDS
MembersGUILD_MEMBER_ADD, GUILD_MEMBER_UPDATE, GUILD_MEMBER_REMOVEGUILD_MEMBERS
MessagesMESSAGE_CREATE, MESSAGE_UPDATE, MESSAGE_DELETEGUILD_MESSAGES or DIRECT_MESSAGES
ReactionsMESSAGE_REACTION_ADD, MESSAGE_REACTION_REMOVEMatching reaction intent
InteractionsINTERACTION_CREATEGUILDS plus application installation
Presence and typingPRESENCE_UPDATE, TYPING_STARTExplicit high-volume intents

Delivery semantics

  • Dispatch is ordered within one live session
  • A resumed session can replay buffered frames after last_seq
  • Replay is bounded by time, count and bytes; INVALID_SESSION requires REST reconciliation
  • Handlers should be idempotent by resource ID and event sequence
  • Unknown payload fields and event names must be ignored for forward compatibility

REST remains authoritative

Gateway events are change notifications, not a permanent event log. After a missed replay window, fetch the affected resource through REST before processing new events.