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



## OpenAPI

````yaml api-reference/openapi.json POST /pull-requests/{pullRequestID}/github/merge
openapi: 3.1.0
info:
  title: Aether API
  version: 0.1.0
servers:
  - url: https://api.runaether.dev
security:
  - bearerAuth: []
paths:
  /pull-requests/{pullRequestID}/github/merge:
    post:
      tags:
        - pull-requests
      summary: Merge a pull request
      description: >-
        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.
      operationId: mergePullRequestGithub
      parameters:
        - in: path
          name: pullRequestID
          required: true
          schema:
            format: uuid
            type: string
        - description: >-
            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.
          explode: false
          in: query
          name: org_id
          schema:
            description: >-
              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.
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MergeTaskPRRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GitHubPullRequest'
          description: OK
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PullRequestsErrorResponse'
          description: Bad Request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PullRequestsErrorResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/PullRequestsErrorResponse'
                  - $ref: '#/components/schemas/OrgAuthorizationErrorResponse'
          description: Forbidden
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PullRequestsErrorResponse'
          description: Not Found
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PullRequestsErrorResponse'
          description: Conflict
        '410':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PullRequestsErrorResponse'
          description: Gone
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PullRequestsErrorResponse'
          description: Unprocessable Entity
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PullRequestsErrorResponse'
          description: Internal Server Error
        '502':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PullRequestsErrorResponse'
          description: Bad Gateway
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PullRequestsErrorResponse'
          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 before GitHub is called when the addressed pull
            request's number is another
          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
          format: uuid
          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
    GitHubPullRequest:
      additionalProperties: false
      properties:
        checks:
          items:
            $ref: '#/components/schemas/TaskGitHubPullRequestCheck'
          type: array
        merge_box:
          $ref: '#/components/schemas/TaskGitHubPullRequestMergeBox'
        reviewers:
          items:
            $ref: '#/components/schemas/TaskGitHubPullRequestReviewer'
          type: array
        reviews:
          items:
            $ref: '#/components/schemas/TaskGitHubPullRequestReview'
          type: array
      required:
        - merge_box
        - checks
        - reviews
        - reviewers
      type: object
    PullRequestsErrorResponse:
      additionalProperties: false
      properties:
        code:
          enum:
            - account_deleting
            - aether_inference_unserved
            - agent_pr_blocked
            - agent_pr_pending
            - agent_profile_changed
            - agent_starts_off
            - agent_uses_own_sign_in
            - answer_on_its_way
            - app_identity_missing
            - attachments_unsupported
            - attribution_unavailable
            - bad_gateway
            - bad_request
            - base_branch_unusable
            - branch_exists
            - caller_inactive
            - chat_archived
            - chat_being_forked
            - chat_moved
            - chat_not_removable
            - chat_settings_fixed
            - chats_not_addable
            - checkout_not_archivable
            - cli_upgrade_required
            - client_outdated
            - computer_cli_outdated
            - computer_starts_no_agents
            - computer_starts_no_forks
            - computer_unreachable
            - conflict
            - connection_creator_only
            - connection_harness_mismatch
            - connection_not_held
            - contents_write_required
            - continuation_failed
            - continuation_unavailable
            - control_forbidden
            - credential_kind_not_admitted
            - credential_named_file
            - detached_head
            - download_unsupported
            - embeddings_unavailable
            - feature_unsupported
            - file_references_unsupported
            - fix_not_requested
            - fix_requests_unrecorded
            - forbidden
            - fork_branch_delete_unsupported
            - fork_forbidden
            - fork_in_progress
            - fork_unsupported
            - gateway_timeout
            - github_failed
            - github_identity_required
            - github_push_access_required
            - gone
            - handed_branch_protected
            - head_moved
            - html_render_nul_byte
            - html_render_too_large
            - idempotency_key_conflict
            - idempotency_key_reused
            - idle_compaction_not_pending
            - idle_compaction_skipped
            - inference_proxy_unavailable
            - insufficient_credits
            - insufficient_inference_balance
            - interaction_mode_unsupported
            - internal_error
            - invalid_request
            - last_queued_message
            - live_protocol_unsupported
            - main_chat_permanent
            - mcp_server_not_connected
            - merge_when_ready_requires_pr_review
            - message_not_queued
            - method_not_allowed
            - mode_forbidden
            - name_follows_session
            - no_checkout_on_computer
            - no_checkpoint_yet
            - no_commit
            - no_dispatch_target
            - no_main_chat
            - no_origin
            - no_work_tree_folder
            - not_acceptable
            - not_found
            - not_implemented
            - onboarding_already_completed
            - onboarding_requirements_missing
            - open_in_terminal
            - org_id_required
            - org_role_insufficient
            - org_suspended
            - payment_required
            - pending_input_answered
            - permission_prompt_open
            - pr_automation_unsupported
            - pr_review_actor_required
            - pr_review_connection_spent
            - pr_review_publish_forbidden
            - precondition_failed
            - project_has_no_repository
            - project_required
            - pull_request_closed
            - pull_request_mirror_failed
            - pull_request_not_mirrored
            - push_failed
            - question_answers
            - question_shortened
            - queue_for_later_unsupported
            - queued_stop_requires_discard
            - rate_limited
            - reasoning_effort_fixed
            - repository_not_connected
            - request_canceled
            - request_expired
            - request_timeout
            - request_too_large
            - review_name_follows_pull_request
            - sandbox_deleted
            - sandbox_failed
            - sandbox_needs_message
            - service_unavailable
            - session_file_missing
            - session_gone
            - session_not_started_by_aether
            - slash_commands_unsupported
            - stack_cycle
            - stack_too_large
            - stack_two_parents
            - stale_execution
            - stale_or_indeterminate
            - stale_pending_input
            - stream_delivery_gap
            - stream_event_conflict
            - task_awaiting_message
            - task_awaiting_tool_response
            - task_backed_by_work_tree
            - task_connection_disconnected
            - task_creator_deleted
            - task_has_no_branch
            - task_has_no_repository
            - task_ineligible
            - task_not_accepting_messages
            - task_not_pinnable
            - task_not_started
            - task_settings_changed
            - task_start_failed
            - task_start_pending
            - teleport_unavailable
            - terminal_chat
            - terminal_chat_continuation_refused
            - terminal_question
            - too_large
            - too_many_live_connections
            - too_many_waiting_messages
            - turn_running
            - unauthenticated
            - unsigned_aether_head
            - unsigned_commit
            - unsupported_changes
            - unsupported_media_type
            - untyped_error
            - user_suspended
            - validation_failed
            - workspace_git_unavailable
            - workspace_gone
            - workspace_outdated
            - workspace_rejected
            - workspace_start_failed
          minLength: 1
          type: string
        error:
          minLength: 1
          type: string
        errors:
          items:
            $ref: '#/components/schemas/ErrorDetail'
          type: array
      required:
        - error
        - code
      type: object
    OrgAuthorizationErrorResponse:
      additionalProperties: false
      properties:
        code:
          enum:
            - org_membership_required
            - org_role_insufficient
            - org_suspended
            - account_deleting
            - agent_host_route_not_allowed
            - credential_kind_not_admitted
            - grant_scope_insufficient
          type: string
        error:
          minLength: 1
          type: string
      required:
        - error
        - code
      type: object
    TaskGitHubPullRequestCheck:
      additionalProperties: false
      properties:
        check_run_id:
          format: int64
          maximum: 9007199254740991
          minimum: 0
          type: integer
        completed_at:
          format: date-time
          type: string
        conclusion:
          minLength: 1
          type: string
        details_url:
          minLength: 1
          type: string
        name:
          type: string
        started_at:
          format: date-time
          type: string
        status:
          minLength: 1
          type: string
        summary:
          type: string
        summary_truncated:
          type: boolean
      required:
        - check_run_id
        - name
        - status
        - summary_truncated
      type: object
    TaskGitHubPullRequestMergeBox:
      additionalProperties: false
      properties:
        additions:
          format: int64
          minimum: 0
          type: integer
        author_login:
          minLength: 1
          type:
            - string
            - 'null'
        base_branch:
          minLength: 1
          type: string
        base_sha:
          pattern: ^[0-9a-f]{40}$
          type: string
        checks_failed:
          format: int64
          minimum: 0
          type: integer
        checks_passed:
          format: int64
          minimum: 0
          type: integer
        checks_total:
          format: int64
          minimum: 0
          type: integer
        ci_status:
          $ref: '#/components/schemas/TaskCIStatus'
        commits:
          format: int64
          minimum: 0
          type: integer
        deletions:
          format: int64
          minimum: 0
          type: integer
        draft:
          type: boolean
        head_branch:
          minLength: 1
          type: string
        head_is_fork:
          type: boolean
        head_sha:
          minLength: 1
          type: string
        html_url:
          minLength: 1
          type: string
        mergeable_state:
          $ref: '#/components/schemas/TaskGitHubPRMergeableState'
        merged_at:
          format: date-time
          type: string
        pr_number:
          format: int64
          minimum: 1
          type: integer
        ready_for_merge:
          type: boolean
        stack_children:
          items:
            $ref: '#/components/schemas/PullRequestStackEdge'
          minItems: 1
          type: array
        stack_parent:
          $ref: '#/components/schemas/PullRequestStackEdge'
        state:
          $ref: '#/components/schemas/TaskGitHubPRState'
        title:
          type: string
      required:
        - pr_number
        - title
        - html_url
        - head_sha
        - head_is_fork
        - author_login
        - draft
        - checks_passed
        - checks_failed
        - checks_total
        - ready_for_merge
        - commits
        - additions
        - deletions
      type: object
    TaskGitHubPullRequestReviewer:
      discriminator:
        mapping:
          team: '#/components/schemas/TaskGitHubPullRequestTeamReviewer'
          user: '#/components/schemas/TaskGitHubPullRequestUserReviewer'
        propertyName: kind
      oneOf:
        - $ref: '#/components/schemas/TaskGitHubPullRequestUserReviewer'
        - $ref: '#/components/schemas/TaskGitHubPullRequestTeamReviewer'
    TaskGitHubPullRequestReview:
      additionalProperties: false
      properties:
        author_is_bot:
          type: boolean
        author_login:
          minLength: 1
          type:
            - string
            - 'null'
        body:
          type: string
        github_review_id:
          format: int64
          maximum: 9007199254740991
          minimum: 1
          type: integer
        html_url:
          minLength: 1
          type: string
        state:
          minLength: 1
          type: string
        submitted_at:
          format: date-time
          type: string
      required:
        - github_review_id
        - author_login
        - author_is_bot
        - state
        - body
        - submitted_at
        - html_url
      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
    TaskCIStatus:
      enum:
        - pending
        - passed
        - failed
      type: string
    TaskGitHubPRMergeableState:
      enum:
        - clean
        - dirty
        - blocked
        - behind
        - unstable
        - unknown
        - draft
        - has_hooks
      type: string
    PullRequestStackEdge:
      additionalProperties: false
      description: >-
        One tracked open pull request on a branch-chain edge: as stack_parent,
        the pull request whose head repository and branch match this pull
        request's base; as an element of stack_children, a pull request whose
        base branch is this pull request's head. Present only when the edge
        exists in Aether's tracked pull-request projection; absence does not
        prove the pull request is unstacked.
      properties:
        html_url:
          format: uri
          pattern: ^[hH][tT][tT][pP][sS]?://
          type: string
        pr_number:
          format: int64
          minimum: 1
          type: integer
        pull_request_id:
          format: uuid
          type: string
        state:
          enum:
            - open
          type: string
        title:
          type: string
      required:
        - pull_request_id
        - pr_number
        - title
        - state
        - html_url
      type: object
    TaskGitHubPRState:
      enum:
        - open
        - closed
        - merged
      type: string
    TaskGitHubPullRequestTeamReviewer:
      additionalProperties: false
      properties:
        decision:
          enum:
            - pending
          type: string
        kind:
          enum:
            - team
          type: string
        team:
          minLength: 1
          type: string
      required:
        - kind
        - team
        - decision
      type: object
    TaskGitHubPullRequestUserReviewer:
      additionalProperties: false
      properties:
        decision:
          $ref: '#/components/schemas/TaskGitHubPullRequestReviewerDecision'
        is_bot:
          type: boolean
        kind:
          enum:
            - user
          type: string
        login:
          minLength: 1
          type: string
      required:
        - kind
        - login
        - is_bot
        - decision
      type: object
    TaskGitHubPullRequestReviewerDecision:
      enum:
        - approved
        - changes_requested
        - commented
        - dismissed
        - pending
      type: string
  securitySchemes:
    bearerAuth:
      bearerFormat: JWT
      scheme: bearer
      type: http

````

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