{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/foundational/json-schema/foundational-monitor-preview-request-schema.json",
  "title": "MonitorPreviewRequest",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/foundational-monitors-api-openapi.yml#/components/schemas/MonitorPreviewRequest",
  "properties": {
    "connectorId": {
      "type": "string",
      "format": "uuid",
      "title": "Connectorid",
      "description": "Public id of the warehouse connector to run as."
    },
    "target": {
      "oneOf": [
        {
          "$ref": "#/$defs/TablePreviewTarget"
        },
        {
          "$ref": "#/$defs/CustomQueryPreviewTarget"
        }
      ],
      "title": "Target"
    },
    "columns": {
      "anyOf": [
        {
          "additionalProperties": {
            "$ref": "#/$defs/ColumnMetricsConfig"
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Columns",
      "description": "Draft column checks, keyed like a monitor config. Omitted: the saved monitor's checks. Empty: no checks, only the row count and sample rows."
    },
    "segmentation": {
      "anyOf": [
        {
          "$ref": "#/$defs/SegmentationConfig"
        },
        {
          "type": "null"
        }
      ]
    },
    "sampleRows": {
      "type": "integer",
      "maximum": 100.0,
      "minimum": 0.0,
      "title": "Samplerows",
      "default": 20
    }
  },
  "type": "object",
  "required": [
    "connectorId",
    "target"
  ],
  "$defs": {
    "CheckConfig": {
      "properties": {
        "min_threshold": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Min Threshold"
        },
        "max_threshold": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Max Threshold"
        },
        "pattern": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Pattern"
        },
        "allowed_values": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Allowed Values"
        }
      },
      "type": "object",
      "title": "CheckConfig"
    },
    "ColumnMetricsConfig": {
      "properties": {
        "column_name": {
          "type": "string",
          "title": "Column Name"
        },
        "metrics": {
          "additionalProperties": {
            "$ref": "#/$defs/CheckConfig"
          },
          "propertyNames": {
            "$ref": "#/$defs/ObservabilityMetricType"
          },
          "type": "object",
          "title": "Metrics",
          "default": {}
        },
        "fixed_case": {
          "type": "boolean",
          "title": "Fixed Case",
          "default": false
        }
      },
      "type": "object",
      "required": [
        "column_name"
      ],
      "title": "ColumnMetricsConfig"
    },
    "CustomQueryPreviewTarget": {
      "properties": {
        "kind": {
          "type": "string",
          "const": "custom_query",
          "title": "Kind"
        },
        "customQueryId": {
          "anyOf": [
            {
              "type": "string",
              "format": "uuid"
            },
            {
              "type": "null"
            }
          ],
          "title": "Customqueryid"
        },
        "queryText": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 100000
            },
            {
              "type": "null"
            }
          ],
          "title": "Querytext"
        },
        "targetDbName": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 512
            },
            {
              "type": "null"
            }
          ],
          "title": "Targetdbname",
          "description": "Database the SQL's unqualified names resolve in."
        },
        "targetSchemaName": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 512
            },
            {
              "type": "null"
            }
          ],
          "title": "Targetschemaname",
          "description": "Schema the SQL's unqualified names resolve in."
        }
      },
      "type": "object",
      "required": [
        "kind"
      ],
      "title": "CustomQueryPreviewTarget",
      "description": "A custom-query monitor: a saved custom query by id, or SQL that is not saved yet."
    },
    "ObservabilityMetricType": {
      "type": "string",
      "enum": [
        "null_count",
        "zero_count",
        "true_count",
        "row_count",
        "distinct_values_count",
        "min",
        "max",
        "count",
        "sum",
        "avg",
        "pattern",
        "allowed_values"
      ],
      "title": "ObservabilityMetricType"
    },
    "SegmentationConfig": {
      "properties": {
        "segment_by": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Segment By",
          "default": []
        },
        "max_segments": {
          "type": "integer",
          "title": "Max Segments",
          "default": 1000
        }
      },
      "type": "object",
      "title": "SegmentationConfig",
      "description": "Configuration for metric segmentation by column values."
    },
    "TablePreviewTarget": {
      "properties": {
        "kind": {
          "type": "string",
          "const": "table",
          "title": "Kind"
        },
        "dbName": {
          "type": "string",
          "maxLength": 512,
          "title": "Dbname"
        },
        "schemaName": {
          "type": "string",
          "maxLength": 512,
          "title": "Schemaname"
        },
        "tableName": {
          "type": "string",
          "maxLength": 512,
          "title": "Tablename"
        },
        "fixedCase": {
          "type": "boolean",
          "title": "Fixedcase",
          "description": "The names are quoted identifiers: do not case-fold them.",
          "default": false
        }
      },
      "type": "object",
      "required": [
        "kind",
        "dbName",
        "schemaName",
        "tableName"
      ],
      "title": "TablePreviewTarget",
      "description": "A warehouse table, named as a table monitor names it."
    }
  }
}