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.
Server-Side RPC
Section titled “Server-Side RPC”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.
Subscribe to Commands
Section titled “Subscribe to Commands”GET https://eu.thingsboard.cloud/api/v1/$ACCESS_TOKEN/rpc?timeout=20000curl -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}}| Field | Description |
|---|---|
id | Integer request identifier — use this in the reply |
method | RPC method name |
params | Method parameters (arbitrary JSON) |
Send a Reply
Section titled “Send a Reply”POST https://eu.thingsboard.cloud/api/v1/$ACCESS_TOKEN/rpc/{id}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.
Client-Side RPC
Section titled “Client-Side RPC”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": {}}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"}