Search the docs
Menu
Updated Edit on GitHub

Server API: devices

Copy as Markdown

These routes are on the server API, port 21114 (21121 in Docker). They take an API key in X-API-Key or a sign-in token; see The HTTP API.

Devices on the server API: their records, live status, bans, IDs, tags, access policy, connection mode and telemetry, and the device lists RustDesk clients and RustDesk Pro scripts read.

GET /api/devices

List device IDs with their GUIDs, for RustDesk Pro scripts.

Devices that are not deleted, of every organization.

On the server API, port 21114. Needs device.view.

Parameter In Type What it is
id query string Only devices whose ID matches this
pageSize query integer default 50, at least 1, at most 1000
current query integer The page; default 1, at least 1

200: Done (application/json)

Field Type Required
total integer yes
data array of object yes
data[].id string
data[].guid string
Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission

POST /api/devices/{guid}/assign

Give a device a strategy or a note, for RustDesk Pro scripts.

Super admins and global admins only. type strategy_name assigns the strategy named in value (by name or GUID; empty takes the device's strategy away); type note sets the note, cut to 1024 characters. The client API port (21121) answers it the same way in both modes of RUSTDESK_API_PROXY; the app's --assign posts here with the device's ID.

On the server API, port 21114.

Parameter In Type Required What it is
guid path string yes The device's GUID from GET /api/devices, or its ID

Request body, application/json:

Field Type Required
type string, one of strategy_name, note yes
value string

200: Done (application/json)

Field Type Required
status "ok" yes
Error When
400 The request is not valid
401 No credential, or one that is not valid
403 The credential's role lacks the permission
404 There is no such item

GET /api/peers

List devices with their live status.

Without limit or page_size it answers every device as a list. With one of them it answers one page as {total, data}. A request with accessible or pageSize in the query is a RustDesk client's and gets the list GET /api/peers/list answers. An account limited to an organization or to device groups gets only those devices.

On the server API, port 21114. Needs device.view.

Parameter In Type What it is
include_deleted query string, one of true true to list deleted devices too
limit query integer Devices per page; turns paging on; default 50, at least 1, at most 500
page_size query integer The same as limit; at least 1, at most 500
page query integer default 1, at least 1

200: Done (application/json)

Array of ServerPeer or object.

Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission

GET /api/peers/list

List the devices a RustDesk client shows.

The device list of the RustDesk client: the devices the signed-in account may see, filtered by folder, device group or tag. An account without device.view gets an empty list.

On the server API, port 21114. Takes the token of a RustDesk client sign-in.

Parameter In Type What it is
page query integer default 1, at least 1
pageSize query integer Devices per page; page_size works too; default 100, at least 1, at most 200
folder_id query string Only the devices of this folder or device group (by ID, GUID or name); group_id, group_name and their other spellings work too
tag query string Only devices with these tags, separated by commas; tags works too

200: Done (application/json)

Field Type Required
total integer yes
data array of RustDeskPeer or null yes
msg "success" yes
Error When
401 No credential, or one that is not valid

POST /api/peers/list

List the devices a RustDesk client shows.

The device list of the RustDesk client: the devices the signed-in account may see, filtered by folder, device group or tag. An account without device.view gets an empty list. The body's fields count as query parameters (at most 4,096 bytes).

On the server API, port 21114. Takes the token of a RustDesk client sign-in.

Parameter In Type What it is
page query integer default 1, at least 1
pageSize query integer Devices per page; page_size works too; default 100, at least 1, at most 200
folder_id query string Only the devices of this folder or device group (by ID, GUID or name); group_id, group_name and their other spellings work too
tag query string Only devices with these tags, separated by commas; tags works too

Request body, application/json:

Field Type
page integer
pageSize integer
folder_id string or integer
tag string

200: Done (application/json)

Field Type Required
total integer yes
data array of RustDeskPeer or null yes
msg "success" yes
Error When
401 No credential, or one that is not valid

GET /api/peers/online

List the devices registered with the signal server now.

An account limited to an organization or to device groups gets only those devices.

On the server API, port 21114. Needs device.view.

200: Done (application/json)

Field Type Required
count integer yes
peers array of PeerSnapshot yes
Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission

GET /api/peers/status/summary

Count the devices registered with the signal server, by status and transport.

Counts every registered device, whatever the account may see.

On the server API, port 21114. Needs device.view.

200: Done (application/json)

Field Type What it is
total integer
online integer
degraded integer
critical integer
udp integer
tcp integer
ws integer
banned integer
disabled integer
avg_uptime_seconds number
avg_beat_age_seconds number Average seconds since the last heartbeat
Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission

GET /api/peers/{id}

Show one device with its live status.

An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.view.

Parameter In Type Required What it is
id path string yes The device ID

200: Done (application/json)

ServerPeer and object.

Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission
404 There is no such item

PATCH /api/peers/{id}

Change a device's note, user, tags, display name or link.

Give only what changes. An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.edit.

Parameter In Type Required What it is
id path string yes The device ID

Request body, application/json:

Field Type What it is
note string
user string
tags string or array of string Comma-separated text or a list
display_name string
linked_peer_id string The device it is linked to; empty removes the link

200: Done (application/json)

Field Type Required
status "updated" yes
id string
Error When
400 The request is not valid
401 No credential, or one that is not valid
403 The credential's role lacks the permission

DELETE /api/peers/{id}

Delete a device.

Moves the device to the bin unless hard is true, and drops its connections. An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.delete.

Parameter In Type Required What it is
id path string yes The device ID
hard query string, one of true true to delete it for good
revoke query string, one of true true to also put the ID on the blocklist and ban it
cascade query string, one of true true to also delete the devices linked to it
cascade_only query string Device IDs separated by commas: the cascade deletes only these of the linked devices

200: Done (application/json)

Field Type Required What it is
status "deleted" yes
id string yes
revoked boolean yes
cascaded array of string Only when set: the linked devices deleted with it
Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission

GET /api/peers/{id}/access-policy

Show who may connect to a device and how.

A device without its own policy answers the defaults, all off. An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.view.

Parameter In Type Required What it is
id path string yes The device ID

200: Done (application/json)

AccessPolicy.

Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission

PUT /api/peers/{id}/access-policy

Set who may connect to a device and how.

Global admins and above. The password is stored hashed; leave it out to keep the one set. Days, times and time zone are checked. An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs org.edit. Only for the role global_admin.

Parameter In Type Required What it is
id path string yes The device ID

Request body, application/json:

Field Type What it is
unattended_enabled boolean
password string A new unattended password
clear_password boolean true removes the password
schedule_enabled boolean
schedule_days string Comma-separated days: mon, tue, wed, thu, fri, sat, sun
schedule_start_time string HH:MM, 24 hours; checked when schedule_enabled is true
schedule_end_time string HH:MM, 24 hours; checked when schedule_enabled is true
schedule_timezone string An IANA time zone
allowed_operators string Comma-separated usernames; empty for all

200: Done (application/json)

Field Type Required
success true yes
Error When
400 The request is not valid
401 No credential, or one that is not valid
403 The credential's role lacks the permission

DELETE /api/peers/{id}/access-policy

Remove a device's own access policy.

Global admins and above. The device falls back to the defaults, all off. An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs org.edit. Only for the role global_admin.

Parameter In Type Required What it is
id path string yes The device ID

200: Done (application/json)

Field Type Required
success true yes
Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission

GET /api/peers/{id}/availability

Show when a device was online over a day.

events is empty while the server keeps no availability history. An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.view.

Parameter In Type Required What it is
id path string yes The device ID
day query string YYYY-MM-DD (default today in UTC)
tz_offset_minutes query integer Minutes from local time to UTC, as JavaScript's getTimezoneOffset gives them; default 0

200: Done (application/json)

PeerAvailability.

Error When
400 The request is not valid
401 No credential, or one that is not valid
403 The credential's role lacks the permission

POST /api/peers/{id}/ban

Ban a device.

The device is disconnected and refused when it registers again. An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.ban.

Parameter In Type Required What it is
id path string yes The device ID

Request body, application/json:

Field Type
reason string

200: Done (application/json)

Field Type Required
status "banned" yes
id string
Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission

POST /api/peers/{id}/change-id

Give a device a new ID.

A live connection keeps going under the new ID. An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.change_id.

Parameter In Type Required What it is
id path string yes The device ID

Request body, application/json:

Field Type Required What it is
new_id string yes 6 to 16 letters, digits, - and _

200: Done (application/json)

Field Type Required
status "changed" yes
old_id string yes
new_id string yes
Error When
400 The request is not valid
401 No credential, or one that is not valid
403 The credential's role lacks the permission
404 There is no such item
409 Another device holds the ID, also a deleted one

GET /api/peers/{id}/connect-password

Show whether the device's organization stored a device password (never the password).

The account must belong to the device's organization unless its role sees every organization. 404 with password_set false when the device has no organization or no password is stored.

On the server API, port 21114. Needs device.connect.

Parameter In Type Required What it is
id path string yes The device ID

200: Done (application/json)

Field Type Required
password_set true yes
org_id string yes
Error When
400 The request is not valid
401 No credential, or one that is not valid
403 The credential's role lacks the permission
404 No password is stored; the answer is {"password_set": false}
503 The server's credential vault is not set up

GET /api/peers/{id}/connection-mode

Show a device's connection mode and whether it can be changed.

An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.view.

Parameter In Type Required What it is
id path string yes The device ID

200: Done (application/json)

Field Type What it is
device_id string
controllable boolean The device's NeoDesk can switch its connection mode
support_agent boolean The device is a support agent, whose mode is fixed
policy ConnectionModePolicy or null
command ConnectionModeCommand or null The latest change, null for none
Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission
404 There is no such item

POST /api/peers/{id}/connection-mode

Let a device accept only incoming connections, or both ways again.

Queues the change for the device. Without operator_id and operator_name the signed-in account is named. An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.connection_mode.

Parameter In Type Required What it is
id path string yes The device ID

Request body, application/json:

Field Type Required
mode string, one of normal, incoming-only yes
reason string yes
operator_id string
operator_name string

200: Done (application/json)

Field Type What it is
created boolean false when the same change was queued already
command ConnectionModeCommand
policy ConnectionModePolicy or null
Error When
400 The request is not valid
401 No credential, or one that is not valid
403 The credential's role lacks the permission
404 There is no such item
409 The device is a support agent (support_agent_permanent), can't switch its mode (capability_required), has no UUID or is blocked

GET /api/peers/{id}/connection-sessions

List the remote sessions to a device, newest first.

An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.view.

Parameter In Type Required What it is
id path string yes The device ID
limit query integer How many; a value outside 1 to 500 counts as 50; default 50, at least 1, at most 500

200: Done (application/json)

Field Type Required
peer_id string yes
count integer yes
sessions array of ConnectionSession yes
Error When
400 The request is not valid
401 No credential, or one that is not valid
403 The credential's role lacks the permission

POST /api/peers/{id}/exec

Run a command on a device through its MeshCentral or NeoDesk agent.

Sends the command and does not wait for its output. A MeshCentral agent needs mesh.terminal, a NeoDesk agent cdap.terminal. An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs mesh.terminal or cdap.terminal.

Parameter In Type Required What it is
id path string yes The device ID

Request body, application/json:

Field Type Required What it is
command string yes
shell boolean MeshCentral agents: run it in a shell

200: Done (application/json)

Field Type Required
transport string, one of mesh, cdap yes
status "sent" yes
Error When
400 The body is not valid, the agent refused, or the device is not connected through either agent
401 No credential, or one that is not valid
403 The credential's role lacks the permission

GET /api/peers/{id}/linked

List the devices linked to a device.

Such as an agent and the desktop client on the same computer. Only the linked devices the account may see. An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.view.

Parameter In Type Required What it is
id path string yes The device ID

200: Done (application/json)

Field Type Required
peer_id string yes
linked array of ServerPeerRow yes
total integer yes
Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission

GET /api/peers/{id}/metrics

List a device's CPU, memory and disk samples.

An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.view.

Parameter In Type Required What it is
id path string yes The device ID
limit query integer How many samples; a value outside 1 to 1000 counts as 100; default 100, at least 1, at most 1000

200: Done (application/json)

Field Type Required What it is
peer_id string yes
count integer yes
metrics array of object yes
metrics[].id integer
metrics[].peer_id string
metrics[].cpu_percent number or null
metrics[].memory_percent number or null
metrics[].disk_percent number or null
metrics[].received_bps number Bits per second the device received, left out when it sent none
metrics[].transmitted_bps number Bits per second the device sent, left out when it sent none
metrics[].created_at string (date-time)
Error When
400 The request is not valid
401 No credential, or one that is not valid
403 The credential's role lacks the permission

GET /api/peers/{id}/policy

Show the organization policy that applies to a device.

The policy groups of the device's organization (connection, features, security, network, update) with the device defaults filled in. A device without an organization gets the defaults. An account of another organization gets 403.

On the server API, port 21114. Needs device.view.

Parameter In Type Required What it is
id path string yes The device ID

200: Done (application/json)

Field Type Required What it is
device_id string yes
org_id string yes Empty for none
policies object yes The policy groups by name
Error When
400 The request is not valid
401 No credential, or one that is not valid
403 The credential's role lacks the permission

GET /api/peers/{id}/reach

Say why a session to a device can or cannot start.

A device the server does not know answers device_unknown, not 404. An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.view.

Parameter In Type Required What it is
id path string yes The device ID

200: Done (application/json)

Field Type Required What it is
reason string, one of online, device_offline, device_unknown, device_revoked, device_blocked, device_banned, device_removed, key_changed yes
last_online string or null (date-time) yes When it was last seen, RFC 3339; null when never or not known
Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission

POST /api/peers/{id}/restore

Bring back a deleted device.

Also lifts its ban and takes its ID off the blocklist. A device that is not deleted answers already_active. An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.delete.

Parameter In Type Required What it is
id path string yes The device ID

200: Done (application/json)

Field Type Required
status string, one of restored, already_active yes
id string yes
Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission
404 There is no such item

POST /api/peers/{id}/session-grant

Issue a short-lived grant for a session to a support agent.

The grant is signed with the server's key and names the signed-in account, so an API key gets 400. Only for passive support agents. An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs the sign-in token of a person; API keys are refused. Needs device.connect.

Parameter In Type Required What it is
id path string yes The device ID

Request body, application/json:

Field Type Required What it is
session_id string at most 128 characters
transport string, one of cdap, relay, interop yes
capabilities array of string, one of screen_view, input, system_audio, clipboard, files, terminal, chat, multi_monitor, privacy_mode, block_input, restart, recording yes
ttl_seconds integer How long the grant holds; default 300, at least 1, at most 600

200: Done (application/json)

Field Type Required What it is
grant string yes
expires_at string (date-time) yes
public_key string yes The server's public key, base64, to check the grant with
Error When
400 The request is not valid
401 No credential, or one that is not valid
403 The credential's role lacks the permission
404 There is no such item
409 The device is not a passive support agent
503 The server cannot sign grants

GET /api/peers/{id}/shell

Show who a device without a desktop runs its shell as, and where that comes from.

An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.view.

Parameter In Type Required What it is
id path string yes The device ID

200: Done (application/json)

Field Type Required What it is
headless boolean yes The device runs NeoDesk without a desktop (its signed heartbeat says so)
shell_user string yes The account the shell runs as; empty for none, and then the device has no shell
source string, one of console, device, none yes Where shell_user comes from
reported_user string yes The account the device was joined with
console_user string yes The account the console set; empty for none
root_allowed boolean yes The device was joined to take root from the console
Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission
404 There is no such device (device not found)

PUT /api/peers/{id}/shell

Set the account a device without a desktop runs its shell as.

An empty shell_user goes back to the account the device was joined with. The device gets the account with its next policy. Root (or SYSTEM on Windows) only on a device joined to take root. An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.edit and device.shell.

Parameter In Type Required What it is
id path string yes The device ID

Request body, application/json:

Field Type Required What it is
shell_user string yes A Linux account name, or a Windows one with its domain (DOMAIN\user, user@domain); no spaces or quotes. Empty for the account the device was joined with; at most 64 characters

200: Done (application/json)

The device's shell after the change, as GET answers it

Field Type
headless boolean
shell_user string
source string, one of console, device, none
reported_user string
console_user string
root_allowed boolean
Error When
400 shell_user is missing or not an account name (invalid_user)
401 No credential, or one that is not valid
403 The credential's role lacks the permission
404 There is no such device (device not found)
409 The device has a desktop (not_headless), or root for a device that was not joined to take it (root_not_allowed)

GET /api/peers/{id}/status

Show a device's live status.

A device registered now answers its live snapshot; one that is not answers what the database holds. An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.view.

Parameter In Type Required What it is
id path string yes The device ID

200: Done (application/json)

Object or object.

Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission
404 There is no such item

PUT /api/peers/{id}/tags

Replace a device's tags.

An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.edit.

Parameter In Type Required What it is
id path string yes The device ID

Request body, application/json:

Field Type What it is
tags string or array of string or null Comma-separated text or a list; null or left out clears the tags

200: Done (application/json)

Field Type Required What it is
status "updated" yes
id string
tags string The tags as stored, comma-separated
Error When
400 The request is not valid
401 No credential, or one that is not valid
403 The credential's role lacks the permission

GET /api/peers/{id}/telemetry

Show the latest telemetry snapshots a device sent.

One snapshot per kind the device sent: identity, metrics, hardware, services, processes, events, activity and files. An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.view.

Parameter In Type Required What it is
id path string yes The device ID

200: Done (application/json)

Field Type Required What it is
device_id string yes
schema 1 yes
snapshots object yes The snapshots by kind
Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission
404 There is no such item

POST /api/peers/{id}/telemetry/command

Queue an allowed command for a device's next heartbeat.

The device picks the command up with its next heartbeat; it expires after 10 minutes. A support agent takes only collect.metrics. files.browse and files.read need agent.files too. An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.connect.

Parameter In Type Required What it is
id path string yes The device ID

Request body, application/json:

Field Type Required What it is
command string, one of collect.hardware, collect.metrics, collect.services, collect.processes, collect.events, collect.activity, files.browse, files.read, service.control, process.terminate yes
args The command's arguments, at most 32 kB of JSON

202: Queued (application/json)

Field Type Required
accepted true yes
command_id integer yes
device_id string yes
Error When
400 The request is not valid
401 No credential, or one that is not valid
403 The credential's role lacks the permission
404 There is no such item

POST /api/peers/{id}/telemetry/refresh

Ask a device's agent for a fresh hardware inventory.

The device picks the command up with its next heartbeat; it expires after 10 minutes. A support agent takes only collect.metrics. An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.edit.

Parameter In Type Required What it is
id path string yes The device ID

202: Queued (application/json)

Field Type Required
accepted true yes
command_id integer yes
device_id string yes
Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission
404 There is no such item

POST /api/peers/{id}/unban

Lift the ban of a device.

Also clears a refused enrollment, so the device can ask again. A device that exists only because its enrollment was refused and banned is removed (peer_removed). An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.ban.

Parameter In Type Required What it is
id path string yes The device ID

200: Done (application/json)

Field Type Required What it is
status "unbanned" yes
id string
peer_removed "true" Only when the device was removed
Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission

POST /api/peers/{id}/unblock

Take a device's ID off the blocklist.

A revoke puts the ID there; afterwards the device can register again. An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.delete.

Parameter In Type Required What it is
id path string yes The device ID

200: Done (application/json)

Field Type Required
status "unblocked" yes
id string
Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission
404 The ID is not on the blocklist (not_blocked)

POST /api/peers/{id}/wol

Wake a device with a Wake-on-LAN packet.

The server sends the magic packet as a UDP broadcast on port 9 from its own network, so it reaches only devices on that network. An account limited to an organization or to device groups gets 403 for a device outside them.

On the server API, port 21114. Needs device.connect.

Parameter In Type Required What it is
id path string yes The device ID

Request body, application/json:

Field Type Required What it is
mac string yes The device's MAC address, like AA:BB:CC:DD:EE:FF

200: Done (application/json)

Field Type Required
success true yes
mac string yes
Error When
400 The request is not valid
401 No credential, or one that is not valid
403 The credential's role lacks the permission
404 There is no such item
500 The packet could not be sent

GET /api/tags/{tag}/peers

List the devices with a tag.

Only the devices the account may see.

On the server API, port 21114. Needs device.view.

Parameter In Type Required What it is
tag path string yes The tag

200: Done (application/json)

Field Type Required
tag string yes
count integer yes
peers array of ServerPeerRow yes
Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission

Type to search pages, sections, commands and settings.