Sample - GitHub REST API
POST/repos/{owner}/{repo}/merges

Merge a branch or commit

Merges a head branch or commit into a base branch in a repository. Supply base and head to identify the branches or commit involved, and optionally provide commit_message for the resulting merge commit. A successful merge returns the resulting commit, while an already completed merge returns no content.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

2 parameters · 3 body fields
ownerstringrequired
The account owner of the repository; the name is not case sensitive.
repostringrequired
The repository name without the `.git` extension; the name is not case sensitive.

Merge request identifying the base branch, head branch or commit, and optional commit message.

basestringrequired
The name of the base branch that the head will be merged into.
headstringrequired
The head to merge. This can be a branch name or a commit SHA1.
commit_messagestringoptional
Commit message to use for the merge commit. If omitted, a default message will be used.

6 status codes
201Returns the resulting merge commit, including its SHA, repository URLs, commit metadata, parent commits, statistics, and changed files.
urlstringrequired
shastringrequired
node_idstringrequired
html_urlstringrequired
comments_urlstringrequired
commitobjectrequired
authorobjectrequired
A GitHub user.
committerobjectrequired
A GitHub user.
parentsarray<object>required
statsobjectoptional
filesarray<DiffEntry>optional
204Returned when the requested head has already been merged into the base branch.
403Returned when the authenticated user is not permitted to merge the specified repository branches.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
404Returned when the repository, base branch, or head branch or commit does not exist.
409Returned when the base and head cannot be merged because of a merge conflict.
422Returned when validation fails or the endpoint has been spammed.
messagestringrequired
documentation_urlstringrequired
errorsarray<object>optional

Error handling

A 403 is returned when the authenticated user is not permitted to merge in the repository. A 404 is returned when the repository, base, or head does not exist. A 409 is returned when the branches cannot be merged cleanly, and a 422 is returned when validation fails or the endpoint has been spammed. base and head are required; head may be a branch name or commit SHA.