Topics
Opcodes & Status Codes
Opcodes & Status Codes
This page groups the most important protocol numbers and status families you will see while building an Astral bot.
Gateway opcodes
These are the core public Gateway opcodes:
| Opcode | Name | Meaning |
|---|---|---|
0 | Dispatch | Event packet such as READY or MESSAGE_CREATE |
1 | Heartbeat | Keep-alive sent by the client |
2 | Identify | Initial authentication payload |
6 | Resume | Resume an existing session |
7 | Reconnect | Server asks the client to reconnect |
9 | Invalid Session | Current session cannot be resumed as-is |
10 | Hello | Initial server packet containing heartbeat interval |
11 | Heartbeat ACK | Heartbeat confirmation |
Minimal Gateway sequence
- Connect to Gateway
- Receive
op: 10 - Start heartbeats
- Send
op: 2 - Process
op: 0dispatch events
Common HTTP status codes
| Status | Meaning |
|---|---|
200 | Request succeeded |
201 | Resource created |
204 | Request succeeded with no response body |
400 | Invalid form body or malformed request |
401 | Invalid or missing authentication |
403 | Authenticated, but not allowed |
404 | Resource not found |
429 | Rate limited |
500 | Server-side failure |
Common error codes
You should treat code as the stable machine-readable field.
Examples:
{
"code": "INVALID_AUTH_TOKEN",
"message": "Invalid authentication token"
}{
"code": "ACCESS_DENIED",
"message": "Access denied"
}{
"code": "INVALID_FORM_BODY",
"message": "Input Validation Error",
"errors": [
{"path": "content", "message": "Content is too long"}
]
}What to branch on in code
Branch on:
- HTTP status
code- field-level
errors[*].pathfor validation failures
Do not branch on the human-readable message field.