Discord API · error code

Discord error 20002: Only bots can use this endpoint

ConfigurationTokens and OAuth2

Last verified against Discord Developer Docs - Opcodes and status codes

What Discord returns
Only bots can use this endpoint

What error 20002 means

The mirror image of 20001. You called a route that Discord reserves for bot users, and the request was authenticated as something else: an OAuth2 bearer token or a user account token.

Bot-only routes include those that only make sense for an application's bot user, such as fetching gateway connection info for sharding with GET /gateway/bot. A web dashboard that holds both a user's bearer token and the bot token can easily pick the wrong one when the two share an HTTP helper.

If you reached this by sending a personal user token, stop. Self-bots violate Discord's terms. Create an application in the Developer Portal, add a bot, and use that bot's token with the Bot prefix.

Check the header before anything else: the value must be the word Bot, a space, then the token.

What it looks like

{
  "message": "Only bots can use this endpoint",
  "code": 20002
}

Why it happens

  • Dashboard backend called a bot route with the logged-in user's bearer token
  • Authorization header used the Bearer prefix with a bot token
  • A user account token was used in place of a bot token
  • Shared request helper defaulted to the wrong credential

How to fix Discord error 20002

  1. 1Confirm the Authorization header is exactly the word Bot, a space, then the token, for this call
  2. 2Separate the user-OAuth client from the bot client in your code
  3. 3Reset the bot token in the Developer Portal if a user token was ever used, and switch to the bot token
  4. 4Retry the request and check it no longer returns 20002
  5. 5If you only need the gateway URL, call GET /gateway, which needs no authorization; keep GET /gateway/bot, with its shard count and session limits, for the bot token.

How to stop it recurring

Name your clients by credential (botClient, userClient) and never let a route choose its token implicitly. A unit test that asserts the header prefix for each wrapper catches this before deployment. Token formatting mistakes that produce 401 instead are covered on 40001.

Official reference: Discord Developer Docs - Opcodes and status codes. See all Discord error codes or the Discord limits and quotas.

Related codes

Error 20002 - quick answers

What does Discord error 20002 mean?

The mirror image of 20001 . You called a route that Discord reserves for bot users, and the request was authenticated as something else: an OAuth2 bearer token or a user account token. Bot-only routes include those that only make sense for an application's bot user, such as fetching gateway connection info for sharding with GET /gateway/bot .

How do I fix Discord error 20002?

1. Confirm the Authorization header is exactly the word Bot, a space, then the token, for this call 2. Separate the user-OAuth client from the bot client in your code 3. Reset the bot token in the Developer Portal if a user token was ever used, and switch to the bot token 4. Retry the request and check it no longer returns 20002 5. If you only need the gateway URL, call GET /gateway , which needs no authorization; keep GET /gateway/bot , with its shard count and session…

Stop debugging Discord by hand

Connect the channel through Conferbot: tokens, webhooks and retries are handled, failures show as readable status.