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

Creating an MR Review

Description

This API is used to create an MR review.

URI

POST /v2/repositories/{repository_id}/merge_requests/{merge_request_iid}/discussions

Table 1 Path parameters

Parameter

Mandatory

Type

Description

repository_id

Yes

Integer

Repository short ID

Minimum value: 1

Maximum value: 2,147,483,647

merge_request_iid

Yes

Integer

MR No.

Minimum value: 1

Maximum value: 2,147,483,647

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

body

Yes

String

Review content

severity

No

String

Severity

assignee_id

No

String

Assigner ID

review_categories

No

String

Review type

review_modules

No

String

Review module

proposer_id

No

String

Proposer ID

position

No

PositionDto object

Code location information

Table 4 PositionDto

Parameter

Mandatory

Type

Description

base_sha

No

String

Base commit node of the source branch

start_sha

No

String

Latest commit node of the target branch

head_sha

No

String

Latest commit node of the source branch

old_path

No

String

Old file path

new_path

No

String

New file path

position_type

No

String

Change type

old_line

No

Integer

Old line No.

new_line

No

Integer

New line No.

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

error

Error object

Response error

result

MergeRequestDiscussionDto object

Response result

status

String

Response status

Table 6 Error

Parameter

Type

Description

code

String

Error codes

message

String

Error message

Table 7 MergeRequestDiscussionDto

Parameter

Type

Description

id

String

Comment ID

individual_note

Boolean

individual_note

notes

Array of NoteDto objects

Main comment and reply list

Array length: 0–1

project_id

Integer

Repository ID

Minimum value: 1

Maximum value: 2,147,483,647

noteable_type

String

Object type

commit_id

String

Associated commit ID

project_full_path

String

Repository path

a_mode

String

Old file mode

b_mode

String

New file mode

deleted_file

Boolean

Whether to delete files during the modification

new_file

Boolean

Whether to add files during the modification

resolved

Boolean

Whether the review is resolved

archived

Boolean

Whether the review is archived

review_categories

String

Review type

review_categories_cn

String

Review type in Chinese

review_categories_en

String

Review type

review_modules

String

Review module

severity

String

Severity

severity_cn

String

Severity in Chinese

severity_en

String

Severity

assignee

UserBasicDto object

Assignee

proposer

UserBasicDto object

Proposer

merge_request_version_params

MergeRequestVersionParamsDto object

MR version information

diff_file

String

Changed file

added_lines

Integer

Added lines

Minimum value: 1

Maximum value: 2,147,483,647

removed_lines

Integer

Deleted lines

Minimum value: 1

Maximum value: 2,147,483,647

Table 8 NoteDto

Parameter

Type

Description

id

Integer

note id

Minimum value: 1

Maximum value: 2,147,483,647

type

String

Note type

body

String

Review content

attachment

String

Attachment

author

UserBasicDto object

Author

created_at

String

Creation time

updated_at

String

Update time

system

Boolean

Whether the log is generated by the system

noteable_id

Integer

Target ID

Minimum value: 1

Maximum value: 2,147,483,647

noteable_type

String

Object type

commit_id

String

Associated commit ID

resolvable

Boolean

Whether can be resolved

is_reply

Boolean

Whether the review is replied

resolved_by

UserBasicDto object

Solver

noteable_iid

Integer

Target No.

Minimum value: 1

Maximum value: 2,147,483,647

discussion_id

String

Discussion ID

project

String

Project

diff_file

String

Changed file

diff

String

Changed content

archived

Boolean

Whether it is archived

review_categories

String

Review type

review_categories_cn

String

Review type in Chinese

review_categories_en

String

Review type

review_modules

String

Review module

severity

String

Severity

severity_cn

String

Severity in Chinese

severity_en

String

Severity

file_path

String

File path

line

String

Line No.

assignee

UserBasicDto object

Assignee

proposer

UserBasicDto object

Proposer

position

PositionDto object

Associated code location

resolved

Boolean

Whether it is resolved

is_outdated

Boolean

Whether it is outdated

Table 9 PositionDto

Parameter

Type

Description

base_sha

String

Base commit node of the source branch

start_sha

String

Latest commit node of the target branch

head_sha

String

Latest commit node of the source branch

old_path

String

Old file path

new_path

String

New file path

position_type

String

Change type

old_line

Integer

Old line No.

new_line

Integer

New line No.

Table 10 UserBasicDto

Parameter

Type

Description

id

Integer

User ID

Minimum value: 1

Maximum value: 2,147,483,647

name

String

Name

username

String

Username

state

String

Status

avatar_url

String

Avatar URL

avatar_path

String

Avatar path

email

String

Email

name_cn

String

Name in Chinese

web_url

String

Homepage

nick_name

String

Alias

tenant_name

String

Tenant name

Table 11 MergeRequestVersionParamsDto

Parameter

Type

Description

diff_id

Integer

Latest MR Change ID

Minimum value: 1

Maximum value: 2,147,483,647

start_sha

String

Latest commit of the target branch

commit_id

String

Latest commit of the source branch

Request Examples

POST https://{endpoint}/v2/repositories/{repository_id}/merge_requests/{merge_request_iid}/discussions

{
  "body" : "Review content",
  "position" : {
    "new_path" : "a.txt",
    "old_path" : "a.txt",
    "new_line" : 1,
    "old_line" : -1
  },
  "severity" : "suggestion"
}

Response Examples

Status code: 200

Request succeeded

{
  "result" : {
    "id" : "b7d95c35c08e0b328bfbafd45408bd2ac28b73f9",
    "individual_note" : false,
    "notes" : [ {
      "id" : 2111886200,
      "type" : "DiffNote",
      "body" : "Review content",
      "author" : {
        "id" : 1234,
        "name" : "beta",
        "username" : "c369c68f1ff84679b5a8ed904d8bff1c",
        "state" : "active",
        "name_cn" : "beta"
      },
      "created_at" : "2023-06-01T17:05:12.000+08:00",
      "updated_at" : "2023-06-01T17:05:12.000+08:00",
      "system" : false,
      "noteable_id" : 19387,
      "noteable_type" : "MergeRequest",
      "resolvable" : true,
      "is_reply" : true,
      "noteable_iid" : 2,
      "discussion_id" : "8bbe6d4e797169c4c1ce56507fdf1abc11f95601",
      "project" : "DevOpsqlcylxm00004/project-test",
      "diff_file" : "7",
      "diff" : "@@ -0,0 +1,0 @@\n+7",
      "archived" : false,
      "review_categories" : "regulations",
      "review_categories_cn" : "Programming regulations",
      "review_categories_en" : "Regulations",
      "review_modules" : "aaa,bbb",
      "severity" : "suggestion",
      "assignee" : {
        "id" : 1234,
        "name" : "beta",
        "username" : "c369c68f1ff84679b5a8ed904d8bff1c",
        "state" : "active",
        "name_cn" : "beta"
      },
      "proposer" : {
        "id" : 1234,
        "name" : "beta",
        "username" : "c369c68f1ff84679b5a8ed904d8bff1c",
        "state" : "active",
        "name_cn" : "beta"
      },
      "position" : {
        "base_sha" : "973bcc0211c32dbaa8473561c6767f74e1a81471",
        "start_sha" : "973bcc0211c32dbaa8473561c6767f74e1a81471",
        "head_sha" : "f5bf0230f9b996ed6c0d64d2b2fef789d91b164c",
        "old_path" : "7",
        "new_path" : "7",
        "position_type" : "text",
        "new_line" : 1
      },
      "resolved" : false,
      "is_outdated" : false
    } ],
    "project_id" : 2111699786,
    "noteable_type" : "MergeRequest",
    "project_full_path" : "DevOpsqlcylxm00004/project-test",
    "a_mode" : "0",
    "b_mode" : "100644",
    "deleted_file" : false,
    "new_file" : true,
    "resolved" : false,
    "archived" : false,
    "review_categories" : "regulations",
      "review_categories_cn" : "Programming regulations",
    "review_categories_en" : "Regulations",
    "review_modules" : "aaa,bbb",
    "severity" : "suggestion",
    "severity_cn" : "Suggestion",
    "severity_en" : "Suggestion",
    "assignee" : {
      "id" : 1234,
      "name" : "beta",
      "username" : "c369c68f1ff84679b5a8ed904d8bff1c",
      "state" : "active",
      "name_cn" : "beta"
    },
    "proposer" : {
      "id" : 1234,
      "name" : "beta",
      "username" : "c369c68f1ff84679b5a8ed904d8bff1c",
      "state" : "active",
      "name_cn" : "beta"
    },
    "diff_file" : "@@ -0,0 +1,0 @@\n+7",
    "added_lines" : 1,
    "removed_lines" : 0
  },
  "status" : "success"
}

Status Codes

Status Codes

Description

200

Request succeeded

Error Codes

See Error Codes.