Sample - GitHub REST API
PUT/repos/{owner}/{repo}/pulls/{pull_number}/merge

Merge a pull request

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."

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

3 parameters · 4 body fields
ownerstringrequired
The account owner of the repository. The name is not case sensitive.
repostringrequired
The name of the repository without the `.git` extension. The name is not case sensitive.
pull_numberintegerrequired
The number that identifies the pull request.
commit_titlestringoptional
Title for the automatic commit message.
commit_messagestringoptional
Extra detail to append to automatic commit message.
shastringoptional
SHA that pull request head must match to allow merge.
merge_methodstringoptional
The merge method to use.
Allowed:mergesquashrebase

6 status codes
200if merge was successful
shastringrequired
mergedbooleanrequired
messagestringrequired
403Forbidden
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
404Resource not found
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
405Method Not Allowed if merge cannot be performed
messagestringoptional
documentation_urlstringoptional
409Conflict if sha was provided and pull request head did not match
messagestringoptional
documentation_urlstringoptional
422Validation failed, or the endpoint has been spammed.
messagestringrequired
documentation_urlstringrequired
errorsarray<object>optional

Error handling

A 403 is returned: Forbidden. A 404 is returned: Resource not found. A 405 is returned: Method Not Allowed if merge cannot be performed. A 409 is returned: Conflict if sha was provided and pull request head did not match. A 422 is returned: Validation failed, or the endpoint has been spammed.