Skip to content
Stand with Ukraine flag

Command & Control

ThingsBoard RPC (Remote Procedure Call) enables bidirectional command exchange between the platform and devices. Commands can flow in either direction: the platform sends instructions to a device (server-side RPC), or a device asks the platform for data (client-side RPC).

The platform sends a command to a device — turn a relay on, change a setpoint, trigger a reboot. Commands can be sent from a dashboard widget, the Rule Engine, or directly via REST API.

One-WayTwo-Way
Device replyNot expectedRequired within timeout
Use caseFire-and-forget commands (turn on LED)Commands that need confirmation or a result
REST response200 OK when ThingsBoard sent the command to the device — no visibility into whether the device processed it or succeededDevice’s reply payload

Lightweight RPC is short-lived and memory-resident. If the device is offline when the command is sent, the command is lost. Good for real-time control of always-connected devices.

Persistent RPC is stored in the database with a configurable TTL. If the device is offline, the command waits until the device reconnects. Good for devices with intermittent connectivity or power-saving modes.

FieldRequiredDescription
methodYesCommand name, e.g. setTemperature
paramsYesJSON parameters. Use {} if none.
timeoutNoMilliseconds to wait for delivery (default: 10 000, min: 5 000)
expirationTimeNoEpoch ms timestamp — overrides timeout
persistentNotrue to store in DB and survive device offline (default: false)
retriesNoRetry attempts for persistent RPC on timeout
additionalInfoNoMetadata attached to persistent RPC Rule Engine events

Persistent commands move through a state machine. Each transition fires a Rule Engine event you can use to track commands in external systems.

StateMeaning
QUEUEDSaved; awaiting delivery
SENTPlatform sent to device
DELIVEREDDevice acknowledged (terminal for one-way)
SUCCESSFULDevice replied (terminal for two-way)
TIMEOUTDelivery timed out; retrying if retries remain
EXPIREDTTL elapsed before delivery
FAILEDAll retries exhausted

A device initiates a request to the platform — for example to fetch the current time, get a weather forecast, or query an access control decision. The platform processes it through the Rule Engine and replies.

Each request carries a method string and a params JSON object. The Rule Engine message includes a requestId UUID in metadata, which the RPC Call Reply node uses to route the response back to the correct device.

Control widgets (RPC Button, Round Switch, Knob Control, etc.) send server-side RPC commands using the same REST API under the hood. You configure the method name and parameters directly in the widget settings — no code required.

See the transport-specific guides for exact topics, subscribe paths, and request/response examples: