Message Reference

Message Object

Represents a message sent in a channel within Discord.

Message Structure
FieldTypeDescription
idsnowflakeid of the message
channel_idsnowflakeid of the channel the message was sent in
guild_id?snowflakeid of the guild the message was sent in
author*user objectthe author of this message (not guaranteed to be a valid user, see below)
member?**partial guild member objectmember properties for this message's author
contentstringcontents of the message
timestampISO8601 timestampwhen this message was sent
edited_timestamp?ISO8601 timestampwhen this message was edited (or null if never)
ttsbooleanwhether this was a TTS message
mention_everyonebooleanwhether this message mentions everyone
mentions***array of user objects, with an additional partial member fieldusers specifically mentioned in the message
mention_rolesarray of role object idsroles specifically mentioned in this message
mention_channels?****array of channel mention objectschannels specifically mentioned in this message
attachmentsarray of attachment objectsany attached files
embedsarray of embed objectsany embedded content
reactions?array of reaction objectsreactions to the message
nonce?integer or stringused for validating a message was sent
pinnedbooleanwhether this message is pinned
webhook_id?snowflakeif the message is generated by a webhook, this is the webhook's id
typeintegertype of message
activity?message activity objectsent with Rich Presence-related chat embeds
application?partial application objectsent with Rich Presence-related chat embeds
application_id?snowflakeif the message is a response to an Interaction, this is the id of the interaction's application
message_reference?message reference objectdata showing the source of a crosspost, channel follow add, pin, or reply message
flags?integermessage flags combined as a bitfield
referenced_message?*****?message objectthe message associated with the message_reference
interaction?message interaction objectsent if the message is a response to an Interaction
thread?channel objectthe thread that was started from this message, includes thread member object
components?Array of message componentssent if the message contains components like buttons, action rows, or other interactive components
sticker_items?array of message sticker item objectssent if the message contains stickers
stickers?array of sticker objectsDeprecated the stickers sent with the message

* The author object follows the structure of the user object, but is only a valid user in the case where the message is generated by a user or bot user. If the message is generated by a webhook, the author object corresponds to the webhook's id, username, and avatar. You can tell if a message is generated by a webhook by checking for the webhook_id on the message object.

** The member object exists in MESSAGE_CREATE and MESSAGE_UPDATE events from text-based guild channels, provided that the author of the message is not a webhook. This allows bots to obtain real-time member data without requiring bots to store member state in memory.

*** The user objects in the mentions array will only have the partial member field present in MESSAGE_CREATE and MESSAGE_UPDATE events from text-based guild channels.

**** Not all channel mentions in a message will appear in mention_channels. Only textual channels that are visible to everyone in a lurkable guild will ever be included. Only crossposted messages (via Channel Following) currently include mention_channels at all. If no mentions in the message meet these requirements, this field will not be sent.

***** This field is only returned for messages with a type of 19 (REPLY) or 21 (THREAD_STARTER_MESSAGE). If the message is a reply but the referenced_message field is not present, the backend did not attempt to fetch the message that was being replied to, so its state is unknown. If the field exists but is null, the referenced message was deleted.

Message Types
TypeValue
DEFAULT0
RECIPIENT_ADD1
RECIPIENT_REMOVE2
CALL3
CHANNEL_NAME_CHANGE4
CHANNEL_ICON_CHANGE5
CHANNEL_PINNED_MESSAGE6
GUILD_MEMBER_JOIN7
USER_PREMIUM_GUILD_SUBSCRIPTION8
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_19
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_210
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_311
CHANNEL_FOLLOW_ADD12
GUILD_DISCOVERY_DISQUALIFIED14
GUILD_DISCOVERY_REQUALIFIED15
GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING16
GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING17
THREAD_CREATED18
REPLY19
APPLICATION_COMMAND20
THREAD_STARTER_MESSAGE21
GUILD_INVITE_REMINDER22
Message Activity Structure
FieldTypeDescription
typeintegertype of message activity
party_id?stringparty_id from a Rich Presence event
Message Activity Types
TypeValue
JOIN1
SPECTATE2
LISTEN3
JOIN_REQUEST5
Message Flags
FlagValueDescription
CROSSPOSTED1 << 0this message has been published to subscribed channels (via Channel Following)
IS_CROSSPOST1 << 1this message originated from a message in another channel (via Channel Following)
SUPPRESS_EMBEDS1 << 2do not include any embeds when serializing this message
SOURCE_MESSAGE_DELETED1 << 3the source message for this crosspost has been deleted (via Channel Following)
URGENT1 << 4this message came from the urgent message system
HAS_THREAD1 << 5this message has an associated thread, with the same id as the message
EPHEMERAL1 << 6this message is only visible to the user who invoked the Interaction
LOADING1 << 7this message is an Interaction Response and the bot is "thinking"
Example Message
json
{
"reactions": [
{
"count": 1,
"me": false,
"emoji": {
"id": null,
"name": "🔥"
}
}
],
"attachments": [],
"tts": false,
"embeds": [],
"timestamp": "2017-07-11T17:27:07.299000+00:00",
"mention_everyone": false,
"id": "334385199974967042",
"pinned": false,
"edited_timestamp": null,
"author": {
"username": "Mason",
"discriminator": "9999",
"id": "53908099506183680",
"avatar": "a_bab14f271d565501444b2ca3be944b25"
},
"mention_roles": [],
"content": "Supa Hot",
"channel_id": "290926798999357250",
"mentions": [],
"type": 0
}
Example Crossposted Message
json
{
"reactions": [
{
"count": 1,
"me": false,
"emoji": {
"id": null,
"name": "🔥"
}
}
],
"attachments": [],
"tts": false,
"embeds": [],
"timestamp": "2017-07-11T17:27:07.299000+00:00",
"mention_everyone": false,
"id": "334385199974967042",
"pinned": false,
"edited_timestamp": null,
"author": {
"username": "Mason",
"discriminator": "9999",
"id": "53908099506183680",
"avatar": "a_bab14f271d565501444b2ca3be944b25"
},
"mention_roles": [],
"mention_channels": [
{
"id": "278325129692446722",
"guild_id": "278325129692446720",
"name": "big-news",
"type": 5
}
],
"content": "Big news! In this <#278325129692446722> channel!",
"channel_id": "290926798999357250",
"mentions": [],
"type": 0,
"flags": 2,
"message_reference": {
"channel_id": "278325129692446722",
"guild_id": "278325129692446720",
"message_id": "306588351130107906"
}
}

Message Reference Object

Message Reference Structure
FieldTypeDescription
message_id?snowflakeid of the originating message
channel_id? *snowflakeid of the originating message's channel
guild_id?snowflakeid of the originating message's guild
fail_if_not_exists?booleanwhen sending, whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message, default true

* channel_id is optional when creating a reply, but will always be present when receiving an event/response that includes this data model.

Message Types

There are multiple message types that have a message_reference object. Since message references are generic attribution to a previous message, there will be more types of messages which have this information in the future.

Crosspost messages
  • These are messages that originated from another channel (IS_CROSSPOST flag).
  • These messages have all three fields, with data of the original message that was crossposted.
Channel Follow Add messages
  • These are automatic messages sent when a channel is followed into the current channel (type 12).
  • These messages have the channel_id and guild_id fields, with data of the followed announcement channel.
Pin messages
  • These are automatic messages sent when a message is pinned (type 6).
  • These messages have message_id and channel_id, and guild_id if it is in a guild, with data of the message that was pinned.
Replies
  • These are messages replying to a previous message (type 19).
  • These messages have message_id and channel_id, and guild_id if it is in a guild, with data of the message that was replied to. The channel_id and guild_id will be the same as the reply.
  • Replies are created by including a message_reference when sending a message. When sending, only message_id is required.
Thread starter messsage
  • These are the first message in a public thread. They point back to the message in the parent channel from which the thread was started (type 21)
  • These messages have message_id, channel_id, and guild_id.
  • These messages will never have content, embeds, or attachments, mainly just the message_reference and referenced_message fields.

Followed Channel Object

Followed Channel Structure
FieldTypeDescription
channel_idsnowflakesource channel id
webhook_idsnowflakecreated target webhook id

Reaction Object

Reaction Structure
FieldTypeDescription
countintegertimes this emoji has been used to react
mebooleanwhether the current user reacted using this emoji
emojipartial emoji objectemoji information

Embed Object

Embed Structure
FieldTypeDescription
title?stringtitle of embed
type?stringtype of embed (always "rich" for webhook embeds)
description?stringdescription of embed
url?stringurl of embed
timestamp?ISO8601 timestamptimestamp of embed content
color?integercolor code of the embed
footer?embed footer objectfooter information
image?embed image objectimage information
thumbnail?embed thumbnail objectthumbnail information
video?embed video objectvideo information
provider?embed provider objectprovider information
author?embed author objectauthor information
fields?array of embed field objectsfields information
Embed Types

Embed types are "loosely defined" and, for the most part, are not used by our clients for rendering. Embed attributes power what is rendered. Embed types should be considered deprecated and might be removed in a future API version.

TypeDescription
richgeneric embed rendered from embed attributes
imageimage embed
videovideo embed
gifvanimated gif image embed rendered as a video embed
articlearticle embed
linklink embed
Embed Thumbnail Structure
FieldTypeDescription
url?stringsource url of thumbnail (only supports http(s) and attachments)
proxy_url?stringa proxied url of the thumbnail
height?integerheight of thumbnail
width?integerwidth of thumbnail
Embed Video Structure
FieldTypeDescription
url?stringsource url of video
proxy_url?stringa proxied url of the video
height?integerheight of video
width?integerwidth of video
Embed Image Structure
FieldTypeDescription
url?stringsource url of image (only supports http(s) and attachments)
proxy_url?stringa proxied url of the image
height?integerheight of image
width?integerwidth of image
Embed Provider Structure
FieldTypeDescription
name?stringname of provider
url?stringurl of provider
Embed Author Structure
FieldTypeDescription
name?stringname of author
url?stringurl of author
icon_url?stringurl of author icon (only supports http(s) and attachments)
proxy_icon_url?stringa proxied url of author icon
FieldTypeDescription
textstringfooter text
icon_url?stringurl of footer icon (only supports http(s) and attachments)
proxy_icon_url?stringa proxied url of footer icon
Embed Field Structure
FieldTypeDescription
namestringname of the field
valuestringvalue of the field
inline?booleanwhether or not this field should display inline

Attachment Object

Attachment Structure
FieldTypeDescription
idsnowflakeattachment id
filenamestringname of file attached
content_type?stringthe attachment's media type
sizeintegersize of file in bytes
urlstringsource url of file
proxy_urlstringa proxied url of file
height??integerheight of file (if image)
width??integerwidth of file (if image)

Channel Mention Object

Channel Mention Structure
FieldTypeDescription
idsnowflakeid of the channel
guild_idsnowflakeid of the guild containing the channel
typeintegerthe type of channel
namestringthe name of the channel

Allowed Mentions Object

The allowed mention field allows for more granular control over mentions without various hacks to the message content. This will always validate against message content to avoid phantom pings (e.g. to ping everyone, you must still have @everyone in the message content), and check against user/bot permissions.

Allowed Mention Types
TypeValueDescription
Role Mentions"roles"Controls role mentions
User Mentions"users"Controls user mentions
Everyone Mentions"everyone"Controls @everyone and @here mentions
Allowed Mentions Structure
FieldTypeDescription
parsearray of allowed mention typesAn array of allowed mention types to parse from the content.
roleslist of snowflakesArray of role_ids to mention (Max size of 100)
userslist of snowflakesArray of user_ids to mention (Max size of 100)
replied_userbooleanFor replies, whether to mention the author of the message being replied to (default false)
Allowed Mentions Reference

Due to the complexity of possibilities, we have included a set of examples and behavior for the allowed mentions field.

If allowed_mentions is not passed in (i.e. the key does not exist), the mentions will be parsed via the content. This corresponds with existing behavior.

In the example below we would ping @here (and also @role124 and @user123)

json
{
"content": "@here Hi there from <@123>, cc <@&124>"
}

To suppress all mentions in a message use:

json
{
"content": "@everyone hi there, <@&123>",
"allowed_mentions": {
"parse": []
}
}

This will suppress all mentions in the message (no @everyone or user mention).

The parse field is mutually exclusive with the other fields. In the example below, we would ping users 123 and role 124, but not @everyone. Note that passing a Falsy value ([], null) into the "users" field does not trigger a validation error.

json
{
"content": "@everyone <@123> <@&124>",
"allowed_mentions": {
"parse": ["users", "roles"],
"users": []
}
}

In the next example, we would ping @everyone, (and also users 123 and 124 if they suppressed @everyone mentions), but we would not ping any roles.

json
{
"content": "@everyone <@123> <@124> <@125> <@&200>",
"allowed_mentions": {
"parse": ["everyone"],
"users": ["123", "124"]
}
}

Due to possible ambiguities, not all configurations are valid. An invalid configuration is as follows

json
{
"content": "@everyone <@123> <@124> <@125> <@&200>",
"allowed_mentions": {
"parse": ["users"],
"users": ["123", "124"]
}
}

Because parse: ["users"] and users: [123, 124] are both present, we would throw a validation error. This is because the conditions cannot be fulfilled simultaneously (they are mutually exclusive).

Any entities with an ID included in the list of IDs can be mentioned. Note that the IDs of entities not present in the message's content will simply be ignored. e.g. The following example is valid, and would mention user 123, but not user 125 since there is no mention of user 125 in the content.

json
{
"content": "<@123> Time for some memes.",
"allowed_mentions": {
"users": ["123", "125"]
}
}

Embed Limits

To facilitate showing rich content, rich embeds do not follow the traditional limits of message content. However, some limits are still in place to prevent excessively large embeds. The following table describes the limits:

Limits

All of the following limits are measured inclusively. Leading and trailing whitespace characters are not included (they are trimmed automatically).

FieldLimit
title256 characters
description4096 characters
fieldsUp to 25 field objects
field.name256 characters
field.value1024 characters
footer.text2048 characters
author.name256 characters

Additionally, the characters in all title, description, field.name, field.value, footer.text, and author.name fields must not exceed 6000 characters in total. Violating any of these constraints will result in a Bad Request response.

Endpoints

Get Channel Messages

GET/channels/{channel.id}/messages

Returns the messages for a channel. If operating on a guild channel, this endpoint requires the VIEW_CHANNEL permission to be present on the current user. If the current user is missing the 'READ_MESSAGE_HISTORY' permission in the channel then this will return no messages (since they cannot read the message history). Returns an array of message objects on success.

Query String Params
FieldTypeDescriptionRequiredDefault
aroundsnowflakeget messages around this message IDfalseabsent
beforesnowflakeget messages before this message IDfalseabsent
aftersnowflakeget messages after this message IDfalseabsent
limitintegermax number of messages to return (1-100)false50

Get Channel Message

GET/channels/{channel.id}/messages/{message.id}

Returns a specific message in the channel. If operating on a guild channel, this endpoint requires the 'READ_MESSAGE_HISTORY' permission to be present on the current user. Returns a message object on success.

Create Message

POST/channels/{channel.id}/messages

Post a message to a guild text or DM channel. Returns a message object. Fires a Message Create Gateway event. See message formatting for more information on how to properly format messages.

Limitations
  • When operating on a guild channel, the current user must have the SEND_MESSAGES permission.
  • When sending a message with tts (text-to-speech) set to true, the current user must have the SEND_TTS_MESSAGES permission.
  • When creating a message as a reply to another message, the current user must have the READ_MESSAGE_HISTORY permission.
    • The referenced message must exist and cannot be a system message.
  • The maximum request size when sending a message is 8MB
  • For the embed object, you can set every field except type (it will be rich regardless of if you try to set it), provider, video, and any height, width, or proxy_url values for images.
  • Files can only be uploaded when using the multipart/form-data content type.

You may create a message as a reply to another message. To do so, include a message_reference with a message_id. The channel_id and guild_id in the message_reference are optional, but will be validated if provided.

> Note that in multipart form data, the `embeds` and `allowed_mentions` fields cannot be used. You can pass a stringified JSON body as a form value as `payload_json` instead. > **If you supply a `payload_json` form value, all fields except for `file` fields will be ignored in the form data**.
JSON/Form Params
FieldTypeDescriptionRequired
contentstringthe message contents (up to 2000 characters)one of content, file, embed(s), sticker_ids
ttsbooleantrue if this is a TTS messagefalse
filefile contentsthe contents of the file being sentone of content, file, embed(s), sticker_ids
embedsarray of embed objectsembedded rich content (up to 6000 characters)one of content, file, embed(s), sticker_ids
embed (deprecated)embed objectembedded rich content, deprecated in favor of embedsone of content, file, embed(s), sticker_ids
payload_jsonstringJSON encoded body of non-file paramsmultipart/form-data only
allowed_mentionsallowed mention objectallowed mentions for the messagefalse
message_referencemessage referenceinclude to make your message a replyfalse
componentsarray of message component objectsthe components to include with the messagefalse
sticker_idsarray of snowflakesIDs of up to 3 stickers in the server to send in the messageone of content, file, embed(s), sticker_ids
Example Request Body (application/json)
json
{
"content": "Hello, World!",
"tts": false,
"embeds": [
{
"title": "Hello, Embed!",
"description": "This is an embedded message."
}
]
}
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, file) 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."
}],
"message_reference": {
"message_id": "233648473390448641"
}
}
-boundary
Content-Disposition: form-data; name="file"; filename="myfilename.png"
Content-Type: image/png
[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 that contain a filename, as you will need a filename to reference against.

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

For example:

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

Crosspost Message

POST/channels/{channel.id}/messages/{message.id}/crosspost

Crosspost a message in a News Channel to following channels. This endpoint requires the 'SEND_MESSAGES' permission, if the current user sent the message, or additionally the 'MANAGE_MESSAGES' permission, for all other messages, to be present for the current user.

Returns a message object.

Create Reaction

PUT/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me

Create a reaction for the message. This endpoint requires the 'READ_MESSAGE_HISTORY' permission to be present on the current user. Additionally, if nobody else has reacted to the message using this emoji, this endpoint requires the 'ADD_REACTIONS' permission to be present on the current user. Returns a 204 empty response on success. The emoji must be URL Encoded or the request will fail with 10014: Unknown Emoji. To use custom emoji, you must encode it in the format name:id with the emoji name and emoji id.

Delete Own Reaction

DELETE/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me

Delete a reaction the current user has made for the message. Returns a 204 empty response on success. The emoji must be URL Encoded or the request will fail with 10014: Unknown Emoji. To use custom emoji, you must encode it in the format name:id with the emoji name and emoji id.

Delete User Reaction

DELETE/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/{user.id}

Deletes another user's reaction. This endpoint requires the 'MANAGE_MESSAGES' permission to be present on the current user. Returns a 204 empty response on success. The emoji must be URL Encoded or the request will fail with 10014: Unknown Emoji. To use custom emoji, you must encode it in the format name:id with the emoji name and emoji id.

Get Reactions

GET/channels/{channel.id}/messages/{message.id}/reactions/{emoji}

Get a list of users that reacted with this emoji. Returns an array of user objects on success. The emoji must be URL Encoded or the request will fail with 10014: Unknown Emoji. To use custom emoji, you must encode it in the format name:id with the emoji name and emoji id.

Query String Params
FieldTypeDescriptionRequiredDefault
aftersnowflakeget users after this user IDfalseabsent
limitintegermax number of users to return (1-100)false25

Delete All Reactions

DELETE/channels/{channel.id}/messages/{message.id}/reactions

Deletes all reactions on a message. This endpoint requires the 'MANAGE_MESSAGES' permission to be present on the current user. Fires a Message Reaction Remove All Gateway event.

Delete All Reactions for Emoji

DELETE/channels/{channel.id}/messages/{message.id}/reactions/{emoji}

Deletes all the reactions for a given emoji on a message. This endpoint requires the MANAGE_MESSAGES permission to be present on the current user. Fires a Message Reaction Remove Emoji Gateway event. The emoji must be URL Encoded or the request will fail with 10014: Unknown Emoji. To use custom emoji, you must encode it in the format name:id with the emoji name and emoji id.

Edit Message

PATCH/channels/{channel.id}/messages/{message.id}

Edit a previously sent message. The fields content, embeds, and flags can be edited by the original message author. Other users can only edit flags and only if they have the MANAGE_MESSAGES permission in the corresponding channel. When specifying flags, ensure to include all previously set flags/bits in addition to ones that you are modifying. Only flags documented in the table below may be modified by users (unsupported flag changes are currently ignored without error).

When the content field is edited, the mentions array in the message object will be reconstructed from scratch based on the new content. The allowed_mentions field of the edit request controls how this happens. If there is no explicit allowed_mentions in the edit request, the content will be parsed with default allowances, that is, without regard to whether or not an allowed_mentions was present in the request that originally created the message.

Returns a message object. Fires a Message Update Gateway event.

JSON/Form Params
FieldTypeDescription
contentstringthe message contents (up to 2000 characters)
embedsarray of embed objectsembedded rich content (up to 6000 characters)
embed (deprecated)embed objectembedded rich content, deprecated in favor of embeds
flagsintegeredit the flags of a message (only SUPPRESS_EMBEDS can currently be set/unset)
filefile contentsthe contents of the file being sent/edited
payload_jsonstringJSON encoded body of non-file params (multipart/form-data only)
allowed_mentionsallowed mention objectallowed mentions for the message
attachmentsarray of attachment objectsattached files to keep
componentsarray of message componentthe components to include with the message

Delete Message

DELETE/channels/{channel.id}/messages/{message.id}

Delete a message. If operating on a guild channel and trying to delete a message that was not sent by the current user, this endpoint requires the MANAGE_MESSAGES permission. Returns a 204 empty response on success. Fires a Message Delete Gateway event.

Bulk Delete Messages

POST/channels/{channel.id}/messages/bulk-delete

Delete multiple messages in a single request. This endpoint can only be used on guild channels and requires the MANAGE_MESSAGES permission. Returns a 204 empty response on success. Fires a Message Delete Bulk Gateway event.

Any message IDs given that do not exist or are invalid will count towards the minimum and maximum message count (currently 2 and 100 respectively).

JSON Params
FieldTypeDescription
messagesarray of snowflakesan array of message ids to delete (2-100)

Get Pinned Messages

GET/channels/{channel.id}/pins

Returns all pinned messages in the channel as an array of message objects.

Pin Message

PUT/channels/{channel.id}/pins/{message.id}

Pin a message in a channel. Requires the MANAGE_MESSAGES permission. Returns a 204 empty response on success.

Unpin Message

DELETE/channels/{channel.id}/pins/{message.id}

Unpin a message in a channel. Requires the MANAGE_MESSAGES permission. Returns a 204 empty response on success.