# Discord API tokens: find, store, rotate, and use them safely with AI agents

Source: https://botpassword.com/keys/discord
Last checked: 2026-10-25

A Discord bot token is on the Bot page of your app in the Developer Portal; click Reset Token to generate one, and Discord cannot show it again. Requests send it as `Authorization: Bot <token>`. Resetting the token is how you revoke and replace it.

## Key types

| Type | Prefix | Secret | Scope | Expiry |
|---|---|---|---|---|
| Bot token | — | Yes | Authorizes API requests with the permissions and intents your bot app has | — |

## How to create a Discord key

1. Open your app in the Discord Developer Portal.
2. In the left sidebar, open the **Bot** page.
3. Under **Token**, click **Reset Token**.
4. Copy it into a safe place, such as a password manager. You cannot view it again unless you regenerate it.

## Limiting what the key can do

A bot token carries your app's permissions. Limit the permissions and privileged intents you enable for the bot, and the permissions in the invite link, to what it needs.

## How to rotate a Discord key

1. On the Bot page, click **Reset Token**.
2. Update the new token in every deployment and secret store.

## How to revoke a Discord key

1. Click **Reset Token** on the app's Bot page to generate a new token.

## If the key leaked

1. Reset the bot token on the Bot page.
2. Update every deployment and secret store with the new token.
3. Check which servers the bot is in and what it did.

## Gotchas

- Bot tokens use the `Bot` scheme in the Authorization header; OAuth2 tokens use `Bearer`.
- Do not commit the token to version control or share it; anyone with it acts as your bot.
- The token is not viewable after you leave the page.

## Using this key with AI agents (BotPassword)

- `run_with`: Runs a command with the key injected as an environment variable or a 0600 temporary file, never on the command line, and redacts the key from the output.
- `http_request`: Makes an authenticated API call after checking the destination against the hosts this key may be sent to. The response comes back with credential-shaped values redacted, and one that holds the key itself is refused.
- `rotate`: Partly built: creates a new key, stores it as pending, verifies it, promotes it, then revokes the old key after a grace period. Today it works for Cloudflare tokens and AWS IAM keys you have set up, and an agent can start it only under a grant with autopilot; other providers cannot be rotated through their API yet.
- `store_secret`: Saves a value the agent already holds as a new vault item.
- `capture_secret`: Planned, not built yet: will read a newly created key straight from the page or command output into the vault.

## FAQ

### Where do I find my Discord bot token?

On the Bot page of your app in the Developer Portal, under Token. If you no longer have it, click Reset Token to generate a new one.

### What does a Discord bot token authorization header look like?

`Authorization: Bot <token>`.

### What do I do if my Discord bot token leaks?

Reset it on the Bot page right away and update every place you use it.

### Can an AI agent use my Discord key without seeing it?

Yes, if the key never enters the agent's context. Instead of pasting the key into a chat or leaving it in a `.env` file the agent can read, keep it in a credential broker that injects it into the command or request on the agent's behalf. BotPassword does this with `run_with`, `http_request`, `store_secret`, so the agent gets the result and never the value.

## Sources

- https://docs.discord.com/developers/quick-start/getting-started
- https://docs.discord.com/developers/reference
- https://docs.discord.com/developers/topics/opcodes-and-status-codes
