Merge requests API
- Tier: Free, Premium, Ultimate
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
Use this API to manage merge requests. You can:
- Automate any part of the code review process.
- Connect code changes to external tools.
- Send merge request information to non-GitLab systems in your preferred format.
- Update, approve, merge, or block merge requests based on data from external systems.
All API calls to non-public information require authentication.
Removals in API v5
The approvals_before_merge attribute is deprecated, and is scheduled for removal
in API v5 in favor of the merge request approvals API.
List merge requests
List all merge requests accessible to the authenticated user. By
default, returns only merge requests created by the current user.
Use scope=all to retrieve all merge requests.
Use the state parameter to get only merge requests with a
given state (opened, closed, locked, or merged) or all states (all).
Searching by locked generally returns no results
as that state is short-lived and transitional. Use the pagination parameters page and
per_page to restrict the list of merge requests.
GET /merge_requests
GET /merge_requests?state=opened
GET /merge_requests?state=all
GET /merge_requests?milestone=release
GET /merge_requests?labels=bug,reproduced
GET /merge_requests?author_id=5
GET /merge_requests?author_username=gitlab-bot
GET /merge_requests?my_reaction_emoji=star
GET /merge_requests?scope=assigned_to_me
GET /merge_requests?scope=reviews_for_me
GET /merge_requests?search=foo&in=titleSupported attributes:
| Attribute | Type | Required | Description |
|---|---|---|---|
approved_by_ids[] | integer array | No | Returns merge requests approved by all the users with the given id, up to 5 users. None returns merge requests with no approvals. Any returns merge requests with an approval. |
approved_by_usernames[] | string array | No | Returns merge requests approved by all the users with the given username, up to 5 users. None returns merge requests with no approvals. Any returns merge requests with an approval. |
approver_ids[] | integer array | No | Returns merge requests which have all users with the specified id as eligible approvers according to the approval rules. None returns merge requests with no eligible approvers. Any returns merge requests with at least one eligible approver. Premium and Ultimate only. |
assignee_id | integer or string | No | Returns merge requests assigned to the given user id. None returns unassigned merge requests. Any returns merge requests with an assignee. Mutually exclusive with assignee_username. |
assignee_username[] | string array | No | Returns merge requests assigned to the given usernames. Mutually exclusive with assignee_id. |
author_id | integer | No | Returns merge requests created by the given user id. Mutually exclusive with author_username. Combine with scope=all or scope=assigned_to_me. |
author_username | string | No | Returns merge requests created by the given username. Mutually exclusive with author_id. |
created_after | datetime | No | Returns merge requests created on or after the given date and time. Expected in ISO 8601 format (2019-03-15T08:00:00Z). |
created_before | datetime | No | Returns merge requests created on or before the given date and time. Expected in ISO 8601 format (2019-03-15T08:00:00Z). |
deployed_after | datetime | No | Returns merge requests deployed after the given date/time. Expected in ISO 8601 format (2019-03-15T08:00:00Z). |
deployed_before | datetime | No | Returns merge requests deployed before the given date/time. Expected in ISO 8601 format (2019-03-15T08:00:00Z). |
merged_after | datetime | No | Returns merge requests merged on or after the given date and time. Expected in ISO 8601 format (2019-03-15T08:00:00Z). |
merged_before | datetime | No | Returns merge requests merged on or before the given date and time. Expected in ISO 8601 format (2019-03-15T08:00:00Z). |
environment | string | No | Returns merge requests deployed to the given environment. |
in | string | No | Change the scope of the search attribute. title, description, or a string joining them with comma. Default is title,description. |
labels | string | No | Returns merge requests matching a comma-separated list of labels. None lists all merge requests with no labels. Any lists all merge requests with at least one label. Predefined names are case-insensitive. |
merge_user_id | integer | No | Returns merge requests merged by the user with the given user id. Mutually exclusive with merge_user_username. Introduced in GitLab 17.0. |
merge_user_username | string | No | Returns merge requests merged by the user with the given username. Mutually exclusive with merge_user_id. Introduced in GitLab 17.0. |
milestone | string | No | Returns merge requests for a specific milestone. None returns merge requests with no milestone. Any returns merge requests that have an assigned milestone. |
my_reaction_emoji | string | No | Returns merge requests reacted by the authenticated user by the given emoji. None returns issues not given a reaction. Any returns issues given at least one reaction. |
non_archived | boolean | No | If true, returns merge requests from non-archived projects only. Default is false. |
not | hash | No | Returns merge requests that do not match the parameters supplied. Accepts: labels, milestone, author_id, author_username, assignee_id, assignee_username, reviewer_id, reviewer_username, my_reaction_emoji. |
order_by | string | No | Returns merge requests ordered by created_at, updated_at, merged_at (introduced in GitLab 17.2), label_priority, priority, milestone_due, popularity, or title fields. Default is created_at. |
reviewer_id | integer or string | No | Returns merge requests which have the user as a reviewer with the given user id. None returns merge requests with no reviewers. Any returns merge requests with any reviewer. Mutually exclusive with reviewer_username. |
reviewer_username | string | No | Returns merge requests which have the user as a reviewer with the given username. None returns merge requests with no reviewers. Any returns merge requests with any reviewer. Mutually exclusive with reviewer_id. |
scope | string | No | Returns merge requests for the given scope: created_by_me, assigned_to_me, reviews_for_me, or all. reviews_for_me returns merge requests where the current user is assigned as a reviewer. Defaults to created_by_me. |
search | string | No | Search merge requests against their title and description. Combine with in attribute. |
sort | string | No | Returns merge requests sorted in asc or desc order. Default is desc. |
source_branch | string | No | Returns merge requests with the given source branch. |
state | string | No | Returns all merge requests (all) or just those that are opened, closed, locked, or merged. Defaults to all. |
target_branch | string | No | Returns merge requests with the given target branch. |
updated_after | datetime | No | Returns merge requests updated on or after the given date and time. Expected in ISO 8601 format (2019-03-15T08:00:00Z). |
updated_before | datetime | No | Returns merge requests updated on or before the given date and time. Expected in ISO 8601 format (2019-03-15T08:00:00Z). |
view | string | No | If simple, returns the iid, URL, title, description, and basic state of merge request. |
draft | boolean | No | Filter merge requests by their draft status. true returns only draft merge requests, false returns non-draft merge requests. Mutually exclusive with wip. |
wip | string | No | Deprecated in GitLab 19.0. Use draft instead. Filter merge requests by their wip status. yes returns only draft merge requests, no returns non-draft merge requests. |
with_labels_details | boolean | No | If true, response returns more details for each label in labels field: :name, :color, :description, :description_html, :text_color. Default is false. |
with_merge_status_recheck | boolean | No | If true, this projection requests (but does not guarantee) an asynchronous recalculation of the merge_status field. Enable the restrict_merge_status_recheck feature flag to ignore this attribute when requested by users without the Developer, Maintainer, or Owner role. |
If successful, returns 200 OK. If view is set to simple,
returns a subset of fields. Otherwise, response attributes include:
| Attribute | Type | Description |
|---|---|---|
allow_collaboration | boolean | If true, this fork allows collaboration from members who can merge to the target branch. Used only for merge requests from forks. |
allow_maintainer_to_push | boolean | Deprecated. Use allow_collaboration instead. |
approvals_before_merge | integer | Deprecated in GitLab 16.0. To configure approval rules, see the merge request approvals API instead. GitLab Premium and Ultimate only. |
assignee[] | object | Deprecated. Use assignees instead. |
assignees[] | array | Users assigned to the merge request. |
assignees.avatar_url | string | Full URL to the assignee’s avatar image. |
assignees.id | integer | The unique ID of the assignee. |
assignees.locked | boolean | If true, the assignee’s account is locked due to failed authentication attempts, and they cannot sign in until the lock expires or an administrator unlocks the account. |
assignees.name | string | Display name of the assignee. Might be redacted, based on current user’s permissions. |
assignees.public_email | string | The public email address of the assignee. |
assignees.state | string | Current state of the assignee’s user account. Possible values: active, blocked, or deactivated. |
assignees.username | string | Username of the merge request assignee. |
assignees.web_url | string | Full URL to the assignee’s profile page. |
author[] | object | Object with information about the user who created the merge request. |
author.avatar_url | string | Full URL to the author’s avatar image. |
author.bot | boolean | If true, the author is a bot. For a list of bot account types, see BOT_USER_TYPES. |
author.id | integer | The unique ID of the user who created the merge request. |
author.locked | boolean | If true, the author’s account is locked due to failed authentication attempts, and they cannot sign in until the lock expires or an administrator unlocks the account. |
author.name | string | Display name of the author. Might be redacted, based on current user’s permissions. |
author.public_email | string | The public email address of the author. |
author.state | string | Current state of the user account. Possible values: active, blocked, or deactivated. |
author.username | string | Username of the merge request author. |
author.web_url | string | Full URL to the author’s profile page. |
blocking_discussions_resolved | boolean | If true, all discussion threads in the merge request must be resolved before merging. |
closed_at | dateTime | Timestamp of when the merge request was closed. |
closed_by[] | object | Object with information about the user who closed the merge request. If null, the merge request is open. |
closed_by.avatar_url | string | Full URL to the closing user’s avatar image. |
closed_by.id | integer | The unique ID of the user who closed the merge request. |
closed_by.locked | boolean | If true, the closing user’s account is locked due to failed authentication attempts, and they cannot sign in until the lock expires or an administrator unlocks the account. |
closed_by.name | string | Display name of the closing user. Might be redacted, based on current user’s permissions. |
closed_by.public_email | string | The public email address of the closing user. |
closed_by.state | string | Current state of the closing user’s account. Possible values: active, blocked, or deactivated. |
closed_by.username | string | Username of the user who closed the merge request. |
closed_by.web_url | string | Full URL to the closing user’s profile page. |
created_at | dateTime | Timestamp of when the merge request was created. |
description | string | Description of the merge request. Contains Markdown rendered as HTML for caching. |
description_html | string | If render_html is set, the rendered HTML version of the description. |
detailed_merge_status | string | Detailed merge status information. See merge status for a list of potential values. |
discussion_locked | boolean | If true, discussions are locked. Only project members can add, edit, or resolve comments in locked discussions. |
downvotes | integer | Number of downvotes for the merge request. |
draft | boolean | If true, the merge request is marked in a draft state. |
force_remove_source_branch | boolean | If true, the project settings force the deletion of the source branch after merge. |
has_conflicts | boolean | If true, the merge request has conflicts and cannot merge. Dependent on the merge_status property. Returns false unless merge_status is cannot_be_merged. |
id | integer | The unique ID of the merge request. |
iid | integer | The internal ID of the merge request in the project. |
imported | boolean | If true, the merge request was imported. |
imported_from | string | Source of import, such as Bitbucket. |
labels[] | array | Array of labels assigned to the merge request. If with_labels_details is true, returns an array for each label. |
labels.archived | boolean | If with_labels_details is true, the label is archived. |
labels.color | string | If with_labels_details is true, the background color of the label. |
labels.description | string | If with_labels_details is true, the description text of the label. If null, the label has no description. |
labels.description_html. | string | If with_labels_details is true, the HTML-rendered description of the label. If null, the label has no description. |
labels.id | integer | If with_labels_details is true, the unique ID of the label. |
labels.name | string | If with_labels_details is true, the name of the label. |
labels.text_color | string | If with_labels_details is true, the text color for the label. |
merge_after | dateTime | If set, timestamp after which the merge request can be merged. Introduced in GitLab 17.8. |
merge_commit_sha | string | If set, the SHA of the merge request commit. Returns null until merged. |
merge_status | string | Status of the merge request. Use detailed_merge_status instead, which accounts for all potential statuses. Affects the has_conflicts property. For important notes on response data, see single merge request response notes. Deprecated in GitLab 15.6. |
merge_user | object | Object with information about the user who merged the merge request, set it to auto-merge, or null. |
merge_when_pipeline_succeeds | boolean | If true, the merge request is set to auto-merge. |
merged_at | dateTime | Timestamp of when the merge request merged. |
merged_by[] | object | Deprecated. Use merge_user instead. |
milestone[] | object | Object with information about the milestone assigned to the merge request. |
milestone.created_at | dateTime | Timestamp when the milestone was created. |
milestone.description | string | Description text of the milestone. If null, the milestone has no description. |
milestone.due_date | date | Due date for the milestone. If null, the milestone has no due date. |
milestone.expired | boolean | If true, the milestone has expired. |
milestone.group_id | integer | ID of the group the milestone belongs to. Included only if the milestone is a group milestone. |
milestone.id | integer | Unique ID of the milestone. |
milestone.iid | integer | Internal ID of the milestone in the project or group. |
milestone.project_id | integer | ID of the project the milestone belongs to. Included only if the milestone is a project milestone. |
milestone.start_date | date | Start date for the milestone. If null, the milestone has no start date |
milestone.state | string | Current state of the milestone, such as active or closed. |
milestone.title | string | Name of the milestone. |
milestone.updated_at | dateTime | Timestamp when the milestone was last updated. |
milestone.web_url | string | Full web URL to view the milestone. |
prepared_at | dateTime | Timestamp of when the merge request was prepared. This field populates one time, only after all the preparation steps complete, and is not updated if more changes are added. |
project_id | integer | The ID of the project containing the merge request. |
reference | string | Deprecated. Use references instead. |
references[] | object | Object with all internal references of the merge request. |
references.full | string | Complete reference to a merge request, including full project path, like gitlab-org/gitlab!123. When requested across groups or projects, identical to references.relative. |
references.relative | string | Reference relative to a specific project or group: !123 for a merge request in the current project, or other-project!123 for another project in the same group. |
references.short | string | Shortest possible reference to a merge request, like !123. When fetched from the merge request’s project, identical to references.relative. |
reviewers[] | array | Reviewers of the merge request. |
reviewers.avatar_url | string | Full URL to the reviewer’s avatar image. |
reviewers.id | integer | The unique ID of the reviewer. |
reviewers.locked | boolean | If true, the reviewer’s account is locked due to failed authentication attempts, and they cannot sign in until the lock expires or an administrator unlocks the account. |
reviewers.name | string | Display name of the reviewer. Might be redacted, based on current user’s permissions. |
reviewers.public_email | string | The public email address of the reviewer. |
reviewers.state | string | Current state of the reviewer’s user account. Possible values: active, blocked, or deactivated. |
reviewers.username | string | Username of the merge request reviewer. |
reviewers.web_url | string | Full URL to the reviewer’s profile page. |
sha | string | SHA of the head commit in the source branch. |
should_remove_source_branch | boolean | If true, the source branch is removed after merge. |
source_branch | string | Name of the source branch. |
source_project_id | integer | ID of the source project. |
squash | boolean | If true, squash commits when merging. |
squash_commit_sha | string | If set, the SHA of the squash commit. Empty until merged. |
squash_on_merge | boolean | If true, commits are squashed on merge. |
state | string | The current state of the merge request. Possible values: opened, closed, merged, or locked. |
target_branch | string | Name of the target branch. |
target_project_id | integer | ID of the target project. |
task_completion_status[] | object | Object with information on the task list completion status. |
task_completion_status.completed_count | integer | Number of completed task list items in the merge request description. Returns 0 if the merge request has no description or no task list items. |
task_completion_status.count | integer | Total number of task list items found in the merge request description. Returns 0 if the merge request has no description or no task list items. |
time_stats[] | object | Object with information on time tracking for this merge request. |
time_stats.human_time_estimate | string | Human-readable format of time_stats.time_estimate, like 3h 30m. |
time_stats.human_total_time_spent | string | Human-readable format of time_stats.total_time_spent, like 3h 30m. |
time_stats.time_estimate | integer | Estimated time to complete the merge request, in seconds. |
time_stats.total_time_spent | integer | Total time spent working on the merge request, in seconds. |
title | string | The merge request title. |
title_html | string | If render_html is true, the rendered HTML version of the title. |
updated_at | dateTime | Timestamp of when the merge request was last updated. |
upvotes | integer | Number of upvotes for the merge request. |
user_notes_count | integer | Number of user comments. |
web_url | string | Web URL to view the merge request. |
work_in_progress | boolean | Deprecated. Use draft instead. |
Other possible responses:
401 Unauthorizedif the access token is invalid.408 Request Timeoutif the database query times out.422 Unprocessable Entityif validation failed.429 Too Many Requestsif using thesearchparameter, and the request has been rate-limited.
Example response:
[
{
"id": 1,
"iid": 1,
"project_id": 3,
"title": "test1",
"description": "fixed login page css paddings",
"state": "merged",
"imported": false,
"imported_from": "none",
"merged_by": { // Deprecated and will be removed in API v5, use `merge_user` instead
"id": 87854,
"name": "Douwe Maan",
"username": "DouweM",
"state": "active",
"avatar_url": "https://gitlab.example.com/uploads/-/system/user/avatar/87854/avatar.png",
"web_url": "https://gitlab.com/DouweM"
},
"merge_user": {
"id": 87854,
"name": "Douwe Maan",
"username": "DouweM",
"state": "active",
"avatar_url": "https://gitlab.example.com/uploads/-/system/user/avatar/87854/avatar.png",
"web_url": "https://gitlab.com/DouweM"
},
"merged_at": "2018-09-07T11:16:17.520Z",
"merge_after": "2018-09-07T11:16:00.000Z",
"prepared_at": "2018-09-04T11:16:17.520Z",
"closed_by": null,
"closed_at": null,
"created_at": "2017-04-29T08:46:00Z",
"updated_at": "2017-04-29T08:46:00Z",
"target_branch": "main",
"source_branch": "test1",
"upvotes": 0,
"downvotes": 0,
"author": {
"bot": false,
"id": 1,
"name": "Administrator",
"username": "admin",
"state": "active",
"avatar_url": null,
"web_url" : "https://gitlab.example.com/admin"
},
"assignee": {
"id": 1,
"name": "Administrator",
"username": "admin",
"state": "active",
"avatar_url": null,
"web_url" : "https://gitlab.example.com/admin"
},
"assignees": [{
"name": "Miss Monserrate Beier",
"username": "axel.block",
"id": 12,
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/46f6f7dc858ada7be1853f7fb96e81da?s=80&d=identicon",
"web_url": "https://gitlab.example.com/axel.block"
}],
"reviewers": [{
"id": 2,
"name": "Sam Bauch",
"username": "kenyatta_oconnell",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/956c92487c6f6f7616b536927e22c9a0?s=80&d=identicon",
"web_url": "http://gitlab.example.com//kenyatta_oconnell"
}],
"source_project_id": 2,
"target_project_id": 3,
"labels": [
"Community contribution",
"Manage"
],
"draft": false,
"work_in_progress": false,
"milestone": {
"id": 5,
"iid": 1,
"project_id": 3,
"title": "v2.0",
"description": "Assumenda aut placeat expedita exercitationem labore sunt enim earum.",
"state": "closed",
"created_at": "2015-02-02T19:49:26.013Z",
"updated_at": "2015-02-02T19:49:26.013Z",
"due_date": "2018-09-22",
"start_date": "2018-08-08",
"web_url": "https://gitlab.example.com/my-group/my-project/milestones/1"
},
"merge_when_pipeline_succeeds": true,
"merge_status": "can_be_merged",
"detailed_merge_status": "not_open",
"sha": "8888888888888888888888888888888888888888",
"merge_commit_sha": null,
"squash_commit_sha": null,
"user_notes_count": 1,
"discussion_locked": null,
"should_remove_source_branch": true,
"force_remove_source_branch": false,
"allow_collaboration": false,
"allow_maintainer_to_push": false,
"web_url": "http://gitlab.example.com/my-group/my-project/merge_requests/1",
"references": {
"short": "!1",
"relative": "my-group/my-project!1",
"full": "my-group/my-project!1"
},
"time_stats": {
"time_estimate": 0,
"total_time_spent": 0,
"human_time_estimate": null,
"human_total_time_spent": null
},
"squash": false,
"task_completion_status":{
"count":0,
"completed_count":0
}
}
]Merge requests list response notes
- Listing merge requests might
not proactively update
merge_status(which also affects thehas_conflicts), as this can be an expensive operation. If you need the value of these fields from this endpoint, set thewith_merge_status_recheckparameter totruein the query. - For notes on merge request object fields, see single merge request response notes.
List project merge requests
List all merge requests for a project.
GET /projects/:id/merge_requests
GET /projects/:id/merge_requests?state=opened
GET /projects/:id/merge_requests?state=all
GET /projects/:id/merge_requests?iids[]=42&iids[]=43
GET /projects/:id/merge_requests?milestone=release
GET /projects/:id/merge_requests?labels=bug,reproduced
GET /projects/:id/merge_requests?my_reaction_emoji=starSupported attributes:
| Attribute | Type | Required | Description |
|---|---|---|---|
id | integer or string | Yes | The ID or URL-encoded path of the project. |
iids[] | integer array | No | Returns merge requests matching the provided IIDs. |
approved_by_ids[] | integer array | No | Returns merge requests approved by all the users with the given id, up to 5 users. None returns merge requests with no approvals. Any returns merge requests with an approval. |
approved_by_usernames[] | string array | No | Returns merge requests approved by all the users with the given username, up to 5 users. None returns merge requests with no approvals. Any returns merge requests with an approval. |
approver_ids[] | integer array | No | Returns merge requests which have all users with the specified id as eligible approvers according to the approval rules. None returns merge requests with no eligible approvers. Any returns merge requests with at least one eligible approver. Premium and Ultimate only. |
assignee_id | integer or string | No | Returns merge requests assigned to the given user id. None returns unassigned merge requests. Any returns merge requests with an assignee. Mutually exclusive with assignee_username. |
assignee_username[] | string array | No | Returns merge requests assigned to the given usernames. Mutually exclusive with assignee_id. |
author_id | integer | No | Returns merge requests created by the given user id. Mutually exclusive with author_username. |
author_username | string | No | Returns merge requests created by the given username. Mutually exclusive with author_id. |
created_after | datetime | No | Returns merge requests created on or after the given date and time. Expected in ISO 8601 format (2019-03-15T08:00:00Z). |
created_before | datetime | No | Returns merge requests created on or before the given date and time. Expected in ISO 8601 format (2019-03-15T08:00:00Z). |
deployed_after | datetime | No | Returns merge requests deployed after the given date and time. Expected in ISO 8601 format (2019-03-15T08:00:00Z). |
deployed_before | datetime | No | Returns merge requests deployed before the given date and time. Expected in ISO 8601 format (2019-03-15T08:00:00Z). |
merged_after | datetime | No | Returns merge requests merged on or after the given date and time. Expected in ISO 8601 format (2019-03-15T08:00:00Z). |
merged_before | datetime | No | Returns merge requests merged on or before the given date and time. Expected in ISO 8601 format (2019-03-15T08:00:00Z). |
environment | string | No | Returns merge requests deployed to the given environment. |
in | string | No | Change the scope of the search attribute. title, description, or a string joining them with comma. Default is title,description. |
labels | string | No | Returns merge requests matching a comma-separated list of labels. None lists all merge requests with no labels. Any lists all merge requests with at least one label. Predefined names are case-insensitive. |
merge_user_id | integer | No | Returns merge requests merged by the user with the given user id. Mutually exclusive with merge_user_username. Introduced in GitLab 17.0. |
merge_user_username | string | No | Returns merge requests merged by the user with the given username. Mutually exclusive with merge_user_id. Introduced in GitLab 17.0. |
milestone | string | No | Returns merge requests for a specific milestone. None returns merge requests with no milestone. Any returns merge requests that have an assigned milestone. |
my_reaction_emoji | string | No | Returns merge requests reacted by the authenticated user by the given emoji. None returns issues not given a reaction. Any returns issues given at least one reaction. |
not | hash | No | Returns merge requests that do not match the parameters supplied. Accepts: labels, milestone, author_id, author_username, assignee_id, assignee_username, reviewer_id, reviewer_username, my_reaction_emoji. |
order_by | string | No | Returns merge requests ordered by created_at, updated_at, merged_at (introduced in GitLab 17.2), label_priority, priority, milestone_due, popularity, or title fields. Default is created_at. |
reviewer_id | integer or string | No | Returns merge requests which have the user as a |