API Reference

Discord's API is based around two core layers, a HTTPS/REST API for general operations, and persistent secure WebSocket based connection for sending and subscribing to real-time events. The most common use case of the Discord API will be providing a service, or access to a platform through the OAuth2 API.

Base URL
Stable: https://discord.com/api
Canary: https://canary.discord.com/api

API Versioning

Discord exposes different versions of the API. You should specify which version to use by including it in the request path like https://discord.com/api/v{version_number}. Omitting the version number from the route will route requests to the current default version (marked below).

API Versions
VersionStatusDefault
10Available
9Available✓ Client
8Deprecated
7Deprecated
6Deprecated✓ API
5Discontinued
4Discontinued
3Discontinued

Error Messages

Starting in API v7, form error responses have improved error formatting. The response will tell you which JSON key contains the error, the error code, and a human readable error message. Discord is frequently adding new error messages, so a complete list of errors is not feasible and would be almost instantly out of date. Here are some examples instead:

Array Error
{
"code": 50035,
"errors": {
"activities": {
"0": {
"platform": {
"_errors": [
{
"code": "BASE_TYPE_CHOICES",
"message": "Value must be one of ('desktop', 'android', 'ios')."
}
]
},
"type": {
"_errors": [
{
"code": "BASE_TYPE_CHOICES",
"message": "Value must be one of (0, 1, 2, 3, 4, 5)."
}
]
}
}
}
},
"message": "Invalid Form Body"
}
Object Error
{
"code": 50035,
"errors": {
"access_token": {
"_errors": [
{
"code": "BASE_TYPE_REQUIRED",
"message": "This field is required"
}
]
}
},
"message": "Invalid Form Body"
}
Request Error
{
"code": 50035,
"message": "Invalid Form Body",
"errors": {
"_errors": [
{
"code": "APPLICATION_COMMAND_TOO_LARGE",
"message": "Command exceeds maximum size (4000)"
}
]
}
}

Authentication

Authenticating with the Discord API can be done in one of two ways:

  1. Using a user or bot token gained by logging into an account or registering a bot. For more information on users and bots, see bots vs user accounts.
  2. Using an OAuth2 bearer token gained through the OAuth2 API.

For all authentication types, authentication is performed with the Authorization HTTP header in the format Authorization: TOKEN_TYPE? TOKEN.

Example User Token Authorization Header
Authorization: MTk4NjIyNDgzNDcxOTI1MjQ4.Cl2FMQ.ZnCjm1XVW7vRze4b7Cq4se7kKWs
Example Bot Token Authorization Header
Authorization: Bot MTk4NjIyNDgzNDcxOTI1MjQ4.Cl2FMQ.ZnCjm1XVW7vRze4b7Cq4se7kKWs
Example Bearer Token Authorization Header
Authorization: Bearer CZhtkLDpNYXgPH9Ml6shqh2OwykChw

Encryption

All HTTP-layer services and protocols (e.g. HTTP, WebSocket) within the Discord API are using TLS 1.2.

Snowflake Format

Discord utilizes Twitter's snowflake format for uniquely identifiable descriptors (IDs). These IDs are guaranteed to be unique across all of Discord, except in some unique scenarios in which child objects share their parent's ID. Because Snowflake IDs are up to 64 bits in size (e.g. a uint64), they are always returned as strings in the HTTP API to prevent integer overflows in some languages. See the Gateway documentation for more information regarding Gateway encoding.

Snowflake ID Broken Down in Binary
111111111111111111111111111111111111111111 11111 11111 111111111111
64 22 17 12 0
Snowflake ID Format Structure (Left to Right)
FieldBitsNumber of bitsDescriptionRetrieval
Timestamp63 to 2242 bitsMilliseconds since Discord Epoch, the first second of 2015 or 1420070400000.(snowflake >> 22) + 1420070400000
Internal worker ID21 to 175 bits(snowflake & 0x3E0000) >> 17
Internal process ID16 to 125 bits(snowflake & 0x1F000) >> 12
Increment11 to 012 bitsFor every ID that is generated on that process, this number is incrementedsnowflake & 0xFFF

Convert Snowflake to DateTime

175928847299117063to binaryNumber of milliseconds since the Discord epoch (first second of 2015)internalworkerIDinternalprocessIDincremented for everygenerated ID on thatprocess0000001001110001000001100101101011000001000000100000000000000111419447057961462015105796012172264+ 1420070400000Discord Epoch (unix timestamp in ms)Parse unix timstamp (ms)2016-04-30 11:18:25.796 UTCto decimal

Snowflake IDs in Pagination

Discord typically uses snowflake IDs in many API routes for pagination. The standardized pagination paradigm utilized is one in which you can specify IDs before and after in combination with limit to retrieve a desired page of results. You will want to refer to the specific endpoint documentation for details.

It is useful to note that snowflake IDs are just numbers with a timestamp, so when dealing with pagination where you want results from the beginning of time (in Discord Epoch, but 0 works here too) or before/after a specific time you can generate a snowflake ID for that time.

Generating a Snowflake ID from a Timestamp Example
(timestamp_ms - DISCORD_EPOCH) << 22

ID Serialization

There are some cases in which the API and Gateway may return IDs in an unexpected format. Internally, Discord stores IDs as integer snowflakes. When IDs are serialized to JSON, bigints are transformed into strings. Given that all Discord IDs are snowflakes, you should always expect a string.

However, there are cases in which passing something to the API will instead return IDs serialized as an integer; this is the case when you send the API or Gateway a value in an id field that is not bigint size. For example, when requesting GUILD_MEMBERS_CHUNK from the gateway:

// Send
{
op: 8,
d: {
guild_id: [ '308994132968210433' ],
user_ids: [ '123123' ]
}
}
// Receive
{
t: 'GUILD_MEMBERS_CHUNK',
s: 3,
op: 0,
d: {
not_found: [ 123123 ],
members: [],
guild_id: '308994132968210433'
}
}

You can see in this case that the sent user_id is not a bigint; therefore, when it is serialized back to JSON by Discord, it is not transformed into a string. This will never happen with IDs that come from Discord. But, this can happen if you send malformed data in your requests.

ISO8601 Date/Time

Discord utilizes the ISO8601 format for most Date/Times returned in the API. This format is referred to as type ISO8601 within tables in this documentation.

Consistency

Discord operates at a scale where true consistency is impossible. Because of this, lots of operations in the API and in-between API services are eventually consistent. Due to this, client actions can never be serialized and may be executed in any order (if executed at all). Along with these constraints, events in Discord may:

  • Never be sent to a client
  • Be sent exactly one time to the client
  • Be sent up to N times per client

Clients should operate on events and results from the API in as much of an idempotent behavior as possible.

HTTP API

User Agent

Clients using the HTTP API should provide a valid User Agent which specifies information about the client library and version in the following format:

User Agent Example
User-Agent: DiscordBot ($url, $versionNumber)

Clients may append more information and metadata to the end of this string as they wish.

Rate Limiting

The HTTP API implements a process for limiting and preventing excessive requests in accordance with RFC 6585. API users that regularly hit and ignore rate limits will have their API keys revoked, and be blocked from the platform. For more information on rate limiting of requests, please see the Rate Limits section.

Boolean Query Strings

Certain endpoints in the API are documented to accept booleans for their query string parameters. While there is no standard system for boolean representation in query string parameters, Discord represents such cases using True, true, or 1 for true and False, false or 0 for false.

Debugging

The HTTP API accepts an optional X-Debug-Options header with a comma-delimited list of debug options. The options in this list can be arbitrary, but the below options have effects:

ValueDescription
canaryForcefully routes the request to the canary API
traceForcefully traces the request with APM
APM Tracing

Discord offers an APM (Application Performance Monitoring) service that allows Discord employees to view traces of requests made to the API. This is useful for debugging issues with the API, and can be enabled by setting trace in the X-Debug-Options header as described above.

When tracing requests, you must provide an additional X-Client-Trace-ID header with a unique identifier for the request. This identifier can be generated with the following pseudocode:

import base64
import random
import struct
import time
class IDGenerator:
def __init__(self):
self.prefix = random.randint(0, 0xFFFFFFFF) & 0xFFFFFFFF
self.creation_time = int(time.time() * 1000)
self.sequence = 0
def generate(self, user_id: int = 0):
uuid = bytearray(24)
# Lowest signed 32 bits
struct.pack_into("<I", uuid, 0, user_id & 0xFFFFFFFF)
struct.pack_into("<I", uuid, 4, user_id >> 32)
struct.pack_into("<I", uuid, 8, self.prefix)
# Lowest signed 32 bits
struct.pack_into("<I", uuid, 12, self.creation_time & 0xFFFFFFFF)
struct.pack_into("<I", uuid, 16, self.creation_time >> 32)
struct.pack_into("<I", uuid, 20, self.sequence)
self.sequence += 1
return base64.b64encode(uuid).decode("utf-8")
if __name__ == "__main__":
generator = IDGenerator()
# Use 0 for user_id if you don't have one
generator.generate(user_id or 0)

After the request is completed, the trace may be viewed by navigating to https://app.datadoghq.com/apm/traces?query=@guid.x-client-trace-id:"{trace_id}"&showAllSpans=true (replacing the {trace_id} with the value you provided).

Gateway API

Discord's Gateway API is used for maintaining persistent, stateful WebSocket connections between your client and Discord servers. These connections are used for sending and receiving real-time events your client can use to track and update local state. The Gateway API uses secure WebSocket connections as specified in RFC 6455. For information on opening Gateway connections, please see the Gateway API section.

Client Properties

Client properties, or "super properties", contain tracking information about the current client, used for analytics and A/B testing purposes. These properties are sent when identifying with the Gateway and are included with every outgoing HTTP request using the X-Super-Properties header as a base 64-encoded JSON object.

Client Properties Structure

Due to the nature of client properties, the structure of this object is not well-defined, and no field is truly required. Additionally, types of fields are not verified, and all documented enums are merely conventions. Fields are marked as required if it's observed that they are sent in all official client properties.

FieldTypeDescription
os 1stringThe operating system of the client
os_versionstringThe operating system version (kernel version for Linux, SDK version for Android)
os_sdk_version? (deprecated)stringThe Android operating system SDK version
os_arch?stringThe architecture of the operating system
app_arch?stringThe architecture of the desktop application
browserstringThe browser the client is using
browser_user_agent 2stringThe user-agent of the client's browser, may be blank on mobile clients
browser_versionstringThe version of the client's browser, may be blank on mobile clients
client_build_number 1integerThe build number of the client
native_build_number??integerThe native metadata version of the desktop client, if using the new update system
client_version? 1stringThe mobile client version
client_event_source??stringThe alternate event source this request originated from
client_performance_cpu? (deprecated)integerThe total CPU utilization of the mobile device (in percent)
client_performance_memory? (deprecated)integerThe total memory utilization of the mobile device (in kilobytes)
cpu_core_count? (deprecated)integerThe number of CPU cores available to the mobile device
release_channel 1stringThe release channel of the client
system_localestringThe primary system locale
device?stringThe model of the mobile device the client is running on
device_vendor_id?stringA unique identifier for the mobile device (random UUID on Android, IdentifierForVendor on iOS)
device_advertiser_id? (deprecated)stringThe advertiser ID of the mobile device
design_idintegerThe design ID of the client
accessibility_support_enabled? (deprecated)booleanWhether accessibility support is enabled
accessibility_features? (deprecated)integerThe accessibility features enabled on the client
window_manager?stringThe Linux window manager (env.XDG_CURRENT_DESKTOP ?? "unknown" + "," + env.GDMSESSION ?? "unknown")
distro?stringThe Linux distribution (output of lsb_release -ds)
referrer?stringThe URL that originally referred the user to Discord
referrer_current?stringSame as referrer but for the current session
referring_domain?stringThe domain of the URL that originally referred the user to Discord
referring_domain_current?stringSame as referring_domain but for the current session
search_engine?stringThe search engine that originally referred the user to Discord, parsed from the referrer URL
search_engine_current?stringSame as search_engine but for the current session
mp_keyword?stringThe search engine query that originally referred the user to Discord, parsed from the q or p (for Yahoo) parameter of the referrer URL
mp_keyword_current?stringSame as mp_keyword but for the current session
utm_campaign?stringThe UTM campaign that originally referred the user to Discord, parsed from the utm_campaign parameter of the referrer URL
utm_campaign_current?stringSame as utm_campaign but for the current session
utm_content?stringThe UTM content that originally referred the user to Discord, parsed from the utm_content parameter of the referrer URL
utm_content_current?stringSame as utm_content but for the current session
utm_medium?stringThe UTM medium that originally referred the user to Discord, parsed from the utm_medium parameter of the referrer URL
utm_medium_current?stringSame as utm_medium but for the current session
utm_source?stringThe UTM source that originally referred the user to Discord, parsed from the utm_source parameter of the referrer URL
utm_source_current?stringSame as utm_source but for the current session
utm_term?stringThe UTM term that originally referred the user to Discord, parsed from the utm_term parameter of the referrer URL
utm_term_current?stringSame as utm_term but for the current session

1 These properties are used to gate experimental features and may be required for certain endpoints. client_version is used instead of client_build_number for mobile experiments. See the experiments documentation for more information.

2 If specified, this value should match the User-Agent header sent by the client.

Operating System Type
ValueDescription
AndroidThe client is running on Android
BlackBerryThe client is running on BlackBerry OS
Mac OS XThe client is running on macOS
iOSThe client is running on iOS
LinuxThe client is running on a Linux distribution
Windows MobileThe client is running on Windows Mobile
WindowsThe client is running on Windows
Browser Type
ValueDescriptionClient Status Type
Discord ClientDesktop clientdesktop
Discord AndroidAndroid clientmobile
Discord iOSiOS clientmobile
Discord EmbeddedEmbedded (e.g. Xbox) clientembedded
Android ChromeGoogle Chrome Androidweb
Android MobileGeneric Android browserweb
BlackBerryBlackBerry browserweb
ChromeGoogle Chrome desktopweb
Chrome iOSGoogle Chrome iOSweb
EdgeMicrosoft Edge desktopweb
Facebook MobileFacebook mobile browserweb
FirefoxMozilla Firefoxweb
Internet ExplorerMicrosoft Internet Explorerweb
KonquerorKDE Konquerorweb
Mobile SafariSafari iOSweb
MozillaGeneric Mozilla-like browserweb
OperaOperaweb
Opera MiniOpera Miniweb
SafariSafari desktopweb
Client Event Source
ValueDescription
OVERLAYThe request originated from the Discord Overlay
Release Channel
ValueDescription
stableStable
ptbPTB
canaryCanary
stagingStaging
internalInternal
googleReleaseGoogle Play Store stable
samsungReleaseSamsung Galaxy Store stable
billingReleaseAndroid billing (unknown)
betaReleaseAndroid beta
canaryReleaseAndroid alpha
internalReleaseInternal employee-only release
developerReleaseInternal developer release
adhocReleaseiOS ad-hoc release
N/ANot applicable release (unknown)
unknownUnknown release
Design ID
ValueNameDescription
0CLASSIC_IAThe classic design (default)
1DESIGN_IAThe full mobile redesign
2DESIGN_TABS_IAThe mobile redesign with tabs
3YOU_BAR_IAThe mobile redesign with the you bar
Accessibility Feature Flags
ValueNameDescription
1 << 0SCREENREADERThe user has a screen reader enabled
1 << 1REDUCED_MOTIONThe user has reduced motion enabled
1 << 2REDUCED_TRANSPARENCYThe user has reduced transparency enabled
1 << 3HIGH_CONTRASTThe user has high contrast enabled
1 << 4BOLD_TEXTThe user has bold text enabled
1 << 5GRAYSCALEThe user has grayscale colors enabled
1 << 6INVERT_COLORSThe user has inverted colors enabled
1 << 7PREFERS_COLOR_SCHEME_LIGHTThe user prefers a light color scheme
1 << 8PREFERS_COLOR_SCHEME_DARKThe user prefers a dark color scheme
1 << 9CHAT_FONT_SCALE_INCREASEDThe user has increased the chat font scale
1 << 10CHAT_FONT_SCALE_DECREASEDThe user has decreased the chat font scale
1 << 11ZOOM_LEVEL_INCREASEDThe user has increased the zoom level
1 << 12ZOOM_LEVEL_DECREASEDThe user has decreased the zoom level
1 << 13MESSAGE_GROUP_SPACING_INCREASEDThe user has increased the message group spacing
1 << 14MESSAGE_GROUP_SPACING_DECREASEDThe user has decreased the message group spacing
1 << 15DARK_SIDEBARThe user has a dark sidebar enabled
1 << 16REDUCED_MOTION_FROM_USER_SETTINGSThe user has reduced motion explicitly enabled from user settings
1 << 17SATURATION_LEVEL_DECREASEDThe user has decreased the saturation level
1 << 18FORCED_COLORSThe user has system high-contrast forced colors enabled
1 << 19FORCED_COLORS_FROM_USER_SETTINGSThe user has high-contrast forced colors explicitly enabled from user settings
1 << 20ROLE_STYLE_ADJUSTEDThe user has adjusted role styles
1 << 21SYNC_PROFILE_THEME_WITH_USER_THEMEThe user has enabled syncing the user profile theme with the client theme
1 << 22REDUCED_MOTION_PREFERS_CROSSFADESThe user has reduced motion enabled and prefers crossfades
1 << 23CONTRAST_LEVEL_INCREASEDThe user has increased the contrast level
1 << 24CONTRAST_LEVEL_DECREASEDThe user has decreased the contrast level
Search Engine
Example Client Properties (Web)
{
"os": "Windows",
"browser": "Chrome",
"device": "",
"system_locale": "en-US",
"browser_user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0",
"browser_version": "124.0.0.0",
"os_version": "10",
"referrer": "https://www.reddit.com/",
"referring_domain": "www.reddit.com",
"referrer_current": "https://www.google.com/",
"referring_domain_current": "www.google.com",
"search_engine_current": "google",
"mp_keyword_current": "discord",
"release_channel": "stable",
"client_build_number": 290453,
"client_event_source": null,
"design_id": 0
}
Example Client Properties (Windows)
{
"os": "Windows",
"browser": "Discord Client",
"release_channel": "canary",
"client_version": "1.0.341",
"os_version": "10.0.26090",
"os_arch": "x64",
"app_arch": "x64",
"system_locale": "en-US",
"browser_user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) discord/1.0.341 Chrome/120.0.6099.291 Electron/28.2.10 Safari/537.36",
"browser_version": "28.2.10",
"client_build_number": 290668,
"native_build_number": 47493,
"client_event_source": null,
"design_id": 0
}
Example Client Properties (macOS)
{
"os": "Mac OS X",
"browser": "Discord Client",
"release_channel": "ptb",
"client_version": "0.0.113",
"os_version": "23.4.0",
"os_arch": "arm64",
"app_arch": "arm64",
"system_locale": "en-US",
"browser_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) discord/0.0.113 Chrome/120.0.6099.291 Electron/28.2.10 Safari/537.36",
"browser_version": "28.2.10",
"client_build_number": 290668,
"native_build_number": null,
"client_event_source": null,
"design_id": 0
}
Example Client Properties (Linux)
{
"os": "Linux",
"browser": "Discord Client",
"release_channel": "canary",
"client_version": "0.0.381",
"os_version": "5.15.153.1-microsoft-standard-WSL2",
"os_arch": "x64",
"app_arch": "x64",
"system_locale": "en-US",
"browser_user_agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) discord/0.0.381 Chrome/120.0.6099.291 Electron/28.2.10 Safari/537.36",
"browser_version": "28.2.10",
"window_manager": "Hyprland,unknown",
"distro": "Ubuntu 22.04.4 LTS",
"client_build_number": 290668,
"native_build_number": null,
"client_event_source": null,
"design_id": 0
}
Example Client Properties (Android)
{
"os": "Android",
"browser": "Discord Android",
"device": "a20e", // Samsung Galaxy A20e
"system_locale": "en-US",
"client_version": "227.6 - rn",
"release_channel": "canaryRelease",
"device_vendor_id": "17503929-a4b8-4490-87bf-0222adfdadc8",
"browser_user_agent": "", // While it is not provided here, the User-Agent header is Discord-Android/227206;RNA
"browser_version": "",
"os_version": "34", // Android 14
"client_build_number": 227206,
"client_event_source": null,
"design_id": 2
}
Example Client Properties (iOS)
{
"os": "iOS",
"browser": "Discord iOS",
"device": "iPhone14,5", // iPhone 13
"system_locale": "en-US",
"client_version": "227.0",
"release_channel": "stable",
"device_vendor_id": "AFF0710F-CEC0-4671-B2CF-0A03D72B5FD0",
"browser_user_agent": "", // While it is not provided here, the User-Agent header is Discord/58755 CFNetwork/1494.0.7 Darwin/23.4.0
"browser_version": "",
"os_version": "17.4.1",
"client_build_number": 58755,
"client_event_source": null,
"design_id": 2
}

Message Formatting

Discord utilizes a subset of markdown for rendering message content on its clients, while also adding some custom functionality to enable things like mentioning users and channels. This functionality uses the following formats:

Formats
TypeStructureExample
User<@USER_ID><@80351110224678912>
User 1<@!USER_ID><@!80351110224678912>
Channel<#CHANNEL_ID><#103735883630395392>
Role<@&ROLE_ID><@&165511591545143296>
Slash Command 2</NAME:COMMAND_ID></airhorn:816437322781949972>
Standard EmojiUnicode Characters💯
Custom Emoji<:NAME:ID><:mmLol:216154654256398347>
Custom Emoji (Animated)<a:NAME:ID><a:b1nzy:392938283556143104>
Unix Timestamp<t:TIMESTAMP><t:1618953630>
Unix Timestamp (Styled)<t:TIMESTAMP:STYLE><t:1618953630:d>

Using the markdown for either users, roles, or channels will usually mention the target(s) accordingly, but this can be suppressed using the allowed_mentions parameter when creating a message. Standard emoji are currently rendered using Twemoji for Desktop/Android and Apple's native emoji on iOS.

Timestamps are expressed in seconds and display the given timestamp in the user's timezone and locale.

1 User mentions with an exclamation mark are deprecated and should be handled like any other user mention.

2 Subcommands and subcommand groups can also be mentioned by using respectively </NAME SUBCOMMAND:ID> and </NAME SUBCOMMAND_GROUP SUBCOMMAND:ID>.

Timestamp Styles
StyleExample OutputDescription
t16:20Short Time
T16:20:30Long Time
d20/04/2021Short Date
D20 April 2021Long Date
f 120 April 2021 16:20Short Date/Time
FTuesday, 20 April 2021 16:20Long Date/Time
R2 months agoRelative Time

1 This is the default.

CDN Formatting

CDN Base URL
https://cdn.discordapp.com/

Discord uses IDs and hashes to render images and other CDN content in the client. These hashes can be retrieved through various API requests, like Get User. Below are the formats, size limitations, and CDN endpoints for content in Discord. The returned format can be changed by changing the extension name at the end of the URL. For images, the returned size can be changed by appending a query string of ?size=desired_size to the URL. Image size can be any power of two between 16 and 4096, with some additional accepted values outlined below.

In the case of endpoints that support animated images, the hash will begin with a_ if it is available in APNG or GIF format (e.g. a_1269e74af4df7417b13759eae50c83dc).

File Formats
NameExtension
JPEG.jpg, .jpeg
PNG.png
SVG.svg
WebP.webp
WebM.webm
GIF.gif
Lottie.json
MP3.mp3
MP4.mp4
OGG.ogg
CDN Endpoints
TypePathSupports
Achievement Icon/app-assets/{application_id}/achievements/{achievement_id}/icons/icon_hash.pngPNG, JPEG, WebP
Application Icon/app-icons/{application_id}/{application_icon}.pngPNG, JPEG, WebP
Application Cover/app-icons/{application_id}/{application_cover_image}.pngPNG, JPEG, WebP
Application Splash/app-icons/{application_id}/{application_splash}.pngPNG, JPEG, WebP
Application Asset/app-assets/{application_id}/{asset_id}.pngPNG, JPEG, WebP
Application Directory Collection/application-directory/collection-items/{item_id}/{item_hash}.pngPNG, JPEG, WebP
Attachment 2/attachments/{channel_id}/[{message_id]/attachment_id}/{attachment_filename}Uploaded format 4
Avatar Decoration Preset/avatar-decoration-presets/{avatar_decoration_data_asset}.pngPNG, JPEG, WebP
Channel Icon/channels/{channel_id}/icons/{channel_icon}.pngPNG, JPEG, WebP
Clan Badge/clan-badges/{guild_id}/{badge_hash}.pngPNG
Clan Banner/clan-banners/{guild_id}/{banner_hash}.pngPNG
Custom Emoji/emojis/{emoji_id}.pngPNG, JPEG, WebP, GIF
Guild Icon/icons/{guild_id}/{guild_icon}.pngPNG, JPEG, WebP, GIF
Guild Splash/splashes/{guild_id}/{guild_splash}.pngPNG, JPEG, WebP
Guild Discovery Splash/discovery-splashes/{guild_id}/{guild_discovery_splash}.pngPNG, JPEG, WebP
Guild Banner/banners/{guild_id}/{guild_banner}.pngPNG, JPEG, WebP, GIF
Guild Home Header/guilds/{guild_id}/home-headers/{guild_home_header}.pngPNG, JPEG, WebP
Guild Scheduled Event Cover/guild-events/{scheduled_event_id}/{scheduled_event_cover_image}.pngPNG, JPEG, WebP
Guild Member Avatar/guilds/{guild_id}/users/{user_id}/avatars/{user_avatar}.pngPNG, JPEG, WebP, GIF
Guild Member Banner/guilds/{guild_id}/users/{user_id}/banners/{user_banner}.pngPNG, JPEG, WebP, GIF
Profile Badge/badge-icons/{badge_icon}.pngPNG
Quest Asset 5/assets/quests/{quest_id}/{asset_name}.png, /assets/quests/{quest_id}/{theme}/{asset_name}.pngPNG, JPEG, GIF, SVG, WebM
Role Icon/roles/{role_id}/icons/{role_icon}.pngPNG, JPEG, WebP
Soundboard Sound/soundboard-sounds/{sound_id}MP3, OGG
Sticker 2 3/stickers/{sticker_id}.pngPNG, Lottie, GIF
Sticker Pack Banner/app-assets/710982414301790216/store/{asset_id}.pngPNG, JPEG, WebP
Team Icon/team-icons/{team_id}/{team_icon}.pngPNG, JPEG, WebP
User Avatar/avatars/{user_id}/{user_avatar}.pngPNG, JPEG, WebP, GIF
Default User Avatar 1 2/embed/avatars/{user_index}.pngPNG
User Banner/banners/{user_id}/{user_banner}.pngPNG, JPEG, WebP, GIF
Video Filter/users/{user_id}/video-filter-assets/{video_filter_id}/{video_filter_asset}.pngPNG, JPEG, GIF, MP4, WEBP

1 The value for user_index in the path for migrated users should be the user's ID shifted 22 bits to the left modulo 6 (i.e. user_id >> 22 % 6). The value for non-migrated users the user's discriminator modulo 5 (Test#1337 would be 1337 % 5, which evaluates to 2). The value for teams should be the team's ID modulo 5 (i.e. team_id % 5). See the section on Discord's new username system for more information.

2 The size of images returned is constant with the size query string parameter being ignored.

3 The sticker will be available as PNG if its format_type is PNG or APNG, GIF if its format_type is GIF, and as Lottie if its format_type is LOTTIE. GIF stickers are not available through the CDN, and must be accessed at https://media.discordapp.net/stickers/{sticker_id}.gif.

4 The attachment will only be available in its uploaded format, which can be any format.

5 The theme path is only used for fetching the game_tile and logotype assets.

CDN Parameters

The CDN supports various query string parameters. These parameters are optional and can be used to modify the returned resource. Parameters are only applicable to image resources.

FieldTypeDescription
sizeintegerThe size of the image to return (if omitted, a default size is used); the size can be any power of two between 16 and 4096, and additionally 20, 22, 24, 28, 40, 44, 48, 56, 60, 80, 96, 100, 160, 240, 300, 320, 480, 600, 640, 1280, 1536, 3072
qualitystringThe quality of the image to return; not supported with all endpoints and image types
keep_aspect_ratioboolean 1Whether the image will be resized to the endpoint's enforced aspect ratio (default false)
passthroughboolean 1Whether the image will be returned in the original, Discord-defined quality and format (usually APNG) if possible (default true); only supported with specific endpoints

1 The CDN only accepts boolean parameters as true or false (not 1 or 0).

Image Quality

The quality of the image to return. Only supported with images of type WebP and JPG (the rest are always lossless). The quality can be any of the following values:

ValueDescription
losslessThe image will be returned in its original format, with no quality loss
highThe image will be returned in a high quality format (the default)
lowThe image will be returned in a low quality format

Signed Attachment URLs

Attachments uploaded to Discord's CDN (like user-uploaded images) have signed URLs with a preset expiry time. Discord automatically refreshes attachment CDN URLs that appear within the client, so when you receive a payload with a signed URL (like when you fetch a message), it will be valid.

When passing CDN URLs into API fields, like url in an embed image object and avatar_url for webhooks, or when simply sending a message, you can pass the CDN URL without any parameters as the value and Discord will automatically render and refresh the URL.

If you need to refresh an attachment URL manually, you can use the Refresh Attachment URLs endpoint with any URL.

Other CDN endpoints listed above are not signed, so they will not expire.

Attachment URL Query Parameters
ParameterDescription
exHex timestamp indicating when an attachment CDN URL will expire
isHex timestamp indicating when the URL was issued
hmUnique signature that remains valid until the URL's expiration
Example Attachment URL
https://cdn.discordapp.com/attachments/1012345678900020080/1234567891233211234/my_image.png?ex=65d903de&is=65c68ede&hm=2481f30dd67f503f54d020ae3b5533b9987fae4e55f2b4e3926e08a3fa3ee24f&

CDN Data

CDN data is a Data URI scheme that supports formats such as JPG, GIF, and PNG. An example Data URI format is:

data: image / jpeg;
base64, BASE64_ENCODED_JPEG_IMAGE_DATA;

Ensure you use the proper content type (e.g. image/jpeg, image/png, image/gif) that matches the image data being provided.

Uploading Files

Some endpoints support file attachments, indicated by the files[n] parameter. To add file(s), the standard application/json body must be replaced by a multipart/form-data body. The JSON message body can optionally be provided using the payload_json parameter.

All files[n] parameters must include a valid Content-Disposition subpart header with a filename and unique name parameter. Each file parameter must be uniquely named in the format files[n] such as files[0], files[1], or files[42]. The suffixed index n is the snowflake placeholder that can be used in the attachments field, which can be passed to the payload_json parameter (or Callback Data Payloads).

Images can also be referenced in embeds using the attachment://filename URL. The filename for these URLs must be ASCII alphanumeric with underscores, dashes, or dots. An example payload is provided below.

Editing Message Attachments

The attachments JSON parameter includes all files that will be appended to the message, including new files and their respective snowflake placeholders (referenced above). When making a PATCH request, only files listed in the attachments parameter will be appended to the message. Any previously-added files that aren't included will be removed.

Example Request Bodies (multipart/form-data)

Note that these examples are small sections of an HTTP request to demonstrate behaviour of this endpoint - client libraries will set their own form boundaries (boundary is just an example). For more information, refer to the multipart/form-data spec.

This example demonstrates usage of the endpoint without payload_json.

-boundary
Content-Disposition: form-data; name="content"
Hello, World!
-boundary
Content-Disposition: form-data; name="tts"
true
-boundary--

This example demonstrates usage of the endpoint with payload_json and all content fields (content, embeds, files[n]) set.

-boundary
Content-Disposition: form-data; name="payload_json"
Content-Type: application/json
{
"content": "Hello, World!",
"embeds": [{
"title": "Hello, Embed!",
"description": "This is an embedded message.",
"thumbnail": {
"url": "attachment://myfile.png"
},
"image": {
"url": "attachment://mygif.gif"
}
}],
"message_reference": {
"message_id": "233648473390448641"
},
"attachments": [{
"id": 0,
"description": "Image of a cute little cat",
"filename": "myfile.png"
}, {
"id": 1,
"description": "Rickroll gif",
"filename": "mygif.gif"
}]
}
-boundary
Content-Disposition: form-data; name="files[0]"; filename="myfile.png"
Content-Type: image/png
[image bytes]
-boundary
Content-Disposition: form-data; name="files[1]"; filename="mygif.gif"
Content-Type: image/gif
[image bytes]
-boundary--
Using Attachments within Embeds

You can upload attachments when creating a message and use those attachments within your embed. To do this, you will want to upload files as part of your multipart/form-data body. Make sure that you're uploading files which contain a filename, as you will need to reference it in your payload.

Within an embed object, you can then set an image to use an attachment as its URL with the attachment scheme syntax: attachment://filename.png

For example:

{
"embeds": [
{
"image": {
"url": "attachment://screenshot.png"
}
}
]
}

Uploading to Google Cloud

You can upload large attachments quickly directly to Discord's Google Cloud storage bucket, using the Create Attachments endpoint to generate upload URLs, and sending each generated URL a PUT request with the intended attachment as the body.

When using Google Cloud uploads, the file upload size limit applies to individual files, rather than the entire request.

An example implementation in Python pseudocode would be:

import requests
import os
url = "https://discord.com/api/v10/channels/<channel_id>/attachments"
headers = {
"Authorization": "Bot <bot_token>"
}
filename = "index.js"
size = os.stat(filename).st_size
json = {
"files": [{
"file_size": size,
"filename": filename
}]
}
r = requests.post(url, headers=headers, json=json)
r.raise_for_status()
upload = r.json()['attachments'][0]
with open(filename, "r") as f:
data = f.read()
r = requests.put(upload['upload_url'], data=data)
r.raise_for_status()
upload_filename = upload['upload_filename']

Now, instead of sending the attachment again in a form body in the request, you can just send the upload_filename! For example:

{
"content": "look at my cute cat!",
"attachments": [
{
"id": "0",
"filename": "cat.png",
"uploaded_filename": "6a08e58a-265f-485a-8c85-5cd4df0edde0/cat.png"
}
]
}

Locales

LocaleLanguage NameNative Name
arArabicالعربية
bgBulgarianбългарски
csCzechČeština
daDanishDansk
deGermanDeutsch
elGreekΕλληνικά
en-GBEnglish, UKEnglish, UK
en-USEnglish, USEnglish, US
es-ESSpanishEspañol
es-419Spanish, LATAMEspañol de América Latina
fiFinnishSuomi
frFrenchFrançais
hiHindiहिन्दी
hrCroatianHrvatski
huHungarianMagyar
idIndonesianBahasa Indonesia
itItalianItaliano
jaJapanese日本語
koKorean한국어
ltLithuanianLietuviškai
nlDutchNederlands
noNorwegianNorsk
plPolishPolski
pt-BRPortuguese, BrazilianPortuguês do Brasil
roRomanianRomână
ruRussianPусский
sv-SESwedishSvenska
thThaiไทย
trTurkishTürkçe
ukUkrainianУкраїнська
viVietnameseTiếng Việt
zh-CNChinese, China中文
zh-TWChinese, Taiwan繁體中文

Documentation Reference

This documentation uses various conventions to describe the API. Here are some common conventions you may see:

Nullable and Optional Resource Fields

Resource fields that may contain a null value have types that are prefixed with a question mark. Resource fields that are optional have names that are suffixed with a question mark.

Example Nullable and Optional Fields
FieldType
optional_field? 1string
nullable_field?string
optional_and_nullable_field??string

1 May be unexpectedly null at 3:00 AM on Tuesdays for accounts created on June 23rd, 2017.

Deprecated/Removed Fields

Fields that are deprecated will be marked with a (deprecated) notice next to them. Fields that are removed (and are kept for completion's sake, such as in enums) will be marked with strikethrough.

Event Fields

Certain fields are only present in structures received over the Gateway. These fields will usually be documented in the Gateway section instead of the main structure.

Badges

Certain endpoints may have badges that describe additional behavior in short form. Here are some examples you may find:

MFA Required

This endpoint may require that users with multi-factor authentication enabled authenticate themselves for certain actions. See the MFA verification documentation for implementation.

This is not applicable to OAuth2 and bot requests.

Audit Log Reason

The endpoint may be used with a X-Audit-Log-Reason header. This header is used to provide a reason for the action being performed. This reason will be shown in the audit log entry for this action. See the audit log documentation for more information.

Unauthenticated Request

These requests do not require the Authorization header to be present.

OAuth2 Request

The endpoint may be used with a bearer token in the Authorization header. The specific scope required (if any) will be provided if you hover over the badge.

Deprecated Endpoint

This endpoint remains active and functionally the same, but it should be avoided if possible as it may be removed in a future API version.