Skip to main content

RPC over IPC

Discord’s RPC server supports IPC (Inter-Process Communication) as transport for native applications and games. This allows high-performance, local communication with the Discord client without requiring network-level overhead.
We recommend using the Discord Social SDK for new projects that are looking to integrate Discord’s social features into their game.
IPC Path
On Linux/macOS, Discord resolves the IPC prefix in this order: XDG_RUNTIME_DIR, TMPDIR, TMP, TEMP, then /tmp as a final fallback.

Connecting to IPC

To begin a session, the application must open the IPC socket and send a HANDSHAKE opcode.

Handshake Payload

The payload is a JSON object containing the RPC version and your application’s client ID.
Example Handshake
Upon success, Discord will respond with a FRAME (Opcode 1) containing the READY event. Once the handshake is complete, all subsequent requests and responses use the FRAME opcode. The internal structure of these frames follows the standard RPC Payload structure
Opcodes
This is a deprecated way, which is only available for old participants of private beta. It is preferable to use RPC that uses IPC.
All Discord clients have an RPC server running on localhost that allows control over local Discord clients.

Connecting to WebSocket

The local RPC server runs on localhost (127.0.0.1) and is set up to process WebSocket connections and proxy API requests.For WebSocket connections, the connection is always ws://127.0.0.1:PORT/?v=VERSION&client_id=CLIENT_ID&encoding=ENCODING:
  • CLIENT_ID is the client ID of the application accessing the RPC Server.
  • VERSION is the version of the RPC Server.
  • PORT is the port of the RPC Server.
  • ENCODING is the type of encoding for this connection to use. json and etf are supported.
To begin, you’ll need to create an app. Head to your apps and click the big plus button. When you create an app on our Developers site, you must specify an “RPC Origin” and “Redirect URI” from which to permit connections and authorizations. The origin you send when connecting and the redirect uri you send when exchanging an authorization code for an access token must match one of the ones entered on the Developers site.When establishing a WebSocket connection, we verify the Origin header on connection to prevent client ID spoofing. You will be instantly disconnected if the Origin does not match.If you’re connecting to the RPC server from within a browser, RPC origins are usually in the form SCHEME://HOST[:PORT], where SCHEME is typically https or http, HOST is your domain or ip, and PORT is the port of the webserver from which the user will be connecting (omitted for ports 80 and 443). For example, https://discord.com would be used if the user were connecting from https://discord.com/some/page/url.If you’re connecting to the RPC server from within a non-browser application (like a game), you just need to make sure that the origin is sent with the upgrade request when connecting to the WebSocket. For local testing, we recommend testing with an origin like https://localhost. For production apps, we recommend setting the origin to your company/game’s domain, for example https://discord.com.

RPC Server Ports

The port range for Discord’s local RPC server is [6463, 6472]. Since the RPC server runs locally, there’s a chance it might not be able to obtain its preferred port when it tries to bind to one. For this reason, the local RPC server will pick one port out of a range of these 10 ports, trying sequentially until it can bind to one. When implementing your client, you should perform the same sequential checking to find the correct port to connect to.
RPC Versions

Restrictions

For connections to the RPC server, a list of approved testers is used to restrict access while you’re still developing. You can invite up to 50 people. For applications/games not approved, we limit you to creating 10 guilds and 10 channels. This limit is raised to virtually unlimited after approval.

Payloads

Payload Structure

Authenticating

In order to call any commands over RPC, you must be authenticated or you will receive a code 4006 error response. To begin, call AUTHORIZE:
RPC Authorize Example
The user will then be prompted to authorize your app to access RPC on Discord. The AUTHORIZE command returns a code that you can exchange with a POST to https://discord.com/api/oauth2/token containing the standard OAuth2 body parameters for the token exchange. The token endpoint on our API will return an access_token that can be sent with AUTHENTICATE:
RPC Authenticate Example
You can now call RPC commands on behalf of the authorized user!

Commands and Events

Commands are requests made to the RPC socket by a client.
The structure of responses from the RPC server is similar to the HTTP API but may not be exactly equivalent.
RPC Commands
Events are payloads sent over the socket to a client that correspond to events in Discord.
RPC Events

AUTHORIZE

Used to authenticate a new client with your app. By default this pops up a modal in-app that asks the user to authorize access to your app. We currently do not allow access to RPC for unapproved apps without being on the game’s list of testers. We grant 50 testing spots, which should be ample for development. After approval, this restriction is removed and your app will be accessible to anyone. We also have an RPC token system to bypass the user authorization modal. This is usable by approved games as well as by users on a game’s list of testers, and also disallows use of the messages.read scope. If you have been granted access, you can send a POST request to https://discord.com/api/oauth2/token/rpc with your application’s client_id and client_secret in the body (sent as a url-encoded body, not JSON). You can then pass the returned rpc_token value to the rpc_token field in your RPC authorize request (documented below).
Authorize Argument Structure
Authorize Response Structure
Example Authorize Command Payload
Example Authorize Response Payload

AUTHENTICATE

Used to authenticate an existing client with your app.
Authenticate Argument Structure
Authenticate Response Structure
OAuth2 Application Structure
Example Authenticate Command Payload
Example Authenticate Response Payload

GET_GUILDS

Used to get a list of guilds the client is in.
Get Guilds Response Structure
Example Get Guilds Command Payload
Example Get Guilds Response Payload

GET_GUILD

Used to get a guild the client is in.
Get Guild Argument Structure
Get Guild Response Structure
Example Get Guild Command Payload
Example Get Guild Response Payload

GET_CHANNEL

Used to get a channel the client is in.
Get Channel Argument Structure
Get Channel Response Structure
Example Get Channel Command Payload
Example Get Channel Response Payload

GET_CHANNELS

Used to get a guild’s channels the client is in.
Get Channels Argument Structure
Get Channels Response Structure
Example Get Channels Command Payload
Example Get Channels Response Payload

SET_USER_VOICE_SETTINGS

Used to change voice settings of users in voice channels
Set User Voice Settings Argument and Response Structure
In the current release, we only support a single modifier of voice settings at a time over RPC. If an app changes voice settings, it will lock voice settings so that other apps connected simultaneously lose the ability to change voice settings. Settings reset to what they were before being changed after the controlling app disconnects. When an app that has previously set voice settings connects, the client will swap to that app’s configured voice settings and lock voice settings again. This is a temporary situation that will be changed in the future.
Pan Object
Example Set User Voice Settings Command Payload
Example Set User Voice Settings Response Payload

SELECT_VOICE_CHANNEL

Used to join and leave voice channels, group dms, or dms. Returns the Get Channel response, null if none.
Select Voice Channel Argument Structure
When trying to join the user to a voice channel, you will receive a 5003 error coded response if the user is already in a voice channel. The force parameter should only be specified in response to the case where a user is already in a voice channel and they have approved to be moved by your app to a new voice channel.
Example Select Voice Channel Command Payload
Example Select Voice Channel Response Payload

GET_SELECTED_VOICE_CHANNEL

Used to get the client’s current voice channel. There are no arguments for this command. Returns the Get Channel response, or null if none.

SELECT_TEXT_CHANNEL

Used to join and leave text channels, group dms, or dms. Returns the Get Channel response, or null if none.
Select Text Channel Argument Structure

GET_VOICE_SETTINGS

Get Voice Settings Response Structure
Voice Settings Input Object
Voice Settings Output Object
Voice Settings Mode Object
Shortcut Key Combo Object
Key Types
Example Get Voice Settings Response Payload

SET_VOICE_SETTINGS

In the current release, we only support a single modifier of voice settings at a time over RPC. If an app changes voice settings, it will lock voice settings so that other apps connected simultaneously lose the ability to change voice settings. Settings reset to what they were before being changed after the controlling app disconnects. When an app that has previously set voice settings connects, the client will swap to that app’s configured voice settings and lock voice settings again. This is a temporary situation that will be changed in the future.
When setting voice settings, all fields are optional. Only passed fields are updated.
Set Voice Settings Argument and Response Structure
Example Set Voice Settings Command Payload
Example Set Voice Settings Response Payload

SUBSCRIBE

Used to subscribe to events. evt of the payload should be set to the event being subscribed to. args of the payload should be set to the args needed for the event.
Subscribe Response Structure
Example Subscribe Command Payload
Example Subscribe Response Payload

UNSUBSCRIBE

Used to unsubscribe from events. evt of the payload should be set to the event that was subscribed to. args of the payload should be set to the args needed for the previously subscribed event.
Unsubscribe Response Structure
Example Unsubscribe Command Payload
Example Unsubscribe Response Payload

SET_CERTIFIED_DEVICES

Used by hardware manufacturers to send information about the current state of their certified devices that are connected to Discord.
Set Certified Devices Argument Structure
Device Object
*These fields are only applicable for AUDIO_INPUT device types
Vendor Object
Model Object
Device Type
Example Set Certified Devices Command Payload
Example Set Certified Devices Response Payload

SET_ACTIVITY

Used to update a user’s Rich Presence.
Set Activity Argument Structure
When using SET_ACTIVITY, the activity object is limited to a type of Playing (0), Listening (2), Watching (3), or Competing (5).
Example Set Activity Payload

SEND_ACTIVITY_JOIN_INVITE

Used to accept an Ask to Join request.
Send Activity Join Invite Argument Structure
Example Send Activity Join Invite Payload

CLOSE_ACTIVITY_REQUEST

Used to reject an Ask to Join request.
Close Activity Request Argument Structure
Example Close Activity Request Payload

READY

Ready Dispatch Data Structure
RPC Server Configuration Object
Example Ready Dispatch Payload

ERROR

Error Data Structure
Example Error Payload

GUILD_STATUS

Guild Status Argument Structure
Guild Status Dispatch Data Structure
Example Guild Status Dispatch Payload

GUILD_CREATE

No arguments
Guild Create Dispatch Data Structure
Example Guild Create Dispatch Payload

CHANNEL_CREATE

No arguments
Channel Create Dispatch Data Structure
Example Channel Create Dispatch Payload

VOICE_CHANNEL_SELECT

No arguments
Voice Channel Select Dispatch Data Structure
Example Voice Channel Select Dispatch Payload

VOICE_SETTINGS_UPDATE

Voice Settings Argument Structure
No arguments. Dispatches the Get Voice Settings response.
Example Voice Settings Dispatch Payload

VOICE_STATE_CREATE/VOICE_STATE_UPDATE/VOICE_STATE_DELETE

Dispatches channel voice state objects
Voice State Argument Structure
Example Voice State Dispatch Payload

VOICE_CONNECTION_STATUS

No arguments
Voice Connection Status Dispatch Data Structure
Voice Connection States
Example Voice Connection Status Dispatch Payload

MESSAGE_CREATE/MESSAGE_UPDATE/MESSAGE_DELETE

Dispatches message objects, with the exception of deletions, which only contains the id in the message object.
Message Argument Structure
Example Message Dispatch Payload

SPEAKING_START/SPEAKING_STOP

Speaking Argument Structure
Speaking Dispatch Data Structure
Example Speaking Dispatch Payload

NOTIFICATION_CREATE

No arguments. This event requires the rpc.notifications.read OAuth2 scope.
Notification Create Dispatch Data Structure
Example Notification Create Dispatch Payload

ACTIVITY_JOIN

No arguments
Activity Join Dispatch Data Structure
Example Activity Join Dispatch Payload

ACTIVITY_SPECTATE

No arguments
Activity Spectate Dispatch Data Structure
Example Activity Spectate Dispatch Payload

ACTIVITY_JOIN_REQUEST

No arguments
Activity Join Request Data Structure
Example Activity Join Request Dispatch Payload

ACTIVITY_INVITE

No arguments
Activity Invite Dispatch Data Structure
Example Activity Invite Dispatch Payload

CURRENT_USER_UPDATE

No arguments. Dispatches the current user’s profile whenever it changes (avatar, username, etc.).
Current User Update Dispatch Data Structure
Example Current User Update Dispatch Payload

RELATIONSHIP_UPDATE

No arguments. Requires the relationships_read OAuth2 scope. Fired when a relationship is added, updated (e.g. presence change), or removed. When a relationship is removed, type will be 0 (NONE).
Relationship Update Dispatch Data Structure
Relationship Types
Presence Object
Example Relationship Update Dispatch Payload

ENTITLEMENT_CREATE

No arguments. Fired when the user acquires a new entitlement for this application.
Entitlement Create Dispatch Data Structure
Entitlement Object
Entitlement Types
Example Entitlement Create Dispatch Payload

ENTITLEMENT_DELETE

No arguments. Fired when an entitlement for this application is removed. The entitlement object in the payload reflects the state of the entitlement at the time of deletion.
Entitlement Delete Dispatch Data Structure
Example Entitlement Delete Dispatch Payload