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

# Open a pull request on a connected repo

> From a branch on GitHub into another, the repo's default branch unless `base` says. Asked again for a branch with one open, it's that one (200, `opened` false). 404 `no_such_branch` for a branch GitHub doesn't have, 422 `nothing_to_merge` for one with no commits of its own, and 422 `github_refused` for anything else GitHub won't take, in its words. Without the app's permission, `details.compare_url` is GitHub's page for opening it by hand. For a member of the project's org who can push to its GitHub repo, as they are on GitHub. 403 `github_not_linked` without a connected GitHub account, `github_no_push` without push on the repo, and `github_no_access` when Patch's GitHub App can't reach it, or hasn't got what this needs, with where to accept that in `details.settings_url`; 404 `gone_from_github`.



## OpenAPI

````yaml /api-reference/openapi.json post /projects/{owner}/{slug}/github/pulls
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}/github/pulls:
    post:
      tags:
        - GitHub
      summary: Open a pull request on a connected repo
      description: >-
        From a branch on GitHub into another, the repo's default branch unless
        `base` says. Asked again for a branch with one open, it's that one (200,
        `opened` false). 404 `no_such_branch` for a branch GitHub doesn't have,
        422 `nothing_to_merge` for one with no commits of its own, and 422
        `github_refused` for anything else GitHub won't take, in its words.
        Without the app's permission, `details.compare_url` is GitHub's page for
        opening it by hand. For a member of the project's org who can push to
        its GitHub repo, as they are on GitHub. 403 `github_not_linked` without
        a connected GitHub account, `github_no_push` without push on the repo,
        and `github_no_access` when Patch's GitHub App can't reach it, or hasn't
        got what this needs, with where to accept that in
        `details.settings_url`; 404 `gone_from_github`.
      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:
                head:
                  type: string
                  pattern: ^(?![-/])(?!.*\.\.)[\w.\-/]{1,200}$
                  example: sky-boost
                  description: The branch to merge, on the same repo
                base:
                  type: string
                  pattern: ^(?![-/])(?!.*\.\.)[\w.\-/]{1,200}$
                  example: main
                  description: 'The branch it goes into: the repo''s default branch, left out'
                title:
                  type: string
                  minLength: 1
                  maxLength: 256
                  example: Add the sky boost
                body:
                  type: string
                  maxLength: 60000
                  description: What it does, in GitHub's Markdown
              required:
                - head
                - title
      responses:
        '200':
          description: It was open already
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/GithubPull'
                  - type: object
                    properties:
                      opened:
                        type: boolean
                        enum:
                          - false
                    required:
                      - opened
        '201':
          description: Opened
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/GithubPull'
                  - type: object
                    properties:
                      opened:
                        type: boolean
                        enum:
                          - true
                    required:
                      - opened
        '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_connected`: the project''s repo isn''t on GitHub'
          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: '`github_unavailable`: GitHub didn''t answer'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearer: []
components:
  schemas:
    GithubPull:
      type: object
      properties:
        number:
          type: integer
          example: 12
        url:
          type: string
          format: uri
          description: Its page on GitHub
        title:
          type: string
        head:
          type: string
          example: sky-boost
          description: The branch it's from
        base:
          type: string
          example: main
          description: The branch it goes into
        state:
          type: string
          enum:
            - open
            - closed
            - merged
        merged_at:
          type:
            - string
            - 'null'
          description: When it merged, or null
        mergeable:
          type:
            - boolean
            - 'null'
          description: >-
            Whether it can merge as it stands, or null while GitHub works that
            out
      required:
        - number
        - url
        - title
        - head
        - base
        - state
        - merged_at
        - mergeable
    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.