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

Attributes

The MQTT Attributes API covers three operations: publishing client-side attributes to ThingsBoard, requesting current attribute values from the server, and subscribing to server-pushed attribute updates. See Attributes for the difference between client-side, server-side, and shared attributes, and Getting Connected for connection parameters and credential types.

Report device state (serial number, firmware version, hardware config) to ThingsBoard.

Format Topic
Short v2/a
Standard v1/devices/me/attributes
{"firmwareVersion": "2.1.0", "serialNumber": "SN-4A21F", "hardwareRevision": "B"}
Terminal window
mosquitto_pub -d -q 1 -h "$THINGSBOARD_HOST" -p 1883 -t "v2/a" -u "$ACCESS_TOKEN" -m '{"firmwareVersion": "2.1.0", "serialNumber": "SN-4A21F"}'

Ask ThingsBoard for the current values of client-side or shared attributes. Useful on device boot to read back configuration stored in ThingsBoard.

Format Subscribe to responses Publish request to
Short v2/a/res/+ v2/a/req/$request_id
Standard v1/devices/me/attributes/response/+ v1/devices/me/attributes/request/$request_id

$request_id is any integer you choose; ThingsBoard echoes it in the response topic so you can match replies to requests.

Request and response payloads:

Request — specify which keys you want:

{"clientKeys": "firmwareVersion,serialNumber", "sharedKeys": "targetTemperature,enabled"}

Response:

{
"client": {"firmwareVersion": "2.1.0", "serialNumber": "SN-4A21F"},
"shared": {"targetTemperature": 24, "enabled": true}
}

Receive pushed notifications whenever a shared attribute is changed from the ThingsBoard side (e.g. an operator changes a setpoint in the dashboard).

Format Subscribe to
Short v2/a
Standard v1/devices/me/attributes

ThingsBoard publishes only the changed keys, request:

Terminal window
mosquitto_sub -d -q 1 -h "$THINGSBOARD_HOST" -p 1883 -t "v2/a" -u "$ACCESS_TOKEN"

Response:

{"targetTemperature": 26}