RPC Versions
| Version | Out of Service |
|---|---|
| 1 | no |
Restrictions
Access to the RPC server is limited while developing. You may invite up to 50 approved testers while your app is unapproved. Unapproved apps are limited to creating 10 guilds and 10 channels. After approval, these limits are raised to virtually unlimited.Payloads
All RPC payloads share a common structure:| Field | Type | Description | Present |
|---|---|---|---|
| cmd | enum | RPC command | Always |
| nonce | string | Unique string used once for replies from the server | In responses to commands (not subscribed events) |
| evt | enum | Subscription event | In subscribed events, errors, and (un)subscribing events |
| data | object | Event data | In responses from the server |
| args | object | Command arguments | In commands sent to the server |
Connecting
The local RPC server runs on127.0.0.1. WebSocket connections use:
CLIENT_ID— the client ID of your applicationVERSION— the RPC server version (currently1)PORT— the RPC server port (see below)ENCODING—jsonoretf
RPC Server Ports
The RPC server picks a port from the range 6463–6472 sequentially. Your client should iterate over these ports until a successful connection is made. Track the successful port for the rest of the session.The RPC server verifies the
Origin header on WebSocket connection to prevent client ID spoofing. You will be instantly disconnected if the origin does not match your registered origins. Set your RPC Origin in the Developer Portal.For non-browser apps (like games), ensure the origin is sent with the WebSocket upgrade request. Use
https://localhost for local testing or your company/game’s domain for production.Authenticating
All RPC commands require authentication. Unauthenticated calls return a4006 error. The two-step authentication process uses AUTHORIZE followed by AUTHENTICATE.
Step 1: AUTHORIZE
Send anAUTHORIZE command to prompt the user to grant your app access. The response returns a code that can be exchanged for an access token.
code with a POST to https://discord.com/api/oauth2/token using the standard OAuth2 token exchange parameters.
Authorize Argument Structure
| Field | Type | Description |
|---|---|---|
| scopes | array of strings | OAuth2 scopes to authorize |
| client_id | string | OAuth2 application ID |
| rpc_token | string | One-time use RPC token (for approved apps/testers) |
| username | string | Username to create a guest account with if the user does not have Discord |
Step 2: AUTHENTICATE
Exchange the OAuth2 access token for an authenticated RPC session:| Field | Type | Description |
|---|---|---|
| user | object | The authenticated user (partial) |
| scopes | array | Authorized OAuth2 scopes |
| expires | date | Expiration date of OAuth2 token |
| application | object | The application the user authorized |
Commands and Events
RPC Commands
| Name | Description |
|---|---|
DISPATCH | Event dispatch |
AUTHORIZE | Authorize a new client with your app |
AUTHENTICATE | Authenticate an existing client with your app |
GET_GUILD | Retrieve guild information from the client |
GET_GUILDS | Retrieve a list of guilds from the client |
GET_CHANNEL | Retrieve channel information from the client |
GET_CHANNELS | Retrieve a list of channels for a guild from the client |
SUBSCRIBE | Subscribe to an RPC event |
UNSUBSCRIBE | Unsubscribe from an RPC event |
SET_USER_VOICE_SETTINGS | Change voice settings of users in voice channels |
SELECT_VOICE_CHANNEL | Join or leave a voice channel, group DM, or DM |
GET_SELECTED_VOICE_CHANNEL | Get the current voice channel the client is in |
SELECT_TEXT_CHANNEL | Join or leave a text channel, group DM, or DM |
GET_VOICE_SETTINGS | Retrieve the client’s voice settings |
SET_VOICE_SETTINGS | Set the client’s voice settings |
SET_CERTIFIED_DEVICES | Send info about certified hardware devices |
SET_ACTIVITY | Update a user’s Rich Presence |
SEND_ACTIVITY_JOIN_INVITE | Consent to a Rich Presence Ask to Join request |
CLOSE_ACTIVITY_REQUEST | Reject a Rich Presence Ask to Join request |
RPC Events
| 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 |
GUILD_STATUS | Sent when a subscribed server’s state changes |
GUILD_CREATE | Sent when a guild is created/joined on the client |
CHANNEL_CREATE | Sent when a channel is created/joined on the client |
VOICE_CHANNEL_SELECT | Sent when the client joins a voice channel |
VOICE_STATE_CREATE | Sent when a user joins a subscribed voice channel |
VOICE_STATE_UPDATE | Sent when a user’s voice state changes in a subscribed voice channel (mute, volume, etc.) |
VOICE_STATE_DELETE | Sent when a user parts a subscribed voice channel |
VOICE_SETTINGS_UPDATE | Sent when the client’s voice settings update |
VOICE_CONNECTION_STATUS | Sent when the client’s voice connection status changes |
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 |
MESSAGE_CREATE | Sent when a message is created in a subscribed text channel |
MESSAGE_UPDATE | Sent when a message is updated in a subscribed text channel |
MESSAGE_DELETE | Sent when a message is deleted in a subscribed text channel |
NOTIFICATION_CREATE | Sent when the client receives a notification (mention or new message in eligible channels) |
ACTIVITY_JOIN | Sent when the user clicks a Rich Presence join invite in chat to join a game |
ACTIVITY_SPECTATE | Sent when the user clicks a Rich Presence spectate invite in chat to spectate a game |
ACTIVITY_JOIN_REQUEST | Sent when the user receives a Rich Presence Ask to Join request |
Command Reference
GET_GUILDS
GET_GUILDS
Used to get a list of guilds the client is in.RequestResponse
GET_GUILD
GET_GUILD
Used to get a specific guild the client is in.Argument Structure
Response Structure
Example
| Field | Type | Description |
|---|---|---|
| guild_id | string | ID of the guild to get |
| timeout | integer | Asynchronously get guild with time to wait before timing out |
| Field | Type | Description |
|---|---|---|
| id | string | Guild ID |
| name | string | Guild name |
| icon_url | string | Guild icon URL |
| members | array of objects | Guild members (deprecated; always returns an empty array) |
GET_CHANNEL
GET_CHANNEL
Used to get a specific channel the client is in.Argument Structure
Response Structure
| Field | Type | Description |
|---|---|---|
| channel_id | string | ID of the channel to get |
| Field | Type | Description |
|---|---|---|
| id | string | Channel ID |
| guild_id | string | Channel’s guild ID |
| name | string | Channel name |
| type | integer | Channel type (guild text: 0, guild voice: 2, dm: 1, group dm: 3) |
| topic | string | (text) Channel topic |
| bitrate | integer | (voice) Bitrate of voice channel |
| user_limit | integer | (voice) User limit of voice channel (0 for none) |
| position | integer | Position of channel in channel list |
| voice_states | array of objects | (voice) Channel’s voice states |
| messages | array of objects | (text) Channel’s messages |
GET_CHANNELS
GET_CHANNELS
Used to get a guild’s channels.Argument Structure
Example
| Field | Type | Description |
|---|---|---|
| guild_id | string | ID of the guild to get channels for |
SET_USER_VOICE_SETTINGS
SET_USER_VOICE_SETTINGS
Used to change voice settings of a specific user in a voice channel.Argument and Response Structure
Example
Only one app may modify voice settings at a time. When an app changes voice settings, it locks them so other apps lose the ability to change them. Settings reset when the controlling app disconnects.
| Field | Type | Description |
|---|---|---|
| user_id | string | User ID |
| pan? | object | Pan settings { left: float, right: float } (0.0–1.0) |
| volume? | integer | Volume (defaults to 100, min 0, max 200) |
| mute? | boolean | Mute state |
SELECT_VOICE_CHANNEL
SELECT_VOICE_CHANNEL
Used to join or leave a voice channel, group DM, or DM. Returns the Get Channel response, or
null if leaving.Argument Structure| Field | Type | Description |
|---|---|---|
| channel_id | string | Channel ID to join (or null to leave) |
| timeout | integer | Asynchronously join channel with time to wait before timing out |
| force | boolean | Force move a user to a voice channel |
| navigate | boolean | Navigate to the channel in the client after joining |
SELECT_TEXT_CHANNEL
SELECT_TEXT_CHANNEL
Used to join or leave a text channel, group DM, or DM. Returns the Get Channel response, or
null if leaving.Argument Structure| Field | Type | Description |
|---|---|---|
| channel_id | string | Channel ID to join (or null to leave) |
| timeout | integer | Asynchronously join channel with time to wait before timing out |
GET_VOICE_SETTINGS / SET_VOICE_SETTINGS
GET_VOICE_SETTINGS / SET_VOICE_SETTINGS
GET_VOICE_SETTINGS retrieves the current voice settings. SET_VOICE_SETTINGS updates them — all fields are optional and only passed fields are updated.Only one app may modify voice settings at a time (same restriction as
SET_USER_VOICE_SETTINGS).| Field | Type | Description |
|---|---|---|
| input | object | Input device settings |
| output | object | Output device settings |
| mode | object | Voice mode settings |
| automatic_gain_control | boolean | State of automatic gain control |
| echo_cancellation | boolean | State of echo cancellation |
| noise_suppression | boolean | State of noise suppression |
| qos | boolean | State of voice quality of service |
| silence_warning | boolean | State of silence warning notice |
| deaf | boolean | State of self-deafen |
| mute | boolean | State of self-mute |
| Field | Type | Description |
|---|---|---|
| device_id | string | Device ID |
| volume | float | Input voice level (0–100) / Output voice level (0–200) |
| available_devices | array of objects | Read-only device objects with id and name string keys |
| Field | Type | Description |
|---|---|---|
| type | string | Voice mode: PUSH_TO_TALK or VOICE_ACTIVITY |
| auto_threshold | boolean | Whether voice activity threshold sets itself automatically |
| threshold | float | Threshold for voice activity in dB (min: -100, max: 0) |
| shortcut | object | Push-to-talk shortcut key combo |
| delay | float | PTT release delay in ms (min: 0, max: 2000) |
| Type | ID |
|---|---|
| KEYBOARD_KEY | 0 |
| MOUSE_BUTTON | 1 |
| KEYBOARD_MODIFIER_KEY | 2 |
| GAMEPAD_BUTTON | 3 |
SUBSCRIBE / UNSUBSCRIBE
SUBSCRIBE / UNSUBSCRIBE
Used to subscribe or unsubscribe from RPC events. Set Unsubscribe Example
evt to the event name and args to the arguments required by that event.Subscribe ExampleSET_CERTIFIED_DEVICES
SET_CERTIFIED_DEVICES
Used by hardware manufacturers to send information about connected certified devices. See Certified Devices for the full integration guide.Argument Structure
Example
| Field | Type | Description |
|---|---|---|
| devices | array of objects | A list of devices for your manufacturer, in order of priority |
SET_ACTIVITY
SET_ACTIVITY
Used to update a user’s Rich Presence.Argument Structure
When using
SET_ACTIVITY, the activity object is limited to a type of Playing (0), Listening (2), Watching (3), or Competing (5).| Field | Type | Description |
|---|---|---|
| pid | integer | The application’s process ID |
| activity | object | The Rich Presence to assign to the user |
SEND_ACTIVITY_JOIN_INVITE / CLOSE_ACTIVITY_REQUEST
SEND_ACTIVITY_JOIN_INVITE / CLOSE_ACTIVITY_REQUEST
Used to accept or reject a Rich Presence Ask to Join request.Argument Structure (both commands)
Example: Accept join request
| Field | Type | Description |
|---|---|---|
| user_id | snowflake | The ID of the requesting user |
Event Reference
READY
READY
Sent immediately after connecting. Contains the RPC version, server configuration, and the current user.
ERROR
ERROR
Sent when an error occurs, including failed command responses.See RPC Error Codes for the full list.
GUILD_STATUS
GUILD_STATUS
Sent when a subscribed server’s state changes. Requires subscribing with a
guild_id argument.VOICE_STATE_CREATE / VOICE_STATE_UPDATE / VOICE_STATE_DELETE
VOICE_STATE_CREATE / VOICE_STATE_UPDATE / VOICE_STATE_DELETE
Dispatched when a user joins, changes state in, or leaves a subscribed voice channel. Requires subscribing with a
channel_id argument.VOICE_CONNECTION_STATUS
VOICE_CONNECTION_STATUS
Sent when the client’s voice connection status changes.Dispatch Data Structure
Voice Connection States
| Field | Type | Description |
|---|---|---|
| state | string | One of the voice connection states listed below |
| hostname | string | Hostname of the connected voice server |
| pings | array of integers | Last 20 pings (in ms) |
| average_ping | integer | Average ping (in ms) |
| last_ping | integer | Last ping (in ms) |
| State | Description |
|---|---|
DISCONNECTED | TCP disconnected |
AWAITING_ENDPOINT | Waiting for voice endpoint |
AUTHENTICATING | TCP authenticating |
CONNECTING | TCP connecting |
CONNECTED | TCP connected |
VOICE_DISCONNECTED | TCP connected, Voice disconnected |
VOICE_CONNECTING | TCP connected, Voice connecting |
VOICE_CONNECTED | TCP connected, Voice connected |
NO_ROUTE | No route to host |
ICE_CHECKING | WebRTC ICE checking |
SPEAKING_START / SPEAKING_STOP
SPEAKING_START / SPEAKING_STOP
Sent when a user in a subscribed voice channel starts or stops speaking. Requires subscribing with a
channel_id argument.MESSAGE_CREATE / MESSAGE_UPDATE / MESSAGE_DELETE
MESSAGE_CREATE / MESSAGE_UPDATE / MESSAGE_DELETE
Dispatched for message events in subscribed text channels. Deletions only include the message ID. Requires subscribing with a
channel_id argument.NOTIFICATION_CREATE
NOTIFICATION_CREATE
Sent when the client receives a notification. Requires the
rpc.notifications.read OAuth2 scope. No subscription arguments needed.| Field | Type | Description |
|---|---|---|
| channel_id | string | ID of channel where notification occurred |
| message | object | Message that generated this notification |
| icon_url | string | Icon URL of the notification |
| title | string | Title of the notification |
| body | string | Body of the notification |
ACTIVITY_JOIN / ACTIVITY_SPECTATE / ACTIVITY_JOIN_REQUEST
ACTIVITY_JOIN / ACTIVITY_SPECTATE / ACTIVITY_JOIN_REQUEST
Rich Presence activity events.
ACTIVITY_JOIN— sent when the user clicks a join invite. Containssecret(thejoin_secretfrom the activity).ACTIVITY_SPECTATE— sent when the user clicks a spectate invite. Containssecret(thespectate_secretfrom the activity).ACTIVITY_JOIN_REQUEST— sent when the user receives an Ask to Join request. Contains a partialuserobject.