Skip to content
Stand with Ukraine flag

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 https://eu.thingsboard.cloud/api/v1/$ACCESS_TOKEN/rpc?timeout=20000
Terminal window
curl -s "http://eu.thingsboard.cloud/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}
}
FieldDescription
idInteger request identifier — use this in the reply
methodRPC method name
paramsMethod parameters (arbitrary JSON)
POST https://eu.thingsboard.cloud/api/v1/$ACCESS_TOKEN/rpc/{id}
Terminal window
curl -s -X POST -H "Content-Type: application/json" -d '{"result":"ok"}' "http://eu.thingsboard.cloud/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 https://eu.thingsboard.cloud/api/v1/$ACCESS_TOKEN/rpc
{"method": "getTime", "params": {}}
Terminal window
curl -s -X POST -H "Content-Type: application/json" -d '{"method":"getTime","params":{}}' "http://eu.thingsboard.cloud/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"}