Skip to content

Merge a pull request

PUT
/repos/{owner}/{repo}/pulls/{pull_number}/merge

Merges a pull request into the base branch. This endpoint triggers notifications. Creating content too quickly using this endpoint may result in secondary rate limiting. For more information, see “Rate limits for the API” and “Best practices for using the REST API.”

API method documentation

owner
required
string

The account owner of the repository. The name is not case sensitive.

repo
required
string

The name of the repository without the .git extension. The name is not case sensitive.

pull_number
required
integer

The number that identifies the pull request.

Media type application/json
object
commit_title

Title for the automatic commit message.

string
commit_message

Extra detail to append to automatic commit message.

string
sha

SHA that pull request head must match to allow merge.

string
merge_method

The merge method to use.

string
Allowed values: merge squash rebase
Examples
Example response-if-merge-was-successful
{
"commit_title": "Expand enum",
"commit_message": "Add a new value to the merge_method enum"
}

If merge was successful

Media type application/json
Pull Request Merge Result

Pull Request Merge Result

object
sha
required
string
merged
required
boolean
message
required
string
Examples
Example response-if-merge-was-successful
{
"sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
"merged": true,
"message": "Pull Request successfully merged"
}

Forbidden

Media type application/json
Basic Error

Basic Error

object
message
string
documentation_url
string
url
string
status
string
Example generated
{
"message": "example",
"documentation_url": "example",
"url": "example",
"status": "example"
}

Resource not found

Media type application/json
Basic Error

Basic Error

object
message
string
documentation_url
string
url
string
status
string
Example generated
{
"message": "example",
"documentation_url": "example",
"url": "example",
"status": "example"
}

Method Not Allowed if merge cannot be performed

Media type application/json
object
message
string
documentation_url
string
Examples
Example response-if-merge-cannot-be-performed
{
"message": "Pull Request is not mergeable"
}

Conflict if sha was provided and pull request head did not match

Media type application/json
object
message
string
documentation_url
string
Examples
Example response-if-sha-was-provided-and-pull-request-head-did-not-match
{
"message": "Head branch was modified. Review and try the merge again."
}

Validation failed, or the endpoint has been spammed.

Media type application/json
Validation Error

Validation Error

object
message
required
string
documentation_url
required
string
errors
Array<object>
object
resource
string
field
string
message
string
code
required
string
index
integer
value
One of:
string
nullable
Example generated
{
"message": "example",
"documentation_url": "example",
"errors": [
{
"resource": "example",
"field": "example",
"message": "example",
"code": "example",
"index": 1,
"value": [
"example"
]
}
]
}