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

# Fork a project's repo into a new project

> Copies the repo's default branch into a new project of `owner`'s (an org you're in), which records this one as its parent, starts at its head with its README, and holds the big files its history names. It brings only what that commit reaches, so no other branch, no tag and no commit the repo has dropped, and it answers once it's all there, a few seconds at most. A repo with more than 100 MB of packed git history, or that takes more than the 4.5 minutes a fork has, answers 422 `too_big`, with nothing made: clone it and `pch push` it to a new repo instead. Big files in Git LFS don't count towards that. A client can give up on a long fork, which goes on without it: asking again answers that fork once it's there, and 503 `fork_in_progress` until then. The slug and name default to this project's. A fork starts no more open than the repo it copies, and only its own org can fork a closed source or private repo (403 `source_closed` for someone else, and 404 for a private one). An org at the most repos it can have gets 403 `repo_limit_reached`, and a repo staff took down is 403 for its own org too. Needs the `publish` scope. A repo whose home is GitHub is copied from GitHub when it's forked, with its history, and only while it's open (409 `fork_on_github`), public on GitHub (422 `needs_public`) and with a licence GitHub can find in it (422 `needs_license`). GitHub is asked as it's forked, so one that went private there, or lost its licence, stops being open, and the fork takes the licence GitHub reads then for its code and its art. When Patch reads the repo again meanwhile, GitHub is asked once more, and a second time answers 409 `github_changed`. One too big for Patch (422 `too_big`), or with big files in Git LFS on GitHub (422 `big_files_on_github`), can't be forked here: fork it on GitHub.



## OpenAPI

````yaml /api-reference/openapi.json post /projects/{owner}/{slug}/fork
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}/fork:
    post:
      tags:
        - Repos
      summary: Fork a project's repo into a new project
      description: >-
        Copies the repo's default branch into a new project of `owner`'s (an org
        you're in), which records this one as its parent, starts at its head
        with its README, and holds the big files its history names. It brings
        only what that commit reaches, so no other branch, no tag and no commit
        the repo has dropped, and it answers once it's all there, a few seconds
        at most. A repo with more than 100 MB of packed git history, or that
        takes more than the 4.5 minutes a fork has, answers 422 `too_big`, with
        nothing made: clone it and `pch push` it to a new repo instead. Big
        files in Git LFS don't count towards that. A client can give up on a
        long fork, which goes on without it: asking again answers that fork once
        it's there, and 503 `fork_in_progress` until then. The slug and name
        default to this project's. A fork starts no more open than the repo it
        copies, and only its own org can fork a closed source or private repo
        (403 `source_closed` for someone else, and 404 for a private one). An
        org at the most repos it can have gets 403 `repo_limit_reached`, and a
        repo staff took down is 403 for its own org too. Needs the `publish`
        scope. A repo whose home is GitHub is copied from GitHub when it's
        forked, with its history, and only while it's open (409
        `fork_on_github`), public on GitHub (422 `needs_public`) and with a
        licence GitHub can find in it (422 `needs_license`). GitHub is asked as
        it's forked, so one that went private there, or lost its licence, stops
        being open, and the fork takes the licence GitHub reads then for its
        code and its art. When Patch reads the repo again meanwhile, GitHub is
        asked once more, and a second time answers 409 `github_changed`. One too
        big for Patch (422 `too_big`), or with big files in Git LFS on GitHub
        (422 `big_files_on_github`), can't be forked here: fork it on 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:
                owner:
                  type: string
                  minLength: 1
                  maxLength: 100
                  description: The org the fork goes to
                slug:
                  type: string
                  minLength: 1
                  maxLength: 64
                name:
                  type: string
                  minLength: 1
                  maxLength: 100
                private:
                  type: boolean
                  description: >-
                    Starts it private, so it's never open. Without it, a fork is
                    as open as the repo it copies, unless it's made from a Patch
                    Desktop chat, which starts it private
              required:
                - owner
      responses:
        '201':
          description: The fork's repo
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Repo'
        '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: >-
            The slug is taken, or the repo has had no push to fork, or its home
            is GitHub and it isn't open, or what GitHub says of it changed while
            it was being forked, twice (`github_changed`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: >-
            It's too big to copy (`too_big`), or its home is GitHub and it can't
            be copied onto Patch: it's private there (`needs_public`), has no
            licence GitHub can find (`needs_license`), or keeps big files in Git
            LFS on GitHub (`big_files_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: The repo couldn't be copied, or GitHub didn't answer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: >-
            The repo is waking up, the fork asked for is still being copied
            (`fork_in_progress`), or forks aren't set up here
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '507':
          description: '`storage_limit_reached`: the org''s repos hold as much as they can'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearer: []
components:
  schemas:
    Repo:
      type: object
      properties:
        name:
          type: string
        summary:
          type:
            - string
            - 'null'
        code_license:
          type: string
          maxLength: 64
          pattern: ^[A-Za-z0-9][A-Za-z0-9.+-]*$
          example: MIT
          description: License of the code
        art_license:
          type: string
          maxLength: 64
          pattern: ^[A-Za-z0-9][A-Za-z0-9.+-]*$
          example: MIT
          description: License of original art and other assets
        clone_url:
          type: string
          format: uri
          example: https://git.patch.gg/patch/demo-mod.git
        visibility:
          type: string
          enum:
            - open
            - closed_source
            - private
          description: >-
            Who can reach the project's repo. open: anyone can find it, read it
            and fork it. closed_source: anyone can find and play what it
            releases; only its org reads the source. private: only its org can
            find it, and anyone else gets a 404. It isn't locked: the game host
            serves a published browser game to anyone who has its address.
        visibility_chosen_at:
          type:
            - string
            - 'null'
          description: >-
            When someone last set `visibility` on purpose, for its org: what to
            send back with a change that depends on nobody having done that
            since
        opening:
          type:
            - object
            - 'null'
          properties:
            status:
              type: string
              enum:
                - scanning
                - secrets_found
                - big_files_unread
                - failed
            says:
              type: string
              description: Where it's got to, to pass on to the person
            found:
              type: array
              items:
                type: object
                properties:
                  kind:
                    type: string
                    example: an AWS access key
                  path:
                    type:
                      - string
                      - 'null'
                    description: Null for a commit's message.
                  line:
                    type: integer
                    minimum: 1
                  commit:
                    type:
                      - string
                      - 'null'
                required:
                  - kind
                  - path
                  - line
                  - commit
              description: >-
                What a later push brought that closed it, as Patch read that
                push, and never a secret's value. Empty for a first push's hold,
                and for a push Patch couldn't read all of.
            was_open:
              type: boolean
              description: >-
                Whether it was open until a later push closed it. With nothing
                in `found`, that's for what Patch couldn't read of the push.
          required:
            - status
            - says
            - found
            - was_open
          description: >-
            For the repo's org. A repo that was open when its first push landed
            stays closed source until a scan of its history is clean, and then
            opens by itself, and so does an open repo that a later push closed
            by bringing a secret, or something Patch couldn't read. This says
            where that's got to. Null for anyone else, and for a repo that isn't
            waiting.
        can_read_source:
          type: boolean
          description: >-
            Whether you can read its source. When false, as for someone outside
            a closed source repo's org, `head_commit`, `last_commit` and
            `readme` are null, and its file, tree and commit reads answer 403
            `source_closed`.
        default_branch:
          type: string
          example: main
        created_at:
          type:
            - string
            - 'null'
          format: date-time
          description: When the repo was made; null until its first push.
        head_commit:
          type:
            - string
            - 'null'
          description: The default branch's latest commit, as of the last push.
        pushed_at:
          type:
            - string
            - 'null'
          format: date-time
        forked_from:
          type:
            - string
            - 'null'
          description: The repo it was forked from, as owner/slug.
          example: patch/demo-mod
        fork_count:
          type: integer
          description: >-
            Its forks anyone can see: open ones with a repo, each once it has a
            public release. Until then a fork is quiet, and nothing counts it.
        clone_count:
          type: integer
          description: >-
            Fresh clones by people outside its org, each cloner counted once a
            day, as the git host saw them.
        training_opt_out:
          type: boolean
          description: When true, Patch doesn't train its own models on this project.
        change_requests:
          type: boolean
          description: >-
            The owner's switch for change requests. Only open repos take them,
            so it does nothing while the repo isn't open.
        open_change_requests:
          type: integer
          description: >-
            How many change requests are open, for whoever can read its source:
            0 for anyone else.
        last_commit:
          type:
            - object
            - 'null'
          properties:
            id:
              type: string
            subject:
              type: string
              description: Its message's first line
            author:
              type: string
            committed_at:
              type: string
              format: date-time
          required:
            - id
            - subject
            - author
            - committed_at
          description: >-
            The default branch's latest commit, as read after the push that
            moved it.
        readme:
          type:
            - object
            - 'null'
          properties:
            path:
              type: string
              example: README.md
            text:
              type: string
          required:
            - path
            - text
          description: >-
            The README at the top of the default branch, its first 128 KB; null
            when there's none.
        readme_pictures:
          type: array
          items:
            type: object
            properties:
              url:
                type: string
                format: uri
                description: The file, as the README writes its address.
              levels:
                $ref: '#/components/schemas/MediaLevels'
              fit:
                type: string
                enum:
                  - cover
                  - contain
                  - pixel
                  - wave
                description: >-
                  How it sits in a card's frame. cover: fills it. contain: a
                  thing on nothing, whole, on the frame's ground. pixel: the
                  same, with its pixels kept sharp. wave: a sound's waveform,
                  across the frame.
            required:
              - url
              - levels
              - fit
          description: >-
            The pictures in a library repo's README, which Patch holds copies
            of, so a page can show them at their levels. Empty for any other
            repo, and for anyone who can't read its source.
        home:
          type: string
          enum:
            - patch
            - github
          description: >-
            Where its repo lives, where connecting GitHub is on (and only
            there): `patch`, or `github` once a GitHub repo is connected to it,
            whose files and commits stay on GitHub. `clone_url` is the same
            either way.
        github:
          type:
            - object
            - 'null'
          properties:
            full_name:
              type: string
              example: sam/sky-mod
            html_url:
              type: string
              format: uri
              example: https://github.com/sam/sky-mod
            private:
              type: boolean
              description: Whether it's private on GitHub
            default_branch:
              type: string
              example: main
            head_commit:
              type:
                - string
                - 'null'
              description: >-
                The default branch's latest commit, as of GitHub's last push
                event
            pushed_at:
              type:
                - string
                - 'null'
              format: date-time
            state:
              type: string
              enum:
                - connected
                - disconnected
                - gone
                - suspended
                - no_access
              description: >-
                connected. disconnected: someone disconnected it on Patch, or it
                moved to an account without Patch's GitHub App. gone: deleted
                from GitHub. suspended: the app is suspended on its account.
                no_access: the app no longer reaches it (uninstalled, or the
                repo was taken out of the installation).
          required:
            - full_name
            - html_url
            - private
            - default_branch
          description: >-
            The GitHub repo that's its home, with `home`. Null on Patch, and for
            someone outside the project's org when the repo is private on
            GitHub.
      required:
        - name
        - summary
        - code_license
        - art_license
        - clone_url
        - visibility
        - opening
        - can_read_source
        - default_branch
        - created_at
        - head_commit
        - pushed_at
        - forked_from
        - fork_count
        - clone_count
        - training_opt_out
        - change_requests
        - open_change_requests
        - last_commit
        - readme
        - readme_pictures
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: version_exists
            message:
              type: string
            details: {}
          required:
            - code
            - message
      required:
        - error
    MediaLevels:
      type: array
      items:
        type: object
        properties:
          width:
            type: integer
          url:
            type: string
        required:
          - width
          - url
      description: >-
        Smaller copies of a picture (WebP) or a clip (MP4, H.264, without
        sound), smallest first, each at its own address that never changes. Show
        the smallest that's sharp where it goes. Empty for animated pictures,
        for flat art and short clips with no smaller copy, and for media from
        before Patch made copies until theirs are made: then use the file
        itself.
  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.