Assign Device to Device Group

This endpoints assigns one or more devices to a specific Device Group.

Request

To assign one or more Devices to a Device Group please make a POST request to the following URL:

HTTP MethodURL
POSThttps://industrial.api.ubidots.com/api/v2.0/device_groups/<device_group_key>/_/assign_devices/

Path Parameters

ParameterTypeDescription
<device_group_key>StringThe id or label of the Device Group, label should use the prefix ~

Query Parameters

ParameterTypeUseDescription
tokenStringAuthenticationAuthentication Token can optionally be sent as a query parameter.
clearBooleanAssigning ModusIf true all existing Devices will be replaced with the Devices sent in the request. If false Devices sent in the request will be appended.

Header

ParameterRequired?Description
X-Auth-HeaderYesAuthentication Token of account
$ curl -X POST 'https://industrial.api.ubidots.com/api/v2.0/device_groups/<device_group_key>/_/assign_devices/' \
 -H 'Content-Type: application/json' \
 -H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
 -d '[
  "5e1cc1e789f9bd33017e05f4",
  "~test",
  {"id": "5e1cc1e789f9bd33babababa"}
]'
{
    "count": 2,
    "next": null,
    "previous": null,
    "results":[
        {
            "url": "https://industrial.api.ubidots.com/api/v2.0/devices/5e1cc1e789f9bd33017e05f4",
            "id": "5e1cc1e789f9bd33017e05f4",
            "label": "truck-v2",
            "name": "Truck v2"
        },
        {
            "url": "https://industrial.api.ubidots.com/api/v2.0/devices/5e1c8d9789f9bd33017e05e5",
            "id": "5e1c8d9789f9bd33017e05e5",
            "label": "test",
            "name": "test"
        },
        {
            "url": "https://industrial.api.ubidots.com/api/v2.0/devices/5e1c8d9789f9bd33017e05e5",
            "id": "5e1cc1e789f9bd33babababa",
            "label": "test2",
            "name": "test2"
        }
    ]
}
{
    "code": 400001,
    "message": "Validation Error.",
    "detail": {
        ....
    }
}
{
    "code": 401001,
    "message": "Authentication credentials were not provided.",
    "detail": "Authentication credentials were not provided."
}

Response

Returns an Object with a results array containing the devices assigned to the device group.