Skip to content
GitmoapAPIBeta
Reviewmerge-requests
POST/repositories/{repo_id}/merge-requests

Create a merge request

create_mr
  • merge_request:create
    A token needs the merge_request:create scope: Create merge requestsGranted by mcp_agent_write, write_api, write_repository.Every operation this scope unlocks
  • Audited · mutation

    x-gitmoap-audit: {"kind":"audited","arg":"mutation"}

  • Quota · open mrs per repo

    x-gitmoap-quota: {"kind":"enforced","arg":"open_mrs_per_repo"}

Opens a merge request from a source branch into a target branch. Both branches must exist and differ, and a target that would close a loop in a stack is refused, as is a second open merge request for the same pair. Open it as a draft to share the changes before they are ready to merge.

Parameters

Path
  • repo_idRepositoryId (string · uuid)Repository ID

Request body

application/json
  • source_branchBranchName (string)
  • target_branchBranchName (string)
  • titleMrTitle (string)
  • descriptionMrDescription (string) or nulloptional
  • draftboolean or nulloptional
Request body exampleSynthesized example
{
"source_branch": "fix/payload-build-pin",
"target_branch": "main",
"title": "Draw the region map from operation density"
}

Responses

201Merge request createdapplication/json
  • created_atstring
  • created_byPrincipalId (string · uuid)The person or agent who opened it.
  • is_draftboolean
  • merge_request_idMergeRequestId (integer · int64)
  • repository_idRepositoryId (string · uuid)
  • source_branchBranchName (string)
  • source_branch_deletedboolean
  • source_branch_headCommitHash (string)
  • statusMergeRequestStatusopenmergedclosed
  • target_branchBranchName (string)
  • target_branch_headCommitHash (string)
  • titleMrTitle (string)
  • updated_atstring
  • author_can_pushboolean or nulloptionalWhether the author can push to the repository — false for a drive-by contributor's merge request. Absent where it was not computed.
  • closed_atstring or nulloptional
  • closed_byPrincipalId (string · uuid) or nulloptional
  • descriptionMrDescription (string) or nulloptional
  • merge_commit_shaCommitHash (string) or nulloptional
  • merged_atstring or nulloptional
  • merged_byPrincipalId (string · uuid) or nulloptional
  • restack_requiredbooleanoptionalPrecise restack signal — set when this MR's downstack was squash-merged (a rebase is genuinely required to drop the duplicated diff). Distinct from the advisory commits_behind. Reset on the MR's next source-advancing write.
  • stack_summaryStackSummary or nulloptionalThe neighbouring merge requests in this stack. Returned when fetching a single merge request, not in listings.
    • The StackSummary schema
    • has_downstackboolean
    • has_upstackboolean
    • downstack_mr_idMergeRequestId (integer · int64) or nulloptional
    • upstack_mr_idsarray of MergeRequestId (integer · int64)optional
  • versioninteger · int64optional0–∞Optimistic-concurrency counter. Bumped on every write; writes condition on the read value.
201 exampleSynthesized example
{
"created_at": "2026-10-08T17:25:40Z",
"created_by": "a3f1c2d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"is_draft": false,
"merge_request_id": 42,
"repository_id": "5b0e7c2a-9d14-4e8b-a6f1-2c3d4e5f6a70",
"source_branch": "fix/payload-build-pin",
"source_branch_deleted": false,
"source_branch_head": "592bbcd629d9b82f0c2583b4b3633a0f1241f778",
"status": "open",
"target_branch": "main",
"target_branch_head": "95942360552f83f73af0f1169980687856c34ba7",
"title": "Label every synthesized example",
"updated_at": "2026-10-13T03:30:38Z",
"author_can_push": false,
"closed_at": "2026-10-12T20:17:50Z",
"closed_by": "c9d8e7f6-a5b4-4c3d-9e2f-1a0b9c8d7e6f",
"description": "Renders each region as density contours of its operations.",
"merge_commit_sha": "1b9593db46da1a0d67ba7879043328b8c8d046af",
"merged_at": "2026-10-09T00:27:19Z",
"merged_by": "b7e2d1c0-9f8e-4d7c-a6b5-c4d3e2f1a0b9",
"restack_required": false,
"stack_summary": {
"has_downstack": false,
"has_upstack": false,
"downstack_mr_id": 42,
"upstack_mr_ids": [
42,
42
]
},
"version": 16
}
400Invalid requestapplication/json
Error codes
  • BAD_REQUESTThe request is malformed: a parameter or a body field is not a well-formed value of its type
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
400 exampleSynthesized example
{
"error": {
"code": "code-2f6f",
"message": "Inline scalar newtypes but keep their brand"
}
}
401Unauthenticated — no credential, or an invalid oneapplication/json
Error codes
  • UNAUTHORIZEDNo credential was sent, or the one sent is invalid, expired or revoked
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
401 exampleSynthesized example
{
"error": {
"code": "code-7cc7",
"message": "Pin a page's payload to the build that rendered it"
}
}
403Forbidden — the caller's access level or token scope is insufficientapplication/json
Error codes
  • FORBIDDENYou are signed in but may not do this here; reason names the permission or the rule that refused it
  • INSUFFICIENT_SCOPEThe access token lacks the scope this operation needs; required_scope names it
  • PERMISSION_REQUIREDYou need a permission you do not hold here; the message names it
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
403 exampleSynthesized example
{
"error": {
"code": "code-c12f",
"message": "Pin a page's payload to the build that rendered it"
}
}
404Not found — or found and private, which is masked as absentapplication/json
Error codes
  • NOT_FOUNDThe resource does not exist — or exists and you cannot see it: a private resource you have no access to answers exactly as an absent one does
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
404 exampleSynthesized example
{
"error": {
"code": "code-0375",
"message": "Pin a page's payload to the build that rendered it"
}
}
409An open merge request already proposes this source into this targetapplication/json
Error codes
  • CONFLICTThe request conflicts with the resource's current state; reason says how
  • LEGAL_ACCEPTANCE_REQUIREDAccept the current Terms of Service before changing anything; reading stays open
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
409 exampleSynthesized example
{
"error": {
"code": "code-2937",
"message": "Stream pipeline status into the run header"
}
}
429Open merge-request limit reached for this repositoryapplication/json
Error codes
  • TOO_MANY_REQUESTSRetryableA quota, a rate limit or a transfer budget is spent. When the response carries Retry-After, retry after that many seconds
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
429 exampleSynthesized example
{
"error": {
"code": "code-e5f8",
"message": "Stream pipeline status into the run header"
}
}

CLI

gitmoap mr create

  • --repo-ididRepository ID (id or owner/repo path)
  • --descriptionstringoptional
  • --draftflagoptional
  • --source-branchstring
  • --target-branchstring
  • --titlestring

Used in these guides