> ## Documentation Index
> Fetch the complete documentation index at: https://docs.runaether.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Merge a pull request

> Merges the exact pull request row named by pullRequestID with the chosen method, pinned to the head commit and the number the caller confirmed. A method the repository's settings disallow is refused with 422 carrying GitHub's message. delete_branch deletes 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. delete_branch is refused with 422 fork_branch_delete_unsupported before merging when the branch lives in a fork (merge_box.head_is_fork). The idempotency key is actor-scoped and claimed before GitHub is called: a completed merge replays its result, while a failed or unfinished one conflicts without merging again. Additionally requires the caller to hold push permission on the repository: a caller who can read the pull request but not push to its repository is refused with 403 github_push_access_required. Requires membership in the owning organization of a task linked to this pull request — the task that published it or a task that reviewed it — and current GitHub access to the repository. 404 covers an unknown pull request, one linked to no organization the caller belongs to, and one whose GitHub access the caller has lost; the three are deliberately indistinguishable.



## OpenAPI

````yaml api-reference/openapi.account.json POST /pull-requests/{pullRequestID}/github/pr/merge
openapi: 3.1.0
info:
  title: Aether Account & Integrations API
  version: 0.1.0
  description: >-
    Account, billing, and integration-management endpoints used by the Aether
    web app and CLI. Root-mounted; NOT part of the versioned /v1 contract.
servers:
  - url: https://api.runaether.dev
security:
  - bearerAuth: []
paths:
  /pull-requests/{pullRequestID}/github/pr/merge:
    post:
      tags:
        - pull-requests
      summary: Merge a pull request
      description: >-
        Merges the exact pull request row named by pullRequestID with the chosen
        method, pinned to the head commit and the number the caller confirmed. A
        method the repository's settings disallow is refused with 422 carrying
        GitHub's message. delete_branch deletes 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.
        delete_branch is refused with 422 fork_branch_delete_unsupported before
        merging when the branch lives in a fork (merge_box.head_is_fork). The
        idempotency key is actor-scoped and claimed before GitHub is called: a
        completed merge replays its result, while a failed or unfinished one
        conflicts without merging again. Additionally requires the caller to
        hold push permission on the repository: a caller who can read the pull
        request but not push to its repository is refused with 403
        github_push_access_required. Requires membership in the owning
        organization of a task linked to this pull request — the task that
        published it or a task that reviewed it — and current GitHub access to
        the repository. 404 covers an unknown pull request, one linked to no
        organization the caller belongs to, and one whose GitHub access the
        caller has lost; the three are deliberately indistinguishable.
      operationId: mergePullRequestGithubPR
      parameters:
        - in: path
          name: pullRequestID
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MergeTaskPRRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MergeTaskPRResponse'
          description: OK
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Bad Request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/ErrorResponse'
                  - $ref: '#/components/schemas/OrgAuthorizationErrorResponse'
          description: Forbidden
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Not Found
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Conflict
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unprocessable Entity
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal Server Error
        '502':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Bad Gateway
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Service Unavailable
components:
  schemas:
    MergeTaskPRRequest:
      additionalProperties: false
      properties:
        delete_branch:
          description: >-
            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.
          type: boolean
        expected_head_sha:
          description: >-
            the exact 40-character lowercase head commit SHA the user reviewed;
            GitHub refuses the merge if the PR head has moved past it
          maxLength: 40
          minLength: 40
          pattern: ^[0-9a-f]{40}$
          type: string
        expected_pr_number:
          description: >-
            the number of the pull request the user reviewed; the merge is
            refused with 409 if the task's primary published pull request is no
            longer this one
          format: int64
          minimum: 1
          type: integer
        idempotency_key:
          description: >-
            client-generated stable key for this merge; a retry with the same
            key replays the first result without merging again
          minLength: 8
          type: string
        method:
          description: >-
            GitHub's merge method: squash, rebase, or merge (a merge commit). A
            method the repository's settings disallow is refused with 422
            carrying GitHub's message.
          enum:
            - squash
            - rebase
            - merge
          type: string
      required:
        - idempotency_key
        - method
        - expected_head_sha
        - expected_pr_number
      type: object
    MergeTaskPRResponse:
      additionalProperties: false
      properties:
        sha:
          minLength: 1
          type: string
      required:
        - sha
      type: object
    ErrorResponse:
      additionalProperties: false
      properties:
        code:
          type: string
        error:
          minLength: 1
          type: string
        errors:
          items:
            $ref: '#/components/schemas/ErrorDetail'
          type: array
      required:
        - error
      type: object
    OrgAuthorizationErrorResponse:
      additionalProperties: false
      properties:
        code:
          enum:
            - org_membership_required
            - org_role_insufficient
            - org_suspended
            - account_deleting
          type: string
        error:
          minLength: 1
          type: string
      required:
        - error
        - code
      type: object
    ErrorDetail:
      additionalProperties: false
      properties:
        location:
          description: >-
            Where the error occurred, e.g. 'body.items[3].tags' or
            'path.thing-id'
          type: string
        message:
          description: Error message text
          type: string
        value:
          description: The value at the given location
      type: object
  securitySchemes:
    bearerAuth:
      bearerFormat: JWT
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.