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

# Record a minute of a play session

> Heartbeat `seq` (1, 2, 3...) covers the session's seq-th minute, so a retried one counts once. `idle_seconds` is how long since the player's last keyboard, mouse, touch or controller input. `visible` is whether the game could be seen (the page in front); leave it out when the client can't tell.



## OpenAPI

````yaml /api-reference/openapi.json post /me/play-sessions/{id}/heartbeat
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/{id}/heartbeat:
    post:
      tags:
        - Play
      summary: Record a minute of a play session
      description: >-
        Heartbeat `seq` (1, 2, 3...) covers the session's seq-th minute, so a
        retried one counts once. `idle_seconds` is how long since the player's
        last keyboard, mouse, touch or controller input. `visible` is whether
        the game could be seen (the page in front); leave it out when the client
        can't tell.
      parameters:
        - schema:
            type: string
            format: uuid
          required: true
          name: id
          in: path
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                seq:
                  type: integer
                  minimum: 1
                  maximum: 100000
                idle_seconds:
                  type: integer
                  minimum: 0
                  maximum: 86400
                visible:
                  type: boolean
              required:
                - seq
                - idle_seconds
      responses:
        '200':
          description: Recorded
          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.