AstralAPI Docs
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:

OpcodeNameMeaning
0DispatchEvent packet such as READY or MESSAGE_CREATE
1HeartbeatKeep-alive sent by the client
2IdentifyInitial authentication payload
6ResumeResume an existing session
7ReconnectServer asks the client to reconnect
9Invalid SessionCurrent session cannot be resumed as-is
10HelloInitial server packet containing heartbeat interval
11Heartbeat ACKHeartbeat confirmation

Minimal Gateway sequence

  1. Connect to Gateway
  2. Receive op: 10
  3. Start heartbeats
  4. Send op: 2
  5. Process op: 0 dispatch events

Common HTTP status codes

StatusMeaning
200Request succeeded
201Resource created
204Request succeeded with no response body
400Invalid form body or malformed request
401Invalid or missing authentication
403Authenticated, but not allowed
404Resource not found
429Rate limited
500Server-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[*].path for validation failures

Do not branch on the human-readable message field.

On this page

Astral API Docs | Opcodes & Status Codes