Updated on 2026-10-27 GMT+08:00

Creating Work Items

Function

This API is used to create work items.

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

codeartsreq:workitem:create

Write

-

  • codeartsreq:Model

  • codeartsreq:ProjectId

-

-

URI

POST /v4/projects/{project_id}/issue

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

A 32-character UUID. It uniquely identifies a project. Obtain a project ID by calling the API for querying projects. The value of project_id in the response message body is a project ID.

Constraints

A string of 32 characters consisting of letters and digits.

Range

N/A

Default Value

N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

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

Constraints

N/A

Range

The value contains 10 to 32,768 characters.

Default Value

N/A

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

actual_work_hours

No

Double

Definition

Actual workloads, automatically calculated by summing detailed workloads in a work item and its child work items.

Constraints

N/A

Range

≥ 0

Default Value

N/A

assigned_id

No

Integer

Definition

Digital ID of the handler. You can obtain the digital ID of a user in a specified project using the API for obtaining the user list of a specified project.

Constraints

≥ 1 digit

Range

≥ 0

Default Value

N/A

begin_time

No

String

Definition

Start time: YYYY–MM–DD.

Constraints

The date is in the YYYY-MM-DD format, and the year ranges from 1000 to 9999.

Range

The value is a date string in the format of YYYY-MM-DD. MM is a two-digit month ranging from 01 to 12, and DD is a two-digit date ranging from 01 to 31.

Default Value

N/A

description

No

String

Definition

Work item description.

Constraints

Can be left blank.

Range

A string of 1 to 200,000 characters.

Default Value

N/A

developer_id

No

Integer

Definition

Digital ID of a developer. You can obtain the digital ID of a user in a specified project using the API for obtaining the user list of a specified project.

Constraints

≥ 1 digit

Range

Min.: 0.

Default Value

N/A

domain_id

No

Integer

Definition

Domain ID.

Constraints

One or more numeric digits.

Range

  • 14: Performance.

  • 15: Function.

  • 16: Reliability.

  • 17: Network security.

  • 18: Maintainability.

  • 19: Other DFX.

  • 20: Availability.

  • Custom domain.

Default Value

N/A

done_ratio

No

Integer

Definition

Work item completion rate.

Constraints

If the input is 0, the completion rate of the work item is 0%. If the input is 100, the completion rate of the work item is 100%.

Range

0–100

Default Value

N/A

end_time

No

String

Definition

End time: YYYY–MM–DD.

Constraints

The date is in the YYYY-MM-DD format, and the year ranges from 1000 to 9999.

Range

The value is a date string in the format of YYYY-MM-DD. MM is a two-digit month ranging from 01 to 12, and DD is a two-digit date ranging from 01 to 31.

Default Value

N/A

expected_work_hours

No

Double

Definition:

Estimated workload.

Constraints:

This field can be left blank.

Options:

Minimum length: 0 characters.

Default value:

N/A

iteration_id

No

Integer

Definition

Sprint ID, which can be obtained using the API for obtaining the sprint list of a specified project. The value of the id field in the response message body is the sprint ID.

Constraints

≥ 1 digit

Range

Min. 0 characters.

Default Value

N/A

module_id

No

Integer

Definition

Module ID, which is the value of id in the response body returned by the API for querying the project module list.

Constraints

≥ 1 digit

Range

Min. 0 characters.

Default Value

N/A

name

Yes

String

Definition

Title.

Constraints

Can be left blank.

Range

Length: 1 to 512 characters

Default Value

N/A

new_custom_fields

No

Array of NewCustomField objects

Definition:

Custom field.

Constraints:

N/A

parent_issue_id

No

Integer

Definition

Parent work item ID.

Constraints

This parameter is mandatory when you create a child work item. Obtained the value from the Performing Advanced Query of Work Items API. The value of the id field in the response body is the work item ID.

Range

≥ 0

Default Value

N/A

priority_id

Yes

Integer

Definition

Priority.

Constraints

N/A

Range

  • 1: Low.

  • 2: Medium.

  • 3: High.

Default Value

N/A

severity_id

No

Integer

Definition

Severity.

Constraints

N/A

Range

  • 10: critical

  • 11: major

  • 12: minor

  • 13: info

Default Value

N/A

status_id

No

Integer

Definition

Status ID.

Constraints

One or more numeric digits.

Range

  • 1: New.

  • 2: In progress.

  • 3: Resolved.

  • 4: Testing.

  • 5: Closed.

  • 6: Rejected.

  • Custom status.

Default Value

N/A

tracker_id

Yes

Integer

Definition

Work item type.

Constraints

An epic can only be the parent work item of a feature. A feature can only be the parent work item of a story. A story can only be the parent work item of a task or bug.

Range

  • 2: task

  • 3: bug

  • 5: epic

  • 6: feature

  • 7: story

Default Value

N/A

assigned_cc

No

String

Definition

CC user UUID. You can confirm the user UUID of a specific project member by calling the Obtaining the Member List of a Specified Project API.

Constraints

Multiple CC user UUIDs are concatenated by commas (,).

Range

N/A

Default Value

N/A

Table 4 NewCustomField

Parameter

Mandatory

Type

Description

custom_field

No

String

Parameter description:

Custom field. You can obtain the custom_field value returned using the [Querying Custom Fields of a Scrum Work Item]ListIssueCustomFields.xml) API.

Constraints:

This field can be left blank.

Options:

N/A

Default value:

N/A

field_name

No

String

Definition:

Values of custom properties. Use commas (,) to separate multiple values, which can be obtained by querying the name value returned when calling the Querying Custom Fields of a Scrum Work Item API.

Constraints:

This field can be left blank.

Value range:

N/A

Default value:

N/A

value

No

String

Definition:

Values of custom properties. Use commas (,) to separate multiple values. You can obtain the value by querying the options value returned when calling the Querying Custom Fields of a Scrum Work Item API.

Constraints:

This field can be left blank.

Value range:

N/A

Default value:

N/A

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

actual_work_hours

Double

Definition

Actual workloads.

Range

N/A

assigned_cc_user

Array of IssueUser objects

Definition:

Cc recipient.

assigned_user

IssueUser object

Definition

Handler.

begin_time

String

Definition:

Start time: YYYY–MM–DD.

Options:

N/A

creator

IssueUser object

Definition:

Creator.

custom_fields

Array of CustomField objects

Definition

Custom property value, which is not recommended. Refer to the new_custom_fields field.

developer

IssueUser object

Definition:

Developer.

domain

domain object

Definition

14: performance

15: function

16: reliability

17: cyber security

18: maintainability

19: other DFX

20: availability

done_ratio

Integer

Definition

Work item progress value.

Range

N/A

end_time

String

Definition:

End time: YYYY–MM–DD.

Options:

N/A

expected_work_hours

Double

Definition:

Estimated workload.

Options:

N/A

id

Integer

Definition

Work item ID.

Range

N/A

iteration

iteration object

Definition:

Sprint.

module

module object

Definition:

Module.

new_custom_fields

Array of NewCustomField objects

Definition:

Custom attribute value.

parent_issue

parent_issue object

Definition:

Parent work item.

priority

priority object

Definition

Work item priority.

1: low

2: medium

3: high

project

IssueProjectResponseV4 object

Definition:

Project information.

severity

severity object

Definition:

Work item severity.

status

status object

Definition

Work item status.

1: new

2: ongoing

3: solved

4: testing

5: closed

6: rejected

tracker

tracker object

Definition

Work item type.

2 (task)

3 (bug)

5 (epic)

6 (feature)

7 (story)

Table 6 IssueUser

Parameter

Type

Description

id

Integer

Definition

User ID.

Range

N/A

name

String

Definition

Username.

Range

N/A

nick_name

String

Definition:

Alias.

Options:

N/A

user_id

String

Definition

User UUID.

Range

N/A

user_num_id

Integer

Definition

Digital ID of a user.

Range

N/A

first_name

String

Definition:

Username.

Value range:

N/A

Table 7 CustomField

Parameter

Type

Description

name

String

Definition:

Custom property name.

Value range:

N/A

new_name

String

Definition:

Custom property name.

Value range:

N/A

value

String

Definition:

Value of the custom property.

Value range:

N/A

Table 8 domain

Parameter

Type

Description

id

Integer

Definition

Domain ID.

Range

N/A

name

String

Definition:

Domain.

Options:

N/A

Table 9 iteration

Parameter

Type

Description

id

Integer

Definition

Sprint ID.

Range

N/A

name

String

Definition:

Sprint name.

Options:

N/A

Table 10 module

Parameter

Type

Description

id

Integer

Definition

Module ID.

Range

N/A

name

String

Definition:

Module.

Options:

N/A

Table 11 NewCustomField

Parameter

Type

Description

custom_field

String

Parameter description:

Custom field. You can obtain the custom_field value returned using the [Querying Custom Fields of a Scrum Work Item]ListIssueCustomFields.xml) API.

field_name

String

Definition:

Values of custom properties. Use commas (,) to separate multiple values, which can be obtained by querying the name value returned when calling the Querying Custom Fields of a Scrum Work Item API.

value

String

Definition:

Values of custom properties. Use commas (,) to separate multiple values. You can obtain the value by querying the options value returned when calling the Querying Custom Fields of a Scrum Work Item API.

Table 12 parent_issue

Parameter

Type

Description

id

Integer

Definition

Parent work item ID.

Range

N/A

name

String

Definition:

Parent work item.

Options:

N/A

Table 13 priority

Parameter

Type

Description

id

Integer

Definition

Priority ID.

Range

N/A

name

String

Definition:

Priority.

Options:

N/A

Table 14 IssueProjectResponseV4

Parameter

Type

Description

project_id

String

Definition

Project ID.

Range

N/A

project_name

String

Definition:

Project name.

Value range:

N/A

project_num_id

Integer

Definition

Digital ID of a project.

Range

≥ 0

Table 15 severity

Parameter

Type

Description

id

Integer

Definition

Severity ID.

Range

N/A

name

String

Definition:

Severity.

Options:

N/A

Table 16 status

Parameter

Type

Description

id

Integer

Definition

Status ID.

Range

N/A

name

String

Definition:

Status name.

Options:

N/A

Table 17 tracker

Parameter

Type

Description

id

Integer

Definition

Type ID.

Range

N/A

name

String

Definition:

Type name.

Options:

N/A

Status code: 400

Table 18 Response body parameters

Parameter

Type

Description

error_code

String

Definition:

Error code.

Value range:

N/A

error_msg

String

Definition:

Error description.

Value range:

N/A

Example Requests

POST https://{endpoint}/v4/projects/526cefde62004de2b62b5e8dd2c2b3af/issue

{
  "assigned_id" : 4091,
  "begin_time" : "2018-1-31",
  "description" : "",
  "developer_id" : 4091,
  "end_time" : "2018-07-05",
  "iteration_id" : 11302238,
  "name" : "test",
  "parent_issue_id" : 1679822,
  "priority_id" : 2,
  "severity_id" : 10,
  "status_id" : 1,
  "tracker_id" : 3,
  "assigned_cc" : "a360371833bf4c558f796fd707b44daf,0b02aa23f93b4309b319cb1db9b24c42"
}

Example Responses

Status code: 200

{
  "id" : 1377843,
  "name" : "testTask",
  "done_ratio" : 0,
  "tracker" : {
    "id" : 2,
    "name" : "Task"
  },
  "priority" : {
    "id" : 1,
    "name" : "Low"
  },
  "security_level" : null,
  "order" : {
    "id" : 1,
    "name" : "1"
  },
  "severity" : {
    "id" : 12,
    "name" : "Minor"
  },
  "status" : {
    "id" : 1,
    "name" : "Initial"
  },
  "release_dev" : "",
  "find_release_dev" : null,
  "env" : null,
  "updated_time" : null,
  "begin_time" : "",
  "end_time" : "",
  "project" : {
    "project_num_id" : 527,
    "project_id" : "ddb260aa69b848599747eadfa632a40f",
    "project_name" : "Scrum0630001"
  },
  "parent_issue" : null,
  "module" : null,
  "domain" : null,
  "iteration" : null,
  "story_point" : null,
  "expected_work_hours" : 0,
  "actual_work_hours" : 0,
  "created_time" : null,
  "custom_fields" : [ ],
  "new_custom_fields" : null,
  "assigned_cc_user" : null,
  "assigned_user" : {
    "user_id" : null,
    "user_num_id" : null,
    "id" : 83,
    "name" : "CodeArtsReq_creq_chm1",
    "nick_name" : "creq_chm1",
    "first_name" : "creq_chm1"
  },
  "creator" : {
    "user_id" : null,
    "user_num_id" : null,
    "id" : 83,
    "name" : "CodeArtsReq_creq_chm1",
    "nick_name" : "creq_chm1",
    "first_name" : "creq_chm1"
  },
  "developer" : null,
  "closed_time" : null,
  "tag_list" : null
}

SDK Sample Code

The SDK sample code is as follows.

Java

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.projectman.v4.region.ProjectManRegion;
import com.huaweicloud.sdk.projectman.v4.*;
import com.huaweicloud.sdk.projectman.v4.model.*;


public class CreateIssueV4Solution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");

        ICredential auth = new BasicCredentials()
                .withAk(ak)
                .withSk(sk);

        ProjectManClient client = ProjectManClient.newBuilder()
                .withCredential(auth)
                .withRegion(ProjectManRegion.valueOf("<YOUR REGION>"))
                .build();
        CreateIssueV4Request request = new CreateIssueV4Request();
        request.withProjectId("{project_id}");
        CreateIssueRequestV4 body = new CreateIssueRequestV4();
        body.withTrackerId(3);
        body.withStatusId(1);
        body.withSeverityId(10);
        body.withPriorityId(2);
        body.withParentIssueId(1679822);
        body.withName("test");
        body.withIterationId(11302238);
        body.withEndTime("2018-07-05");
        body.withDeveloperId(4091);
        body.withDescription("");
        body.withBeginTime("2018-1-31");
        body.withAssignedId(4091);
        request.withBody(body);
        try {
            CreateIssueV4Response response = client.createIssueV4(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}

Python

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkprojectman.v4.region.projectman_region import ProjectManRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkprojectman.v4 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]

    credentials = BasicCredentials(ak, sk)

    client = ProjectManClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(ProjectManRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = CreateIssueV4Request()
        request.project_id = "{project_id}"
        request.body = CreateIssueRequestV4(
            tracker_id=3,
            status_id=1,
            severity_id=10,
            priority_id=2,
            parent_issue_id=1679822,
            name="test",
            iteration_id=11302238,
            end_time="2018-07-05",
            developer_id=4091,
            description="",
            begin_time="2018-1-31",
            assigned_id=4091
        )
        response = client.create_issue_v4(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Go

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    projectman "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/projectman/v4"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/projectman/v4/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/projectman/v4/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")

    auth, err := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        SafeBuild()

    if err != nil {
        fmt.Println(err)
        return
    }

    hcClient, err := projectman.ProjectManClientBuilder().
         WithRegion(region.ValueOf("<YOUR REGION>")).
         WithCredential(auth).
         SafeBuild()


    if err != nil {
        fmt.Println(err)
        return
    }

    client := projectman.NewProjectManClient(hcClient)

    request := &model.CreateIssueV4Request{}
	request.ProjectId = "{project_id}"
	statusIdCreateIssueRequestV4:= int32(1)
	severityIdCreateIssueRequestV4:= int32(10)
	parentIssueIdCreateIssueRequestV4:= int32(1679822)
	iterationIdCreateIssueRequestV4:= int32(11302238)
	endTimeCreateIssueRequestV4:= "2018-07-05"
	developerIdCreateIssueRequestV4:= int32(4091)
	descriptionCreateIssueRequestV4:= ""
	beginTimeCreateIssueRequestV4:= "2018-1-31"
	assignedIdCreateIssueRequestV4:= int32(4091)
	request.Body = &model.CreateIssueRequestV4{
		TrackerId: int32(3),
		StatusId: &statusIdCreateIssueRequestV4,
		SeverityId: &severityIdCreateIssueRequestV4,
		PriorityId: int32(2),
		ParentIssueId: &parentIssueIdCreateIssueRequestV4,
		Name: "test",
		IterationId: &iterationIdCreateIssueRequestV4,
		EndTime: &endTimeCreateIssueRequestV4,
		DeveloperId: &developerIdCreateIssueRequestV4,
		Description: &descriptionCreateIssueRequestV4,
		BeginTime: &beginTimeCreateIssueRequestV4,
		AssignedId: &assignedIdCreateIssueRequestV4,
	}
	response, err := client.CreateIssueV4(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

More

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

200

Response for a successful work item creation request.

400

Response for a failed API request.

Error Codes

See Error Codes.