> ## Documentation Index
> Fetch the complete documentation index at: https://docs.galtea.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Preview monitor content-filter matches

> Read-only preview for a CANDIDATE monitor config: how many and which recent past sessions the given content filter and sampling percentage would select, over a trailing window. Runs no evaluations, spends no credits, and writes nothing (no processed marks). Use it while creating or editing a monitor. The match count is exact; for a create preview (no `monitorId`) the sampled subset is representative, not the exact set the created monitor will draw.




## OpenAPI

````yaml https://api.galtea.ai/openapi.json post /monitors/preview
openapi: 3.0.0
info:
  version: 1.0.0
  title: Product Management Service API
  description: API documentation for Product Management Service
  contact:
    name: Galtea AI
servers:
  - url: https://api.galtea.ai
security:
  - bearerAuth: []
tags: []
externalDocs:
  description: Galtea Platform Documentation
  url: https://docs.galtea.ai
paths:
  /monitors/preview:
    post:
      tags:
        - monitors
      summary: Preview monitor content-filter matches
      description: >
        Read-only preview for a CANDIDATE monitor config: how many and which
        recent past sessions the given content filter and sampling percentage
        would select, over a trailing window. Runs no evaluations, spends no
        credits, and writes nothing (no processed marks). Use it while creating
        or editing a monitor. The match count is exact; for a create preview (no
        `monitorId`) the sampled subset is representative, not the exact set the
        created monitor will draw.
      operationId: previewMonitorMatches
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - productId
                - samplingPercentage
              properties:
                productId:
                  type: string
                  description: Product whose recent production sessions the preview scans.
                  example: prod_123
                versionId:
                  type: string
                  nullable: true
                  description: >-
                    Optional version to narrow the preview to. Null previews the
                    whole product.
                  example: version_123
                filterQuery:
                  type: string
                  nullable: true
                  maxLength: 500
                  description: >-
                    Candidate content filter. Null means every recent session
                    matches (sampling only).
                  example: refund
                filterTarget:
                  type: string
                  enum:
                    - INPUT
                    - OUTPUT
                    - EITHER
                  nullable: true
                  description: >-
                    Which side of a turn filterQuery matches against. Set
                    together with filterQuery.
                  example: EITHER
                excludeQuery:
                  type: string
                  nullable: true
                  maxLength: 500
                  description: >
                    Candidate exclude filter. Comma-separated terms; a session
                    is dropped when a turn whose chosen target (excludeTarget)
                    contains ANY term. Null excludes nothing. Set together with
                    excludeTarget. Independent of filterQuery.
                  example: test, internal
                excludeTarget:
                  type: string
                  enum:
                    - INPUT
                    - OUTPUT
                    - EITHER
                  nullable: true
                  description: >-
                    Which side of a turn excludeQuery matches against. Set
                    together with excludeQuery.
                  example: EITHER
                samplingPercentage:
                  type: number
                  minimum: 0
                  exclusiveMinimum: true
                  maximum: 100
                  description: Candidate sampling percentage (greater than 0, at most 100).
                  example: 10
                days:
                  type: integer
                  minimum: 1
                  maximum: 90
                  description: >-
                    Trailing window in days to look back over (default 90, max
                    90).
                  example: 90
                monitorId:
                  type: string
                  nullable: true
                  description: >
                    Existing monitor id when previewing an EDIT, so sampling
                    uses its real seed (exact). Omit for a create preview
                    (representative sampling).
                  example: monitor_123
      responses:
        '200':
          description: Preview computed successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MonitorMatchPreview'
        '400':
          description: Invalid request body
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: >
            The caller cannot create monitors for this product. A product in
            another organization also yields 403 (not 404), so the endpoint
            never leaks whether a foreign product exists.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: >-
            No product exists with the given id (a product in another
            organization yields 403, not 404)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  schemas:
    MonitorMatchPreview:
      type: object
      description: >-
        Read-only preview of how many and which recent past sessions a candidate
        monitor content filter and sampling percentage would select. No
        evaluations run and no credits are spent.
      required:
        - range
        - candidateCount
        - matchCount
        - sampledCount
        - approximateSampling
        - sampledSessions
      properties:
        range:
          type: object
          required:
            - from
            - to
          properties:
            from:
              type: string
              format: date-time
            to:
              type: string
              format: date-time
        candidateCount:
          type: integer
          description: >-
            Recent closed production sessions considered (bounded by the window
            and an internal cap).
          example: 500
        matchCount:
          type: integer
          description: >-
            Sessions whose content matched the candidate filter (exact; a null
            filter matches every candidate).
          example: 120
        sampledCount:
          type: integer
          description: Matched sessions that also fell in the sampling fraction.
          example: 12
        approximateSampling:
          type: boolean
          description: >-
            True for a create preview (no monitorId): the sampled subset is
            representative, computed from a placeholder seed. The match count is
            always exact.
          example: true
        sampledSessions:
          type: array
          description: The would-be-selected sessions, most-recent first (capped at 100).
          items:
            type: object
            required:
              - sessionId
              - versionId
              - createdAt
              - turnCount
              - matchedText
            properties:
              sessionId:
                type: string
                example: session_123
              versionId:
                type: string
                example: version_123
              createdAt:
                type: string
                format: date-time
              turnCount:
                type: integer
                example: 4
              matchedText:
                type: string
                description: >-
                  A short snippet of the matched content (centered on the first
                  matched term with a content filter) or the first turn input
                  (without a filter). Capped at ~160 characters plus ellipsis
                  markers.
                example: >-
                  I would like a refund for my last order because it arrived
                  damaged…
    Error:
      type: object
      properties:
        error:
          type: string
          example: Error type
        message:
          type: string
          example: Error message description
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key authorization. Pass your API key in the Authorization header as
        a Bearer token. Both new (`gsk_*`) and legacy (`gsk-`) API keys are
        accepted, e.g. `Authorization: Bearer gsk_...` or `Authorization: Bearer
        gsk-...`.

````