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

# Start linking your GitHub account with a code: for pch and agents

> GitHub's device flow: show the person `user_code` and `verification_uri`, where they enter it, then ask `GET /me/github/device/{id}` no more often than every `interval` seconds. Once they have, Patch keeps their GitHub user token, as from GitHub's sign-in in a browser. Needs the `publish` scope.



## OpenAPI

````yaml /api-reference/openapi.json post /me/github/device
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:
  /me/github/device:
    post:
      tags:
        - GitHub
      summary: 'Start linking your GitHub account with a code: for pch and agents'
      description: >-
        GitHub's device flow: show the person `user_code` and
        `verification_uri`, where they enter it, then ask `GET
        /me/github/device/{id}` no more often than every `interval` seconds.
        Once they have, Patch keeps their GitHub user token, as from GitHub's
        sign-in in a browser. Needs the `publish` scope.
      responses:
        '201':
          description: The code for the person to enter
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GithubDeviceFlow'
        '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'
        '502':
          description: GitHub didn't answer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearer: []
components:
  schemas:
    GithubDeviceFlow:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Ask GET /me/github/device/{id} how it stands
        user_code:
          type: string
          example: WDJB-MJHT
        verification_uri:
          type: string
          format: uri
          example: https://github.com/login/device
        interval:
          type: integer
          description: Seconds to wait between asking
        expires_in:
          type: integer
          description: Seconds the code works for
      required:
        - id
        - user_code
        - verification_uri
        - interval
        - expires_in
    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.