Skip to content
© 2026 The ThingsBoard Authors
Try for free

ThingsBoard Cloud

Choose your data region

Your data stays in the region you choose, for residency and compliance. No credit card required.

Rather run it yourself? Install on your own servers

RPC

Subscribe to the RPC topic to receive commands targeted at downstream devices.

Topic: v1/gateway/rpc (subscribe + publish)

Replace GATEWAY_DEVICE_ACCESS_TOKEN in the commands below with the gateway device’s access token.

Terminal window
mosquitto_sub -h "mqtt.thingsboard.cloud" -t "v1/gateway/rpc" -u "GATEWAY_DEVICE_ACCESS_TOKEN"

Incoming command format:

{
"device": "Device A",
"data": {"id": 1, "method": "toggle_gpio", "params": {"pin": 1}}
}
Field Description
device The target device name
data.id Request identifier — must be echoed in the reply
data.method RPC method name
data.params Method parameters (arbitrary JSON)

Send the reply to the same topic:

{"device": "Device A", "id": 1, "data": {"success": true}}
Terminal window
mosquitto_pub -h "mqtt.thingsboard.cloud" -t "v1/gateway/rpc" -u "GATEWAY_DEVICE_ACCESS_TOKEN" -m '{"device":"Device A","id":1,"data":{"success":true}}'