Updated on 2026-04-03 GMT+08:00

Creating a Task

Function

This API is used to create a task.

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}/common/task

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

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

enterprise_project_id

No

String

Definition

Enterprise project ID, which is used to filter assets in different enterprise projects. For details, see Obtaining an Enterprise Project ID.

To query assets in all enterprise projects, set this parameter to all_granted_eps.

Constraints

You need to set this parameter only after the enterprise project function is enabled.

Range

The value can contain 1 to 256 characters.

Default Value

0: default enterprise project.

Request Parameters

Table 3 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 4 Request body parameters

Parameter

Mandatory

Type

Description

task_type

Yes

String

Task type. The options are as follows:

  • cluster_scan: cluster scanning

  • iac_scan: IAC scanning

cluster_scan_info

No

cluster_scan_info object

Parameter for creating a cluster scan task. This parameter is mandatory when the task type is cluster_scan.

iac_scan_info

No

iac_scan_info object

Parameters for creating an IAC security scanning task. This parameter is mandatory when TaskType is set to iac_scan.

Table 5 cluster_scan_info

Parameter

Mandatory

Type

Description

scan_type_list

Yes

Array of strings

Definition

Scan item type list.

Constraints

N/A

Range

  • cluster_vul: cluster vulnerability

  • risk_assessment: risk assessment

  • benchmark: security and compliance

Default Value

N/A

range_type

Yes

String

Scanning scope type. The options are as follows:

  • all_cluster: Scan all clusters that meet the scanning conditions.

  • specific_cluster: scans a specified cluster.

cluster_id_list

No

Array of strings

ID list of clusters to be scanned. This parameter is mandatory if the scan scope type is specific_cluster.

Table 6 iac_scan_info

Parameter

Mandatory

Type

Description

file_type

Yes

String

File type. The options are as follows:

  • dockerfile: Dockerfile file

  • k8s_yaml: Kubernetes YAML file

file_id_list

Yes

Array of strings

List of IDs of files to be scanned. You can obtain the IDs of files that are successfully uploaded from the response data of the file upload API /v5/{project_id}/common/files/batch-upload.

Response Parameters

Status code: 200

Table 7 Response body parameters

Parameter

Type

Description

task_id

String

ID of the created task.

Example Requests

Create a cluster scan task to scan for vulnerabilities in all the clusters whose project_id is 2b31ed520xxxxxxebedb6e57xxxxxxxx.

POST https://{endpoint}/v5/2b31ed520xxxxxxebedb6e57xxxxxxxx/common/task?enterprise_project_id=all_granted_eps

{
  "task_type" : "cluster_scan",
  "cluster_scan_info" : {
    "scan_type_list" : [ "cluster_vul" ],
    "range_type" : "all_cluster"
  }
}

Example Responses

Status code: 200

Request succeeded.

{
  "task_id" : "d8xxxx05-8xx5-4xx0-9xx6-c3dbxxxxxxac"
}

Status Codes

Status Code

Description

200

Request succeeded.

Error Codes

See Error Codes.