Skip to main content

nRF Cloud MQTT topics

The MQTT API uses topics. Topics that begin with $aws are AWS reserved topics. All other topics are custom-defined by nRF Cloud.

In the following sections, ${mqttTopicPrefix} is the value of the mqttTopicPrefix JSON field in the response to the FetchAccountInfo endpoint.

Permissions to access these topics are managed by IoT security policies. See Device security for more information.

Topics used by devices running the nRF Cloud library

Devices running the nRF Cloud library, whether through Asset Tracker or a custom application, use the topics in this section.

Shadow topics

The nRF Cloud library supports the following MQTT topics for retrieving and managing the device state through the shadow. See also the AWS documentation regarding MQTT topics reserved for shadows.

TopicPublishSubscribePurpose
${device_id}/shadow/get/accepted-XReceive a trimmed shadow that contains only essential shadow data.
$aws/things/${deviceId}/shadow/get/rejected-XReceive info about a rejected shadow request.
$aws/things/${deviceId}/shadow/update/delta-XReceive info about changes in the shadow request.
$aws/things/${deviceId}/shadow/getX-Request the device's shadow.
$aws/things/${deviceId}/shadow/updateX-Update the device shadow.

After connecting and getting the shadow contents, the device looks for {"pairing":{"state":"paired"}}. If instead it finds {"state":"not_associated"}, the device waits for association. If found, the device derives and stores the c2d and d2c topics.

Message topics

Preface each of these topics with mqttTopicPrefix. nRF Cloud supports messages sent to any topic prefixed with ${mqttTopicPrefix}/m.

Schemas

The following table explains the message topic schemas used by nRF Cloud and devices.

SchemaDescription
c2dCloud-to-device
d2cDevice-to-cloud
c2gCloud-to-gateway
g2cGateway-to-cloud

The nRF Cloud portal, nRF Cloud library, and Asset Tracker application all use /d2c, /d2c/bulk and /c2d. If you want the nRF Cloud portal to work with and properly display these messages, send the data formatted according to /d2c schemas.

Topics

The following table shows supported message topics.

TopicPublishSubscribePurpose
m/d/${deviceId}/c2d/r-XReceive messages from nRF Cloud not related to Location Services.
Deprecated m/d/${deviceId}/c2d-XThis topic is deprecated. See /c2d/r. Receive messages from nRF Cloud.
m/d/${deviceId}/d2cX-Publish messages to nRF Cloud.
m/d/${deviceId}/d2c/bulkX-Publish a batch of messages to nRF Cloud as an array, which republishes each message in the array to the /d2c topic as if each message were published individually. Messages sent to /d2c/bulk are not stored. Useful for ultra-low power (ULP) scenarios. This is currently the only supported bulk processing topic.
gateways/${gatewayId}/c2g-XReceive messages from nRF Cloud. Applies to LTE gateways only.
gateways/${gatewayId}/g2cX-Publish messages to nRF Cloud. Applies to LTE gateways only.

Location Services topics

The following table shows topics related to Location Services.

TopicPublishSubscribePurpose
/m/d/${โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹deviceId}โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹/agps/r-XReceive A-GPS data from nRF Cloud.
/m/d/${โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹deviceId}โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹/pgps/r-XReceive P-GPS data from nRF Cloud.
/m/d/${โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹deviceId}โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹/wifi/r-XReceive Wi-Fi data from nRF Cloud.
/m/d/${โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹deviceId}โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹/cell_pos/r-XReceive cell data from nRF Cloud.
/m/d/${โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹deviceId}โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹/ground_fix/r-XReceive ground fix data from nRF Cloud.

FOTA topics

These topics relate to the firmware over-the-air (FOTA) update service, which sends an update job that the target device can execute to update its firmware.

Preface each of these topics with mqttTopicPrefix.

TopicPublishSubscribePurpose
${deviceId}/jobs/rcv-XReceive a FOTA job execution for an IP-based device.
${deviceId}/jobs/ble/rcv-XReceive a FOTA job execution for a Bluetoothยฎ Low Energy (LE) device. Applies to LTE gateways only.
${deviceId}/jobs/reqX-Request the current pending job execution for an IP-based device.
${deviceId}/jobs/updateX-Update the status of a job execution for an IP-based device.
${gatewayId}/jobs/ble/reqX-Request the current pending job execution for a Bluetooth LE device. Applies to LTE gateways only.
${gatewayId}/jobs/ble/updateX-Update the status of a job execution for a Bluetooth LE device. Applies to LTE gateways only.

Additional topics supported by nRF Cloud

The following topics are not directly supported by the nRF Cloud library.

Preface each of these topics with mqttTopicPrefix.

TopicPublishSubscribePurpose
m/#XXSend and receive device messages, and have them automatically stored in the cloud for later retrieval. The nRF Cloud library uses the m/# topic fragment on /d2c and /c2d. nRF Cloud processes and stores any device messages sent over topics that start with the m topic fragment, for example, m/sensor/temperature/room2.
a/connections-XReceive connection events from your devices, informing you when they connected and disconnected.