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

# Update metric baseline

> Update mutable fields on an anomaly-detection baseline. All fields optional.



## OpenAPI

````yaml /api-reference/v1/metrics-v1.yaml patch /metrics/{metric_id}/baselines/{baseline_id}
openapi: 3.0.3
info:
  title: Coval Metrics API
  version: 1.0.0
  description: |
    Manage custom evaluation metrics for agent testing and monitoring.
  contact:
    name: Coval API Support
    email: support@coval.dev
    url: https://docs.coval.ai
  license:
    name: Proprietary
    url: https://coval.dev/terms
servers:
  - url: https://api.coval.dev/v1
    description: Production API
security:
  - ApiKeyAuth: []
tags:
  - name: Metrics
    description: CRUD operations for custom evaluation metrics
paths:
  /metrics/{metric_id}/baselines/{baseline_id}:
    patch:
      tags:
        - Metrics
      summary: Update metric baseline
      description: >-
        Update mutable fields on an anomaly-detection baseline. All fields
        optional.
      operationId: updateMetricBaseline
      parameters:
        - name: metric_id
          in: path
          required: true
          schema:
            type: string
            pattern: ^[a-zA-Z0-9]{22}$
          description: 22-character metric ID
        - name: baseline_id
          in: path
          required: true
          schema:
            type: string
            minLength: 26
            maxLength: 26
          description: 26-character baseline ULID.
          example: 01HXKZ4M5N6P7Q8R9STVWXYZAB
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateMetricBaselineRequest'
            examples:
              activate:
                summary: Promote a baseline from STANDBY to ACTIVE
                value:
                  status: ACTIVE
              retune:
                summary: Adjust sigma threshold and direction
                value:
                  sigma_threshold: 3
                  direction: BOTH
              rename:
                summary: Rename a baseline
                value:
                  display_name: Resolution rate baseline (prod)
      responses:
        '200':
          description: Baseline updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Baseline'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    UpdateMetricBaselineRequest:
      type: object
      description: Request body for updating a baseline. All fields optional.
      properties:
        display_name:
          type: string
          nullable: true
          maxLength: 200
          description: User-facing label.
        sigma_threshold:
          type: number
          nullable: true
          minimum: 0
          exclusiveMinimum: true
          description: Sigmas from the baseline that constitute an anomaly.
        direction:
          allOf:
            - $ref: '#/components/schemas/BaselineDirection'
        status:
          allOf:
            - $ref: '#/components/schemas/BaselineStatus'
    Baseline:
      type: object
      description: Anomaly-detection baseline for a metric.
      required:
        - ulid
        - status
        - detection_method
        - sigma_threshold
        - direction
        - created_at
        - last_updated_at
      properties:
        ulid:
          type: string
          description: Baseline ULID.
          example: 01HXKZ4M5N6P7Q8R9STVWXYZAB
        metric_id:
          type: string
          nullable: true
          description: Metric ULID.
        agent_id:
          type: string
          nullable: true
          description: Agent ID. Null for org-wide baselines.
        test_set_id:
          type: string
          nullable: true
          description: Test set ULID. Null for monitoring.
        persona_id:
          type: string
          nullable: true
          description: Persona ULID. Null when the baseline covers all personas.
        display_name:
          type: string
          nullable: true
          description: User-facing label.
        status:
          $ref: '#/components/schemas/BaselineStatus'
        detection_method:
          $ref: '#/components/schemas/BaselineDetectionMethod'
        baseline_float:
          type: number
          nullable: true
          description: Current baseline mean estimate.
        baseline_sigma:
          type: number
          nullable: true
          description: Current baseline standard deviation estimate.
        observation_count:
          type: integer
          default: 0
          description: Number of observations processed.
        sigma_threshold:
          type: number
          description: Sigmas from the baseline that constitute an anomaly.
        direction:
          $ref: '#/components/schemas/BaselineDirection'
        sigma_bands:
          type: object
          nullable: true
          additionalProperties:
            type: number
          description: >
            Computed sigma bands keyed by level (e.g. `upper_1sigma`,
            `lower_2sigma`,

            `upper_2sigma`). Null when baseline stats are not yet populated.
            Levels

            controlled by the `sigma_levels` query param.
        last_processed_run_completed_at:
          type: string
          format: date-time
          nullable: true
          description: 'Cursor: when the last processed run completed.'
        created_at:
          type: string
          format: date-time
        last_updated_at:
          type: string
          format: date-time
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              enum:
                - INVALID_ARGUMENT
                - UNAUTHENTICATED
                - PERMISSION_DENIED
                - NOT_FOUND
                - ALREADY_EXISTS
                - INTERNAL
            message:
              type: string
            details:
              type: array
              items:
                type: object
                properties:
                  field:
                    type: string
                    nullable: true
                  description:
                    type: string
    BaselineDirection:
      type: string
      description: Which direction(s) of deviation count as anomalous.
      enum:
        - BOTH
        - ABOVE
        - BELOW
    BaselineStatus:
      type: string
      description: Baseline lifecycle status.
      enum:
        - ACTIVE
        - STANDBY
        - ARCHIVED
    BaselineDetectionMethod:
      type: string
      description: Anomaly detection algorithm. Currently only EWMA.
      enum:
        - EWMA
  responses:
    Unauthorized:
      description: Authentication failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: UNAUTHENTICATED
              message: Authentication failed
              details:
                - field: X-API-Key
                  description: Invalid or missing API key
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: NOT_FOUND
              message: Metric not found
              details:
                - field: metric_id
                  description: No metric found with this ID
    InternalError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: INTERNAL
              message: Internal server error
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key for authentication

````