Discord API · error code

Discord error 20012: Not authorized to perform this action on this application

ConfigurationHTTP 403Permissions and access

Last verified against Discord Developer Docs - Opcodes and status codes

What Discord returns
You are not authorized to perform this action on this application

What error 20012 means

The token you used is valid, but it does not have authority over the application named in the request. This is about ownership of the Discord application, not about permissions inside a server. It appears on the application-level endpoints: registering or editing slash commands, managing application emoji, editing the application object, role connection metadata, and similar routes that take /applications/{application.id}/.

The usual root cause is a mismatch between the bot token and the application ID. A bot token belongs to exactly one application. If your deploy script hard-codes a different application ID (a teammate's app, an old app, a typo), Discord authenticates you successfully and then refuses because you are not the owner of the app you are trying to change.

It can also occur when using a user OAuth2 token on application routes where only the bot token or the owning user is allowed.

What it looks like

{
  "message": "You are not authorized to perform this action on this application",
  "code": 20012
}

Why it happens

  • APPLICATION_ID / CLIENT_ID environment variable points at a different application than the bot token
  • Copied the application ID from the wrong entry in the Developer Portal
  • Using an OAuth2 bearer token instead of the bot token on /applications/{id}/commands
  • Team-owned application where the token belongs to a bot of a different app
  • Stale configuration after the bot was reset or recreated

How to fix Discord error 20012

  1. 1Call GET /oauth2/applications/@me with the bot token; the returned id is the only application ID you may use with that token
  2. 2Replace the configured application ID with that value and retry
  3. 3Use Authorization: Bot for command registration; bearer tokens are not accepted there
  4. 4If you intentionally manage several apps, keep one token/application pair per environment and never mix them
  5. 5Check the Developer Portal team membership if a teammate created the app

How to stop it recurring

Derive the application ID at startup from the token (GET /oauth2/applications/@me or from the READY payload's application.id) instead of configuring it separately. That makes a token/app mismatch impossible.

Multi-environment setups avoid this class of bug by never sharing IDs between apps: one application, one token, one env file. If the mismatch is between scopes rather than applications, the failure is 50026; command registration quotas are on the Discord limits page.

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

Related codes

Error 20012 - quick answers

What does Discord error 20012 mean?

The token you used is valid, but it does not have authority over the application named in the request. This is about ownership of the Discord application , not about permissions inside a server.

How do I fix Discord error 20012?

1. Call GET /oauth2/applications/@me with the bot token; the returned id is the only application ID you may use with that token 2. Replace the configured application ID with that value and retry 3. Use Authorization: Bot for command registration; bearer tokens are not accepted there 4. If you intentionally manage several apps, keep one token/application pair per environment and never mix them 5. Check the Developer Portal team membership if a teammate created the app

Stop debugging Discord by hand

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