Merge a pull request
curl --request POST \
--url https://api.runaether.dev/pull-requests/{pullRequestID}/github/merge \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expected_head_sha": "<string>",
"expected_pr_number": 2,
"idempotency_key": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"delete_branch": true
}
'import requests
url = "https://api.runaether.dev/pull-requests/{pullRequestID}/github/merge"
payload = {
"expected_head_sha": "<string>",
"expected_pr_number": 2,
"idempotency_key": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"delete_branch": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
expected_head_sha: '<string>',
expected_pr_number: 2,
idempotency_key: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
delete_branch: true
})
};
fetch('https://api.runaether.dev/pull-requests/{pullRequestID}/github/merge', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.runaether.dev/pull-requests/{pullRequestID}/github/merge",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'expected_head_sha' => '<string>',
'expected_pr_number' => 2,
'idempotency_key' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'delete_branch' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.runaether.dev/pull-requests/{pullRequestID}/github/merge"
payload := strings.NewReader("{\n \"expected_head_sha\": \"<string>\",\n \"expected_pr_number\": 2,\n \"idempotency_key\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"delete_branch\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.runaether.dev/pull-requests/{pullRequestID}/github/merge")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"expected_head_sha\": \"<string>\",\n \"expected_pr_number\": 2,\n \"idempotency_key\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"delete_branch\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.runaether.dev/pull-requests/{pullRequestID}/github/merge")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"expected_head_sha\": \"<string>\",\n \"expected_pr_number\": 2,\n \"idempotency_key\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"delete_branch\": true\n}"
response = http.request(request)
puts response.read_body{
"checks": [
{
"check_run_id": 4503599627370495,
"name": "<string>",
"status": "<string>",
"summary_truncated": true,
"completed_at": "2023-11-07T05:31:56Z",
"conclusion": "<string>",
"details_url": "<string>",
"started_at": "2023-11-07T05:31:56Z",
"summary": "<string>"
}
],
"merge_box": {
"additions": 1,
"author_login": "<string>",
"checks_failed": 1,
"checks_passed": 1,
"checks_total": 1,
"commits": 1,
"deletions": 1,
"draft": true,
"head_is_fork": true,
"head_sha": "<string>",
"html_url": "<string>",
"pr_number": 2,
"ready_for_merge": true,
"title": "<string>",
"base_branch": "<string>",
"base_sha": "<string>",
"ci_status": "pending",
"head_branch": "<string>",
"mergeable_state": "clean",
"merged_at": "2023-11-07T05:31:56Z",
"stack_children": [
{
"html_url": "<string>",
"pr_number": 2,
"pull_request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"state": "open",
"title": "<string>"
}
],
"stack_parent": {
"html_url": "<string>",
"pr_number": 2,
"pull_request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"state": "open",
"title": "<string>"
},
"state": "open"
},
"reviewers": [
{
"decision": "approved",
"is_bot": true,
"kind": "user",
"login": "<string>"
}
],
"reviews": [
{
"author_is_bot": true,
"author_login": "<string>",
"body": "<string>",
"github_review_id": 4503599627370496,
"html_url": "<string>",
"state": "<string>",
"submitted_at": "2023-11-07T05:31:56Z"
}
]
}{
"code": "account_deleting",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "account_deleting",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "account_deleting",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "account_deleting",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "account_deleting",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "account_deleting",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "account_deleting",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "account_deleting",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "account_deleting",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "account_deleting",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}Pull Requests
Merge a pull request
Merges a pull request with the chosen method at the head and number the caller confirmed, optionally deleting its head branch, and answers with the pull request read after the merge.
Use this tool when you need to:
- Merge a reviewed pull request by squash, rebase or merge commit
- Merge and clean up the head branch in one call, without merging a commit pushed after the review
Examples:
- POST /pull-requests/{pullRequestID}/github/merge {"idempotency_key": "6f1c1f6e-8a1e-4c55-9d6e-3f7a2b1c0d11", "method": "squash", "expected_head_sha": "9fceb02d0ae598e95dc970b74767f19372d61af8", "expected_pr_number": 482}
- POST /pull-requests/6f1c2a9e-3b7d-4c55-9a2e-0d8b1f4e7c21/github/merge {"idempotency_key": "8d2c4b6a-1f3e-4a5b-9c7d-2e4f6a8b0c1d", "method": "rebase", "expected_head_sha": "9fceb02d0ae598e95dc970b74767f19372d61af8", "expected_pr_number": 482, "delete_branch": true}
Hints:
- pullRequestID is the pull request's uuid and org_id an optional uuid naming the owning organization to act in, the org_id getPullRequest answers. Required: idempotency_key (a uuid), method (squash, rebase or merge), expected_head_sha (exactly 40 lowercase hex characters) and expected_pr_number (an integer of at least 1); delete_branch is optional, false when omitted.
- The schema answers 422 for a missing, malformed or unknown field, and a body that is not JSON is 400.
- expected_pr_number other than this pull request's number is a 409 before GitHub is called or the key claimed. GitHub merges only at expected_head_sha, so a head that moved past it, or a pull request GitHub will not merge (conflicts, required checks, branch protection), is a 409 carrying GitHub's reason; a method the repository disallows is a 422 with GitHub's message.
- delete_branch true deletes the head branch after the merge, and only while it still points at the merged head: a fork's branch is refused with 422 fork_branch_delete_unsupported before anything merges or the key is claimed, a branch a push moved is kept and answered with a 409 naming the merge commit, and another deletion failure is a 502 naming it.
- The idempotency key is the caller's on this pull request and claimed before GitHub is called: a completed key does not merge again and answers the pull request as read now, and a key whose first attempt failed or never finished is a 409; every refusal after the claim burns the key.
- These 409s carry the generic code conflict, not head_moved or idempotency_key_conflict.
- Answers 200 with the GitHubPullRequest, the shape getPullRequestGithub reads, as read after the merge; the mirror records the merge before its webhook arrives.
- Use getPullRequestGithub instead to check ready_for_merge and read the head_sha to confirm, and closePullRequestGithub to close without merging.
- A member with a product role (owner, admin or member) in an owning organization of the pull request (one whose task published or reviewed it, or with a project on its repository) who holds push permission on its repository may call it; the merge is made through Aether's GitHub App installation.
- A caller who can read the repository but not push is refused with 403 github_push_access_required, a viewer or billing member with 403 org_role_insufficient and a suspended organization with 403 org_suspended, each when no other owning organization admits the caller, and an agent host's grant with 403 agent_host_route_not_allowed; 503 when the membership check is unavailable.
- A pull request that does not exist, one no organization of the caller owns, an org_id that does not own it and one whose repository the caller cannot see on GitHub (no usable GitHub authorization for its installation included) answer the same 404; omitting org_id while more than one owning organization admits the caller is a 422 org_id_required, a GitHub access check that cannot run is a 500, and another GitHub failure a 502.
POST
/
pull-requests
/
{pullRequestID}
/
github
/
merge
Merge a pull request
curl --request POST \
--url https://api.runaether.dev/pull-requests/{pullRequestID}/github/merge \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expected_head_sha": "<string>",
"expected_pr_number": 2,
"idempotency_key": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"delete_branch": true
}
'import requests
url = "https://api.runaether.dev/pull-requests/{pullRequestID}/github/merge"
payload = {
"expected_head_sha": "<string>",
"expected_pr_number": 2,
"idempotency_key": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"delete_branch": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
expected_head_sha: '<string>',
expected_pr_number: 2,
idempotency_key: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
delete_branch: true
})
};
fetch('https://api.runaether.dev/pull-requests/{pullRequestID}/github/merge', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.runaether.dev/pull-requests/{pullRequestID}/github/merge",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'expected_head_sha' => '<string>',
'expected_pr_number' => 2,
'idempotency_key' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'delete_branch' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.runaether.dev/pull-requests/{pullRequestID}/github/merge"
payload := strings.NewReader("{\n \"expected_head_sha\": \"<string>\",\n \"expected_pr_number\": 2,\n \"idempotency_key\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"delete_branch\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.runaether.dev/pull-requests/{pullRequestID}/github/merge")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"expected_head_sha\": \"<string>\",\n \"expected_pr_number\": 2,\n \"idempotency_key\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"delete_branch\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.runaether.dev/pull-requests/{pullRequestID}/github/merge")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"expected_head_sha\": \"<string>\",\n \"expected_pr_number\": 2,\n \"idempotency_key\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"delete_branch\": true\n}"
response = http.request(request)
puts response.read_body{
"checks": [
{
"check_run_id": 4503599627370495,
"name": "<string>",
"status": "<string>",
"summary_truncated": true,
"completed_at": "2023-11-07T05:31:56Z",
"conclusion": "<string>",
"details_url": "<string>",
"started_at": "2023-11-07T05:31:56Z",
"summary": "<string>"
}
],
"merge_box": {
"additions": 1,
"author_login": "<string>",
"checks_failed": 1,
"checks_passed": 1,
"checks_total": 1,
"commits": 1,
"deletions": 1,
"draft": true,
"head_is_fork": true,
"head_sha": "<string>",
"html_url": "<string>",
"pr_number": 2,
"ready_for_merge": true,
"title": "<string>",
"base_branch": "<string>",
"base_sha": "<string>",
"ci_status": "pending",
"head_branch": "<string>",
"mergeable_state": "clean",
"merged_at": "2023-11-07T05:31:56Z",
"stack_children": [
{
"html_url": "<string>",
"pr_number": 2,
"pull_request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"state": "open",
"title": "<string>"
}
],
"stack_parent": {
"html_url": "<string>",
"pr_number": 2,
"pull_request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"state": "open",
"title": "<string>"
},
"state": "open"
},
"reviewers": [
{
"decision": "approved",
"is_bot": true,
"kind": "user",
"login": "<string>"
}
],
"reviews": [
{
"author_is_bot": true,
"author_login": "<string>",
"body": "<string>",
"github_review_id": 4503599627370496,
"html_url": "<string>",
"state": "<string>",
"submitted_at": "2023-11-07T05:31:56Z"
}
]
}{
"code": "account_deleting",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "account_deleting",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "account_deleting",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "account_deleting",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "account_deleting",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "account_deleting",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "account_deleting",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "account_deleting",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "account_deleting",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "account_deleting",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}Authorizations
Query Parameters
The pull request's owning organization to act in: the org_id the PullRequest carries. Omitted, getPullRequest and the review page's operations (its review, file, head snapshot and stack) act in the owning organization getPullRequest ranks first, and a console operation refuses with 422 org_id_required when more than one of the caller's organizations owns the pull request.
Body
application/json
True: delete the head branch once the merge succeeds, and only while it still points at the merged head; a branch a push moved is kept and answered with 409 naming the merge commit. Refused with 422 fork_branch_delete_unsupported before merging when the head branch lives in a fork. False or omitted: the branch stays.