---
title: "Merge a pull request asynchronously"
method: PUT
path: "/repos/{owner}/{repo}/pulls/{pull_number}/merge-async"
tags: ["pulls"]
---

# Merge a pull request asynchronously

`PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge-async`

Merges a pull request into the base branch in the background. Merging in this way allows certain types of errors to be retried, and avoids the risk of timeouts for particularly complex merges.

This is the required method for merging stacked PRs, but also supports unstacked PRs. When using this endpoint to merge a stacked pull request, all pull requests in the stack up to and including the requested PR will be merged into the base branch.

The response includes a UUID that can be used to fetch the result of the merge. If another asynchronous merge request has already been made for this pull request, the UUID of that request will be returned instead with a 409 response status to indicate that the merge options may be different from those that were requested. If there isn't an existing asynchronous merge request, a 202 response status is used.

If the pull request is already merged, the merge commit OID will be returned immediately with a 200 status.

If the pull request cannot be merged (e.g. because it is closed, or still a draft) this result will be returned immediately with a 400 response status. Branch protection rules and repository rules are not run at this stage, only basic pull request state checks are performed.

## Path parameters

- `owner` string, required
- `repo` string, required
- `pull_number` integer, required

## Request body

- object, nullable
  - `commit_title` string — Title for the automatic commit message.
  - `commit_message` string — Extra detail to append to automatic commit message.
  - `sha` string — SHA that pull request head must match to allow merge. If not provided, the current head of the PR at the time of the request will be used; if the PR is pushed in between the merge being requested and being executed, the merge will be cancelled.
  - `merge_method` 'merge' | 'squash' | 'rebase' — The merge method to use.
  - `merge_action` 'default' | 'direct_merge' | 'merge_queue' — The action that will be taken to merge the pull request. `direct_merge` merges the pull request directly without using a merge queue; `merge_queue` adds the pull request to a merge queue; `default` selects the most appropriate option.

## Response `200`

if the pull request was already merged, or is already in a merge queue

- PullRequestMergeAsyncResult — Pull Request Merge Async Result
  - `status` 'pending' | 'merged' | 'enqueued' | 'failed', required
  - `details` union, required
    - object — When an asynchronous merge request was created or already existed
      - `message` string, required
      - `uuid` string, required
      - `merge_method` 'default' | 'merge' | 'squash' | 'rebase', required
      - `merge_action` 'default' | 'merge_queue' | 'direct_merge', required
      - `expected_head_sha` string, required — SHA that the pull request head must match for the enqueued merge to proceed.
    - object — When the pull request cannot be merged
      - `message` string, required
    - object — When the pull request is already merged
      - `message` string, required
      - `sha` string, required

## Other responses

- `202` — if the merge request was accepted and will run in the background
- `400` — if the pull request is not ready to be merged, e.g. because it is closed
- `403` — Forbidden
- `404` — Resource not found
- `409` — if there is an existing merge request already enqueued for this pull request
- `422` — Validation failed, or the endpoint has been spammed.

---

[API](https://skmtc.net/github/apis/rest-api.md) · [All operations](https://skmtc.net/github/apis/rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/github/rest-api/versions/80850db290cd/schema)
