### Authentication Examples Source: https://context7.com/discord/discord-api-spec/llms.txt Examples demonstrating how to authenticate requests using Bot Tokens and OAuth2. ```APIDOC ## Authentication All requests must include an `Authorization` header. Bot tokens use the `Bot ` prefix; OAuth2 Bearer tokens use the `Bearer ` prefix. ```bash # Bot Token authentication curl https://discord.com/api/v10/users/@me \ -H "Authorization: Bot MTExMTExMTExMTExMTExMTEx.XXXXXX.YYYYYYYYYYYYYYYYYYYYYY" # OAuth2 Bearer token authentication curl https://discord.com/api/v10/users/@me \ -H "Authorization: Bearer ACCESS_TOKEN_HERE" # Obtain an OAuth2 token via client credentials curl -X POST https://discord.com/api/v10/oauth2/token \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "grant_type=client_credentials&scope=identify+guilds" \ -u "CLIENT_ID:CLIENT_SECRET" # Response: {"access_token":"...","token_type":"Bearer","expires_in":604800,"scope":"identify guilds"} ``` ``` -------------------------------- ### Get the bot's OAuth2 application info Source: https://context7.com/discord/discord-api-spec/llms.txt Retrieve information about the bot's OAuth2 application, including installation parameters. ```APIDOC ## GET /oauth2/applications/@me ### Description Get the bot's OAuth2 application information, including details like `install_params` and `role_connections_verification_url`. ### Method GET ### Endpoint /oauth2/applications/@me ### Request Example ```bash curl https://discord.com/api/v10/oauth2/applications/@me \ -H "Authorization: Bearer OAUTH2_TOKEN" ``` ### Response #### Success Response (200) - Returns an Application object with details such as `install_params`, `role_connections_verification_url`, etc. ### Response Example ```json { "id": "123456789012345678", "name": "My Awesome Bot", "install_params": { "scopes": ["bot", "applications.commands"], "permissions": "104181633" }, "role_connections_verification_url": "https://example.com/verify" } ``` ``` -------------------------------- ### GET /applications/@me Source: https://context7.com/discord/discord-api-spec/llms.txt Retrieves the application object associated with the requesting bot token. ```APIDOC ## GET /applications/@me — Get My Application Returns the application object associated with the requesting bot token. Useful for reading the bot's own application metadata (name, description, icon, flags, install parameters). ```bash curl https://discord.com/api/v10/applications/@me \ -H "Authorization: Bot BOT_TOKEN" # Response (200): # { # "id": "123456789012345678", # "name": "MyBot", # "description": "A helpful bot", # "icon": "abc123iconhash", # "flags": 65536, # "bot_public": true, # "bot_require_code_grant": false, # "verify_key": "deadbeef..." # } ``` ``` -------------------------------- ### Get My Application Metadata Source: https://context7.com/discord/discord-api-spec/llms.txt Retrieve metadata for the bot's application using its token. This includes name, description, icon, and flags. ```bash curl https://discord.com/api/v10/applications/@me \ -H "Authorization: Bot BOT_TOKEN" ``` -------------------------------- ### Get a template by code Source: https://context7.com/discord/discord-api-spec/llms.txt Retrieve a guild template using its unique code. ```APIDOC ## GET /guilds/templates/{code} ### Description Retrieve a guild template by its unique code. This endpoint does not require bot authentication. ### Method GET ### Endpoint /guilds/templates/{code} ### Parameters #### Path Parameters - **code** (string) - Required - The unique code of the guild template. ### Request Example ```bash curl https://discord.com/api/v10/guilds/templates/HXnQfnSA5u9S \ -H "Authorization: Bot BOT_TOKEN" ``` ### Response #### Success Response (200) - Returns a GuildTemplate object containing `code`, `name`, `description`, `usage_count`, `creator`, `created_at`, `updated_at`, and `source_guild_id`. ### Response Example ```json { "code": "HXnQfnSA5u9S", "name": "My Awesome Template", "description": "A template for a cool server.", "usage_count": 10, "creator": {...}, "created_at": "2023-01-01T12:00:00.000Z", "updated_at": "2023-01-01T12:00:00.000Z", "source_guild_id": "111122223333444455" } ``` ``` -------------------------------- ### Get a Specific Application Command Source: https://context7.com/discord/discord-api-spec/llms.txt Retrieves details for a specific global application command. Requires application ID and command ID. ```bash curl https://discord.com/api/v10/applications/123456789012345678/commands/987654321098765432 \ -H "Authorization: Bot BOT_TOKEN" ``` -------------------------------- ### Get Gateway URL with Sharding Recommendations Source: https://context7.com/discord/discord-api-spec/llms.txt Retrieve the WebSocket gateway URL along with sharding recommendations. Requires a bot token for authorization. ```bash curl https://discord.com/api/v10/gateway/bot \ -H "Authorization: Bot BOT_TOKEN" ``` -------------------------------- ### Get Guild Template by Code Source: https://context7.com/discord/discord-api-spec/llms.txt Retrieve a specific guild template using its unique code. Requires bot token for authorization. ```bash curl https://discord.com/api/v10/guilds/templates/HXnQfnSA5u9S \ -H "Authorization: Bot BOT_TOKEN" ``` -------------------------------- ### Get gateway URL with sharding recommendations Source: https://context7.com/discord/discord-api-spec/llms.txt Retrieve the WebSocket gateway URL and sharding information for bots. ```APIDOC ## GET /gateway/bot ### Description Retrieve the WebSocket gateway URL and recommended sharding information for bots. Requires bot authentication. ### Method GET ### Endpoint /gateway/bot ### Request Example ```bash curl https://discord.com/api/v10/gateway/bot \ -H "Authorization: Bot BOT_TOKEN" ``` ### Response #### Success Response (200) - **url** (string) - The WebSocket gateway URL. - **shards** (integer) - Recommended number of shards. - **session_start_limit** (object) - Information about session start limits. - **total** (integer) - Maximum number of concurrent sessions. - **remaining** (integer) - Number of remaining sessions. - **reset_after** (integer) - Milliseconds after which the limit resets. - **max_concurrency** (integer) - Maximum number of concurrent connections per gateway instance. ### Response Example ```json { "url": "wss://gateway.discord.gg", "shards": 4, "session_start_limit": { "total": 1000, "remaining": 999, "reset_after": 14400000, "max_concurrency": 1 } } ``` ``` -------------------------------- ### Get a lobby Source: https://context7.com/discord/discord-api-spec/llms.txt Retrieve information about a specific lobby. ```APIDOC ## GET /lobbies/{lobby_id} ### Description Retrieve information about a specific lobby using its ID. ### Method GET ### Endpoint /lobbies/{lobby_id} ### Parameters #### Path Parameters - **lobby_id** (string) - Required - The ID of the lobby to retrieve. ### Request Example ```bash curl https://discord.com/api/v10/lobbies/LOBBY_ID \ -H "Authorization: Bot BOT_TOKEN" ``` ### Response #### Success Response (200) - Returns a Lobby object. ### Response Example ```json { "id": "LOBBY_ID", "application_id": "123456789012345678", "metadata": {"game_mode": "deathmatch", "max_players": "8"}, "members": [], "linked_channel": null, "capacity": 8 } ``` ``` -------------------------------- ### Get Lobby Source: https://context7.com/discord/discord-api-spec/llms.txt Retrieve a specific lobby by its ID. Requires bot token for authorization. ```bash curl https://discord.com/api/v10/lobbies/LOBBY_ID \ -H "Authorization: Bot BOT_TOKEN" ``` -------------------------------- ### Get User by ID Source: https://context7.com/discord/discord-api-spec/llms.txt Fetches a user's public profile information using their user ID. Requires a bot token. ```bash curl https://discord.com/api/v10/users/USER_ID \ -H "Authorization: Bot BOT_TOKEN" ``` -------------------------------- ### Get Single Sticker Source: https://context7.com/discord/discord-api-spec/llms.txt Retrieves details for a specific sticker by its ID. Requires sticker ID. ```bash curl https://discord.com/api/v10/stickers/STICKER_ID \ -H "Authorization: Bot BOT_TOKEN" ``` -------------------------------- ### Get Bot's OAuth2 Application Info Source: https://context7.com/discord/discord-api-spec/llms.txt Retrieve information about the bot's OAuth2 application. Requires a bot token for authorization. ```bash curl https://discord.com/api/v10/oauth2/applications/@me \ -H "Authorization: Bearer OAUTH2_TOKEN" ``` -------------------------------- ### Get Current User Source: https://context7.com/discord/discord-api-spec/llms.txt Retrieves the authenticated user's profile information. Works for both bot and OAuth2 tokens. ```bash curl https://discord.com/api/v10/users/@me \ -H "Authorization: Bot BOT_TOKEN" ``` -------------------------------- ### Get Guild Command Permissions Source: https://context7.com/discord/discord-api-spec/llms.txt Fetches permission overrides for all application commands within a specific guild. Returns an array of permission objects. ```bash curl https://discord.com/api/v10/applications/123456789012345678/guilds/111122223333444455/commands/permissions \ -H "Authorization: Bot BOT_TOKEN" ``` -------------------------------- ### Serve Interactive API Docs with Redocly CLI Source: https://context7.com/discord/discord-api-spec/llms.txt Serve an interactive Swagger UI locally using the Redocly CLI to explore the Discord API documentation. ```bash # Serve an interactive Swagger UI locally npx @redocly/cli preview-docs specs/openapi.json # Opens http://localhost:8080 with browsable API docs ``` -------------------------------- ### List and Create Channel Invites Source: https://context7.com/discord/discord-api-spec/llms.txt Use these endpoints to list existing invites for a channel or create new temporary or permanent invites. ```bash curl https://discord.com/api/v10/channels/555566667777888899/invites \ -H "Authorization: Bot BOT_TOKEN" ``` ```bash curl -X POST https://discord.com/api/v10/channels/555566667777888899/invites \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '{"max_age": 86400, "max_uses": 50, "temporary": false, "unique": true}' ``` -------------------------------- ### Manage Application Commands (Global) Source: https://context7.com/discord/discord-api-spec/llms.txt List, create, or bulk-overwrite global slash commands for an application. Bulk-overwrite (PUT) atomically replaces all existing global commands. ```bash # List global commands curl "https://discord.com/api/v10/applications/123456789012345678/commands?with_localizations=true" \ -H "Authorization: Bot BOT_TOKEN" ``` ```bash # Create a global slash command curl -X POST https://discord.com/api/v10/applications/123456789012345678/commands \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "greet", "type": 1, "description": "Greet a user", "options": [{"name":"user","description":"User to greet","type":6,"required":true}] }' ``` ```bash # Bulk overwrite all global commands curl -X PUT https://discord.com/api/v10/applications/123456789012345678/commands \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '[ {"name":"ping","description":"Ping the bot","type":1}, {"name":"info","description":"Get server info","type":1} ]' ``` -------------------------------- ### Get the gateway URL Source: https://context7.com/discord/discord-api-spec/llms.txt Retrieve the WebSocket gateway URL for real-time communication. ```APIDOC ## GET /gateway ### Description Retrieve the WebSocket gateway URL. This endpoint does not require authentication. ### Method GET ### Endpoint /gateway ### Response #### Success Response (200) - **url** (string) - The WebSocket gateway URL. ### Response Example ```json { "url": "wss://gateway.discord.gg" } ``` ``` -------------------------------- ### List Guild Templates Source: https://context7.com/discord/discord-api-spec/llms.txt List all available guild templates for a specific guild. Requires bot token for authorization. ```bash curl https://discord.com/api/v10/guilds/111122223333444455/templates \ -H "Authorization: Bot BOT_TOKEN" ``` -------------------------------- ### Get Original Webhook Message Source: https://context7.com/discord/discord-api-spec/llms.txt Retrieves the original message sent by a webhook. ```APIDOC ## GET /webhooks/{webhook_id}/{webhook_token}/messages/@original ### Description Retrieves the original message sent by the webhook. ### Method GET ### Endpoint /webhooks/{webhook_id}/{webhook_token}/messages/@original ### Response #### Success Response (200) - **Message object** - The original message object. ``` -------------------------------- ### Create Lobby Source: https://context7.com/discord/discord-api-spec/llms.txt Create a new game lobby with specified application ID, metadata, and idle timeout. Requires bot token and JSON content type. ```bash curl -X POST https://discord.com/api/v10/lobbies \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "application_id": "123456789012345678", "metadata": {"game_mode": "deathmatch", "max_players": "8"}, "idle_timeout_ms": 300000 }' ``` -------------------------------- ### Update My Application Settings Source: https://context7.com/discord/discord-api-spec/llms.txt Modify application settings like description, tags, and interaction endpoint URL. Requires the bot token and `Content-Type: application/json` header. ```bash curl -X PATCH https://discord.com/api/v10/applications/@me \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "description": "An updated bot description", "tags": ["utility", "moderation"], "interactions_endpoint_url": "https://mybot.example.com/interactions" }' ``` -------------------------------- ### Create Stage Instance Source: https://context7.com/discord/discord-api-spec/llms.txt Creates a new stage instance for a stage channel. Requires channel ID, topic, privacy level, and notification setting. ```bash curl -X POST https://discord.com/api/v10/stage-instances \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "channel_id": "STAGE_CHANNEL_ID", "topic": "AMA with the dev team", "privacy_level": 2, "send_start_notification": true }' ``` -------------------------------- ### Get Gateway URL Source: https://context7.com/discord/discord-api-spec/llms.txt Retrieve the WebSocket gateway URL. This endpoint does not require authentication. ```bash curl https://discord.com/api/v10/gateway ``` -------------------------------- ### GET/POST/PUT /applications/{application_id}/commands Source: https://context7.com/discord/discord-api-spec/llms.txt Manages global slash commands for an application, including listing, creating, and bulk-overwriting. ```APIDOC ## GET/POST/PUT /applications/{application_id}/commands — Application Commands (Global) Lists, creates, or bulk-overwrites global slash commands for an application. Supports optional `with_localizations` query parameter when listing. Bulk-set (PUT) replaces all global commands atomically (max 130 commands). ```bash # List global commands curl "https://discord.com/api/v10/applications/123456789012345678/commands?with_localizations=true" \ -H "Authorization: Bot BOT_TOKEN" # Response: [{"id":"...","application_id":"...","name":"ping","description":"Replies with Pong","version":"1"}] # Create a global slash command curl -X POST https://discord.com/api/v10/applications/123456789012345678/commands \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "greet", "type": 1, "description": "Greet a user", "options": [{"name":"user","description":"User to greet","type":6,"required":true}] }' # Response (200/201): created ApplicationCommandResponse # Bulk overwrite all global commands curl -X PUT https://discord.com/api/v10/applications/123456789012345678/commands \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '[ {"name":"ping","description":"Ping the bot","type":1}, {"name":"info","description":"Get server info","type":1} ]' # Response (200): array of ApplicationCommandResponse ``` ``` -------------------------------- ### Manage Guild Settings Source: https://context7.com/discord/discord-api-spec/llms.txt Retrieve and update core guild settings such as name, icon, and AFK channel. Use `with_counts=true` to include member and presence counts. ```bash curl "https://discord.com/api/v10/guilds/111122223333444455?with_counts=true" \ -H "Authorization: Bot BOT_TOKEN" ``` ```bash curl -X PATCH https://discord.com/api/v10/guilds/111122223333444455 \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "Updated Server Name", "afk_timeout": 300, "default_message_notifications": 1 }' ``` -------------------------------- ### Get Guild Source: https://context7.com/discord/discord-api-spec/llms.txt Retrieves the full guild object, optionally including member and presence counts. ```APIDOC ## GET /guilds/{guild_id} ### Description Fetches the full guild object for a given guild ID. ### Method GET ### Endpoint /guilds/{guild_id} ### Parameters #### Query Parameters - **with_counts** (boolean) - Optional - Whether to include `approximate_member_count` and `approximate_presence_count` in the response. ### Response #### Success Response (200) - **Guild object** - The guild object, potentially with counts if `with_counts=true`. ``` -------------------------------- ### Channel Invites Source: https://context7.com/discord/discord-api-spec/llms.txt Create and list invites for a channel. ```APIDOC ## Channel Invites — /channels/{channel_id}/invites Create and list invites for a channel. ### Method POST ### Endpoint `/channels/{channel_id}/invites` ### Description Creates a new invite for the specified channel. ### Parameters #### Path Parameters - **channel_id** (snowflake) - Required - The ID of the channel to create an invite for. ### Response - **Invite object** - The created invite object. --- ### Method GET ### Endpoint `/channels/{channel_id}/invites` ### Description Retrieves a list of all invites for the specified channel. ### Parameters #### Path Parameters - **channel_id** (snowflake) - Required - The ID of the channel to list invites for. ### Response - **array of Invite objects** - A list of invite objects for the channel. ``` -------------------------------- ### Create Invite Source: https://context7.com/discord/discord-api-spec/llms.txt Creates a temporary invite for a channel that expires after 24 hours. ```APIDOC ## POST /channels/{channel_id}/invites ### Description Creates a temporary invite for a channel with a maximum age of 24 hours and a maximum of 50 uses. ### Method POST ### Endpoint /channels/{channel_id}/invites ### Parameters #### Request Body - **max_age** (integer) - Required - Duration in seconds the invite is valid for (e.g., 86400 for 24 hours). - **max_uses** (integer) - Required - Maximum number of times the invite can be used. - **temporary** (boolean) - Required - Whether the invite grants temporary membership. - **unique** (boolean) - Required - Whether the invite is unique. ### Response #### Success Response (200) - **Invite object** - An Invite object with code, guild, channel, inviter, and expires_at. ``` -------------------------------- ### Introspect OAuth2 Token Source: https://context7.com/discord/discord-api-spec/llms.txt Use this endpoint to get information about the current OAuth2 token. Requires an OAuth2 token for authorization. ```bash curl https://discord.com/api/v10/oauth2/@me \ -H "Authorization: Bearer OAUTH2_TOKEN" ``` -------------------------------- ### Create Test Entitlement Source: https://context7.com/discord/discord-api-spec/llms.txt Creates a test entitlement for a user or guild. Requires SKU ID, owner ID, and owner type (1 for GUILD, 2 for USER). ```bash curl -X POST https://discord.com/api/v10/applications/123456789012345678/entitlements \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '{"sku_id": "SKU_ID", "owner_id": "USER_OR_GUILD_ID", "owner_type": 2}' ``` -------------------------------- ### Generate Python Client for Preview Spec Source: https://context7.com/discord/discord-api-spec/llms.txt Generate a Python client using the OpenAPI generator for the unstable preview version of the Discord API specification. ```bash # Use the preview spec (unstable) to access experimental endpoints npx @openapitools/openapi-generator-cli generate \ -i specs/openapi_preview.json \ -g python \ -o ./generated/discord-preview-client ``` -------------------------------- ### Update the bot's own voice state Source: https://context7.com/discord/discord-api-spec/llms.txt Update the bot's own voice state, for example, to request to speak in a Stage channel. ```APIDOC ## PATCH /guilds/{guild_id}/voice-states/@me ### Description Update the bot's own voice state. This can be used to join a voice channel or request to speak in a Stage channel. ### Method PATCH ### Endpoint /guilds/{guild_id}/voice-states/@me ### Parameters #### Path Parameters - **guild_id** (string) - Required - The ID of the guild. ### Request Body - **channel_id** (string) - Required - The ID of the target voice channel (e.g., a Stage channel). - **request_to_speak_timestamp** (string) - Optional - The ISO 8601 timestamp when the bot requested to speak. ### Request Example ```bash curl -X PATCH https://discord.com/api/v10/guilds/111122223333444455/voice-states/@me \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '{"channel_id": "STAGE_CHANNEL_ID", "request_to_speak_timestamp": "2025-09-01T18:00:00.000Z"}' ``` ### Response #### Success Response (204) - No content is returned on success. ``` -------------------------------- ### Authenticate with Bot Token or OAuth2 Source: https://context7.com/discord/discord-api-spec/llms.txt Use the `Authorization` header with either a `Bot ` prefix for bot tokens or a `Bearer ` prefix for OAuth2 tokens. The client credentials flow can be used to obtain an OAuth2 token. ```bash # Bot Token authentication curl https://discord.com/api/v10/users/@me \ -H "Authorization: Bot MTExMTExMTExMTExMTExMTEx.XXXXXX.YYYYYYYYYYYYYYYYYYYYYY" ``` ```bash # OAuth2 Bearer token authentication curl https://discord.com/api/v10/users/@me \ -H "Authorization: Bearer ACCESS_TOKEN_HERE" ``` ```bash # Obtain an OAuth2 token via client credentials curl -X POST https://discord.com/api/v10/oauth2/token \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "grant_type=client_credentials&scope=identify+guilds" \ -u "CLIENT_ID:CLIENT_SECRET" ``` -------------------------------- ### Create Webhook Source: https://context7.com/discord/discord-api-spec/llms.txt Creates a new webhook in a specified channel. ```APIDOC ## POST /channels/{channel_id}/webhooks ### Description Creates a webhook in a channel that can be used to send messages without a bot being online. ### Method POST ### Endpoint /channels/{channel_id}/webhooks ### Parameters #### Request Body - **name** (string) - Required - The name of the webhook. - **avatar** (string) - Optional - The default avatar for the webhook in base64 format. ### Response #### Success Response (200) - **Webhook object** - A Webhook object containing id, token, channel_id, and url. ``` -------------------------------- ### Create a Guild-Scoped Application Command Source: https://context7.com/discord/discord-api-spec/llms.txt Registers a new application command within a specific guild. Uses POST with a JSON payload defining the command. ```bash curl -X POST https://discord.com/api/v10/applications/123456789012345678/guilds/111122223333444455/commands \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '{"name":"admin-reset","description":"Admin reset command","type":1,"default_member_permissions":"8"}' ``` -------------------------------- ### Create a lobby Source: https://context7.com/discord/discord-api-spec/llms.txt Create a new lobby for embedded activities and SDK integrations. ```APIDOC ## POST /lobbies ### Description Create a new lobby. This is used for managing real-time game lobbies for embedded activities. ### Method POST ### Endpoint /lobbies ### Request Body - **application_id** (string) - Required - The ID of the application creating the lobby. - **metadata** (object) - Optional - Key-value pairs for lobby metadata (e.g., game mode, max players). - **idle_timeout_ms** (integer) - Optional - The time in milliseconds after which the lobby will be automatically deleted if idle. ### Request Example ```bash curl -X POST https://discord.com/api/v10/lobbies \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "application_id": "123456789012345678", "metadata": {"game_mode": "deathmatch", "max_players": "8"}, "idle_timeout_ms": 300000 }' ``` ### Response #### Success Response (200) - Returns a Lobby object containing `id`, `application_id`, `metadata`, `members`, `linked_channel`, and `capacity`. ### Response Example ```json { "id": "LOBBY_ID", "application_id": "123456789012345678", "metadata": {"game_mode": "deathmatch", "max_players": "8"}, "members": [], "linked_channel": null, "capacity": 8 } ``` ``` -------------------------------- ### Generate Python Client with openapi-python-client Source: https://context7.com/discord/discord-api-spec/llms.txt Generate a Python client for the Discord API using the openapi-python-client tool. ```bash # Generate Python client with openapi-python-client openapi-python-client generate --path specs/openapi.json --output-path ./discord_client ``` -------------------------------- ### Manage Webhooks Source: https://context7.com/discord/discord-api-spec/llms.txt Create, execute, and manage webhooks for sending messages without a bot online. Supports GitHub and Slack compatible formats. ```bash curl -X POST https://discord.com/api/v10/channels/555566667777888899/webhooks \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '{"name": "Alert Bot", "avatar": null}' ``` ```bash curl -X POST "https://discord.com/api/v10/webhooks/WEBHOOK_ID/WEBHOOK_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "content": "Deployment succeeded! ✅", "username": "CI/CD Bot", "avatar_url": "https://example.com/bot-avatar.png", "embeds": [{ "title": "Build #42", "description": "All checks passed.", "color": 3066993 }] }' ``` ```bash curl "https://discord.com/api/v10/webhooks/WEBHOOK_ID/WEBHOOK_TOKEN/messages/@original" \ -H "Authorization: Bot BOT_TOKEN" ``` ```bash curl -X POST "https://discord.com/api/v10/webhooks/WEBHOOK_ID/WEBHOOK_TOKEN/github" \ -H "Content-Type: application/json" \ -H "X-GitHub-Event: push" \ -d '{"ref":"refs/heads/main","repository":{"full_name":"owner/repo"},"commits":[...]}' ``` ```bash curl -X POST "https://discord.com/api/v10/webhooks/WEBHOOK_ID/WEBHOOK_TOKEN/slack" \ -H "Content-Type: application/json" \ -d '{"text": "Hello from Slack-compatible webhook!"}' ``` -------------------------------- ### Stage Instances Source: https://context7.com/discord/discord-api-spec/llms.txt Endpoints for managing stage instances. ```APIDOC ## POST /stage-instances ### Description Creates a new stage instance for an active stage channel. ### Method POST ### Endpoint /stage-instances ### Parameters #### Request Body - **channel_id** (snowflake) - Required - The ID of the stage channel. - **topic** (string) - Required - The topic of the stage instance. - **privacy_level** (integer) - Optional - The privacy level of the stage instance (2 for GUILD_ONLY). - **send_start_notification** (boolean) - Optional - Whether to send a notification when the stage starts. ### Request Example ```bash curl -X POST https://discord.com/api/v10/stage-instances \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "channel_id": "STAGE_CHANNEL_ID", "topic": "AMA with the dev team", "privacy_level": 2, "send_start_notification": true }' ``` ### Response #### Success Response (200) - Returns the created StageInstance object. ``` ```APIDOC ## PATCH /stage-instances/{channel_id} ### Description Updates the topic of an existing stage instance. ### Method PATCH ### Endpoint /stage-instances/{channel_id} ### Parameters #### Path Parameters - **channel_id** (snowflake) - Required - The ID of the stage channel. #### Request Body - **topic** (string) - Required - The new topic for the stage instance. ### Request Example ```bash curl -X PATCH https://discord.com/api/v10/stage-instances/STAGE_CHANNEL_ID \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '{"topic": "New topic: Q&A session"}' ``` ### Response #### Success Response (200) - Returns the updated StageInstance object. ``` ```APIDOC ## DELETE /stage-instances/{channel_id} ### Description Deletes a stage instance. ### Method DELETE ### Endpoint /stage-instances/{channel_id} ### Parameters #### Path Parameters - **channel_id** (snowflake) - Required - The ID of the stage channel. ### Request Example ```bash curl -X DELETE https://discord.com/api/v10/stage-instances/STAGE_CHANNEL_ID \ -H "Authorization: Bot BOT_TOKEN" ``` ### Response #### Success Response (204) No content. ``` -------------------------------- ### List Invites Source: https://context7.com/discord/discord-api-spec/llms.txt Retrieves a list of all existing invites for a given channel. ```APIDOC ## GET /channels/{channel_id}/invites ### Description Lists all existing invites for a channel. ### Method GET ### Endpoint /channels/{channel_id}/invites ### Response #### Success Response (200) - **invites** (array) - An array of Invite objects. ``` -------------------------------- ### Handle Discord API Rate Limits in Shell Source: https://context7.com/discord/discord-api-spec/llms.txt This script demonstrates how to fetch API response headers, check for a 429 status code, and use the 'retry_after' value to implement exponential backoff. ```bash # Example response headers on any endpoint: # X-RateLimit-Limit: 5 # Max requests in the window # X-RateLimit-Remaining: 4 # Remaining requests before hitting the limit # X-RateLimit-Reset: 1693000000.123 # Unix timestamp when the bucket resets # X-RateLimit-Reset-After: 0.877 # Seconds until the bucket resets # X-RateLimit-Bucket: abcd1234 # Identifies the rate limit bucket # X-RateLimit-Global: true # (only on 429) if the global rate limit was hit # Retry-After: 1.0 # (on 429) seconds to wait before retrying # Handle 429 in a shell script response=$(curl -s -w "\n%{http_code}" https://discord.com/api/v10/users/@me \ -H "Authorization: Bot BOT_TOKEN") http_code=$(echo "$response" | tail -1) if [ "$http_code" = "429" ]; then retry_after=$(echo "$response" | head -1 | python3 -c "import sys,json; print(json.load(sys.stdin)['retry_after'])") sleep "$retry_after" fi ``` -------------------------------- ### List Guild-Scoped Application Commands Source: https://context7.com/discord/discord-api-spec/llms.txt Retrieves all application commands registered for a specific guild. Requires application and guild IDs. ```bash curl "https://discord.com/api/v10/applications/123456789012345678/guilds/111122223333444455/commands" \ -H "Authorization: Bot BOT_TOKEN" ``` -------------------------------- ### Create Guild Sticker Source: https://context7.com/discord/discord-api-spec/llms.txt Uploads a custom sticker to a guild. This endpoint uses multipart/form-data and requires file, name, description, and tags. ```bash curl -X POST https://discord.com/api/v10/guilds/111122223333444455/stickers \ -H "Authorization: Bot BOT_TOKEN" \ -F "name=mySticker" \ -F "description=A cool sticker" \ -F "tags=wave" \ -F "file=@sticker.png;type=image/png" ``` -------------------------------- ### Sync Guild Template Source: https://context7.com/discord/discord-api-spec/llms.txt Sync a guild template to reflect the latest changes in the guild. Requires bot token and uses PUT method. ```bash curl -X PUT https://discord.com/api/v10/guilds/111122223333444455/templates/HXnQfnSA5u9S \ -H "Authorization: Bot BOT_TOKEN" ``` -------------------------------- ### Execute Slack-Compatible Webhook Source: https://context7.com/discord/discord-api-spec/llms.txt Executes a webhook with Slack-formatted payloads. ```APIDOC ## POST /webhooks/{webhook_id}/{webhook_token}/slack ### Description Sends a Slack-formatted payload to a webhook. ### Method POST ### Endpoint /webhooks/{webhook_id}/{webhook_token}/slack ### Parameters #### Request Body - **(object)** - Required - The Slack-compatible payload in JSON format (e.g., `{"text": "Hello!"}`). ``` -------------------------------- ### Import OpenAPI Spec into Postman Source: https://context7.com/discord/discord-api-spec/llms.txt Import the Discord API OpenAPI specification into Postman using the command-line interface. ```bash # Import into Postman via CLI postman import --file specs/openapi.json ``` -------------------------------- ### List Entitlements by User Source: https://context7.com/discord/discord-api-spec/llms.txt Fetches entitlements for a specific user within an application. Supports pagination with a limit parameter. ```bash curl "https://discord.com/api/v10/applications/123456789012345678/entitlements?user_id=USER_ID&limit=25" \ -H "Authorization: Bot BOT_TOKEN" ``` -------------------------------- ### Respond to an Interaction Source: https://context7.com/discord/discord-api-spec/llms.txt Creates a response to a received interaction (slash command, component, modal). Must be called within 3 seconds. ```bash curl -X POST "https://discord.com/api/v10/interactions/INTERACTION_ID/INTERACTION_TOKEN/callback" \ -H "Content-Type: application/json" \ -d '{ "type": 4, "data": { "content": "Pong! 🏓", "flags": 64 } }' ``` -------------------------------- ### List all templates for a guild Source: https://context7.com/discord/discord-api-spec/llms.txt Retrieve a list of all guild templates associated with a specific guild. ```APIDOC ## GET /guilds/{guild_id}/templates ### Description List all guild templates created for a specific guild. ### Method GET ### Endpoint /guilds/{guild_id}/templates ### Parameters #### Path Parameters - **guild_id** (string) - Required - The ID of the guild. ### Request Example ```bash curl https://discord.com/api/v10/guilds/111122223333444455/templates \ -H "Authorization: Bot BOT_TOKEN" ``` ### Response #### Success Response (200) - Returns an array of GuildTemplate objects. ### Response Example ```json [ { "code": "HXnQfnSA5u9S", "name": "My Awesome Template", "description": "A template for a cool server.", "usage_count": 10, "creator": {...}, "created_at": "2023-01-01T12:00:00.000Z", "updated_at": "2023-01-01T12:00:00.000Z", "source_guild_id": "111122223333444455" } ] ``` ``` -------------------------------- ### List Voice Regions Source: https://context7.com/discord/discord-api-spec/llms.txt List all available voice server regions. Requires bot token for authorization. ```bash curl https://discord.com/api/v10/voice/regions \ -H "Authorization: Bot BOT_TOKEN" ``` -------------------------------- ### Manage Guild Roles Source: https://context7.com/discord/discord-api-spec/llms.txt Create, list, update, delete, and reorder roles within a guild. Permissions can be specified as a string of bits. ```bash curl https://discord.com/api/v10/guilds/111122223333444455/roles \ -H "Authorization: Bot BOT_TOKEN" ``` ```bash curl -X POST https://discord.com/api/v10/guilds/111122223333444455/roles \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '{"name": "Moderator", "permissions": "1099511627775", "color": 3447003, "hoist": true, "mentionable": true}' ``` ```bash curl -X PATCH https://discord.com/api/v10/guilds/111122223333444455/roles \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '[{"id":"ROLE_ID_A","position":2},{"id":"ROLE_ID_B","position":1}]' ``` ```bash curl -X DELETE https://discord.com/api/v10/guilds/111122223333444455/roles/ROLE_ID \ -H "Authorization: Bot BOT_TOKEN" ``` -------------------------------- ### Execute Webhook Source: https://context7.com/discord/discord-api-spec/llms.txt Executes a webhook to send a message to a channel. ```APIDOC ## POST /webhooks/{webhook_id}/{webhook_token} ### Description Executes a webhook to send a message. Supports custom username, avatar, and embeds. ### Method POST ### Endpoint /webhooks/{webhook_id}/{webhook_token} ### Parameters #### Query Parameters - **wait** (boolean) - Optional - If true, the response will be the message object. #### Request Body - **content** (string) - Optional - The text content of the message. - **username** (string) - Optional - Override the default username of the webhook. - **avatar_url** (string) - Optional - Override the default avatar of the webhook. - **embeds** (array) - Optional - An array of embed objects to send with the message. ### Response #### Success Response (200/204) - **Message object** - If `wait=true` is used, returns the sent message object. Otherwise, returns 204 No Content. ``` -------------------------------- ### Manage Guild Members Source: https://context7.com/discord/discord-api-spec/llms.txt List, search, update, and remove members from a guild. Pagination is supported for member listing. ```bash curl "https://discord.com/api/v10/guilds/111122223333444455/members?limit=100&after=0" \ -H "Authorization: Bot BOT_TOKEN" ``` ```bash curl "https://discord.com/api/v10/guilds/111122223333444455/members/search?query=alice&limit=10" \ -H "Authorization: Bot BOT_TOKEN" ``` ```bash curl -X PATCH https://discord.com/api/v10/guilds/111122223333444455/members/USER_ID \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '{"nick": "Alice (Admin)", "roles": ["ROLE_ID_1", "ROLE_ID_2"]}' ``` ```bash curl -X DELETE https://discord.com/api/v10/guilds/111122223333444455/members/USER_ID \ -H "Authorization: Bot BOT_TOKEN" ``` -------------------------------- ### Execute GitHub-Compatible Webhook Source: https://context7.com/discord/discord-api-spec/llms.txt Executes a webhook with GitHub event payloads, auto-formatting them for Discord. ```APIDOC ## POST /webhooks/{webhook_id}/{webhook_token}/github ### Description Sends a GitHub event payload to a webhook, which auto-formats it for Discord. ### Method POST ### Endpoint /webhooks/{webhook_id}/{webhook_token}/github ### Parameters #### Headers - **X-GitHub-Event** (string) - Required - The type of GitHub event (e.g., `push`). #### Request Body - **(object)** - Required - The GitHub event payload in JSON format. ``` -------------------------------- ### Respond to an Interaction Source: https://context7.com/discord/discord-api-spec/llms.txt Endpoint to create a response to a user interaction, such as a slash command or button click. Must be called within 3 seconds of receiving the interaction. ```APIDOC ## Immediately reply to a slash command ```bash curl -X POST "https://discord.com/api/v10/interactions/INTERACTION_ID/INTERACTION_TOKEN/callback" \ -H "Content-Type: application/json" \ -d '{ "type": 4, "data": { "content": "Pong! 🏓", "flags": 64 } }' ``` # type 4 = CHANNEL_MESSAGE_WITH_SOURCE; flags 64 = ephemeral # Response (200/204) ## Deferred response (acknowledge, then follow up later) ```bash curl -X POST "https://discord.com/api/v10/interactions/INTERACTION_ID/INTERACTION_TOKEN/callback" \ -H "Content-Type: application/json" \ -d '{"type": 5}' ``` # Response (200/204) ``` -------------------------------- ### List Official Sticker Packs Source: https://context7.com/discord/discord-api-spec/llms.txt Fetches a list of all official Discord sticker packs. Requires bot token. ```bash curl https://discord.com/api/v10/sticker-packs \ -H "Authorization: Bot BOT_TOKEN" ``` -------------------------------- ### List and Create Messages Source: https://context7.com/discord/discord-api-spec/llms.txt Endpoints for listing messages in a channel and sending new messages. Supports various query parameters for listing and rich content for sending. ```APIDOC ## List the 10 most recent messages ```bash curl "https://discord.com/api/v10/channels/555566667777888899/messages?limit=10" \ -H "Authorization: Bot BOT_TOKEN" ``` # Response: array of Message objects ## Send a plain text message ```bash curl -X POST https://discord.com/api/v10/channels/555566667777888899/messages \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '{"content": "Hello, world!"}' ``` ## Send a message with an embed and a button component ```bash curl -X POST https://discord.com/api/v10/channels/555566667777888899/messages \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "content": "Check this out:", "embeds": [{ "title": "My Embed", "description": "Embed body text", "color": 5814783 }], "components": [{ "type": 1, "components": [{"type":2,"style":1,"label":"Click Me","custom_id":"btn_click"}] }] }' ``` # Response (200): Message object with id, channel_id, author, content, timestamp, etc. ``` -------------------------------- ### Add Member to Lobby Source: https://context7.com/discord/discord-api-spec/llms.txt Add a user to a lobby and set their metadata. Requires bot token and JSON content type. ```bash curl -X PUT https://discord.com/api/v10/lobbies/LOBBY_ID/members/USER_ID \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '{"metadata": {"team": "blue", "role": "sniper"}}' ``` -------------------------------- ### Update an Application Command Source: https://context7.com/discord/discord-api-spec/llms.txt Modifies an existing global application command's description and permissions. Uses PATCH method with JSON payload. ```bash curl -X PATCH https://discord.com/api/v10/applications/123456789012345678/commands/987654321098765432 \ -H "Authorization: Bot BOT_TOKEN" \ -H "Content-Type: application/json" \ -d '{"description": "Updated description", "default_member_permissions": "8"}' ``` -------------------------------- ### GET/PATCH/DELETE /applications/{application_id}/commands/{command_id} Source: https://context7.com/discord/discord-api-spec/llms.txt Manages a specific global application command by its ID, allowing retrieval, update, or deletion. ```APIDOC ## GET/PATCH/DELETE /applications/{application_id}/commands/{command_id} — Single Command Management Retrieves, updates, or deletes a specific global application command by its ID. ```bash ```