Skip to main content

Gateway

All gateway events in Discord are tagged with an opcode that denotes the payload type. Your connection to our gateway may also sometimes close. When it does, you will receive a close code that tells you what happened.
Gateway Opcodes
Gateway Close Event Codes
In order to prevent broken reconnect loops, you should consider some close codes as a signal to stop reconnecting. This can be because your token expired, or your identification is invalid. This table explains what the application defined close codes for the gateway are, and which close codes you should not attempt to reconnect.

Voice

Our voice gateways have their own set of opcodes and close codes.
Voice Opcodes
Voice Close Event Codes

HTTP

Our API will return semantically valid HTTP response codes based on the success of your request. The following table can be used as a reference for response codes it will return.
HTTP Response Codes

JSON

Along with the HTTP error code, our API can also return more detailed error codes through a code key in the JSON error response. The response will also contain a message key containing a more friendly error string. Some of these errors may include additional details in the form of Error Messages provided by an errors object.
JSON Error Codes
Example JSON Error Response

RPC

RPC is the local Discord server running on localhost. Access to the RPC server requires approval from Discord.
RPC Error Codes
RPC Close Event Codes