Skip to content

Add a merge request to a merge train

POST
/api/v4/projects/{id}/merge_trains/merge_requests/{merge_request_iid}

Adds a specified merge request to a merge train.

id
required
One of:
string

The ID or URL-encoded path of the project

Example
11
merge_request_iid
required
integer

The IID of the merge request

Media type application/json
object
sha

If present, then the SHA must match the HEAD of the source branch, otherwise the merge fails.

string
nullable
squash

When true, the commits will be squashed into a single commit on merge

boolean
nullable
when_pipeline_succeeds

Deprecated. Use the auto_merge parameter instead.

boolean
nullable
auto_merge

When true, this merge request will be set to auto merge

boolean
nullable
Example generated
{
"sha": "example",
"squash": true,
"when_pipeline_succeeds": true,
"auto_merge": true
}

Created

Media type application/json
object
id
integer format: int64
merge_request
object
id
integer format: int64
iid
integer
project_id
integer format: int64
title
string
description
string
state
string
created_at
string format: date-time
updated_at
string format: date-time
web_url
string
user
object
id
integer format: int64
username
string
public_email
string
name
string
state
string
locked
boolean
avatar_url
string
avatar_path
string
custom_attributes
Array<object>
object
key
string
value
string
web_url
string
pipeline
object
id
integer format: int64
iid
integer
project_id
integer format: int64
sha
string
ref
string
status
string
source
string
created_at
string format: date-time
updated_at
string format: date-time
web_url
string
created_at
string format: date-time
updated_at
string format: date-time
target_branch
string
status
string
merged_at
string format: date-time
duration

Time spent in seconds

integer
Example
{
"id": 38,
"merge_request": {
"id": 84,
"iid": 14,
"project_id": 4,
"title": "Test MR 1580978354",
"description": "Repellendus impedit et vel velit dignissimos.",
"state": "closed",
"created_at": "2022-08-17T12:46:35.053Z",
"updated_at": "2022-11-14T17:22:01.470Z",
"web_url": "http://local.gitlab.test:8181/root/merge-train-race-condition/-/merge_requests/59"
},
"user": {
"id": 1,
"username": "admin",
"public_email": "john@example.com",
"name": "Administrator",
"state": "active",
"avatar_url": "https://gravatar.com/avatar/1",
"avatar_path": "/user/avatar/28/The-Big-Lebowski-400-400.png",
"custom_attributes": [
{
"key": "foo",
"value": "bar"
}
],
"web_url": "https://gitlab.example.com/root"
},
"pipeline": {
"id": 1,
"iid": 2,
"project_id": 3,
"sha": "0ec9e58fdfca6cdd6652c083c9edb53abc0bad52",
"ref": "feature-branch",
"status": "success",
"source": "push",
"created_at": "2022-10-21T16:49:48.000+02:00",
"updated_at": "2022-10-21T16:49:48.000+02:00",
"web_url": "https://gitlab.example.com/gitlab-org/gitlab-foss/-/pipelines/61"
},
"created_at": "2015-12-24T15:51:21.880Z",
"updated_at": "2015-12-24T17:54:31.198Z",
"target_branch": "develop",
"status": "merging",
"merged_at": "2015-12-24T17:54:31.198Z",
"duration": 127
}

Accepted

Media type application/json
object
id
integer format: int64
merge_request
object
id
integer format: int64
iid
integer
project_id
integer format: int64
title
string
description
string
state
string
created_at
string format: date-time
updated_at
string format: date-time
web_url
string
user
object
id
integer format: int64
username
string
public_email
string
name
string
state
string
locked
boolean
avatar_url
string
avatar_path
string
custom_attributes
Array<object>
object
key
string
value
string
web_url
string
pipeline
object
id
integer format: int64
iid
integer
project_id
integer format: int64
sha
string
ref
string
status
string
source
string
created_at
string format: date-time
updated_at
string format: date-time
web_url
string
created_at
string format: date-time
updated_at
string format: date-time
target_branch
string
status
string
merged_at
string format: date-time
duration

Time spent in seconds

integer
Example
{
"id": 38,
"merge_request": {
"id": 84,
"iid": 14,
"project_id": 4,
"title": "Test MR 1580978354",
"description": "Repellendus impedit et vel velit dignissimos.",
"state": "closed",
"created_at": "2022-08-17T12:46:35.053Z",
"updated_at": "2022-11-14T17:22:01.470Z",
"web_url": "http://local.gitlab.test:8181/root/merge-train-race-condition/-/merge_requests/59"
},
"user": {
"id": 1,
"username": "admin",
"public_email": "john@example.com",
"name": "Administrator",
"state": "active",
"avatar_url": "https://gravatar.com/avatar/1",
"avatar_path": "/user/avatar/28/The-Big-Lebowski-400-400.png",
"custom_attributes": [
{
"key": "foo",
"value": "bar"
}
],
"web_url": "https://gitlab.example.com/root"
},
"pipeline": {
"id": 1,
"iid": 2,
"project_id": 3,
"sha": "0ec9e58fdfca6cdd6652c083c9edb53abc0bad52",
"ref": "feature-branch",
"status": "success",
"source": "push",
"created_at": "2022-10-21T16:49:48.000+02:00",
"updated_at": "2022-10-21T16:49:48.000+02:00",
"web_url": "https://gitlab.example.com/gitlab-org/gitlab-foss/-/pipelines/61"
},
"created_at": "2015-12-24T15:51:21.880Z",
"updated_at": "2015-12-24T17:54:31.198Z",
"target_branch": "develop",
"status": "merging",
"merged_at": "2015-12-24T17:54:31.198Z",
"duration": 127
}

Failed to merge

Unauthorized

Forbidden

Not found

Conflict