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

# Merge a change request

> The repo's org. The request has to be up to date with the branch it's for: then merging moves that branch to the request's latest commit, or with `squash` adds one commit with its files and its author, dated now, whose message is `message` (the title and description unless you say). When the branch has moved on, its author updates their branch first. `head` is the commit you looked at, so that what you merge is what you read. Needs the `publish` scope.



## OpenAPI

````yaml /api-reference/openapi.json post /projects/{owner}/{slug}/change-requests/{number}/merge
openapi: 3.1.0
info:
  title: Patch API
  version: 1.0.0
  description: >-
    The public API behind patch.gg, the desktop app and pch. Changes within v1
    are additive only. Errors are { error: { code, message, details } }; branch
    on code.
servers:
  - url: https://patch.gg/api/v1
security: []
paths:
  /projects/{owner}/{slug}/change-requests/{number}/merge:
    post:
      tags:
        - Change requests
      summary: Merge a change request
      description: >-
        The repo's org. The request has to be up to date with the branch it's
        for: then merging moves that branch to the request's latest commit, or
        with `squash` adds one commit with its files and its author, dated now,
        whose message is `message` (the title and description unless you say).
        When the branch has moved on, its author updates their branch first.
        `head` is the commit you looked at, so that what you merge is what you
        read. Needs the `publish` scope.
      parameters:
        - schema:
            type: string
            example: patch
          required: true
          name: owner
          in: path
        - schema:
            type: string
            example: demo-mod
          required: true
          name: slug
          in: path
        - schema:
            type: integer
            minimum: 1
            example: 12
          required: true
          name: number
          in: path
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                squash:
                  type: boolean
                  default: false
                message:
                  type: string
                  minLength: 1
                  maxLength: 20000
                head:
                  type: string
                  pattern: ^[0-9a-f]{40}$
                  description: >-
                    The request's latest commit as you last read it. When it's
                    moved on since, it doesn't merge: 409 `request_moved`.
      responses:
        '200':
          description: Merged
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChangeRequest'
        '308':
          description: Renamed; follow the Location header
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Not signed in
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Not allowed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: >-
            Not open, behind the branch it's for (`out_of_date`), or it has new
            commits you haven't read, or that haven't shown up here yet
            (`request_moved`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: The branch it's for isn't there anymore
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '502':
          description: It couldn't be merged just now
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: Change requests aren't set up here, or the repo is waking up
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearer: []
components:
  schemas:
    ChangeRequest:
      type: object
      properties:
        number:
          type: integer
          example: 12
        title:
          type: string
          example: Port to 26.5
        description:
          type: string
        state:
          type: string
          enum:
            - open
            - merged
            - declined
            - withdrawn
          description: >-
            open: waiting on the repo's owner. merged: its commits are in the
            branch it was for. declined: the owner turned it down. withdrawn:
            its author took it back.
        from:
          type:
            - string
            - 'null'
          description: >-
            The repo its branch is in, as owner/slug: the fork it comes from, or
            this repo itself for one of its own branches. Null if you can't
            reach the fork.
          example: kai/sky-mod
        branch:
          type: string
          description: The branch it offers, in `from`
          example: port-26.5
        into:
          type: string
          description: The branch it would change in this repo
          example: '26.5'
        head_commit:
          type: string
          description: >-
            Its latest commit, as copied into this repo, where a clone doesn't
            see it: `git fetch <clone_url> <head_commit>` gets its commits while
            it's open.
        problems:
          type: array
          items:
            type: string
          description: >-
            What stopped the latest push to its branch being copied, which stays
            out of the request until it's fixed: a refusal, a fork that isn't
            open, which copies when it opens, or a copy that failed, which a new
            push tries again. Empty says nothing has stopped one, and a copy may
            still be on its way.
        author:
          type:
            - string
            - 'null'
          description: 'Who opened it: their username'
          example: kai
        talk_count:
          type: integer
          description: Posts in its talk
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        closed_at:
          type:
            - string
            - 'null'
          format: date-time
        closed_by:
          type:
            - string
            - 'null'
          description: 'Who merged, declined or withdrew it: their username'
        merge_commit:
          type:
            - string
            - 'null'
          description: The commit its branch was at after the merge.
      required:
        - number
        - title
        - description
        - state
        - from
        - branch
        - into
        - head_commit
        - problems
        - author
        - talk_count
        - created_at
        - updated_at
        - closed_at
        - closed_by
        - merge_commit
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: version_exists
            message:
              type: string
            details: {}
          required:
            - code
            - message
      required:
        - error
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: An API key (pch_...) or the token from pch login.

````

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