Skip to main content
Documentation - Discord Docs

Search documentation

Type to search this documentation.

On this pageOverview

Embedded App SDK Reference

The Embedded App SDK handles making RPC calls between your application and Discord. It is designed to assist developers in developing interactive Activities like games.

To learn more about building Activities, check out our Building an Activity tutorial or explore our Sample Projects.


The Embedded App SDK is available via npm and GitHub.

In your frontend JavaScript project directory, install using your package manager of choice.

npm install @discord/embedded-app-sdk

After installing, you can import and instantiate the SDK in your project.

JavaScript
import { DiscordSDK } from "@discord/embedded-app-sdk";

const discordSdk = new DiscordSDK(DISCORD_CLIENT_ID);

Name Description
ready Resolves when your app has successfully connected to the Discord client
subscribe Subscribe to an Embedded App SDK Event
unsubscribe Unsubscribe to an Embedded App SDK Event
close Close an Embedded App

Resolves when your app has successfully connected to the Discord client.

Web iOS Android
✅ ✅ ✅

No scopes required

ready(): Promise<void>

JavaScript
async function setup() {
  await discordSdk.ready();
  // The rest of your app logic
}

Used to subscribe to a specific event from the list of SDK Events.

Web iOS Android
✅ ✅ ✅

Depends on the event. Refer to the Required Scopes for the specific event you are subscribing to.

subscribe<Event>(event: Event, listener: (data: EventPayloadData<Event>) => void, ...subscribeArgs: Partial<EventPayloadData<Event>>): Promise<EventEmitter>

JavaScript
await discordSdk.subscribe("SDK_EVENT_NAME", eventHandler, args);

Used to unsubscribe to SDK Events that your app has already subscribed to.

Web iOS Android
✅ ✅ ✅

No scopes required

The EventPayloadData will vary based on the event you are unsubscribing from. See the specific event for details.

unsubscribe<Event>(event: Event, listener: (data: EventPayloadData<Event>) => void, ...subscribeArgs: Partial<EventPayloadData<Event>>): Promise<EventEmitter>

JavaScript
await discordSdk.unsubscribe("SDK_EVENT_NAME");

Used to close your app with a specified code and reason.

Web iOS Android
✅ ✅ ✅

No scopes required

close(code: RPCCloseCodes, message: string): void

JavaScript
discordSdk.close(RPCCloseCodes.CLOSE_NORMAL, "You exited from app");

Developers can use these commands to interact with the Discord client. The following SDK commands are prefixed with .commands, such as, discordSDK.commands.authenticate.

Name Description
authenticate Authenticate an existing client with your app
authorize Authorize a new client with your app
captureLog Forward logs to your own logger
encourageHardwareAcceleration Presents a modal dialog to allow enabling of hardware acceleration
getChannel Returns information about the channel, per the channel_id
getChannelPermissions Returns permissions for the current user in the currently connected channel
getEntitlements Returns a list of entitlements for the current user
getInstanceConnectedParticipants Returns all participants connected to the instance
getPlatformBehaviors Returns information about supported platform behaviors
getRelationships Allows your app to access a user’s Discord Friends list, their pending requests, and blocked users. This scope is part of our Social SDK - submit for access here. Social SDK Terms apply, including Section 5(a)(ii) to the data you obtain
getSkus Returns a list of your app's SKUs
initiateImageUpload Presents the file upload flow in the Discord client
openExternalLink Allows for opening an external link from within the Discord client
openInviteDialog Presents a modal dialog with Channel Invite UI without requiring additional OAuth scopes
openShareMomentDialog Presents a modal dialog to share media to a channel or DM
setActivity Modifies how your activity's rich presence is displayed in the Discord client
setConfig Set whether or not the PIP (picture-in-picture) is interactive
setOrientationLockState Set options for orientation and picture-in-picture (PIP) modes
shareLink Presents a modal for the user to share a link to your activity with custom query params
startPurchase Launches the purchase flow for a specific SKU, per the sku_id
userSettingsGetLocale Returns the current user's locale

Authenticate an existing client with your app.

Web iOS Android
✅ ✅ ✅

No scopes required

authenticate(args: AuthenticateRequest): Promise<AuthenticateResponse>

JavaScript
await discordSdk.commands.authenticate({
  access_token: 'ACCESS_TOKEN_STRING'
});

Authorize a new client with your app.

Web iOS Android
✅ ✅ ✅

No scopes required

authorize(args: AuthorizeRequest): Promise<AuthorizeResponse>

JavaScript
await discordSdk.commands.authorize({
  client_id: DISCORD_CLIENT_ID,
  response_type: "code",
  state: "",
  prompt: "none",
  scope: [
    // "applications.builds.upload",
    // "applications.builds.read",
    // "applications.store.update",
    // "applications.entitlements",
    // "bot",
    "identify",
    // "connections",
    // "email",
    // "gdm.join",
    "guilds",
    // "guilds.join",
    // "guilds.members.read",
    // "messages.read",
    // "relationships.read",
    // 'rpc.activities.write',
    // "rpc.notifications.read",
    // "rpc.voice.write",
    // "rpc.voice.read",
    // "webhook.incoming",
  ],
});

Forward logs to your own logger.

Web iOS Android
✅ ✅ ✅

No scopes required

captureLog(args: CaptureLogRequest): Promise<void>

JavaScript
await discordSdk.commands.captureLog({
  level: 'log',
  message: 'This is my log message!'
});

Presents a modal dialog to allow enabling of hardware acceleration.

Web iOS Android
✅ ⛔️ ⛔️

No scopes required

encourageHardwareAcceleration(): Promise<EncourageHardwareAccelerationResponse>

JavaScript
await discordSdk.commands.encourageHardwareAcceleration();

Returns information about the channel for a provided channel ID.

Web iOS Android
✅ ✅ ✅
  • [guilds] for guild channels
  • [guilds, dm_channels.read] for GDM channels. dm_channels.read requires approval from Discord.

getChannel(args: GetChannelRequest): Promise<GetChannelResponse>

JavaScript
await discordSdk.commands.getChannel({
  channel_id: discordSdk.channelId,
});

Returns permissions for the current user in the currently connected channel.

Web iOS Android
✅ ✅ ✅
  • guilds.members.read

getChannelPermissions(): Promise<GetChannelPermissionsResponse>

JavaScript
await discordSdk.commands.getChannelPermissions();

Returns a list of entitlements for the current user.

Web iOS Android
✅ ✅ ✅

No scopes required

getEntitlements(): Promise<GetEntitlementsResponse>

JavaScript
await discordSdk.commands.getEntitlements();

Returns all participants connected to the instance.

Web iOS Android
✅ ✅ ✅

No scopes required

getInstanceConnectedParticipants(): Promise<GetInstanceConnectedParticipantsResponse>

JavaScript
await discordSdk.commands.getInstanceConnectedParticipants();

Returns information about supported platform behaviors.

Web iOS Android
✅ ✅ ✅

No scopes required

getPlatformBehaviors(): Promise<GetPlatformBehaviorsResponse>

JavaScript
await discordSdk.commands.getPlatformBehaviors();

Returns the current user's relationships.

Web iOS Android
✅ ✅ ✅
  • relationships.read

getRelationships(): Promise<GetRelationshipsResponse>

JavaScript
await discordSdk.commands.getRelationships();

Returns a list of SKU objects. SKUs without prices are automatically filtered out.

Web iOS Android
✅ ✅ ✅

No scopes required

getSkus(): Promise<GetSkusResponse>

JavaScript
await discordSdk.commands.getSkus();

Presents the file upload flow in the Discord client.

Web iOS Android
✅ ✅ ✅

No scopes required

initiateImageUpload(): Promise<InitiateImageUploadResponse>

JavaScript
await discordSdk.commands.initiateImageUpload();

Allows for opening an external link from within the Discord client.

Web iOS Android
✅ ✅ ✅

No scopes required

openExternalLink(args: OpenExternalLinkRequest): Promise<OpenExternalLinkResponse>

JavaScript
await discordSdk.commands.openExternalLink({
  url: 'string url'
});

Presents a modal dialog with Channel Invite UI without requiring additional OAuth scopes.

Web iOS Android
✅ ✅ ✅

No scopes required

openInviteDialog(): Promise<void>

JavaScript
await discordSdk.commands.openInviteDialog();

Presents a modal dialog to share media to a channel or direct message.

Web iOS Android
✅ ⛔️ ⛔️

No scopes required

openShareMomentDialog(args: OpenShareMomentDialogRequest) Promise<void>

JavaScript
await discordSdk.commands.openShareMomentDialog({
  mediaUrl: 'DISCORD_CDN_URL'
});

Modifies how your Activity's Rich Presence data is displayed in the Discord client. The inner activity field is a partial Activity object.

Read the guide on Using Rich Presence with the Embedded App SDK for more usage details.

Web iOS Android
✅ ✅ ✅
  • rpc.activities.write

setActivity(args: SetActivityRequest): Promise<Activity>

JavaScript
await discordSdk.commands.setActivity({
  activity: {
    type: 0,
    details: 'Details',
    state: 'Playing'
  }
});

Set whether or not the PIP (picture-in-picture) is interactive.

Web iOS Android
✅ ⛔️ ⛔️

No scopes required

setConfig(args: SetConfigRequest): Promise<SetConfigResponse>

JavaScript
await discordSdk.commands.setConfig({
  use_interactive_pip: true
})

Locks the application to specific orientations in each of the supported layout modes.

Web iOS Android
⛔️ ✅ ✅

No scopes required

setOrientationLockState(args: SetOrientationLockStateRequest): Promise<void>

JavaScript
import {Common} from '@discord/embedded-app-sdk';

await discordSdk.commands.setOrientationLockState({
  lock_state: Common.OrientationLockStateTypeObject.LANDSCAPE,
  picture_in_picture_lock_state: Common.OrientationLockStateTypeObject.LANDSCAPE,
  grid_lock_state: Common.OrientationLockStateTypeObject.UNLOCKED
});

Presents the user with a modal to share a link

Web iOS Android
✅ ✅ ✅

No scopes required

shareLink(args: ShareLinkRequest): Promise<ShareLinkResponse><void>

JavaScript
const { success } = await discordSdk.commands.shareLink({
  message: 'This message is shared alongside the link!',
  custom_id: 'some_custom_id',
});
success ? console.log('User shared link!') : console.log('User did not share link!');

Launches the purchase flow for a specific SKU ID.

Web iOS Android
✅ ⛔️ ⛔️

No scopes required

startPurchase(args: StartPurchaseRequest): Promise<StartPurchaseResponse>

JavaScript
await discordSdk.commands.startPurchase({sku_id: skuId});

Returns the current user's locale.

Web iOS Android
✅ ✅ ✅
  • identify

userSettingsGetLocale(): Promise<UserSettingsGetLocaleResponse>

JavaScript
await discordSdk.commands.userSettingsGetLocale();

Developers may use the following events alongside the subscribe() SDK method to subscribe to events from Discord and supported devices.

Name Description
READY non-subscription event sent immediately after connecting, contains server information
ERROR non-subscription event sent when there is an error, including command responses
VOICE_STATE_UPDATE sent when a user's voice state changes in a subscribed voice channel (mute, volume, etc.)
SPEAKING_START sent when a user in a subscribed voice channel speaks
SPEAKING_STOP sent when a user in a subscribed voice channel stops speaking
ACTIVITY_LAYOUT_MODE_UPDATE Received when a user changes the layout mode in the Discord client
ORIENTATION_UPDATE Received when screen orientation changes
CURRENT_USER_UPDATE Received when the current user object changes
CURRENT_GUILD_MEMBER_UPDATE Received when the current guild member object changes
THERMAL_STATE_UPDATE Received when Android or iOS thermal states are surfaced to the Discord app
ACTIVITY_INSTANCE_PARTICIPANTS_UPDATE Received when the number of instance participants changes
RELATIONSHIP_UPDATE Received when a relationship of the current user is updated
ENTITLEMENT_CREATE Received when an entitlement is created for a SKU

Non-subscription event sent immediately after connecting, contains server information.

No scopes required

JavaScript
{
  "v": 1,
  "config": {
      "cdn_host": "cdn.discordapp.com",
      "api_endpoint": "//discord.com/api",
      "environment": "production"
  }
}

Non-subscription event sent when there is an error, including command responses.

No scopes required

JavaScript
{
  "code": 4006,
  "message": "Not authenticated or invalid scope"
}

Received when a user's voice state changes in a subscribed voice channel (mute, volume, etc).

  • rpc.voice.read
JavaScript
{
  "voice_state": {
    "mute": false,
    "deaf": false,
    "self_mute": false,
    "self_deaf": false,
    "suppress": false
  },
  "user": {
    "id": "190320984123768832",
    "username": "test 2",
    "discriminator": "7479",
    "avatar": "b004ec1740a63ca06ae2e14c5cee11f3",
    "bot": false
  },
  "nick": "test user 2",
  "volume": 110,
  "mute": false,
  "pan": {
    "left": 1.0,
    "right": 1.0
  }
}

Received when a user in a subscribed voice channel speaks.

  • rpc.voice.read
JavaScript
{
  "channel_id": "7173758092142710784",
  "user_id": "7173758143913005056"
}

Received when a user in a subscribed voice channel stops speaking.

  • rpc.voice.read
JavaScript
{
  "channel_id": "7173758211307081728",
  "user_id": "7173758261412237312"
}

Received when a user changes the layout mode in the Discord client.

No scopes required

JavaScript
{
  "layout_mode": 1
}

Received when screen orientation changes.

No scopes required

JavaScript
{
  "screen_orientation": 1
}

Received when the current user object changes.

  • identify
JavaScript
{
  "id": "7173771622812225536",
  "username": "beef_supreme",
  "discriminator": "0",
  "global_name": "Dis Cord",
  "avatar": "abcdefg",
  "avatar_decoration_data": {
    "asset": "abcdefg",
    "sku_id": "123456789"
  },
  "bot": false,
  "flags": 1,
  "premium_type": 2
}

Received when the current guild member object changes.

  • identify
  • guilds.members.read
JavaScript
{
  "user_id": "7173771622812225536",
  "nick": "beef_supreme",
  "guild_id": "613425648685547541"
  "avatar": "abcdefg",
  "avatar_decoration_data": {
    "asset": "abcdefg",
    "sku_id": "123456789"
  },
  "color_string": "#ffff00"
}

Received when Android or iOS thermal states are surfaced to the Discord mobile app.

No scopes required

JavaScript
{
  thermal_state: 0
}

Received when the number of instance participants changes.

No scopes required

JavaScript
{
  "participants": [
    {
      "id": "7173771622812225536",
      "username": "beef_supreme",
      "discriminator": "0",
      "global_name": "Dis Cord",
      "avatar": "abcdefg",
      "avatar_decoration_data": {
        "asset": "abcdefg",
        "sku_id": "123456789"
      },
      "bot": false,
      "flags": 1,
      "premium_type": 2
    }
  ]
}

Received when a relationship of the current user is updated.

  • relationships.read
JavaScript
{
  "type": 1,
  "user": {
      "id": "7173771622812225536",
      "username": "beef_supreme",
      "discriminator": "0",
      "global_name": "Dis Cord",
      "avatar": "abcdefg",
      "avatar_decoration_data": {
        "asset": "abcdefg",
        "sku_id": "123456789"
      },
      "bot": false,
      "flags": 1,
      "premium_type": 2
  }
}

Property Type
name string
type number
url? string | null
created_at? number | null
timestamps? Timestamp | null
application_id? string | null
details? string | null
details_url? string | null
state? string | null
state_url? string | null
emoji? Emoji | null
party? Party | null
assets? Assets | null
secrets? Secrets | null
instance? boolean | null
flags? number | null
Property Type
large_image? string | null
large_text? string | null
large_url? string | null
small_image? string | null
small_text? string | null
small_url? string | null
Property Type
description string
icon? string | null
id string
rpc_origins? string[]
name string
Property Type
id string
filename string
size number
url string
proxy_url string
height? number | null
width? number | null
Property Type
access_token? string | null
Property Type
access_token string
user User
scopes string[]
expires string
application Application
Property Type
client_id string
scope OAuthScopes[]
response_type? 'code'
code_challenge? string
state? string
prompt? 'none'
code_challenge_method? 'S256'
Property Type
code string
Property Type
asset string
sku_id? string | null
Property Type
level ConsoleLevel
message string
Property Type
id string
guild_id string
type number
name string
Property Type
title? string | null
type? string | null
description? string | null
url? string | null
timestamp? string | null
color? number | null
footer? EmbedFooter | null
image? Image | null
thumbnail? Image | null
video? Video | null
provider? EmbedProvider | null
author? EmbedAuthor | null
fields? EmbedField[] | null
Property Type
name? string | null
url? string | null
icon_url? string | null
proxy_icon_url? string | null
Property Type
name string
value string
inline boolean
Property Type
text string
icon_url? string | null
proxy_icon_url? string | null
Property Type
name? string | null
url? string | null
Property Type
id string
name? string | null
roles? string[] | null
user? User | null
require_colons? boolean | null
managed? boolean | null
animated? boolean | null
available? boolean | null
Property Type
enabled boolean
Property Type
id string
sku_id string
application_id string
user_id string
gift_code_flags number
type string | number
gifter_user_id? string | null
branches? string[] | null
starts_at? string | null
ends_at? string | null
parent_id? string | null
consumed? boolean | null
deleted? boolean | null
gift_code_batch_id? string | null
Property Type
permissions bigint | string
Property Type
channel_id string
Property Type
id string
type ChannelTypesObject
guild_id? string | null
name? string | null
topic? string | null
bitrate? number | null
user_limit? number | null
position? number | null
voice_states UserVoiceState[]
messages Message[]
Property Type
entitlements Entitlement[]
Property Type
participants User[]
Property Type
iosKeyboardResizesView? boolean
Property Type
relationships Relationship[]
Property Type
skus Sku[]
Property Type
user User
nick? string | null
roles string[]
joined_at string
deaf boolean
mute boolean
Property Type
user_id string
nick? string | null
guild_id string
avatar? string | null
avatar_decoration_data? AvatarDecorationData | null
color_string? string | null
Property Type
url? string | null
proxy_url? string | null
height? number | null
width? number | null
Property Type
image_url string
Property Type
id string
channel_id string
guild_id? string | null
author? User | null
member? GuildMember | null
content string
timestamp string
edited_timestamp? string | null
tts boolean
mention_everyone boolean
mentions User[]
mention_roles string[]
mention_channels ChannelMention[]
attachments Attachment[]
embeds Embed[]
reactions? Reaction[] | null
nonce? string number | null
pinned boolean
webhook_id? string | null
type number
activity? MessageActivity | null
application? MessageApplication | null
message_reference? MessageReference | null
flags? number
stickers? Sticker[] | null
referenced_message? Message | null
Property Type
type number
party_id? string | null
Property Type
id string
cover_image? string | null
description string
icon? string | null
name string
Property Type
message_id? string | null
channel_id? string | null
guild_id? string | null
Property Type
url string
Property Type
opened boolean | null
Property Type
mediaUrl string
Property Type
id? string | null
size? number[] | null
Property Type
count number
me boolean
emoji Emoji
Property Type
type number
user User
Property Type
join? string
match? string
Property Type
activity Activity
Property Type
use_interactive_pip boolean
Property Type
use_interactive_pip boolean
Property Type
lock_state OrientationLockState
picture_in_picture_lock_state OrientationLockState
grid_lock_state OrientationLockState
Property Type
custom_id? string
message string
Property Type
success boolean
Property Type
id string
name string
type SkuTypeObject
price SkuPrice
application_id string
flags number
release_date string | null
Property Type
amount number
currency string
Property Type
sku_id string
Value
Entitlement[] | null
Property Type
start? number
end? number
Property Type
id string
username string
discriminator string
global_name? string | null
avatar? string | null
avatar_decoration_data AvatarDecorationData | null
bot boolean
flags? number | null
premium_type? number | null
Property Type
locale string
Property Type
mute boolean
nick string
user User
voice_state VoiceState
volume number
Property Type
url? string | null
height? number | null
width? number | null
Property Type
mute boolean
deaf boolean
self_mute boolean
self_deaf boolean
suppress boolean
Name Value
UNHANDLED -1
DM 1
GROUP_DM 3
GUILD_TEXT 0
GUILD_VOICE 2
GUILD_CATEGORY 4
GUILD_ANNOUNCEMENT 5
GUILD_STORE 6
ANNOUNCEMENT_THREAD 10
PUBLIC_THREAD 11
PRIVATE_THREAD 12
GUILD_STAGE_VOICE 13
GUILD_DIRECTORY 14
GUILD_FORUM 15
Value
'error'
'log'
'warn'
'debug'
'info'
Name Value
UNHANDLED -1
UNLOCKED 1
PORTRAIT 2
LANDSCAPE 3
Name Value
UNHANDLED -1
NOMINAL 0
FAIR 1
SERIOUS 2
CRITICAL 3
Name Value
UNHANDLED -1
PORTRAIT 0
LANDSCAPE 1
Name Value
UNHANDLED -1
FOCUSED 0
PIP 1
GRID 2
Value
'bot'
'rpc'
'identify'
'connections'
'email'
'guilds'
'guilds.join'
'guilds.members.read'
'gdm.join'
'messages.read'
'rpc.notifications.read'
'rpc.voice.write'
'rpc.voice.read'
'rpc.activities.write'
'webhook.incoming'
'applications.commands'
'applications.builds.upload'
'applications.builds.read'
'applications.store.update'
'applications.entitlements'
'relationships.read'
'activities.read'
'activities.write'
'dm_channels.read'
Name Code
CLOSE_NORMAL 1000
CLOSE_UNSUPPORTED 1003
CLOSE_ABNORMAL 1006
INVALID_CLIENTID 4000
INVALID_ORIGIN 4001
RATELIMITED 4002
TOKEN_REVOKED 4003
INVALID_VERSION 4004
INVALID_ENCODING 4005
Name Value
UNHANDLED -1
APPLICATION 1
DLC 2
CONSUMABLE 3
BUNDLE 4
SUBSCRIPTION 5
Value Name Description
0 None The user has no relationship with the other user.
1 Friend The user is friends with the other user.
2 Blocked The current user has blocked the target user.
3 Pending Incoming The current user has received a friend request from the target user, but it is not yet accepted.
4 Pending Outgoing The current user has sent a friend request to the target user, but it is not yet accepted.
5 Implicit The Implicit type is documented for visibility, but should be unused in the SDK.
6 Suggestion The Suggestion type is documented for visibility, but should be unused in the SDK.
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu