> ## 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 a monitor

> Partially updates a monitor. All fields are optional; omitted fields
retain their current values (PATCH semantics).

When `conditions` or `channels` are provided, they **replace** the
existing set atomically (delete old, create new).




## OpenAPI

````yaml /api-reference/v1/monitors-v1.yaml patch /monitors/{monitor_id}
openapi: 3.0.3
info:
  title: Coval Monitors API
  version: 1.0.0
  description: |
    API for managing monitors — metric-based alerting rules that evaluate
    on run completion and dispatch notifications to configured channels.

    Monitors support:
    - Per-run metric checks (single value, run average, run fraction)
    - AND/OR condition logic across multiple metrics
    - Multi-channel notifications (Slack, email, webhook, human review)
    - Cooldown/deduplication
    - Custom message templates
  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
security:
  - ApiKeyAuth: []
tags:
  - name: Monitors
    description: CRUD operations for monitor definitions
  - name: Monitor Events
    description: Monitor evaluation event history
paths:
  /monitors/{monitor_id}:
    patch:
      tags:
        - Monitors
      summary: Update a monitor
      description: |
        Partially updates a monitor. All fields are optional; omitted fields
        retain their current values (PATCH semantics).

        When `conditions` or `channels` are provided, they **replace** the
        existing set atomically (delete old, create new).
      operationId: updateMonitor
      parameters:
        - $ref: '#/components/parameters/MonitorId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateMonitorRequest'
      responses:
        '200':
          description: Monitor updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MonitorResource'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/PermissionDenied'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: Monitor name conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  parameters:
    MonitorId:
      name: monitor_id
      in: path
      required: true
      schema:
        type: string
        pattern: ^[0-9A-Z]{26}$
      description: Monitor ULID
      example: 01HZ0EXAMPLE00000000000000
  schemas:
    UpdateMonitorRequest:
      type: object
      properties:
        name:
          type: string
          maxLength: 200
        description:
          type: string
          maxLength: 2000
        evaluation_type:
          $ref: '#/components/schemas/MonitorEvaluationType'
        scope:
          $ref: '#/components/schemas/MonitorScope'
        match_mode:
          $ref: '#/components/schemas/MonitorMatchMode'
        cooldown_seconds:
          type: integer
          minimum: 0
          maximum: 86400
        custom_message_template:
          type: string
          nullable: true
        agent_ids:
          type: array
          nullable: true
          items:
            type: string
        required_tags:
          type: array
          nullable: true
          items:
            type: string
        scheduled_run_ids:
          type: array
          nullable: true
          items:
            type: string
        conditions:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/ConditionInput'
          description: Replaces all existing conditions
        channels:
          type: array
          items:
            $ref: '#/components/schemas/ChannelInput'
          description: Replaces all existing channels
    MonitorResource:
      type: object
      required:
        - ulid
        - name
        - status
        - evaluation_type
        - scope
        - match_mode
        - cooldown_seconds
        - trigger_count
        - conditions
        - channels
        - create_time
        - update_time
      properties:
        ulid:
          type: string
          pattern: ^[0-9A-Z]{26}$
          description: Monitor ULID
          example: 01HZ0EXAMPLE00000000000000
        name:
          type: string
          maxLength: 200
          description: Human-readable monitor name
          example: Latency SLA Monitor
        description:
          type: string
          default: ''
          description: Optional description
        status:
          type: string
          enum:
            - ACTIVE
            - DELETED
          description: Monitor status
        evaluation_type:
          $ref: '#/components/schemas/MonitorEvaluationType'
        scope:
          $ref: '#/components/schemas/MonitorScope'
        match_mode:
          $ref: '#/components/schemas/MonitorMatchMode'
        cooldown_seconds:
          type: integer
          minimum: 0
          maximum: 86400
          description: Minimum seconds between triggers
        custom_message_template:
          type: string
          nullable: true
          maxLength: 5000
          description: Custom notification message template
        agent_ids:
          type: array
          nullable: true
          items:
            type: string
          description: Restrict to specific agent IDs
        required_tags:
          type: array
          nullable: true
          items:
            type: string
          description: Restrict to runs with these tags
        scheduled_run_ids:
          type: array
          nullable: true
          items:
            type: string
          description: Restrict to runs originating from these scheduled runs
        trigger_count:
          type: integer
          description: Number of times this monitor has triggered
        last_triggered_at:
          type: string
          format: date-time
          nullable: true
          description: Last trigger timestamp
        conditions:
          type: array
          items:
            $ref: '#/components/schemas/MonitorCondition'
          description: Evaluation conditions
        channels:
          type: array
          items:
            $ref: '#/components/schemas/MonitorChannel'
          description: Notification channels
        create_time:
          type: string
          format: date-time
          description: Creation timestamp
        update_time:
          type: string
          format: date-time
          description: Last update timestamp
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
            - details
          properties:
            code:
              type: string
              enum:
                - INVALID_ARGUMENT
                - UNAUTHENTICATED
                - PERMISSION_DENIED
                - NOT_FOUND
                - ALREADY_EXISTS
                - INTERNAL
            message:
              type: string
              description: Human-readable error message
            details:
              type: array
              items:
                type: object
                properties:
                  field:
                    type: string
                    nullable: true
                  description:
                    type: string
    MonitorEvaluationType:
      type: string
      enum:
        - ON_RUN_COMPLETE
      description: When the monitor evaluates
    MonitorScope:
      type: string
      enum:
        - ALL
        - MONITORING
        - SIMULATION
      description: Which runs the monitor applies to
    MonitorMatchMode:
      type: string
      enum:
        - ALL
        - ANY
      description: How multiple conditions are combined (AND vs OR)
    ConditionInput:
      type: object
      required:
        - metric_id
        - aggregation
        - operator
      properties:
        metric_id:
          type: string
          description: ULID of the metric to evaluate
        aggregation:
          $ref: '#/components/schemas/ConditionAggregation'
        operator:
          $ref: '#/components/schemas/ConditionOperator'
        threshold_float:
          type: number
          nullable: true
        threshold_string:
          type: string
          nullable: true
        window_size_days:
          type: integer
          nullable: true
          minimum: 1
          maximum: 365
        window_size_runs:
          type: integer
          nullable: true
          minimum: 1
          maximum: 10000
        match_value:
          type: string
          nullable: true
        match_mode:
          type: string
          nullable: true
          enum:
            - exact
            - contains
            - contains_case_insensitive
    ChannelInput:
      type: object
      required:
        - channel_type
        - config
      properties:
        channel_type:
          $ref: '#/components/schemas/ChannelType'
        config:
          type: object
          description: Channel-specific configuration
    MonitorCondition:
      type: object
      required:
        - ulid
        - metric_id
        - aggregation
        - operator
      properties:
        ulid:
          type: string
          pattern: ^[0-9A-Z]{26}$
          description: Condition ULID
        metric_id:
          type: string
          description: ULID of the metric to evaluate
        aggregation:
          $ref: '#/components/schemas/ConditionAggregation'
        operator:
          $ref: '#/components/schemas/ConditionOperator'
        threshold_float:
          type: number
          nullable: true
          description: Numeric threshold
        threshold_string:
          type: string
          nullable: true
          description: String threshold
        window_size_days:
          type: integer
          nullable: true
          minimum: 1
          maximum: 365
          description: Rolling window size in days
        window_size_runs:
          type: integer
          nullable: true
          minimum: 1
          maximum: 10000
          description: Rolling window size in runs
        match_value:
          type: string
          nullable: true
          description: String match value for fraction conditions
        match_mode:
          type: string
          nullable: true
          enum:
            - exact
            - contains
            - contains_case_insensitive
          description: String match mode
    MonitorChannel:
      type: object
      required:
        - ulid
        - channel_type
        - config
      properties:
        ulid:
          type: string
          pattern: ^[0-9A-Z]{26}$
          description: Channel ULID
        channel_type:
          $ref: '#/components/schemas/ChannelType'
        config:
          type: object
          description: >
            Channel-specific configuration.


            **SLACK**: `{"channel_id": "C0123ABC", "channel_name": "#alerts"}`


            **EMAIL**: `{"recipients": ["team@company.com"]}`


            **WEBHOOK**: `{"url": "https://...", "method": "POST", "auth_token":
            "..."}`


            **HUMAN_REVIEW**: `{"project_id": "...", "sample_rate": 0.1}`
    ConditionAggregation:
      type: string
      enum:
        - SINGLE
        - RUN_AVERAGE
        - RUN_FRACTION
      description: |
        Aggregation mode for a condition.
        - SINGLE: Per-simulation value (average across sim outputs)
        - RUN_AVERAGE: Average from pre-computed run aggregate
        - RUN_FRACTION: Fraction matching a string value in the run
    ConditionOperator:
      type: string
      enum:
        - GT
        - GTE
        - LT
        - LTE
        - EQ
        - NEQ
      description: Comparison operator
    ChannelType:
      type: string
      enum:
        - SLACK
        - EMAIL
        - WEBHOOK
        - HUMAN_REVIEW
      description: Notification channel type
  responses:
    BadRequest:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: INVALID_ARGUMENT
              message: Invalid request body
              details:
                - field: conditions
                  description: >-
                    Value error, List should have at least 1 item after
                    validation
    Unauthorized:
      description: Unauthorized
      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
    PermissionDenied:
      description: Permission Denied
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: PERMISSION_DENIED
              message: Insufficient permissions
              details:
                - field: permissions
                  description: 'Required scope: monitors:read'
    NotFound:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: NOT_FOUND
              message: Monitor not found
              details:
                - field: monitor_id
                  description: Monitor '01HZ0EXAMPLE00000000000000' not found
    InternalError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: INTERNAL
              message: Internal server error
              details:
                - description: An unexpected error occurred
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key for authentication

````