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

ThingsBoard supports both server-initiated and device-initiated RPC over HTTP. For a full explanation of the RPC model, see Command & Control.

See Getting Connected for authentication and connection details.

The device polls for commands using a long-lived GET request. When a server-side RPC is triggered (from the Rule Engine, REST API, or a dashboard widget), ThingsBoard returns it as the response body.

GET http(s)://THINGSBOARD_HOST/api/v1/$ACCESS_TOKEN/rpc?timeout=20000
Terminal window
curl -s "http://$THINGSBOARD_HOST/api/v1/$ACCESS_TOKEN/rpc?timeout=20000"

The request blocks until a command arrives or the timeout (milliseconds) elapses. On receiving a command:

{
"id": 1,
"method": "setGpio",
"params": {"pin": 23, "value": 1}
}
Field Description
id Integer request identifier — use this in the reply
method RPC method name
params Method parameters (arbitrary JSON)
POST http(s)://THINGSBOARD_HOST/api/v1/$ACCESS_TOKEN/rpc/{id}
Terminal window
curl -s -X POST -H "Content-Type: application/json" -d '{"result":"ok"}' "http://$THINGSBOARD_HOST/api/v1/$ACCESS_TOKEN/rpc/1"

Replace 1 with the id value from the received command.

The device initiates an RPC call to the server with a POST request:

POST http(s)://THINGSBOARD_HOST/api/v1/$ACCESS_TOKEN/rpc
{"method": "getTime", "params": {}}
Terminal window
curl -s -X POST -H "Content-Type: application/json" -d '{"method":"getTime","params":{}}' "http://$THINGSBOARD_HOST/api/v1/$ACCESS_TOKEN/rpc"

The Rule Engine processes the request and the response body contains the result returned by the RPC reply node:

{"time": "2026-01-01T12:00:00Z"}