Working with device groups with the nRF Cloud APIs
This page explains device group operations in the nRF Cloud REST API.
Device groups are called tags in some endpoints in the nRF Cloud APIs.
You cannot use the REST API to manage user access to device groups. Use the nRF Cloud portal for this.
Viewing device groups
Use the ListDeviceTags
endpoint to show all tags associated with an account. If you are not an owner or admin, you will see only the groups you have access to.
Use the FetchDevice
endpoint to view a single device's information, including which groups it is in.
Adding device groups at provisioning
You can add groups to a device at provisioning. If you want to add a device to multiple groups, separate them using a pipe |
character in the CSV file or message body text.
See the documentation for the ProvisionDevices
endpoint for more information on formatting.
Managing groups for a device
Use the UpdateDeviceTags
endpoint to edit the groups associated with a device.
The content of the message body for this endpoint replaces existing groups the device is added to. For example, if you have a device in group test1
and want to add it to test2
as well, make sure you include both groups in the message body. Any existing group associations will be removed if you do not include them.
Include the device ID as a path parameter. Specify group names in the message body, enclosed in double quotation marks ("
). Separate multiple groups with a comma, with one line for each group:
[
"test1",
"test2"
]
The server responds with a 202
code if successful.
Use the ListDevices
or FetchDevice
endpoints to verify that the device's groups have been updated.
The following example shows the portion of the response that includes the device's groups:
"id": "nrf-0123456789012345",
"tags": [
"test1",
"test2"
],
You can also check the device's page in the nRF Cloud portal.