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

Creating a Check Task

Function

This API is used to create a code check task in a project. You can set the project ID, code repository address, branch, and rule set.

Calling Method

For details, see Calling APIs.

Authorization Information

Each account root user has all the permissions required to call all APIs, but IAM users must be assigned the following required identity policy-based permissions. For details about the required permissions, see Permissions Policies and Supported Actions.

Action

Access Level

Resource Type (*: required)

Condition Key

Alias

Dependencies

codeartscheck:task:create

Write

task *

-

-

-

-

codeartscheck:ProjectId

URI

POST /v2/{project_id}/task

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition :

32-character project UUID. Obtain it by calling the API used to query the project list.

Constraints:

N/A

Value range:

1 to 32 characters.

Default value:

N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition :

User token. Obtain one by calling the IAM API Obtaining a User Token. The value of X-Subject-Token in the response header is a token.

Constraints:

N/A

Value range:

1–100,000 characters.

Default value:

N/A

Content-Type

No

String

Definition:

Media type and encoding format.

Constraints:

N/A

Value range:

N/A

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

git_url

Yes

String

Definition:

Code repository address.

Constraints:

N/A

Value range:

An address starting with git for repo or an address starting with http for other sources.

Default value:

N/A

git_branch

Yes

String

Definition

Repository branch for which you want to create a task.

Constraints

N/A

Range

N/A

Default Value

N/A

language

No

Array of strings

Definition

Array of enabled languages. For details about the supported languages, see the feature updates.

Constraints

Set either this parameter or rule_sets.

Range

N/A

Default Value

N/A

rule_sets

No

Array of RuleSetV2 objects

Definition:

Array of enabled rule sets. Passing languages without rule set IDs is equivalent to passing the language parameter. The default rule sets of these languages in the project will be enabled. For details about the supported languages, see the feature updates.

Constraints:

Set either this parameter or language.

task_type

No

String

Definition

Task type.

Constraints

N/A

Range

  • full: full check task for the specified repository branch

  • inc: MR incremental check task

Default Value

full

username

No

String

Definition

Username. Use this parameter together with access_token to create a general Git endpoint to store the information about a third-party repository.

Constraints

Set either the combination of username and access_token or endpoint_id.

Range

N/A

Default Value

N/A

access_token

No

String

Definition

Password or access key/token. Use this parameter together with username to create a general Git endpoint to store the information about a third-party repository.

Constraints

Set either the combination of username and access_token or endpoint_id.

Range

N/A

Default Value

N/A

endpoint_id

No

String

Definition:

The ID of an existing code source endpoint for storing repository information in a project. If no endpoint is specified when you create a task based on the third-party code source, an endpoint is automatically created. The account must have the permission to create endpoints, and the number of endpoints in the project cannot reach the upper limit.

Constraints:

Set either the combination of username and access_token or endpoint_id.

Range:

N/A

Default value:

N/A

inc_config

No

IncConfigV2 object

Definition

Parameters for creating a branch task or MR task based on a task.

Constraints

N/A

resource_pool_id

No

String

Definition

The ID of a purchased agent pool. If this parameter is passed during task creation, the task will use the corresponding agent pool.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 4 RuleSetV2

Parameter

Mandatory

Type

Description

ruleset_id

No

String

Definition:

Rule set ID.

Constraints:

1 to 32 characters.

Value range:

N/A

Default value:

Default rule set of a language in the project.

language

Yes

String

Definition

Check language. For details about the supported languages, see the feature updates.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 5 IncConfigV2

Parameter

Mandatory

Type

Description

parent_task_id

No

String

Definition

ID of the task to associate.

Constraints

32-character UUID.

Range

N/A

Default Value

N/A

git_source_branch

No

String

Definition

Source branch of the MR incremental task.

Constraints

N/A

Range

N/A

Default Value

N/A

git_target_branch

No

String

Definition

Target branch of the MR incremental task.

Constraints

N/A

Range

N/A

Default Value

N/A

merge_id

No

String

Definition

MR ID.

Constraints

N/A

Range

N/A

Default Value

N/A

event_type

No

String

Definition

Pass this parameter when creating an MR incremental task.

Constraints

N/A

Range

merge_request

Default Value

N/A

action

No

String

Definition

Pass this parameter when creating an MR incremental task.

Constraints

N/A

Range

open

Default Value

N/A

title

No

String

Definition

MR title. Pass this parameter when creating an MR incremental task.

Constraints

N/A

Range

N/A

Default Value

N/A

Response Parameters

Status code: 200

Table 6 Response body parameters

Parameter

Type

Description

task_id

String

Definition

Task ID.

Range

32-character UUID for a full check task and MR_+32-character UUID for an MR incremental check task.

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Definition:

Error code.

Value range:

N/A

error_msg

String

Definition:

Error message.

Value range:

N/A

Status code: 401

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Definition:

Error code.

Value range:

N/A

error_msg

String

Definition:

Error message.

Value range:

N/A

Example Requests

Create a check task: Set the check type to source, the code repository branch to master, and the language to cpp. The code repository URL is displayed based on the site requirements.

POST https://{endpoint}/v2/{project_id}/task

{
  "git_url" : "git@code*****************958.git",
  "git_branch" : "master",
  "language" : [ "cpp" ]
}

Example Responses

Status code: 200

Request succeeded!

{
  "task_id" : "d161fd0**********cb3c1d6a783e"
}

Status code: 400

Bad Request

{
  "error_code" : "CC.xxxxxxxx.400",
  "error_msg" : "Verify request parameter failed. Check whether the request parameters are correct."
}

Status code: 401

Unauthorized

{
  "error_code" : "CC.00000003",
  "error_msg" : "Authentication information expired."
}

Status Codes

Status Code

Description

200

Request succeeded!

400

Bad Request

401

Unauthorized

Error Codes

See Error Codes.