Skip to content
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 Commands

ThingsBoard executes LwM2M operations on devices via RPC commands. Send them from the REST API, a dashboard widget, or the RPC Debug Terminal. For a full explanation of the RPC model, see Command & Control.

Every LwM2M RPC command has two fields:

{
"method": "Read",
"params": {"id": "/3/0/9"}
}
Field Description
method LwM2M operation name (see table below)
params Target resource and additional options

Use either the resource path or a key defined in the device profile:

Format Example
Resource path {"id": "/3/0/9"}
Path with object version {"id": "/3_1.2/0/9"}
Key {"key": "batteryLevel"}

In the RPC Debug Terminal omit the JSON wrapper — write Read {"id":"/3/0/9"} directly.

Method Interface Description
Read Device Management Read a resource, instance, or all object instances
Discover Device Management List available resources on an object or instance
WriteUpdate Device Management Partial update — change specified resources, leave others
WriteReplace Device Management Replace resource value(s) entirely
WriteAttributes Device Management Set NOTIFICATION-class attributes (pmin, pmax, gt, lt, st)
ReadComposite Device Management Read multiple resources across different objects at once
WriteComposite Device Management Write multiple resources across different objects atomically
Execute Device Management Trigger an action (e.g., reboot, firmware install)
Delete Device Management Delete an Object Instance
Observe Information Reporting Start observing a resource for changes
ObserveCancel Information Reporting Cancel a single observation
ObserveCancelAll Information Reporting Cancel all observations on the device (ThingsBoard-specific)
ObserveReadAll Information Reporting List all active observations (ThingsBoard-specific)
ObserveComposite Information Reporting Observe multiple resources in a single request
ObserveCompositeCancel Information Reporting Cancel a composite observation
DiscoverAll ThingsBoard-specific Return the full object/resource hierarchy of the client

Read the current value of a resource, instance, or all object instances.

{"method": "Read", "params": {"id": "/3/0/9"}}
# Terminal request:
Read {"id":"/3/0/9"}
# Response:
{"result":"CONTENT","value":"LwM2mSingleResource [id=9, value=100, type=INTEGER]"}

Read by key:

Read {"key":"batteryLevel"}

Read an entire object instance:

Read {"id":"/3/0"}

List the resources instantiated on an object or instance, returned as CoRE Link format.

{"method": "Discover", "params": {"id": "/3"}}
# Terminal:
Discover {"id":"/3"}
# Response:
{"result":"CONTENT","value":"</3>,</3/0/0>,</3/0/1>,</3/0/2>,..."}

Partially update resource values — unspecified resources are not changed.

{"method": "WriteUpdate", "params": {"id": "/3/0", "value": {"14": "+5", "15": "Europe/Kyiv"}}}
WriteUpdate {"id":"/3/0","value":{"14":"+5","15":"Europe/Kyiv"}}
# Response: {"result":"CHANGED"}

Replace a resource value entirely.

{"method": "WriteReplace", "params": {"id": "/19/0/0", "value": "0081"}}
WriteReplace {"id": "/19/0/0", "value": "0081"}
# Response: {"result":"CHANGED"}

Set NOTIFICATION-class attributes on a resource (pmin, pmax, gt, lt, st). See Data Model for attribute descriptions.

{"method": "WriteAttributes", "params": {"id": "/19/0/0", "attributes": {"pmax": 120, "pmin": 10}}}
WriteAttributes {"id":"/19/0/0","attributes":{"pmax":120,"pmin":10}}
# Response: {"result":"CHANGED"}

Read any combination of resources, instances, or objects in a single request. Non-atomic — resources without a valid value are omitted from the response.

{"method": "ReadComposite", "params": {"ids": ["/3/0/9", "/1_1.2"]}}
ReadComposite {"ids":["/3/0/9","/1_1.2"]}
# Response: {"result":"CONTENT","value":"{/3/0/9=LwM2mSingleResource [id=9, value=75, type=INTEGER], ...}"}

Read by keys:

ReadComposite {"keys":["batteryLevel","updateResult","pkgversion"]}

Write multiple resources across different objects atomically. All resources must be writable — the operation fails if any single write would fail.

{"method": "WriteComposite", "params": {"nodes": {"/19_1.1/0": {"0": {"0": "00ad45675600"}}, "/3_1.0/0/15": "Europe/Kyiv"}}}
WriteComposite {"nodes":{"/19_1.1/0":{"0":{"0":"00ad45675600"}},"/3_1.0/0/15":"Europe/Kyiv"}}
# Response: {"result":"CHANGED"}

Trigger an action on the device. Can only target individual executable resources.

{"method": "Execute", "params": {"id": "/3/0/4"}}
Execute {"id":"/3/0/4"}
# Response: {"result":"CHANGED"}

Common execute targets:

Path Action
/3/0/4 Reboot device
/5/0/2 Trigger firmware update install
/1/0/8 Registration Update Trigger
/1/0/9 Bootstrap-Request Trigger

Execute a resource with arguments: execute Reboot on the device, passing a single-digit argument 5.

{"method": "Execute", "params": {"id": "/3/0/4", "value": 5}}
Execute {"id":"/3/0/4","value":5}
# Response: {"result":"CHANGED"}

Execute a resource with arguments: execute Factory Reset on the device with argument 2 set to 60.

{"method": "Execute", "params": {"id": "/3/0/5", "value": "2='60'"}}
Execute {"id":"/3/0/5","value":"2='60'"}
# Response: {"result":"CHANGED"}

Execute a resource with multiple parameters: execute Factory Reset on the device with two arguments:

  • Digit 2 without a value.
  • Digit 0 with a link value.
{"method": "Execute", "params": {"id": "/3/0/5", "value": "2,0='https://thingsboard.io/docs/reference/lwm2m-api/'"}}
Execute {"id":"/3/0/5","value":"2,0='https://thingsboard.io/docs/reference/lwm2m-api/'"}
# Response: {"result":"CHANGED"}

Execute a resource with multiple parameters: execute Factory Reset with multiple arguments without values.

  • According to the OMA LwM2M execute arguments format, this represents ten arguments from 0 to 9, none of which have values.
{"method": "Execute", "params": {"id": "/3/0/5", "value": "0,1,2,3,4,5,6,7,8,9"}}
Execute {"id":"/3/0/5","value":"0,1,2,3,4,5,6,7,8,9"}
# Response: {"result":"CHANGED"}

Delete an Object Instance. The mandatory Device Object (ID 3) cannot be deleted.

{"method": "Delete", "params": {"id": "/19/1"}}
Delete {"id":"/19/1"}
# Response: {"result":"DELETE"}

Subscribe to changes on a resource, instance, or object. ThingsBoard receives a notification each time the value changes.

{"method": "Observe", "params": {"id": "/3/0/9"}}
Observe {"id":"/3/0/9"}
# Response: {"result":"CONTENT","value":"LwM2mSingleResource [id=9, value=28, type=INTEGER]"}

End a specific observation relationship.

{"method": "ObserveCancel", "params": {"id": "/5/0/7"}}
ObserveCancel {"id":"/5/0/7"}
# Response: {"result":"CONTENT","value":"1"}

Observe multiple resources across different objects in a single request.

{"method": "ObserveComposite", "params": {"ids": ["/5/0/7", "/5/0/5", "/3/0/9"]}}
ObserveComposite {"ids":["/5/0/7","/5/0/5","/3/0/9"]}
# Response: {"result":"CONTENT","value":"{/5/0/7=..., /5/0/5=..., /3/0/9=...}"}

Cancel a previously established composite observation.

{"method": "ObserveCompositeCancel", "params": {"ids": ["/5/0/7", "/5/0/5", "/3/0/9"]}}
ObserveCompositeCancel {"ids":["/5/0/7","/5/0/5","/3/0/9"]}
# Response: {"result":"CONTENT","value":"1"}

ThingsBoard-specific. Cancel all observations on the device at once. Use before switching observe strategies.

{"method": "ObserveCancelAll", "params": {}}
ObserveCancelAll
# Response: {"result":"CONTENT","value":"8"} // 8 observations cancelled

ThingsBoard-specific. Return a list of all currently active observations on the device.

{"method": "ObserveReadAll", "params": {}}
ObserveReadAll
# Response: {"result":"CONTENT","value":"[\"/5/0/7\",\"/3/0/3\",\"/5/0/3\",\"/5/0/5\"]"}

ThingsBoard-specific. Return the full object and resource hierarchy of the connected client, built from the registration message. Does not send any request to the device — useful for troubleshooting and verifying object versions.

{"method": "DiscoverAll", "params": {}}
DiscoverAll
# Response: {"result":"CONTENT","value":"[{\"url\":\"/\",\"attributes\":{\"ct\":\"110\",\"rt\":\"\\\"oma.lwm2m\\\"\"}},{\"url\":\"/1\",\"attributes\":{\"ver\":\"1.1\"}},...]"}