Skip to main content
An Interaction is the message that your application receives when a user uses an application command or a message component.
  • For Slash Commands, it includes the values that the user submitted.
  • For User Commands and Message Commands, it includes the resolved user or message on which the action was taken.
  • For Message Components, it includes identifying information about the component that was used, plus metadata about how the interaction was triggered: the guild_id, channel, member, and other fields.

Interaction Object

Interaction Structure

FieldTypeDescription
idsnowflakeID of the interaction
application_idsnowflakeID of the application this interaction is for
typeinteraction typeType of interaction
data?*interaction dataInteraction data payload
guild?partial guild objectGuild that the interaction was sent from
guild_id?snowflakeGuild that the interaction was sent from
channel?partial channel objectChannel that the interaction was sent from
channel_id?snowflakeChannel that the interaction was sent from
member?**guild member objectGuild member data for the invoking user, including permissions
user?user objectUser object for the invoking user, if invoked in a DM
tokenstringContinuation token for responding to the interaction
versionintegerRead-only property, always 1
message?message objectFor components or modals triggered by components, the message they were attached to
app_permissions***stringBitwise set of permissions the app has in the source location of the interaction
locale?****stringSelected language of the invoking user
guild_locale?stringGuild’s preferred locale, if invoked in a guild
entitlementsarray of entitlement objectsFor monetized apps, any entitlements for the invoking user, representing access to premium SKUs
authorizing_integration_ownersdictionary with keys of application integration typesMapping of installation contexts that the interaction was authorized for to related user or guild IDs
context?interaction context typeContext where the interaction was triggered from
attachment_size_limitintegerAttachment size limit in bytes
* Always present on application command, message component, and modal submit interaction types. Optional for future-proofing. ** member is sent when the interaction is invoked in a guild, and user is sent when invoked in a DM. *** app_permissions includes ATTACH_FILES | EMBED_LINKS | MENTION_EVERYONE for (G)DMs with other users, and additionally includes USE_EXTERNAL_EMOJIS for DMs with the app’s bot user. **** Available on all interaction types except PING.

Interaction Type

NameValue
PING1
APPLICATION_COMMAND2
MESSAGE_COMPONENT3
APPLICATION_COMMAND_AUTOCOMPLETE4
MODAL_SUBMIT5

Interaction Context Types

Context in Discord where an interaction can be used, or where it was triggered from. Details about using interaction contexts for application commands is in the commands context documentation.
NameValueDescription
GUILD0Interaction can be used within servers
BOT_DM1Interaction can be used within DMs with the app’s bot user
PRIVATE_CHANNEL2Interaction can be used within Group DMs and DMs other than the app’s bot user

Authorizing Integration Owners Object

The authorizing_integration_owners field includes details about the authorizing user or server for the installation(s) relevant to the interaction. For apps installed to a user, it can be used to tell the difference between the authorizing user and the user that triggered an interaction (like a message component). A key will only be present if:
  • The app has been authorized to the installation context corresponding to the key (GUILD_INSTALL or USER_INSTALL)
  • The interaction is supported in the source interaction context for the installation context corresponding to the key
  • For command invocations, the command must be supported in the installation context
The values in authorizing_integration_owners depend on the key:
  • If the key is GUILD_INSTALL ("0"), the value is the guild ID if triggered from a server, or "0" if triggered from a DM with the app’s bot user.
  • If the key is USER_INSTALL ("1"), the value is the ID of the authorizing user.

Interaction Data

While the data field is guaranteed to be present for all interaction types besides PING, its structure will vary:
Interaction TypeInteraction Data
PING (1)N/A
APPLICATION_COMMAND (2)Application Command Data Structure
MESSAGE_COMPONENT (3)Message Component Data Structure
APPLICATION_COMMAND_AUTOCOMPLETE (4)Application Command Data Structure
MODAL_SUBMIT (5)Modal Submit Data Structure

Application Command Data Structure

Sent in APPLICATION_COMMAND and APPLICATION_COMMAND_AUTOCOMPLETE interactions.
FieldTypeDescription
idsnowflakeID of the invoked command
namestringName of the invoked command
typeintegerType of the invoked command
resolved?resolved dataConverted users + roles + channels + attachments
options?*array of application command interaction data optionsParams + values from the user
guild_id?snowflakeID of the guild the command is registered to
target_id?snowflakeID of the user or message targeted by a user or message command
* This can be partial when in response to APPLICATION_COMMAND_AUTOCOMPLETE.

Message Component Data Structure

FieldTypeDescription
custom_idstringcustom_id of the component
component_typeintegerType of the component
values?*array of select option valuesValues the user selected in a select menu component
resolved?resolved dataResolved entities from selected options
* Always present for select menu components.
FieldTypeDescription
custom_idstringThe custom ID provided for the modal
componentsarray of component interaction responsesValues submitted by the user
resolved?resolved dataResolved entities from selected options

Resolved Data Structure

If data for a Member is included, data for its corresponding User will also be included.
FieldTypeDescription
users?Map of Snowflakes to user objectsIDs and User objects
members?*Map of Snowflakes to partial member objectsIDs and partial Member objects
roles?Map of Snowflakes to role objectsIDs and Role objects
channels?**Map of Snowflakes to partial channel objectsIDs and partial Channel objects
messages?Map of Snowflakes to partial message objectsIDs and partial Message objects
attachments?Map of Snowflakes to attachment objectsIDs and attachment objects
* Partial Member objects are missing user, deaf, and mute fields. ** Partial Channel objects only have id, name, type, permissions, last_message_id, last_pin_timestamp, nsfw, parent_id, guild_id, flags, rate_limit_per_user, topic, and position fields. Threads will also have the thread_metadata field.

Application Command Interaction Data Option Structure

All options have names, and an option can either be a parameter and input value—in which case value will be set—or it can denote a subcommand or group—in which case it will contain a top-level key and another array of options. value and options are mutually exclusive.
FieldTypeDescription
namestringName of the parameter
typeintegerValue of application command option type
value?string, integer, double, or booleanValue of the option resulting from user input
options?array of application command interaction data optionsPresent if this option is a group or subcommand
focused?booleantrue if this option is the currently focused option for autocomplete

Receiving an Interaction

When a user interacts with your app, your app will receive an Interaction. Your app can receive an interaction in one of two ways: These two methods are mutually exclusive. The INTERACTION_CREATE gateway event may be handled by connected clients, while the webhook method does not require a connected client. If you want to receive interactions via HTTP-based outgoing webhooks, you must configure an Interactions Endpoint URL for your app. You can read about preparing and adding an Interactions Endpoint URL in the Preparing for Interactions section.

Interaction Metadata

An Interaction includes metadata to aid your application in handling it, as well as data specific to the interaction type. You can find samples for each interaction type on their respective pages:

Responding to an Interaction

Interactions—both receiving and responding—are webhooks under the hood. Responding to an Interaction is just like sending a webhook request.
Interaction responses have the same header requirements as normal HTTP API requests. See here for further information.

Interaction Response Structure

FieldTypeDescription
typeinteraction callback typeType of response
data?interaction callback dataAn optional response message

Interaction Callback Type

NameValueDescription
PONG1ACK a Ping
CHANNEL_MESSAGE_WITH_SOURCE4Respond to an interaction with a message
DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE5ACK an interaction and edit a response later; the user sees a loading state
DEFERRED_UPDATE_MESSAGE*6For components, ACK an interaction and edit the original message later; the user does not see a loading state
UPDATE_MESSAGE*7For components, edit the message the component was attached to
APPLICATION_COMMAND_AUTOCOMPLETE_RESULT8Respond to an autocomplete interaction with suggested choices
MODAL**9Respond to an interaction with a popup modal
PREMIUM_REQUIRED10Deprecated; respond to an interaction with an upgrade button, only available for apps with monetization enabled
LAUNCH_ACTIVITY12Launch the Activity associated with the app. Only available for apps with Activities enabled
* Only valid for component-based interactions. ** Not available for MODAL_SUBMIT and PING interactions.

Messages

Not all message fields are currently supported.
FieldTypeDescription
tts?booleanWhether the response is TTS
content?stringMessage content
embeds?array of embedsSupports up to 10 embeds
allowed_mentions?allowed mentions objectAllowed mentions object
flags?*integerMessage flags combined as a bitfield (only SUPPRESS_EMBEDS, EPHEMERAL, IS_COMPONENTS_V2, IS_VOICE_MESSAGE, and SUPPRESS_NOTIFICATIONS can be set)
components?array of componentsMessage components
attachments?**array of partial attachment objectsAttachment objects with filename and description
poll?poll request objectDetails about the poll
* If you create a callback with type DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE, the only valid message flag is EPHEMERAL. To create a component-based message with IS_COMPONENTS_V2, use the edit original response endpoint. ** See Uploading Files for details.

Autocomplete

FieldTypeDescription
choicesarray of choicesAutocomplete choices (max of 25 choices)
FieldTypeDescription
custom_idstringDeveloper-defined identifier for the modal, 1-100 characters
titlestringTitle of the popup modal, max 45 characters
componentsarray of componentsBetween 1 and 5 (inclusive) components that make up the modal
If your application responds with user data, you should use allowed_mentions to filter which mentions in the content actually ping.

Interaction Callback

When responding to an interaction, make a POST request to /interactions/<interaction_id>/<interaction_token>/callback. The interaction_id is the unique ID of that individual Interaction from the received payload. The interaction_token is the unique token for that interaction from the received payload. If you are receiving Interactions over the gateway, you have to respond via HTTP. Responses to Interactions are not sent as commands over the gateway. If you send this request for an interaction received over HTTP, respond to the original HTTP request with a 202 and no body.
import requests

url = "https://discord.com/api/v10/interactions/<interaction_id>/<interaction_token>/callback"

json = {
    "type": 4,
    "data": {
        "content": "Congrats on sending your command!"
    }
}
r = requests.post(url, json=json)
Interaction tokens are valid for 15 minutes and can be used to send followup messages, but you must send an initial response within 3 seconds of receiving the event. If the 3-second deadline is exceeded, the token will be invalidated.
If you receive interactions over HTTP, your server can also respond to the received POST request directly. Respond with a 200 status code and specify a type and optional data:
@app.route('/', methods=['POST'])
def my_command():
    if request.json["type"] == 1:
        return jsonify({
            "type": 1
        })

    else:
        return jsonify({
            "type": 4,
            "data": {
                "tts": False,
                "content": "Congrats on sending your command!",
                "embeds": [],
                "allowed_mentions": { "parse": [] }
            }
        })

Followup Messages

Sometimes, you want to send followup messages to a user after responding to an interaction, or edit your original response. Whether you receive Interactions over the gateway or by outgoing webhook, you can use the following endpoints:
  • PATCH /webhooks/<application_id>/<interaction_token>/messages/@original — Edit your initial response
  • DELETE /webhooks/<application_id>/<interaction_token>/messages/@original — Delete your initial response
  • POST /webhooks/<application_id>/<interaction_token> — Send a new followup message
  • PATCH /webhooks/<application_id>/<interaction_token>/messages/<message_id> — Edit a message sent with that token
Interactions webhooks share the same rate limit properties as normal webhooks.
Interaction tokens are valid for 15 minutes, meaning you can respond to an interaction within that time frame.
The endpoints below are not bound to the application’s Global Rate Limit.

Create Interaction Response

POST /interactions/{interaction.id}/{interaction.token}/callback Create a response to an Interaction. Body is an interaction response object. Returns 204 unless with_response is set to true, which returns 200 with the body as an interaction callback response object. This endpoint also supports file attachments similar to the webhook endpoints. Refer to Uploading Files for details. Query String Params
FieldTypeDescription
with_response?booleanWhether to include an interaction callback object as the response

Get Original Interaction Response

GET /webhooks/{application.id}/{interaction.token}/messages/@original Returns the initial Interaction response. Functions the same as Get Webhook Message.

Edit Original Interaction Response

PATCH /webhooks/{application.id}/{interaction.token}/messages/@original Edits the initial Interaction response. Functions the same as Edit Webhook Message.

Delete Original Interaction Response

DELETE /webhooks/{application.id}/{interaction.token}/messages/@original Deletes the initial Interaction response. Returns 204 No Content on success.

Create Followup Message

POST /webhooks/{application.id}/{interaction.token}
Apps are limited to 5 followup messages per interaction if it was initiated from a user-installed app and isn’t installed in the server.
Create a followup message for an Interaction. Functions the same as Execute Webhook, but wait is always true. The thread_id, avatar_url, and username parameters are not supported for interaction followups. You can use the EPHEMERAL message flag (1 << 6, value 64) to send a message only the user can see.

Get Followup Message

GET /webhooks/{application.id}/{interaction.token}/messages/{message.id} Returns a followup message for an Interaction. Functions the same as Get Webhook Message.

Edit Followup Message

PATCH /webhooks/{application.id}/{interaction.token}/messages/{message.id} Edits a followup message for an Interaction. Functions the same as Edit Webhook Message.

Delete Followup Message

DELETE /webhooks/{application.id}/{interaction.token}/messages/{message.id} Deletes a followup message for an Interaction. Returns 204 No Content on success.