Create Group from Mender API

Hello there,
I’m trying to develop an integration between our services and Mender.
I need to create and maintain groups of devices in mender.
In my service i have a list of customers that i want to use as Groups in mender.
So i started developing a little connector between my service and Mender.
Than i found out that mender has no CRUD for Groups!
Just a GET for the group list : https://docs.mender.io/2.2/apis/open-source/management-apis/device-inventory#groups-get

Someone knows how to manage groups from API?

Hello!

you can add device to a group with PUT (https://docs.mender.io/2.2/apis/open-source/management-apis/device-inventory#add-a-device-to-a-group), remove device from group with DELETE (https://docs.mender.io/2.2/apis/open-source/management-apis/device-inventory#devices-id-group-name-delete), get the group the device belongs to (https://docs.mender.io/2.2/apis/open-source/management-apis/device-inventory#get-a-selected-devices-group), get groups (https://docs.mender.io/2.2/apis/open-source/management-apis/device-inventory#groups-get), and list devices in given group (https://docs.mender.io/2.2/apis/open-source/management-apis/device-inventory#groups-name-devices-get).
once group has no devices it ceases to exist.

hope it help,
peter

Hello,

thanks I’m currently stuck with creating group. If I read API right I should use PATH method to create new group and add my device to it. I’m using:

curl -X PATCH -k -H "Authorization: Bearer $JWT" -H "Content-Type: application/json" -d "{"DeviceIDs": ["5f3ea06314e0ef000110776f"]}" $MENDER_SERVER_URI/api/management/v1/inventory/groups/releases/devices | jq '.'

but getting:

{
  "error": "Method not allowed"
}

I’m using mender server v2.1. Any ideas what is the flow to add device to new group? Thanks.

Hej Marek!

I think you should use PUT -d ‘{“group”:“releases”}’ /api/management/v1/inventory/devices/5f3ea06314e0ef000110776f/group
does that work?

thanks for using Mender!
peter

@peter Yes that works! Thanks.