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

# Create metrics preview

> Requires scopes: eval:read



## OpenAPI

````yaml /api-reference/openapi.json post /api/metrics/preview
openapi: 3.1.0
info:
  title: EvalGate API
  version: 3.7.6
  description: EvalGate API. See docs/api-contract.md for stability commitments.
servers:
  - url: https://evalgate.com
    description: Production
  - url: http://localhost:3000
    description: Local
security: []
paths:
  /api/metrics/preview:
    post:
      tags:
        - metrics
      summary: Create metrics preview
      description: 'Requires scopes: eval:read'
      operationId: post_metrics_preview
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PostApiMetricsPreviewRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/PostApiMetricsPreviewResponse200ApplicationJson
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
      security:
        - bearerAuth:
            - eval:read
components:
  schemas:
    PostApiMetricsPreviewRequest:
      type: object
      properties:
        definition:
          type: object
          properties:
            source:
              oneOf:
                - type: string
                  enum:
                    - traces
                - type: string
                  enum:
                    - experiments
                - type: string
                  enum:
                    - model_calls
                - type: string
                  enum:
                    - eval_runs
                - type: string
                  enum:
                    - online_evals
                - type: string
                  enum:
                    - review
            metricKey:
              type: string
            measure:
              type: string
            aggregation:
              oneOf:
                - type: string
                  enum:
                    - max
                - type: string
                  enum:
                    - count
                - type: string
                  enum:
                    - sum
                - type: string
                  enum:
                    - avg
                - type: string
                  enum:
                    - min
                - type: string
                  enum:
                    - p50
                - type: string
                  enum:
                    - p95
                - type: string
                  enum:
                    - p99
                - type: string
                  enum:
                    - rate
            window:
              oneOf:
                - type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - relative
                    lookbackSeconds:
                      type: number
                    timezone:
                      type: string
                  additionalProperties: false
                  required:
                    - type
                    - lookbackSeconds
                - type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - absolute
                    from:
                      type: string
                    to:
                      type: string
                    timezone:
                      type: string
                  additionalProperties: false
                  required:
                    - type
                    - from
                    - to
            unknownPolicy:
              oneOf:
                - type: string
                  enum:
                    - fail
                - type: string
                  enum:
                    - exclude
                - type: string
                  enum:
                    - include_as_zero
            calibrationBoundary:
              oneOf:
                - type: object
                  properties:
                    state:
                      type: string
                      enum:
                        - not_applicable
                  additionalProperties: false
                  required:
                    - state
                - type: object
                  properties:
                    state:
                      type: string
                      enum:
                        - exact
                  additionalProperties: false
                  required:
                    - state
                - type: object
                  properties:
                    state:
                      type: string
                      enum:
                        - calibrated
                    mappingVersionId:
                      type: string
                  additionalProperties: false
                  required:
                    - state
                    - mappingVersionId
                - type: object
                  properties:
                    reason:
                      type: string
                    state:
                      type: string
                      enum:
                        - not_comparable
                  additionalProperties: false
                  required:
                    - reason
                    - state
            filters:
              type: array
              items:
                type: object
                properties:
                  operator:
                    oneOf:
                      - type: string
                        enum:
                          - exists
                      - type: string
                        enum:
                          - in
                      - type: string
                        enum:
                          - not_in
                      - type: string
                        enum:
                          - gte
                      - type: string
                        enum:
                          - lte
                      - type: string
                        enum:
                          - eq
                      - type: string
                        enum:
                          - neq
                      - type: string
                        enum:
                          - gt
                      - type: string
                        enum:
                          - lt
                      - type: string
                        enum:
                          - contains
                  field:
                    type: string
                  value:
                    $ref: '#/components/schemas/JsonValue'
                additionalProperties: false
                required:
                  - operator
                  - field
            groupBy:
              type: array
              items:
                type: string
            timeGrain:
              oneOf:
                - type: string
                  enum:
                    - minute
                - type: string
                  enum:
                    - hour
                - type: string
                  enum:
                    - day
                - type: string
                  enum:
                    - week
          additionalProperties: false
          required:
            - source
            - metricKey
            - measure
            - aggregation
            - window
            - unknownPolicy
            - calibrationBoundary
        filters:
          type: array
          items:
            type: object
            properties:
              operator:
                oneOf:
                  - type: string
                    enum:
                      - exists
                  - type: string
                    enum:
                      - in
                  - type: string
                    enum:
                      - not_in
                  - type: string
                    enum:
                      - gte
                  - type: string
                    enum:
                      - lte
                  - type: string
                    enum:
                      - eq
                  - type: string
                    enum:
                      - neq
                  - type: string
                    enum:
                      - gt
                  - type: string
                    enum:
                      - lt
                  - type: string
                    enum:
                      - contains
              field:
                type: string
              value:
                $ref: '#/components/schemas/JsonValue'
            additionalProperties: false
            required:
              - operator
              - field
        window:
          oneOf:
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - relative
                lookbackSeconds:
                  type: number
                timezone:
                  type: string
              additionalProperties: false
              required:
                - type
                - lookbackSeconds
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - absolute
                from:
                  type: string
                to:
                  type: string
                timezone:
                  type: string
              additionalProperties: false
              required:
                - type
                - from
                - to
      additionalProperties: false
      required:
        - definition
    PostApiMetricsPreviewResponse200ApplicationJson:
      type: object
      properties:
        window:
          type: object
          properties:
            from:
              type: string
            to:
              type: string
            timezone:
              type: string
          additionalProperties: false
          required:
            - from
            - to
            - timezone
        result:
          type: object
          properties:
            status:
              oneOf:
                - type: string
                  enum:
                    - failed
                - type: string
                  enum:
                    - success
                - type: string
                  enum:
                    - partial
            value:
              oneOf:
                - type: 'null'
                - type: number
            knownCount:
              type: number
            unknownCount:
              type: number
            evidenceIds:
              type: array
              items:
                type: string
            warnings:
              type: array
              items:
                type: string
            errorCode:
              type: string
          additionalProperties: false
          required:
            - status
            - value
            - knownCount
            - unknownCount
            - evidenceIds
            - warnings
        series:
          type: array
          items:
            type: object
            properties:
              key:
                type: string
              bucket:
                type: string
              group:
                type: object
                additionalProperties:
                  type: string
              result:
                type: object
                properties:
                  status:
                    oneOf:
                      - type: string
                        enum:
                          - failed
                      - type: string
                        enum:
                          - success
                      - type: string
                        enum:
                          - partial
                  value:
                    oneOf:
                      - type: 'null'
                      - type: number
                  knownCount:
                    type: number
                  unknownCount:
                    type: number
                  evidenceIds:
                    type: array
                    items:
                      type: string
                  warnings:
                    type: array
                    items:
                      type: string
                  errorCode:
                    type: string
                additionalProperties: false
                required:
                  - status
                  - value
                  - knownCount
                  - unknownCount
                  - evidenceIds
                  - warnings
            additionalProperties: false
            required:
              - key
              - bucket
              - group
              - result
        sample:
          type: array
          items:
            type: object
            properties:
              timestamp:
                type: string
              value:
                oneOf:
                  - type: 'null'
                  - type: number
              numerator:
                type: number
              denominator:
                type: number
              group:
                type: object
                additionalProperties:
                  type: string
              evidenceIds:
                type: array
                items:
                  type: string
            additionalProperties: false
            required:
              - timestamp
              - value
        sampleTruncated:
          type: boolean
      additionalProperties: false
      required:
        - window
        - result
        - series
        - sample
        - sampleTruncated
    JsonValue:
      oneOf:
        - type: 'null'
        - type: boolean
        - type: number
        - type: string
        - type: array
          items:
            $ref: '#/components/schemas/JsonValue'
        - type: object
          additionalProperties:
            $ref: '#/components/schemas/JsonValue'
    ApiError:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - UNAUTHORIZED
                - FORBIDDEN
                - NOT_FOUND
                - VALIDATION_ERROR
                - RATE_LIMITED
                - CONFLICT
                - INTERNAL_ERROR
                - SERVICE_UNAVAILABLE
                - QUOTA_EXCEEDED
                - NO_ORG_MEMBERSHIP
                - CROSS_ORG_REFERENCE
                - INCOMPLETE
                - MALFORMED
            message:
              type: string
            details: {}
            requestId:
              type: string
              format: uuid
          required:
            - code
            - message
      required:
        - error
  responses:
    ValidationError:
      description: Validation error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    Conflict:
      description: Conflict
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    RateLimited:
      description: Rate limit exceeded
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    InternalError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key or Session Token

````