CreateChangeRequest - Create a change request

Updated at:

Creates a merge request in a specified repository.

Applicable editions

Central edition, Region edition

Service endpoint and authorization information

  • Get service endpoint: Replace the {domain} placeholder in the API request syntax.

  • Get personal access token.

  • Get the organization ID (Central edition only). Go to the organization admin console and find the organization ID on the basic information page.

Product

Resource

Required permissions

code management

merge request

read/write

Request syntax

Central edition

POST https://{domain}/oapi/v1/codeup/organizations/{organizationId}/repositories/{repositoryId}/changeRequests

Region edition

POST https://{domain}/oapi/v1/codeup/repositories/{repositoryId}/changeRequests

Request headers

Parameter

Type

Required

Description

Example value

x-yunxiao-token

string

Yes

Personal access token for Alibaba Cloud DevOps.

pt-0fh3****0fbG_35af****0484

Request parameters

Parameter

Type

Position

Required

Description

Example value

organizationId

string

path

  • Yes: Central edition

  • No: Region edition

Organization ID.

60d54f3daccf2bbd6659f3ad

repositoryId

string

path

Yes

Repository ID or URL-encoded full path.

2813489 or 60de7a6852743a5162b5f957%2FDemoRepo

-

object

body

No

description

string

body

No

Description of the merge request. Maximum 10,000 characters.

mr description

reviewerUserIds

array[string]

body

No

User IDs of the reviewers.

["62c795xxxb468af8"]

sourceBranch

string

body

Yes

Source branch for the merge request.

demo-branch

sourceProjectId

integer

body

Yes

ID of the source repository.

2813489

targetBranch

string

body

Yes

Target branch for the merge request.

master

targetProjectId

integer

body

Yes

ID of the target repository.

2813489

title

string

body

Yes

Merge request title. Maximum 256 characters.

mr title

triggerAIReviewRun

boolean

body

No

Whether to trigger an AI review. Defaults to false.

false

workItemIds

string

body

No

Comma-separated string of associated work item IDs.

722200214032b6b31e6f1434ab,xxx

Request example

Central edition

curl -X 'POST' \
  'https://{domain}/oapi/v1/codeup/organizations/60d54f3daccf2bbd6659f3ad/repositories/2813489/changeRequests' \
  -H 'Content-Type: application/json' \
  -H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484' \
  --data '
    {
        "description": "mr description",
        "reviewerUserIds": ["62c795xxxb468af8"],
        "sourceBranch": "demo-branch",
        "sourceProjectId": 2813489,
        "targetBranch": "master",
        "targetProjectId": 2813489,
        "title": "mr title",
        "triggerAIReviewRun": false,
        "workItemIds": "722200214032b6b31e6f1434ab,xxx"
    }'

Region edition

curl -X 'POST' \
  'https://{domain}/oapi/v1/codeup/repositories/2813489/changeRequests' \
  -H 'Content-Type: application/json' \
  -H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484' \
  --data '
    {
        "description": "mr description",
        "reviewerUserIds": ["62c795xxxb468af8"],
        "sourceBranch": "demo-branch",
        "sourceProjectId": 2813489,
        "targetBranch": "master",
        "targetProjectId": 2813489,
        "title": "mr title",
        "triggerAIReviewRun": false,
        "workItemIds": "722200214032b6b31e6f1434ab,xxx"
    }'

Return parameters

Parameter

Type

Description

Example value

-

object

ahead

integer

Number of commits the source branch is ahead of the target branch.

1

allRequirementsPass

boolean

Whether all required checks have passed.

true

author

object

Author information.

avatar

string

URL of the user's avatar.

https://example/example/w/100/h/100

email

string

Email address of the user.

username@example.com

name

string

Name of the user.

codeup-name

state

string

User state. Valid values: active (available) and blocked (unavailable).

active

userId

string

Alibaba Cloud DevOps user ID.

62c795xxxb468af8

username

string

Username used for login.

codeup-username

behind

integer

Number of commits the source branch is behind the target branch.

1

canRevertOrCherryPick

boolean

Whether the merge request can be reverted or cherry-picked.

true

conflictCheckStatus

string

Conflict check status. Valid values: CHECKING (in progress), HAS_CONFLICT (has conflicts), NO_CONFLICT (no conflicts), or FAILED (failed).

NO_CONFLICT

createFrom

string

How the merge request was created. WEB: via the web UI. COMMAND_LINE: via the command line.

WEB

createTime

string

Creation time of the merge request, in ISO 8601 format.

2024-10-05T15:30:45Z

description

string

Description of the merge request.

mr description

detailUrl

string

URL of the merge request detail page.

https://example.com/example/example_demo/change/1

hasReverted

boolean

Whether the merge request has been reverted.

false

localId

integer

Repository-scoped ID of the merge request.

1

mergedRevision

string

SHA of the merge commit. Available only when status is MERGED.

6da8c14b5a9102998148b7ea35f96507d5304f74

mrType

string

Merge request type. CODE_REVIEW: code review. REF_REVIEW: branch or tag review.

CODE_REVIEW

projectId

integer

Repository ID.

2813489

reviewers

array

Users assigned as reviewers.

-

object

avatar

string

URL of the user's avatar.

https://example/example/w/100/h/100

email

string

Email address of the user.

username@example.com

hasCommented

boolean

Whether the reviewer has commented.

true

hasReviewed

boolean

Whether the reviewer has completed their review.

true

name

string

Name of the user.

codeup-name

reviewOpinionStatus

string

Reviewer's decision. Valid values: PASS and NOT_PASS.

PASS

reviewTime

string

Time the review was submitted, in ISO 8601 format.

2024-10-05T15:30:45Z

state

string

User state. Valid values: active (available) and blocked (unavailable).

active

userId

string

Alibaba Cloud DevOps user ID.

62c795xxxb468af8

username

string

Username used for login.

codeup-username

sourceBranch

string

Source branch.

demo-branch

sourceProjectId

integer

ID of the source repository.

2813489

status

string

Merge request status. Valid values: UNDER_DEV (in development), UNDER_REVIEW (in review), TO_BE_MERGED (ready to merge), CLOSED, and MERGED.

UNDER_REVIEW

subscribers

array

Users subscribed to the merge request.

-

object

Subscriber information.

avatar

string

URL of the user's avatar.

https://example/example/w/100/h/100

email

string

Email address of the user.

username@example.com

name

string

Name of the user.

codeup-name

state

string

User state. Valid values: active (available) and blocked (unavailable).

active

userId

string

Alibaba Cloud DevOps user ID.

62c795xxxb468af8

username

string

Username used for login.

codeup-username

supportMergeFastForwardOnly

boolean

Whether the merge request supports a fast-forward-only merge.

true

targetBranch

string

Target branch.

master

targetProjectId

integer

ID of the target repository.

2813489

targetProjectNameWithNamespace

string

Target repository name with full namespace. The namespace and project name are separated by / (a slash surrounded by spaces).

60de7a6852743a5162b5f957 / DemoRepo

targetProjectPathWithNamespace

string

Target repository path with full namespace. The namespace and project path are separated by a forward slash (/).

60de7a6852743a5162b5f957/DemoRepo

title

string

Merge request title.

mr title

totalCommentCount

integer

Total number of comments.

1

unResolvedCommentCount

integer

Number of unresolved comments.

1

updateTime

string

Last update time of the merge request, in ISO 8601 format.

2024-10-05T15:30:45Z

webUrl

string

URL of the merge request.

https://example.com/example/example_demo/change/1

Response example

{
    "ahead": 1,
    "allRequirementsPass": true,
    "author": {
        "avatar": "https://example/example/w/100/h/100",
        "email": "username@example.com",
        "name": "codeup-name",
        "state": "active",
        "userId": "62c795xxxb468af8",
        "username": "codeup-username"
    },
    "behind": 1,
    "canRevertOrCherryPick": true,
    "conflictCheckStatus": "NO_CONFLICT",
    "createFrom": "WEB",
    "createTime": "2024-10-05T15:30:45Z",
    "description": "mr description",
    "detailUrl": "https://example.com/example/example_demo/change/1",
    "hasReverted": false,
    "localId": 1,
    "mergedRevision": "6da8c14b5a9102998148b7ea35f96507d5304f74",
    "mrType": "CODE_REVIEW",
    "projectId": 2813489,
    "reviewers": [
        {
            "avatar": "https://example/example/w/100/h/100",
            "email": "username@example.com",
            "hasCommented": true,
            "hasReviewed": true,
            "name": "codeup-name",
            "reviewOpinionStatus": "PASS",
            "reviewTime": "2024-10-05T15:30:45Z",
            "state": "active",
            "userId": "62c795xxxb468af8",
            "username": "codeup-username"
        }
    ],
    "sourceBranch": "demo-branch",
    "sourceProjectId": 2813489,
    "status": "UNDER_REVIEW",
    "subscribers": [
        {
            "avatar": "https://example/example/w/100/h/100",
            "email": "username@example.com",
            "name": "codeup-name",
            "state": "active",
            "userId": "62c795xxxb468af8",
            "username": "codeup-username"
        }
    ],
    "supportMergeFastForwardOnly": true,
    "targetBranch": "master",
    "targetProjectId": 2813489,
    "targetProjectNameWithNamespace": "60de7a6852743a5162b5f957 / DemoRepo",
    "targetProjectPathWithNamespace": "60de7a6852743a5162b5f957/DemoRepo",
    "title": "mr title",
    "totalCommentCount": 1,
    "unResolvedCommentCount": 1,
    "updateTime": "2024-10-05T15:30:45Z",
    "webUrl": "https://example.com/example/example_demo/change/1"
}

Error codes

For API error codes, refer to the Error Center.