Skip to content
Stand with Ukraine flag

RPC

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

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

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

Incoming command format:

{
"device": "Device A",
"data": {"id": 1, "method": "toggle_gpio", "params": {"pin": 1}}
}
FieldDescription
deviceThe target device name
data.idRequest identifier — must be echoed in the reply
data.methodRPC method name
data.paramsMethod 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 "$ACCESS_TOKEN" -m '{"device":"Device A","id":1,"data":{"success":true}}'