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

# Offer a branch to this repo

> Opens a change request from `branch` of `from` into `into`, this repo's default branch unless you say. `from` is a fork of this repo, or a fork of one of its forks, and you're in its org. The branch's commits are first copied into this repo, on a hidden branch a clone doesn't see, and read as they're copied. `git fetch <clone_url> <head_commit>` gets them while it's open. Only open repos take change requests from forks, unless their owner turned them off. The fork has to be open too, since its commits become readable here.

The repo's own org can offer one of its branches into another, so a change is looked at before it lands: leave `from` out, or name this repo. That works whatever the repo's visibility, and whether or not it takes change requests from forks, since its commits are already in it. The branch has to be there and not be `into` (422 `same_branch`). Anyone in the org can merge it, whoever opened it withdraws it, and the rest of the org declines it.

A repo whose home is GitHub takes none: its changes are pull requests on GitHub (403 `change_requests_off`, with that page in `details.pull_requests`). Needs the `publish` scope.



## OpenAPI

````yaml /api-reference/openapi.json post /projects/{owner}/{slug}/change-requests
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:
    post:
      tags:
        - Change requests
      summary: Offer a branch to this repo
      description: >-
        Opens a change request from `branch` of `from` into `into`, this repo's
        default branch unless you say. `from` is a fork of this repo, or a fork
        of one of its forks, and you're in its org. The branch's commits are
        first copied into this repo, on a hidden branch a clone doesn't see, and
        read as they're copied. `git fetch <clone_url> <head_commit>` gets them
        while it's open. Only open repos take change requests from forks, unless
        their owner turned them off. The fork has to be open too, since its
        commits become readable here.


        The repo's own org can offer one of its branches into another, so a
        change is looked at before it lands: leave `from` out, or name this
        repo. That works whatever the repo's visibility, and whether or not it
        takes change requests from forks, since its commits are already in it.
        The branch has to be there and not be `into` (422 `same_branch`). Anyone
        in the org can merge it, whoever opened it withdraws it, and the rest of
        the org declines it.


        A repo whose home is GitHub takes none: its changes are pull requests on
        GitHub (403 `change_requests_off`, with that page in
        `details.pull_requests`). 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
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                from:
                  type: string
                  pattern: ^[^/\s]+\/[^/\s]+$
                  description: >-
                    The fork, as owner/slug. Leave it out, or name this repo, to
                    offer one of this repo's own branches, as its org.
                  example: kai/sky-mod
                branch:
                  type: string
                  pattern: ^(?![-/])(?!.*\.\.)[\w.\-/]{1,200}$
                  example: port-26.5
                  description: The branch it offers, in `from`
                into:
                  type: string
                  pattern: ^(?![-/])(?!.*\.\.)[\w.\-/]{1,200}$
                  example: main
                  description: >-
                    The branch it would change here; the default branch unless
                    you say
                title:
                  type: string
                  minLength: 1
                  maxLength: 200
                description:
                  type: string
                  maxLength: 20000
              required:
                - branch
                - title
      responses:
        '201':
          description: Opened
          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: A request from that branch into that one is already open
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: >-
            Not a fork of this repo, a fork that isn't open, a branch that isn't
            there, one of this repo's branches offered into itself
            (`same_branch`), or commits that can't be copied (`checks_failed`,
            with what stopped them in `details.problems`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: >-
            Too many requests: wait as long as `Retry-After` says
            (`retry_after_s` in `details`), then retry
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '502':
          description: The branch couldn't be copied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: Change requests aren't set up here
          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.