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

# Keep a chat turn's agent trace

> Patch Desktop calls this after each turn of a chat, to keep the turn's whole trace: what the agent was sent, every model call and tool call, and how it ended. It answers with a URL to PUT the gzipped trace to, which takes only those bytes. Traces are kept under your account.



## OpenAPI

````yaml /api-reference/openapi.json post /me/agent-traces
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/agent-traces:
    post:
      tags:
        - Chats
      summary: Keep a chat turn's agent trace
      description: >-
        Patch Desktop calls this after each turn of a chat, to keep the turn's
        whole trace: what the agent was sent, every model call and tool call,
        and how it ended. It answers with a URL to PUT the gzipped trace to,
        which takes only those bytes. Traces are kept under your account.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                trace_id:
                  type: string
                  format: uuid
                size:
                  type: integer
                  minimum: 1
                  maximum: 268435456
                  description: Bytes, gzipped
                sha256:
                  type: string
                  pattern: ^[0-9a-f]{64}$
                started_at:
                  type: string
                  format: date-time
                  description: When the turn started; now if left out
              required:
                - trace_id
                - size
                - sha256
      responses:
        '200':
          description: Where to upload the trace
          content:
            application/json:
              schema:
                type: object
                properties:
                  key:
                    type: string
                  upload:
                    type: object
                    properties:
                      method:
                        type: string
                        enum:
                          - PUT
                      url:
                        type: string
                      headers:
                        type: object
                        additionalProperties:
                          type: string
                      expires_at:
                        type: string
                    required:
                      - method
                      - url
                      - headers
                      - expires_at
                required:
                  - key
                  - upload
        '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:
    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.