Create Group

Last Updated on : 2024-06-29 02:08:45download

Devices in the same space can be grouped together.

API address

POST: /v2.1/cloud/thing/group

Request parameter

Description of body

Parameter nameTypeINRequiredDescription
space_idStringbodytrueThe ID of the specified space.
group_nameStringbodytrueThe name of the specified group.
device_idsListbodytrueThe list of up to 20 device IDs.
product_idStringbodyfalseThe product ID (PID). If a PID is passed, the product image will be used as the group's icon.

Return parameter

Parameter nameTypeDescription
resultJsonObjectThe returned result of the specified group.
successBooleanIndicates whether the API is called successfully. Valid values:
  • true: The API call succeeded.
  • false: The API call failed.
tLongThe timestamp.
tidStringThe link ID.

Description of result

Parameter nameTypeDescription
group_idLongThe group ID.
group_nameStringThe name of the specified group.
space_idStringThe ID of the space to which the specified group belongs.
icon_urlStringThe icon of the specified group. A product picture is used by default.
create_timeLongThe time when a group is created.
update_timeLongThe time when a group is updated.
task_idStringThe task ID.
task_typeIntegerThe type of tasks. Valid values:
  • 1: Add. For example, create a group.
  • 2: Update. For example, add a device to a group or remove a device from a group.
  • 3: Delete. For example, delete a group.
task_expire_secondLongThe number of seconds after which the task will expire. Do not modify the relationship between the group and the devices until the task is completed.

Request example

POST: /v2.1/cloud/thing/group
{
  "space_id": "16702****",
  "group_name": "testGroup****",
  "device_ids": [
    "vdevo17059963113****",
    "vdevo17059963185****"
  ],
  "product_id": "oftxwukuvzoc****"
}

Return example

{
    "tid": "fafbfba7020e11efbe7a366d87620758",
    "result": {
        "icon_url": "https://images.tuyacn.com/smart/solution/142004/673976648441****.png",
        "create_time": 1713944884506,
        "group_name": "testGroup****",
        "task_id": "1783040196380512256",
        "update_time": 1713944884506,
        "group_id": "1393****",
        "task_expire_second": 14,
        "task_type": 1,
        "space_id": "16702****"
    },
    "t": 1713944885422,
    "success": true
}

Error code

For more information, see error code.

Limits on API Request Frequency

For more information, see Limits on API Request Frequency.