> ## 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 a play session

> Patch Desktop calls this when a mod's game starts running, and the play page when a browser game opens. The client makes the id, so a retried start is the same session. Then send a heartbeat every `heartbeat_s` seconds and end it. Play by the project's own team is recorded but never counted in its insights.



## OpenAPI

````yaml /api-reference/openapi.json post /me/play-sessions
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/play-sessions:
    post:
      tags:
        - Play
      summary: Start a play session
      description: >-
        Patch Desktop calls this when a mod's game starts running, and the play
        page when a browser game opens. The client makes the id, so a retried
        start is the same session. Then send a heartbeat every `heartbeat_s`
        seconds and end it. Play by the project's own team is recorded but never
        counted in its insights.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: string
                  format: uuid
                  description: Made by the client (a UUID)
                project:
                  type: string
                  pattern: ^[a-z0-9][a-z0-9_-]*\/[a-z0-9][a-z0-9-]*$
                  example: mira/lantern-run
                version:
                  type: string
                  minLength: 1
                  maxLength: 64
                  example: 1.2.0
                client:
                  type: string
                  enum:
                    - desktop
                    - web
                device_id:
                  type: string
                  maxLength: 64
                  description: >-
                    The Patch Desktop install or browser playing, made by the
                    client
                app_version:
                  type: string
                  maxLength: 40
              required:
                - id
                - project
                - version
                - client
      responses:
        '201':
          description: Started
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlaySession'
        '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'
      security:
        - bearer: []
components:
  schemas:
    PlaySession:
      type: object
      properties:
        id:
          type: string
          format: uuid
        project:
          type: string
          example: mira/lantern-run
        version:
          type: string
        client:
          type: string
          example: desktop
        started_at:
          type: string
        last_seen_at:
          type: string
        ended_at:
          type:
            - string
            - 'null'
        end:
          type:
            - string
            - 'null'
          enum:
            - ended
            - exited
            - crashed
            - timed_out
            - null
        heartbeat_s:
          type: integer
          description: Send a heartbeat this often
      required:
        - id
        - project
        - version
        - client
        - started_at
        - last_seen_at
        - ended_at
        - end
        - heartbeat_s
    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.