Lesstep
GitLab · merge requests · create merge request API · Checked October 24, 2026

GitLab: why the merge request was not created

Creating a merge request through the API (POST /projects/:id/merge_requests with source_branch, target_branch and title) is refused with 409, 422, 400 or 403, and GitLab's API documentation does not list what each means. All of this is from GitLab's source (lib/api/merge_requests.rb, handle_merge_request_errors! in lib/api/helpers/merge_requests_helpers.rb, the validations in app/models/merge_request.rb and MergeRequests::CreateService), read on October 24, 2026.

The answers

A token without the api scope is refused with 403 too, but that answer says insufficient_scope; see which scope to add. A project path that does not exist, or that you cannot see, answers 404; see address or access.

Where it stands

curl -H "PRIVATE-TOKEN: your-token" "https://gitlab.com/api/v4/projects/group%2Fproject/merge_requests?state=opened&source_branch=feature&target_branch=main"

This lists the open merge requests from feature into main: the one the 409 names is among them. To see whether GitLab has the branch, …/projects/group%2Fproject/repository/branches/feature answers 404 when it does not. Use your own server's address instead of gitlab.com.

What to do

In IntelliJ IDEA: "Failed to create merge request", "No changes between …", "Unable to create merge request from … to …" and "Commits will be pushed to a protected branch"

The New Merge Request tab of the GitLab support built into IntelliJ IDEA checks the two branches before you create, then sends the same POST /projects/:id/merge_requests as above. In the source (checked October 30, 2026; IntelliJ IDEA: GitLabMergeRequestCreateViewModel.kt, GitLabMergeRequestCreateStatusComponentFactory.kt, GitLabMergeRequestsApi.kt, GitSharedSettings.java):

GitLab merge requests in IntelliJ IDEA

Merge Request Inbox for GitLab, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, creates a merge request from the branch you are on. When GitLab does not have the branch yet, it offers to push it first; it does not accept the same branch as the target; and when GitLab answers 409, it says that a merge request for this branch is already open, with GitLab's words, which name it. For 403, it says that your role in the project or its settings may not let your account do it; other refusals in GitLab's words. Reading is free; creating, approving, commenting and merging are Pro (US$1.50 a month, with a 30-day trial).

GITLAB is a trademark of GitLab Inc.; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by GitLab Inc. or JetBrains.

More: GitLab merge refused (405, 409, 422) · GitLab approval refused (401, 409) · GitLab comment or thread refused (400, 403) · GitLab "insufficient_scope" · GitLab 401 "invalid_token" · GitLab 404 "Project Not Found" · GitLab rebase refused or failed (403, 409) · GitLab merge request list refused (400, 404) · GitLab merge request changes cut short ("1000+", too_large) · GitLab 429 "Retry later" (rate limits) · GitLab "compare_timeout": true (diff limits) · GitLab merge request plugins for IntelliJ IDEA, compared · 日本語