Updated on 2026-01-05 GMT+08:00

Creating a Host Group

Function

Create a host group.

URI

POST /v3/{project_id}/lts/host-group

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain a project ID, see Obtaining the Project ID, Account ID, Log Group ID, and Log Stream ID.

Minimum: 1

Maximum: 64

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token obtained from IAM. For details about how to obtain a user token, see Obtaining a User Token.

Minimum: 1

Maximum: 10000

Content-Type

Yes

String

Set this parameter to application/json;charset=UTF-8.

Minimum: 30

Maximum: 30

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

host_group_name

Yes

String

Host group name, which must be unique. Use only letters, digits, hyphens (-), underscores (_), and periods (.). Do not start with a period or underscore or end with a period.

Minimum: 1

Maximum: 64

host_group_type

Yes

String

Host group type.

  • windows

  • linux

host_id_list

No

Array of strings

Host group ID list. The host type must be the same as the host group type.

This field can be set only when the host group access type is IP address.

Minimum: 36

Maximum: 36

host_group_tag

No

Array of HostGroupTag objects

Tag information. You can add up to 20 tags.

agent_access_type

No

String

Host access type.

  • LABEL

  • IP

labels

No

Array of strings

Host group custom identifiers. If the host access type is LABEL, this field saves the host group identifiers.

  • Only letters, digits, hyphens (-), underscores (_), and periods (.) are allowed.

  • Each identifier contains a maximum of 128 characters.

Table 4 HostGroupTag

Parameter

Mandatory

Type

Description

key

Yes

String

Tag key, which must be unique.

  • A tag key can contain letters, digits, spaces, and special characters (_.:=+-@), but cannot start or end with a space or start with sys.

  • A tag key can contain up to 128 characters.

value

No

String

Tag value.

  • A tag value can contain letters, digits, spaces, and special characters (_.:=+-@).

  • A tag value can contain up to 255 characters.

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

host_group_id

String

Host group ID.

host_group_name

String

Host group name.

host_group_type

String

Host group type.

  • linux

  • windows

host_id_list

Array of strings

Host ID list.

host_group_tag

Array of HostGroupTagResBody objects

Tag information.

create_time

Long

Creation time.

update_time

Long

Update time.

labels

Array of strings

Host group identifier.

agent_access_type

String

Host access type.

Table 6 HostGroupTagResBody

Parameter

Type

Description

key

String

Tag key.

value

String

Tag value.

tags_to_streams_enable

Boolean

Whether to apply the tag to the log stream. Only a tag of a log group can be directly applied to its log stream.

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Error code

error_msg

String

Error description

Status code: 500

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Error code

error_msg

String

Error description

Example Requests

Create a host group. Parameters host_group_name and host_group_type are mandatory.

POST https://{endpoint}/v3/{project_id}/lts/host-group

{
  "agent_access_type" : "IP",
  "create_time" : 1749782743454,
  "host_group_id" : "204f02a9-5956-4d05-b80f-7657e6bbf8e0",
  "host_group_name" : "test-api6",
  "host_group_tag" : [ {
    "key" : "1",
    "tags_to_streams_enable" : true,
    "value" : "1"
  } ],
  "host_group_type" : "linux",
  "host_id_list" : [ "2b0d2d32-3db6-470b-8559-df24e1f659a1", "8a2a1b3e-8739-4d77-aecc-6b54e32209c1" ],
  "labels" : [ ],
  "update_time" : 1749782743454
}

Example Responses

Status code: 200

The host group is created.

{
  "host_group_id" : "598c77aa-c69b-42f0-8cb8-983178ad5b38",
  "host_group_name" : "APIxx3",
  "host_group_type" : "linux",
  "host_id_list" : [ "dc1dab7e-b045-4e77-bda4-914d083d1bf7" ],
  "host_group_tag" : [ {
    "key" : "xxx",
    "value" : "xxx",
    "tags_to_streams_enable" : true
  } ],
  "create_time" : 1635149410332,
  "update_time" : 1635149410332
}

Status code: 400

Invalid request. Modify the request based on the description in error_msg before a retry.

{
  "error_code" : "LTS.1812",
  "error_msg" : "Invalid host group id"
}

Status code: 500

The server has received the request but encountered an internal error.

{
  "error_code" : "LTS.0010",
  "error_msg" : "Internal Server Error"
}

Status Codes

Status Code

Description

200

The host group is created.

400

Invalid request. Modify the request based on the description in error_msg before a retry.

500

The server has received the request but encountered an internal error.

Error Codes

See Error Codes.