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

Adding a Scan Rule

Function

This API is used to add a scan rule based on the specified project ID. The rule includes the rule name, description, type, and matching logic.

Calling Method

For details, see Calling APIs.

URI

POST /v1/{project_id}/scan-rules

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID, which is used to identify a specific project.

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

category

No

String

Rule category, which is used to identify BUILT_IN (built-in rules) and BUILT_SELF (user-defined rules).

content

No

Array of ScanRuleContentInfo objects

Rule content list, including the rule content.

logic_operator

No

String

Logical operator, which can be AND, OR, or REGEX (regular expression).

match_rate

No

Integer

Match rate, indicating the accuracy or priority of rule matching.

min_match

No

Integer

Minimum matching times, that is, the minimum condition that must be met when a rule is matched.

rule_desc

No

String

Rule description, which briefly describes the rule function.

rule_name

No

String

Rule name, which is used to identify and manage rules.

rule_type

No

String

Rule type, which can be KEYWORD (keyword), REGEX (regular expression), or NLP (natural language).

templates

No

Array of CreateTemplateRuleInfo objects

Template association information, including the association details between the rule and the template.

Table 3 ScanRuleContentInfo

Parameter

Mandatory

Type

Description

effective_mode

No

String

Rule effective mode, indicating the application mode of the rule.

location

No

String

Rule application position, indicating the specific application position of the rule in the data.

rule_content

No

String

Detailed rule content.

Table 4 CreateTemplateRuleInfo

Parameter

Mandatory

Type

Description

classification_id

No

String

Classification and grading ID, which indicates the classification to which a rule belongs.

is_used

No

Boolean

Whether the rule is enabled.

rule_id

No

String

Rule ID, which uniquely identifies a rule.

security_level_id

No

String

Risk level ID, which indicates the risk level of a rule.

template_id

No

String

Template ID, which is used to identify a specific scan template.

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

msg

String

Returned message, which is used to describe the operation result or status information.

status

String

Returned status, which indicates whether the operation is successful. For example, 200 indicates that the operation is successful, and 400 indicates that the request is invalid.

Status code: 201

Rule added.

Example Requests

POST /v1/{project_id}/scan-rules

{
  "category" : "string",
  "content" : [ { } ],
  "logic_operator" : "string",
  "match_rate" : 0,
  "min_match" : 0,
  "rule_desc" : "string",
  "rule_name" : "string",
  "rule_type" : "string",
  "templates" : [ { } ]
}

Example Responses

None

Status Codes

Status Code

Description

200

If the request is successful, the result of adding a rule is returned.

201

Rule added.

401

Unauthorized. The user is not logged in or the token is invalid.

403

Unauthorized to access the resource.

404

The specified project is not found.

Error Codes

See Error Codes.