Skip to content
Stand with Ukraine flag

Attributes

Upload client-side attributes for one or more devices.

Topic: v1/gateway/attributes

{
"Device A": {"fw_version": "1.0", "battery": 87},
"Device B": {"fw_version": "2.1", "battery": 92}
}
Terminal window
mosquitto_pub -h "mqtt.thingsboard.cloud" -t "v1/gateway/attributes" -u "$ACCESS_TOKEN" -m '{"Device A":{"fw_version":"1.0","battery":87}}'

Subscribe to the response topic first, then publish the request.

Subscribe: v1/gateway/attributes/response

Publish: v1/gateway/attributes/request

{
"id": 1,
"device": "Device A",
"client": ["fw_version", "battery"],
"shared": ["targetFwVersion"]
}
FieldRequiredDescription
idYesInteger request identifier — echoed in the response
deviceYesDevice name
clientNoClient-side attribute keys to return
sharedNoShared attribute keys to return
Terminal window
mosquitto_sub -h "mqtt.thingsboard.cloud" -t "v1/gateway/attributes/response" -u "$ACCESS_TOKEN" &
mosquitto_pub -h "mqtt.thingsboard.cloud" -t "v1/gateway/attributes/request" -u "$ACCESS_TOKEN" -m '{"id":1,"device":"Device A","client":["fw_version"],"shared":["targetFwVersion"]}'

Subscribe to receive push notifications when shared attributes change for any downstream device.

Topic: v1/gateway/attributes (subscribe)

Terminal window
mosquitto_sub -h "mqtt.thingsboard.cloud" -t "v1/gateway/attributes" -u "$ACCESS_TOKEN"

ThingsBoard delivers updates in this format:

{
"device": "Device A",
"data": {"targetFwVersion": "2.0", "enabled": true}
}