Skip to content

Cookie preferences

We use cookies for our own analytics, to see how our campaigns perform and, if you allow it, to load content from other services such as the Google site search. We never sell your data. Necessary cookies keep the site working and cannot be switched off. See our Cookie Policy for details and our Privacy Policy for how we handle personal data.

Security, load balancing and remembering your cookie choice.

Show us which pages people read, how they find the site and where they get stuck, so we can improve it (Google Analytics, Microsoft Clarity).

Show us which of our ad campaigns bring visitors to the site and remember the campaign or partner link you arrived from (Google Ads, LinkedIn, Meta, partner program). We do not use these cookies to build advertising profiles.

Load the site search from Google when you use it. Google sets its own cookies and shows ads in the search results.

© 2026 The ThingsBoard Authors
22.5k 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"}