Start here: the token is on the Bot page, behind Reset Token
To get a Discord bot token, open the Discord Developer Portal, select your application, go to the Bot page, and click Reset Token under Token. Copy the value immediately: Discord shows it once, and the only way to see a token again is to generate a new one. There is no "reveal" button for an existing token, so if you have lost yours, resetting is the answer, not recovery.
Last verified: November 2026 against Discord's Developer documentation and the Developer Portal.
Discord's own getting started guide puts it plainly: "You won't be able to view your token again unless you regenerate it, so make sure to keep it somewhere safe (like in a password manager)." That single sentence explains most of the "where is my Discord bot token" searches. The token you copied last month is not stored anywhere you can read back; Discord's developer help center even has an article titled "Why can't I copy my bot's token?" for exactly this situation.
| You want to... | Do this |
|---|---|
| Get a token for a brand-new bot | Create the application, open Bot, click Reset Token, copy it once |
| Find the token you created earlier | You cannot. Reset it and update every place that used the old one |
| Stop a leaked token from working | Reset Token immediately; the old value stops authenticating |
| Let someone else run the bot | Add them to a Developer Team or give them the secret through a secrets manager, never chat |
Step by step: creating the app and generating the token
- Sign in at
discord.com/developers/applicationswith the Discord account that should own the bot. Ownership matters: whoever owns the application controls its token. - Click New Application, give it a name, agree to the terms shown, and create it.
- In the left sidebar, open Bot. Newly created applications have a bot user enabled by default, so there is no separate "Add Bot" step on current portals.
- Under Token, click Reset Token and confirm. If your account uses two-factor authentication, expect to be asked for a code.
- Copy the token that appears and paste it straight into your secrets store or
.envfile. Do not paste it into chat, a ticket or a screenshot. - While you are on the Bot page, check the Privileged Gateway Intents toggles. A token that works but a bot that sees empty messages is an intents problem, not a token problem.
Three other values on the same application are often confused with the token. None of them can log a bot in:
| Value | Where it lives | What it is for |
|---|---|---|
| Bot token | Bot page, Token section | Authenticates your bot to the Gateway and REST API: Authorization: Bot <token> |
| Application ID (client ID) | General Information | Public identifier; used in invite links and command registration |
| Public Key | General Information | Verifies signatures on HTTP interaction requests Discord sends you |
| Client Secret | OAuth2 page | Exchanges OAuth2 codes for user access tokens; never used for bot login |
If you paste the client secret or public key where the bot token belongs, the Gateway closes the connection with close code 4004 Authentication failed, and REST calls return HTTP 401 (Unauthorized).
Using the token in code
The token is a bearer secret. Every HTTP request your bot makes sends it in a header with the literal prefix Bot, as shown in Discord's API reference:
Authorization: Bot YOUR_BOT_TOKEN
Libraries add that prefix for you, so pass the bare token. A quick way to confirm the token is valid without starting your whole bot is to ask the API who you are:
curl -s -H "Authorization: Bot $DISCORD_TOKEN" https://discord.com/api/v10/users/@me
A valid token returns your bot user's JSON (with "bot": true). An invalid one returns 401 with {"message": "401: Unauthorized", "code": 0}.
discord.js
import { Client, Events, GatewayIntentBits } from "discord.js";
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
// Events.ClientReady is "clientReady"; the old "ready" name is deprecated since 14.22
client.once(Events.ClientReady, () => console.log(`Logged in as ${client.user.tag}`));
client.login(process.env.DISCORD_TOKEN);
discord.py
import os, discord
intents = discord.Intents.default()
client = discord.Client(intents=intents)
client.run(os.environ["DISCORD_TOKEN"])
Reading from os.environ[...] rather than os.getenv(...) is deliberate: a missing variable raises immediately with a clear error instead of passing None to the library and producing a confusing authentication failure.
The token in Go, Java, C# and Rust - and the library that wants the prefix
The Bot prefix rule has one well-known exception. Most libraries take the bare token and add the prefix themselves, but discordgo expects you to include it: the comment above its New() function in the library source says "If the token is for a bot, it must be prefixed with "Bot "". Pass a bare token there and every REST call fails with 401 while you stare at a token you know is correct.
| Library | How the token goes in | Add "Bot " yourself? |
|---|---|---|
| discord.js (Node) | client.login(token) | No |
| discord.py / Pycord / nextcord | bot.run(token) | No |
| discordgo (Go) | discordgo.New("Bot " + token) | Yes |
| JDA (Java) | JDABuilder.createDefault(token) | No |
| Discord.Net (C#) | LoginAsync(TokenType.Bot, token) | No - the token type is a separate argument |
| serenity (Rust) | Client::builder(&token, intents) | No |
| Raw HTTP | Authorization: Bot <token> header | Yes, it is part of the header value |
Go (discordgo)
token := os.Getenv("DISCORD_TOKEN")
if token == "" {
log.Fatal("DISCORD_TOKEN is not set")
}
dg, err := discordgo.New("Bot " + token)
if err != nil {
log.Fatal(err)
}
if err := dg.Open(); err != nil {
log.Fatal(err) // a bad token fails here
}
defer dg.Close()Java (JDA)
String token = System.getenv("DISCORD_TOKEN");
if (token == null || token.isBlank()) throw new IllegalStateException("DISCORD_TOKEN is not set");
JDA jda = JDABuilder.createDefault(token).build();
jda.awaitReady();C# (Discord.Net)
var token = Environment.GetEnvironmentVariable("DISCORD_TOKEN")
?? throw new InvalidOperationException("DISCORD_TOKEN is not set");
var client = new DiscordSocketClient();
await client.LoginAsync(TokenType.Bot, token);
await client.StartAsync();Rust (serenity)
let token = std::env::var("DISCORD_TOKEN").expect("DISCORD_TOKEN is not set");
let mut client = Client::builder(&token, GatewayIntents::GUILDS).await?;
client.start().await?;Every snippet fails loudly when the variable is missing. That is the same principle as os.environ[...] above: an empty token should stop the process at startup with a message that names the variable, not produce a vague 50014 Invalid authentication token provided or a gateway 4004 ten lines later. Every one of these libraries talks to the same REST API and the same WebSocket Gateway, so the error codes are identical whichever language you pick.
HTTP-only bots: the token, the public key and the interaction token
Not every Discord app keeps a Gateway connection open. If you set an Interactions Endpoint URL on the General Information page, Discord delivers slash commands, buttons and modals to your server as HTTP POST requests instead. Discord's interactions documentation is explicit that the two delivery methods are mutually exclusive: once the endpoint is set, those interactions stop arriving as INTERACTION_CREATE events on the Gateway. That catches people who set the URL "to try it" and then wonder why their discord.js handler went quiet.
An HTTP-only app uses three different secrets for three different jobs, and mixing them up is the usual cause of a failing endpoint:
| Credential | Where it comes from | Used for | Lifetime |
|---|---|---|---|
| Bot token | Bot page, Reset Token | REST calls as the bot: registering commands, fetching channels, sending ordinary messages | Until you reset it |
| Public Key | General Information page | Verifying the X-Signature-Ed25519 and X-Signature-Timestamp headers on every request Discord sends you | Fixed for the application; it is public by design |
| Interaction token | Inside each interaction payload | Answering that one interaction: the initial callback and any follow-up messages | 15 minutes, and only if you answered within 3 seconds |
| OAuth2 access token | Token exchange on the OAuth2 flow | Acting for a user who authorized your app (Bearer, not Bot) | expires_in of 604800 seconds (7 days) in Discord's examples |
The rules from Discord's interactions overview that trip people up:
- Verify every request. Discord signs each request with the headers above. If the signature does not validate against your Public Key, return
401. Discord will not save the endpoint URL until your server answers its test request correctly, and it checks with deliberately bad signatures. - Answer PING with PONG. When you save the URL, Discord sends a
PING(type: 1). Reply200with{"type": 1}and a validContent-Type. - Respond within 3 seconds. The interaction token is valid for 15 minutes, but only if you send the initial response within 3 seconds. Miss it and the user sees "The application did not respond" while your later calls fail with 10062 Unknown interaction. For slow work, send a deferred response first and edit it afterwards; the "application did not respond" guide shows the pattern in four libraries.
- Answer once. A second initial response to the same interaction returns 40060 Interaction has already been acknowledged; use the follow-up endpoints instead.
The practical win for token hygiene: replies go to /interactions/{id}/{token}/callback and /webhooks/{application_id}/{interaction_token}, so the interaction token in the URL does the work. The process that answers users does not have to hold the bot token at all. Keep the bot token in the deploy job that registers commands. Discord's OAuth2 docs also offer a client credentials grant for this: a Bearer token for the app owner with the applications.commands.update scope can update commands. The same page warns you to be "super-extra-very" careful with the client ID and client secret that grant uses. A leaked interaction token is limited to one interaction for at most 15 minutes; a leaked bot token is the whole bot.
If you are designing which credential lives where, our breakdown of Slack bot token types covers the same separation on Slack, where it is even more granular, and the guide to getting a Telegram bot token shows the opposite extreme: one token that does everything. On Discord the general pattern is the same as for any API key: give each process the narrowest credential that does its job.
Storing the token so it never reaches Git
Discord's docs warn never to share your token or check it into version control. In practice that means the token exists in exactly two kinds of places: a secrets store and the environment of the running process.
Local development: .env plus .gitignore
# .env (never committed)
DISCORD_TOKEN=paste-the-token-here
# .gitignore
.env
Add .env to .gitignore before the first commit. Commit a .env.example with the variable names and empty values so collaborators know what to set. Load the file with dotenv (Node), python-dotenv, or Node's built-in --env-file=.env flag on recent Node versions.
Production
- Hosting platforms: use the platform's environment-variable or secrets panel rather than shipping a
.envfile in the image. - CI/CD: GitHub Actions secrets, GitLab CI variables marked masked and protected.
- Containers: pass the token at runtime (
docker run -e DISCORD_TOKEN, Kubernetes Secrets, Docker secrets), never withENVorARGin the Dockerfile - build args and layers are readable by anyone who can pull the image. - Logs: never log the client options object or the raw request headers; both contain the token.
One small habit pays for itself: give the variable the same name everywhere (DISCORD_TOKEN), so a reset means changing one secret per environment rather than hunting through config files.
If the token leaked: reset first, investigate second
Anyone who has your token is your bot. They can read everything it can read, post as it, and use every permission it was granted in every server it is in - including Administrator if someone was generous with the invite. Treat a leaked token as a live incident:
- Reset the token on the Bot page right now. The new value replaces the old one; anything still holding the old token stops authenticating. This is the only step that actually stops an attacker.
- Update your deployment with the new token and restart. Your own bot is now offline until you do.
- Check what happened. Review the audit log in the servers your bot is in for messages, role changes, bans or webhook creations you did not make.
- Remove the token from where it leaked, then clean up history. Deleting a commit or rewriting Git history does not un-leak a secret; it only prevents the next person from finding it. The reset in step 1 is what matters.
- Reduce blast radius for next time: request only the permissions the bot needs (see the Discord permissions calculator) and avoid Administrator.
What GitHub does with leaked Discord tokens
GitHub's secret scanning recognizes Discord bot tokens. In GitHub's list of supported secret scanning patterns, the Discord Bot Token (discord_bot_token) is a partner pattern - meaning tokens found in public repositories are reported directly to Discord - and push protection can block a commit that contains one. Do not count on that as your safety net: forums, paste sites, Docker images and client-side bundles are not GitHub, and what Discord does with a partner report is Discord's process, not something you control. If you suspect exposure, reset the token yourself.
Crash loops after a reset
A bot process that keeps restarting with an old token sends a stream of 401s. Discord's rate limit documentation temporarily restricts IP addresses that make too many invalid requests - currently 10,000 per 10 minutes, counting 401, 403 and 429 responses. Make your process exit and stay down on authentication failure instead of retrying forever, or a stale token on one server can get your whole host temporarily blocked.
Teams, shared ownership and separate dev and prod bots
A bot owned by one person's account is a single point of failure: if that person leaves or loses access, nobody can reset the token. Discord's Developer Teams fix that. Team membership requires two-factor authentication on each member's account, and an existing app moves over with Transfer App to Team at the bottom of its General Information page.
| Team role | Can reset the bot token? | Notes |
|---|---|---|
| Owner | Yes | Only role that can take destructive actions such as deleting the app; one per team |
| Admin | Yes | Same as owner minus destructive actions; can invite and remove members |
| Developer | Yes - Discord lists resetting the bot token as a Developer action | Cannot manage the team or delete apps |
| Read-only | Not among its listed actions | Can view app info and IDs, and invite private team bots |
Give engineers who deploy the bot the Developer role and keep Admin for the people who manage access. When someone leaves the team, reset the token as part of offboarding; they may still have a copy.
Use two applications, not one token in two places
Create a second application for development (for example "MyBot Dev") with its own token, and install it only in a private test server. You get a token you can paste into a laptop .env without risking production, slash-command experiments that never appear in real servers, and the freedom to reset the dev token whenever it ends up somewhere it should not. Production keeps its token in the secrets manager and nowhere else.
Token-related errors at a glance
| Symptom | Meaning | Fix |
|---|---|---|
| Gateway closes with 4004 | Token wrong, revoked or not a bot token | Reset, update the secret, restart |
| REST returns 401 Unauthorized | Missing or invalid Authorization: Bot header | Check the header prefix and the variable actually loaded |
Library says token is None / undefined | Environment variable not loaded | Load the .env file or set the variable in the host |
| Repeated 401s, then the host is blocked | Invalid-request limit tripped by a restart loop | Exit on auth failure; stop the loop |
Planning a reset: a rotation runbook without surprises
Discord gives a bot one token at a time. There is no second "next" key you can roll out before revoking the first, so every rotation includes a moment when the old token is dead and the new one is not deployed yet. You cannot avoid that moment, but you can make it short.
When to rotate even without a leak
- Someone with access to the token leaves the team, or a contractor engagement ends.
- The token appeared in a log line, an error tracker, a CI output or a support ticket - even a private one.
- A laptop or server that held a
.envfile is lost or rebuilt from an untrusted image. - You moved the bot to a new host and the old one is not fully decommissioned.
The runbook
- Prepare first. Know every place the token is set: production, staging, CI and any worker or shard process. Leave one of them out and you get a crash loop that shows up as 401s from that host.
- Reset Token on the Bot page and copy the new value straight into your secrets manager.
- Update and restart every environment. Sharded bots need the new token on every shard, because each shard identifies separately.
- Verify with
curlagainst/users/@mefrom the production host, then watch logs for gateway 4004 or REST 401 from anything you missed. - Stop retry loops. A forgotten process retrying with the old token counts toward the invalid-request limit described above. That limit sits alongside the usual 429 rate limit responses; our Discord limits page summarizes both.
What a reset does not rotate
Channel webhooks carry their own token inside the webhook URL, separate from the bot token. If your bot created webhooks and the incident exposed those URLs as well, resetting the bot token does nothing for them: delete the webhooks and create new ones. The same goes for the client secret on the OAuth2 page, which has its own reset button. A real incident review covers all three, and our chatbot security guide walks through the wider checklist for any bot that holds credentials.
Never use a user token (selfbots)
Some tutorials show how to pull the token from your own Discord client's browser storage and run "a bot" with it. That is a user token, and automating a normal user account is a "self-bot". Discord's OAuth2 documentation states that developers must abide by the Developer Terms of Service, "which includes refraining from automating standard user accounts (generally called 'self-bots') outside of the OAuth2/bot API." Breaking the Developer Terms puts the account itself at risk.
A user token is also far more dangerous to leak than a bot token: it is your account, with your DMs, friends and every server you have joined. If you have ever pasted your user token into a tool or script, secure the account immediately: change your password and turn on two-factor authentication.
The legitimate options are a real bot application (this guide), a channel webhook if you only need to post messages into one channel, or OAuth2 with user consent when you need to act on behalf of users within the scopes Discord allows.
After you have the token: invite, intents, first run
A valid token on its own does not put your bot anywhere. The bot still needs to be installed to a server, which is an OAuth2 authorization done by someone with Manage Server in that server. The checklist from token to a responding bot:
- Token stored as
DISCORD_TOKENand confirmed with the/users/@mecurl above. - Install link configured on the Installation page (scopes
botandapplications.commands, plus the permissions your bot needs), then opened by a server admin. - Intents requested in code match the toggles on the Bot page. Requesting a privileged intent that is not enabled closes the connection with close code 4014.
- Channel permissions let the bot see and post where you are testing; otherwise you get 50013 Missing Permissions or 50001 Missing Access.
If the bot logs in and then stays silent, our Discord bot not responding guide walks through the remaining causes in order, and the Discord error code directory explains each code you might hit. For long-term community setups, see Discord bot community management.
If what you actually need is a support or lead-capture bot on Discord rather than a codebase to maintain, Conferbot's Discord integration connects a bot you build visually, and you paste the token into it once instead of hosting a process yourself.
Running Discord as a support or sales channel, not just a community server
For a hobby bot, the token is one secret on one laptop. For a business that runs support, onboarding or sales on Discord, it is an operational dependency. Someone has to own the application, rotate the token when people leave, keep the process running, and notice at 2 a.m. when it starts failing with 4004. That overhead is the same whether the bot answers ten questions a week or ten thousand.
Discord is a real customer channel in some industries more than others: education, where servers act as course cohorts and study groups; media and creator businesses, where the server is the fan community; tech companies, whose developer communities increasingly live on Discord; and nonprofits running volunteer hubs. If moderation and community growth are the real job, our guide to Discord bot community management is the better next read.
What changes when you stop hand-rolling the bot
With Conferbot's Discord integration you still create the application and copy the token once - the steps at the top of this guide - then paste it under Channels. Conferbot keeps the Gateway connection alive, so there is no process for you to host, restart or protect on a server you run. Our step-by-step guide to making a Discord bot without coding walks through the rest of the setup. The conversation is a visual flow: FAQ answers, onboarding questions and lead capture with buttons, plus live chat handover when a member needs a person. Discord is available on every plan, including Free. On Pro and up, flows can also send data to tools through the integrations hub (Zapier, HubSpot, Google Sheets and others).
One honest limit: Conferbot answers in DMs, replies and threads with messages and buttons. It does not register slash commands and it is not a moderation bot, so keep a dedicated moderation bot if you need bans and filters.
When to stop maintaining the plumbing
Everything above is credential plumbing: where the token lives, which library wants a prefix, how rotation works, which secret answers interactions, what happens when an old process keeps retrying. None of it is your product. It is the toll for running a Discord bot yourself. Every other platform charges its own version - Telegram has BotFather and one all-powerful token, Slack has a choice of token types - and the job multiplies with each channel you add. When requests start failing under load, our guide to API rate limiting covers the pacing side.
That is a fair trade for a bot you enjoy building. It is a worse one when Discord is one of several customer channels you are expected to keep alive. Conferbot runs the same flow on Telegram, WhatsApp, Slack and a website widget, so the token you created above becomes the last Discord credential you have to think about. You can start on the free plan and connect the bot in a few minutes.
Start free with Conferbot - the free plan includes 600 conversations a month and needs no credit card, so you can have the same flow running on a second channel this afternoon.
If you are setting up a bot today, the order is: token, invite link, Message Content intent, first run. If the bot is online but silent, go to the not-responding guide. If you are rotating tokens on your third platform this month, that is the signal to stop.
Was this article helpful?
Build and deploy in 10 minutes. No coding needed.
How to Get a Discord Bot Token (and Why You Can Only See It Once) FAQ
Everything you need to know about chatbots for how to get a discord bot token (and why you can only see it once).
About the Author
The Conferbot team writes about building, deploying, and improving AI chatbots.
View all articlesRelated Articles
From the reference shelf
Fact-checked reference pages and free tools for the platform this article covers.