コンテンツにスキップ

Create an app and get your credentials

このコンテンツはまだ日本語訳がありません。

Status Stable · Last verified 2026-07-11 · API v10 · Source Developer Portal

A concrete walkthrough to get every credential the examples need.

  1. Go to the Developer Portal → Applications.
  2. Click New Application, name it, accept the terms, Create.
  3. On General Information, copy:
    • Application IDDISCORD_APPLICATION_ID
    • Public KeyDISCORD_PUBLIC_KEY (used to verify interactions)

That’s enough for an interaction-endpoint app — no bot required.

Only if you need to connect to the gateway or act as a bot member.

  1. Open the Bot tab.
  2. Click Reset TokenCopy → store as DISCORD_BOT_TOKEN.
    • The token is shown once. If you lose it, reset again (which invalidates the old one).
  3. Configure Privileged Gateway Intents only if your app needs them (MESSAGE CONTENT, SERVER MEMBERS, PRESENCE) — see intents. Leave them off otherwise.

For OAuth2 flows (login-with-Discord, installs):

  1. OAuth2 tab → copy Client ID (= Application ID).
  2. Reset Secret → store as DISCORD_CLIENT_SECRET.
  3. Add your Redirect URI(s) for the authorization-code flow.

Under Installation (and Bot/OAuth2 as needed), choose the installation contexts your app supports:

  • Guild Install — added to a server; can include the bot scope.
  • User Install — installed to a user; commands follow them across Discord. Currently limited to the applications.commands scope by default.

Set the default install link so people can add your app.

DISCORD_APPLICATION_ID=123456789012345678
DISCORD_PUBLIC_KEY=abc... # not secret, but keep it tidy
DISCORD_BOT_TOKEN=REPLACE_ME # SECRET
DISCORD_CLIENT_SECRET=REPLACE_ME # SECRET

Copy from the repo’s .env.example, which documents every value. .env is git-ignored.

Terminal window
curl "https://discord.com/api/v10/users/@me" \
-H "Authorization: Bot $DISCORD_BOT_TOKEN"

A JSON user object with "bot": true means the token works.

  • Register and handle commands → Interactions.
  • Connect for live events → Gateway.
  • Generate an install link with the right scopes → OAuth2.