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

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-Way Two-Way
Device reply Not expected Required within timeout
Use case Fire-and-forget commands (turn on LED) Commands that need confirmation or a result
REST response 200 OK when ThingsBoard sent the command to the device — no visibility into whether the device processed it or succeeded Device’s reply payload
REST response on failure 504 — command was not sent to the device (usually no active session) 504 — command was not sent (usually no active session), or no reply arrived within the timeout

Lightweight RPC is short-lived and memory-resident. If the device is offline when the command is sent, the command is lost unless the device connects before the timeout. 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.

Field Required Description
method Yes Command name, e.g. setTemperature
params Yes JSON parameters. Use {} if none.
timeout No Milliseconds to wait for delivery, or for the reply in a two-way RPC (default: 10 000, min: 5 000)
expirationTime No Epoch ms timestamp — overrides timeout
persistent No true to store in DB and survive device offline (default: false)
retries No How many times to resend a persistent RPC whose delivery wasn’t acknowledged (MQTT QoS 1, CoAP confirmable, LwM2M). If omitted, the server limit applies (5 by default); larger values are capped to it.
additionalInfo No Metadata 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.

State Meaning
QUEUED Saved; awaiting delivery
SENT Platform sent to device
DELIVERED Device acknowledged (terminal for one-way)
SUCCESSFUL Device replied (terminal for two-way)
TIMEOUT Delivery wasn’t acknowledged in time; resent if retries remain (see Delivery Retries)
EXPIRED TTL elapsed before delivery, or before the reply for a two-way RPC
FAILED Delivery retries ran out, the device or transport returned an error, or, with a sequential strategy that waits for a reply, no reply arrived in time

ThingsBoard resends a command only when the device doesn’t acknowledge its delivery in time. It can detect this over MQTT with QoS 1, CoAP confirmable messages, and LwM2M. Over HTTP, SNMP, MQTT with QoS 0, and CoAP non-confirmable messages, a command counts as delivered once it’s sent.

A CoAP device must acknowledge a command within its PSM Activity Timer (PSM mode) or Paging Transmission Window (other modes), set on the device or its device profile.

Resends happen only before the command expires, so set timeout or expirationTime well beyond the device’s acknowledgment wait.

A command in the TIMEOUT state isn’t resent right away: it’s resent when the device reconnects or subscribes to RPC again, or when a CoAP or LwM2M device wakes up.

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.

Widgets that change a device state through RPC, like the Command Button, Toggle Button, Power Button, Single Switch, Slider, Value Stepper, Knob Control, and Round Switch, send a one-way RPC. SCADA symbol actions set to Execute RPC do the same. These widgets don’t wait for a reply, and a reply from the device isn’t processed. To get the device’s reply, send a two-way RPC with one of these:

  • RPC Button widget with Is one way command cleared.
  • RPC Call Request rule node, which sends a two-way RPC unless the message metadata sets oneway to true.
  • REST API: POST /api/rpc/twoway/{deviceId}.

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