Authenticating devices with MQTT

Events sent to the MQTT service must include the sender's unique Device ID and Access Key in the userProperties object of the message payload. (As received from the Register Device API)

Events should be sent with a QoS (quality of service) value of 1, which guarantees all messages will be received in case of network issues.

Event data structure

A typical MQTT message has the following parameters:

{
 "topic": "/v1/device/DEVICE_ID",
   "properties": {
     "userProperties": {
      "device_id": "DEVICE_ID",
      "access_key": "ACCESS_KEY"
     }
   },
   "payload": "JSON STRING" 
}

Verify that the client library used for MQTT supports passing event metadata such as user properties.

Notes

In some events the field correlationData might be appended, holding the ID of the resource you are responding to.