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

Creating a Custom Rule

Function

This API is used to create a custom rule.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, no identity policy-based permission required for calling this API.

URI

POST /v5/{project_id}/custom/rule/config

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID, which is used to specify the project that an asset belongs to. After the project ID is configured, you can query assets in the project using the project ID. For details about how to obtain it, see Obtaining a Project ID.

Constraints

N/A

Range

The value can contain 1 to 256 characters.

Default Value

N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

User token, which contains user identity and permissions. The token can be used for identity authentication when an API is called. For details about how to obtain the token, see Obtaining a User Token.

Constraints

N/A

Range

The value can contain 1 to 32,768 characters.

Default Value

N/A

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

rule_name

Yes

String

Definition

Rule name

Constraints

N/A

Range

The value can contain 1 to 64 characters.

Default Value

N/A

is_all_host

No

Boolean

Definition

Whether to select all servers.

Constraints

N/A

Range

  • true: yes

  • false: no

Default Value

false

custom_rule_value_info

Yes

CustomRuleValueInfo object

agent_ids

No

Array of strings

Definition

Agent list

Constraints

N/A

Range

1 to 1000 agent IDs

Default Value

N/A

Table 4 CustomRuleValueInfo

Parameter

Mandatory

Type

Description

rule_type

Yes

String

Definition

Rule type.

Constraints

Mandatory.

Range

  • black_hash: blacklisted hash

Default Value

N/A

hash_type

Yes

String

Definition

Hash

Constraints

Mandatory.

Range

  • SHA-256: sha256sum

  • MD5: md5sum

  • SHA-1: sha1sum

Default Value

N/A

auto_block

Yes

Integer

Definition

Whether to automatically block alarms.

Constraints

Mandatory.

Range

  • 0: Alarms are not automatically blocked.

  • 1: Alarms are automatically blocked.

Default Value

N/A

rule_values

Yes

Array of strings

Definition

Rule set list

Constraints

Mandatory.

Range

1 to 1000 rule values

Default Value

N/A

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

rule_id

String

Definition

Rule ID.

Range

The value can contain 1 to 36 characters.

Example Requests

Create a custom rule.

POST https://{endpoint}/v5/{project_id}/custom/rule/config

{
  "rule_name" : "rule_name1",
  "custom_rule_value_info" : {
    "rule_values" : [ "08a7baa28dd268f8a12bc1f6fd95869321fe51144c5bf3321a6f6305edcd5245" ],
    "hash_type" : "sha256",
    "rule_type" : "black_hash",
    "auto_block" : 1
  },
  "agent_ids" : [ "af08124fd77581dcd2a5f7cdaa208c285af0a1480f7ca9b5258193c021ca2637" ]
}

Example Responses

Status code: 200

Request succeeded.

{
  "rule_id" : "47421976-688d-41be-b70a-6ed126231611"
}

Status Codes

Status Code

Description

200

Request succeeded.

Error Codes

See Error Codes.