Bot API docs

Tokens, rate limits and errors

Tokens

Every REST request carries the token in the Authorization header:

Authorization: Bot <token>

A token looks like Discord's: three parts separated by dots, the first being the bot's id in base64. A missing or wrong token gets 401 with { "message": "401: Unauthorized", "code": 0 }. The gateway takes the token in Identify, with or without Bot in front.

GET /gateway is the only endpoint that works without a token. There are no user tokens. OAuth2 bearer tokens, from Login with Voicaw, only open GET /users/@me and GET /oauth2/@me: the rest of the bot API is for bots only.

Rate limits

Each bot may make 50 requests a second in all. On top of that, routes have their own limits, counted per bot and per channel or guild:

RouteLimit
Send a message5 per 5 s, per channel
Edit a message5 per 5 s, per channel
Delete a message5 per second, per channel
Bulk delete1 per second, per channel
Get messages10 per second, per channel
Add or remove reactions4 per second, per channel
Pin or unpin5 per 5 s, per channel
Typing5 per 5 s, per channel
Start a thread5 per 5 s, per channel
Create an invite5 per 5 s, per channel
Edit or delete a channel5 per 10 s, per channel
Set or remove a permission overwrite10 per 10 s, per channel
Create a channel5 per 5 s, per guild
Create, edit or move roles5 per 5 s, per guild (each)
Edit a member, add or remove a member's role10 per 10 s, per guild (each)
Kick5 per 5 s, per guild
Ban or unban5 per 5 s, per guild
Change the bot's name or picture2 per hour

Limited routes answer with Discord's headers, so libraries pace themselves: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-RateLimit-Reset-After and X-RateLimit-Bucket. Over a limit, you get 429 with a Retry-After header and:

{ "message": "You are being rate limited.", "retry_after": 1.234, "global": false, "code": 0 }

X-RateLimit-Scope is user for a route's limit, or global (with X-RateLimit-Global: true) for the 50 a second. The gateway has its own limit: see Gateway.

Errors

Errors are Discord's shape (plus error, the same text):

{ "message": "Missing Permissions", "code": 50013 }

{
  "message": "Invalid Form Body",
  "code": 50035,
  "errors": { "embeds": { "0": { "title": { "_errors": [{ "code": "BASE_TYPE_MAX_LENGTH", "message": "Must be 256 or fewer in length." }] } } } }
}

The codes you can get:

CodeMeaning
0Unauthorized (401), Not Found for an unknown route (404), or rate limited (429)
10003Unknown Channel (also a channel the bot can't see)
10004Unknown Guild (also a guild the bot isn't in)
10007Unknown Member
10008Unknown Message
10011Unknown Role
10013Unknown User (also anyone the bot shares no guild with)
10014Unknown Emoji
10026Unknown Ban
30003Too many pinned messages (250 per channel)
30010Too many reactions (20 per bot per message)
40005Request too large (files: 10 at most, 25 MB together; JSON: 1 MB)
50003Cannot execute action on a DM channel (reactions, pins, threads… in a DM, or deleting the person's message)
50005Cannot edit a message authored by another user
50006Cannot send an empty message
50007Cannot send messages to this user (no shared guild, blocked, or they turned bot DMs off)
50013Missing Permissions, or ranked too low (roles and members above the bot's highest role)
50021Cannot execute action on a system message
50024Cannot execute action on this channel type
50035Invalid Form Body (with errors saying which field), or a request Voicaw refuses
50109The request body isn't valid JSON
160004That message already has a thread

A channel, guild or user the bot isn't allowed to see answers as if it didn't exist (404), not with Missing Access.