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
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
Version | Status | Default |
---|---|---|
10 | Available | |
9 | Available | ✓ Client |
8 | Deprecated | |
7 | Deprecated | |
6 | Deprecated | ✓ API |
5 | Discontinued | |
4 | Discontinued | |
3 | Discontinued |
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:
- 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.
- 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
Example Bot Token Authorization Header
Example Bearer Token Authorization Header
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
Snowflake ID Format Structure (Left to Right)
Field | Bits | Number of bits | Description | Retrieval |
---|---|---|---|---|
Timestamp | 63 to 22 | 42 bits | Milliseconds since Discord Epoch, the first second of 2015 or 1420070400000. | (snowflake >> 22) + 1420070400000 |
Internal worker ID | 21 to 17 | 5 bits | (snowflake & 0x3E0000) >> 17 | |
Internal process ID | 16 to 12 | 5 bits | (snowflake & 0x1F000) >> 12 | |
Increment | 11 to 0 | 12 bits | For every ID that is generated on that process, this number is incremented | snowflake & 0xFFF |
Convert Snowflake to DateTime
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
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:
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
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:
Value | Description |
---|---|
canary | Forcefully routes the request to the canary API |
trace | Forcefully 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:
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.
Field | Type | Description |
---|---|---|
os 1 | string | The operating system of the client |
os_version | string | The operating system version (kernel version for Linux, SDK version for Android) |
os_sdk_version? (deprecated) | string | The Android operating system SDK version |
os_arch? | string | The architecture of the operating system |
app_arch? | string | The architecture of the desktop application |
browser | string | The browser the client is using |
browser_user_agent 2 | string | The user-agent of the client's browser, may be blank on mobile clients |
browser_version | string | The version of the client's browser, may be blank on mobile clients |
client_build_number 1 | integer | The build number of the client |
native_build_number? | ?integer | The native metadata version of the desktop client, if using the new update system |
client_version? 1 | string | The mobile client version |
client_event_source? | ?string | The alternate event source this request originated from |
client_performance_cpu? (deprecated) | integer | The total CPU utilization of the mobile device (in percent) |
client_performance_memory? (deprecated) | integer | The total memory utilization of the mobile device (in kilobytes) |
cpu_core_count? (deprecated) | integer | The number of CPU cores available to the mobile device |
release_channel 1 | string | The release channel of the client |
system_locale | string | The primary system locale |
device? | string | The model of the mobile device the client is running on |
device_vendor_id? | string | A unique identifier for the mobile device (random UUID on Android, IdentifierForVendor on iOS) |
device_advertiser_id? (deprecated) | string | The advertiser ID of the mobile device |
design_id | integer | The design ID of the client |
accessibility_support_enabled? (deprecated) | boolean | Whether accessibility support is enabled |
accessibility_features? (deprecated) | integer | The accessibility features enabled on the client |
window_manager? | string | The Linux window manager (env.XDG_CURRENT_DESKTOP ?? "unknown" + "," + env.GDMSESSION ?? "unknown" ) |
distro? | string | The Linux distribution (output of lsb_release -ds ) |
referrer? | string | The URL that originally referred the user to Discord |
referrer_current? | string | Same as referrer but for the current session |
referring_domain? | string | The domain of the URL that originally referred the user to Discord |
referring_domain_current? | string | Same as referring_domain but for the current session |
search_engine? | string | The search engine that originally referred the user to Discord, parsed from the referrer URL |
search_engine_current? | string | Same as search_engine but for the current session |
mp_keyword? | string | The 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? | string | Same as mp_keyword but for the current session |
utm_campaign? | string | The UTM campaign that originally referred the user to Discord, parsed from the utm_campaign parameter of the referrer URL |
utm_campaign_current? | string | Same as utm_campaign but for the current session |
utm_content? | string | The UTM content that originally referred the user to Discord, parsed from the utm_content parameter of the referrer URL |
utm_content_current? | string | Same as utm_content but for the current session |
utm_medium? | string | The UTM medium that originally referred the user to Discord, parsed from the utm_medium parameter of the referrer URL |
utm_medium_current? | string | Same as utm_medium but for the current session |
utm_source? | string | The UTM source that originally referred the user to Discord, parsed from the utm_source parameter of the referrer URL |
utm_source_current? | string | Same as utm_source but for the current session |
utm_term? | string | The UTM term that originally referred the user to Discord, parsed from the utm_term parameter of the referrer URL |
utm_term_current? | string | Same 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
Value | Description |
---|---|
Android | The client is running on Android |
BlackBerry | The client is running on BlackBerry OS |
Mac OS X | The client is running on macOS |
iOS | The client is running on iOS |
Linux | The client is running on a Linux distribution |
Windows Mobile | The client is running on Windows Mobile |
Windows | The client is running on Windows |
Browser Type
Value | Description | Client Status Type |
---|---|---|
Discord Client | Desktop client | desktop |
Discord Android | Android client | mobile |
Discord iOS | iOS client | mobile |
Discord Embedded | Embedded (e.g. Xbox) client | embedded |
Android Chrome | Google Chrome Android | web |
Android Mobile | Generic Android browser | web |
BlackBerry | BlackBerry browser | web |
Chrome | Google Chrome desktop | web |
Chrome iOS | Google Chrome iOS | web |
Edge | Microsoft Edge desktop | web |
Facebook Mobile | Facebook mobile browser | web |
Firefox | Mozilla Firefox | web |
Internet Explorer | Microsoft Internet Explorer | web |
Konqueror | KDE Konqueror | web |
Mobile Safari | Safari iOS | web |
Mozilla | Generic Mozilla-like browser | web |
Opera | Opera | web |
Opera Mini | Opera Mini | web |
Safari | Safari desktop | web |
Client Event Source
Value | Description |
---|---|
OVERLAY | The request originated from the Discord Overlay |
Release Channel
Value | Description |
---|---|
stable | Stable |
ptb | PTB |
canary | Canary |
staging | Staging |
internal | Internal |
googleRelease | Google Play Store stable |
billingRelease | Android billing (unknown) |
betaRelease | Android beta |
canaryRelease | Android alpha |
internalRelease | Internal employee-only release |
developerRelease | Internal developer release |
adhocRelease | iOS ad-hoc release |
N/A | Not applicable release (unknown) |
unknown | Unknown release |
Design ID
Value | Name | Description |
---|---|---|
0 | CLASSIC_IA | The classic design (default) |
1 | DESIGN_IA | The full mobile redesign |
2 | DESIGN_TABS_IA | The mobile redesign with tabs |
3 | YOU_BAR_IA | The mobile redesign with the you bar |
Accessibility Feature Flags
Value | Name | Description |
---|---|---|
1 << 0 | SCREENREADER | The user has a screen reader enabled |
1 << 1 | REDUCED_MOTION | The user has reduced motion enabled |
1 << 2 | REDUCED_TRANSPARENCY | The user has reduced transparency enabled |
1 << 3 | HIGH_CONTRAST | The user has high contrast enabled |
1 << 4 | BOLD_TEXT | The user has bold text enabled |
1 << 5 | GRAYSCALE | The user has grayscale colors enabled |
1 << 6 | INVERT_COLORS | The user has inverted colors enabled |
1 << 7 | PREFERS_COLOR_SCHEME_LIGHT | The user prefers a light color scheme |
1 << 8 | PREFERS_COLOR_SCHEME_DARK | The user prefers a dark color scheme |
1 << 9 | CHAT_FONT_SCALE_INCREASED | The user has increased the chat font scale |
1 << 10 | CHAT_FONT_SCALE_DECREASED | The user has decreased the chat font scale |
1 << 11 | ZOOM_LEVEL_INCREASED | The user has increased the zoom level |
1 << 12 | ZOOM_LEVEL_DECREASED | The user has decreased the zoom level |
1 << 13 | MESSAGE_GROUP_SPACING_INCREASED | The user has increased the message group spacing |
1 << 14 | MESSAGE_GROUP_SPACING_DECREASED | The user has decreased the message group spacing |
1 << 15 | DARK_SIDEBAR | The user has a dark sidebar enabled |
1 << 16 | REDUCED_MOTION_FROM_USER_SETTINGS | The user has reduced motion explicitly enabled from user settings |
1 << 17 | SATURATION_LEVEL_DECREASED | The user has decreased the saturation level |
1 << 18 | FORCED_COLORS | The user has system high-contrast forced colors enabled |
1 << 19 | FORCED_COLORS_FROM_USER_SETTINGS | The user has high-contrast forced colors explicitly enabled from user settings |
1 << 20 | ROLE_STYLE_ADJUSTED | The user has adjusted role styles |
1 << 21 | SYNC_PROFILE_THEME_WITH_USER_THEME | The user has enabled syncing the user profile theme with the client theme |
1 << 22 | REDUCED_MOTION_PREFERS_CROSSFADES | The user has reduced motion enabled and prefers crossfades |
1 << 23 | CONTRAST_LEVEL_INCREASED | The user has increased the contrast level |
1 << 24 | CONTRAST_LEVEL_DECREASED | The user has decreased the contrast level |
Search Engine
Value | Description |
---|---|
Google search engine | |
bing | Bing search engine |
yahoo | Yahoo search engine |
duckduckgo | DuckDuckGo 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
Type | Structure | Example |
---|---|---|
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 Emoji | Unicode 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
Style | Example Output | Description |
---|---|---|
t | 16:20 | Short Time |
T | 16:20:30 | Long Time |
d | 20/04/2021 | Short Date |
D | 20 April 2021 | Long Date |
f 1 | 20 April 2021 16:20 | Short Date/Time |
F | Tuesday, 20 April 2021 16:20 | Long Date/Time |
R | 2 months ago | Relative Time |
1 This is the default.
CDN Formatting
CDN Base URL
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
Name | Extension |
---|---|
JPEG | .jpg, .jpeg |
PNG | .png |
SVG | .svg |
WebP | .webp |
WebM | .webm |
GIF | .gif |
Lottie | .json |
MP3 | .mp3 |
MP4 | .mp4 |
OGG | .ogg |
CDN Endpoints
Type | Path | Supports |
---|---|---|
Achievement Icon | /app-assets/{application_id}/achievements/{achievement_id}/icons/icon_hash.png | PNG, JPEG, WebP |
Application Icon | /app-icons/{application_id}/{application_icon}.png | PNG, JPEG, WebP |
Application Cover | /app-icons/{application_id}/{application_cover_image}.png | PNG, JPEG, WebP |
Application Splash | /app-icons/{application_id}/{application_splash}.png | PNG, JPEG, WebP |
Application Asset | /app-assets/{application_id}/{asset_id}.png | PNG, JPEG, WebP |
Application Directory Collection | /application-directory/collection-items/{item_id}/{item_hash}.png | PNG, 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}.png | PNG, JPEG, WebP |
Channel Icon | /channels/{channel_id}/icons/{channel_icon}.png | PNG, JPEG, WebP |
Clan Badge | /clan-badges/{guild_id}/{badge_hash}.png | PNG |
Clan Banner | /clan-banners/{guild_id}/{banner_hash}.png | PNG |
Custom Emoji | /emojis/{emoji_id}.png | PNG, JPEG, WebP, GIF |
Guild Icon | /icons/{guild_id}/{guild_icon}.png | PNG, JPEG, WebP, GIF |
Guild Splash | /splashes/{guild_id}/{guild_splash}.png | PNG, JPEG, WebP |
Guild Discovery Splash | /discovery-splashes/{guild_id}/{guild_discovery_splash}.png | PNG, JPEG, WebP |
Guild Banner | /banners/{guild_id}/{guild_banner}.png | PNG, JPEG, WebP, GIF |
Guild Home Header | /guilds/{guild_id}/home-headers/{guild_home_header}.png | PNG, JPEG, WebP |
Guild Scheduled Event Cover | /guild-events/{scheduled_event_id}/{scheduled_event_cover_image}.png | PNG, JPEG, WebP |
Guild Member Avatar | /guilds/{guild_id}/users/{user_id}/avatars/{user_avatar}.png | PNG, JPEG, WebP, GIF |
Guild Member Banner | /guilds/{guild_id}/users/{user_id}/banners/{user_banner}.png | PNG, JPEG, WebP, GIF |
Profile Badge | /badge-icons/{badge_icon}.png | PNG |
Quest Asset 5 | /assets/quests/{quest_id}/{asset_name}.png, /assets/quests/{quest_id}/{theme}/{asset_name}.png | PNG, JPEG, GIF, SVG, WebM |
Role Icon | /roles/{role_id}/icons/{role_icon}.png | PNG, JPEG, WebP |
Soundboard Sound | /soundboard-sounds/{sound_id} | MP3, OGG |
Sticker 2 3 | /stickers/{sticker_id}.png | PNG, Lottie, GIF |
Sticker Pack Banner | /app-assets/710982414301790216/store/{asset_id}.png | PNG, JPEG, WebP |
Team Icon | /team-icons/{team_id}/{team_icon}.png | PNG, JPEG, WebP |
User Avatar | /avatars/{user_id}/{user_avatar}.png | PNG, JPEG, WebP, GIF |
Default User Avatar 1 2 | /embed/avatars/{user_index}.png | PNG |
User Banner | /banners/{user_id}/{user_banner}.png | PNG, JPEG, WebP, GIF |
Video Filter | /users/{user_id}/video-filter-assets/{video_filter_id}/{video_filter_asset}.png | PNG, 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.
Field | Type | Description |
---|---|---|
size | integer | The 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 |
quality | string | The quality of the image to return; not supported with all endpoints and image types |
keep_aspect_ratio | boolean 1 | Whether the image will be resized to the endpoint's enforced aspect ratio (default false) |
passthrough | boolean 1 | Whether 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:
Value | Description |
---|---|
lossless | The image will be returned in its original format, with no quality loss |
high | The image will be returned in a high quality format (the default) |
low | The 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
Parameter | Description |
---|---|
ex | Hex timestamp indicating when an attachment CDN URL will expire |
is | Hex timestamp indicating when the URL was issued |
hm | Unique signature that remains valid until the URL's expiration |
Example Attachment URL
CDN Data
CDN data is a Data URI scheme that supports formats such as JPG, GIF, and PNG. An example Data URI format is:
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
.
-boundaryContent-Disposition: form-data; name="content"Hello, World!-boundaryContent-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.
-boundaryContent-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": {"type": 0,"channel_id": "233648473390448640","message_id": "233648473390448641"},"attachments": [{"id": 0,"description": "Image of a cute little cat","filename": "myfile.png"}, {"id": 1,"description": "Rickroll gif","filename": "mygif.gif"}]}-boundaryContent-Disposition: form-data; name="files[0]"; filename="myfile.png"Content-Type: image/png[image bytes]-boundaryContent-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:
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
Locale | Language Name | Native Name |
---|---|---|
ar | Arabic | العربية |
bg | Bulgarian | български |
cs | Czech | Čeština |
da | Danish | Dansk |
de | German | Deutsch |
el | Greek | Ελληνικά |
en-GB | English, UK | English, UK |
en-US | English, US | English, US |
es-ES | Spanish | Español |
es-419 | Spanish, LATAM | Español de América Latina |
fi | Finnish | Suomi |
fr | French | Français |
hi | Hindi | हिन्दी |
hr | Croatian | Hrvatski |
hu | Hungarian | Magyar |
id | Indonesian | Bahasa Indonesia |
it | Italian | Italiano |
ja | Japanese | 日本語 |
ko | Korean | 한국어 |
lt | Lithuanian | Lietuviškai |
nl | Dutch | Nederlands |
no | Norwegian | Norsk |
pl | Polish | Polski |
pt-BR | Portuguese, Brazilian | Português do Brasil |
ro | Romanian | Română |
ru | Russian | Pусский |
sv-SE | Swedish | Svenska |
th | Thai | ไทย |
tr | Turkish | Türkçe |
uk | Ukrainian | Українська |
vi | Vietnamese | Tiếng Việt |
zh-CN | Chinese, China | 中文 |
zh-TW | Chinese, 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
Field | Type |
---|---|
optional_field? 1 | string |
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.
Field Limits
A best effort is made to document the limits of fields where possible (e.g. maximum length of a string, maximum number of array elements). These limits are not exhaustive and may not cover all edge cases.
A fallback limit of 1521 array elements and 152133 characters is used when no well-defined limit exists.
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.