{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/foundational/json-schema/foundational-public-custom-query-monitor-request-schema.json",
  "title": "PublicCustomQueryMonitorRequest",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/foundational-monitors-api-openapi.yml#/components/schemas/PublicCustomQueryMonitorRequest",
  "properties": {
    "customQueryId": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Customqueryid",
      "description": "The monitor to replace. Omitted: create one."
    },
    "connectorId": {
      "type": "string",
      "format": "uuid",
      "title": "Connectorid",
      "description": "Public id of the warehouse connector the query runs on."
    },
    "name": {
      "type": "string",
      "title": "Name"
    },
    "description": {
      "type": "string",
      "title": "Description",
      "default": ""
    },
    "query": {
      "type": "string",
      "title": "Query",
      "description": "One read-only SQL query."
    },
    "enabled": {
      "type": "boolean",
      "title": "Enabled",
      "default": true
    },
    "columnsNames": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Columnsnames",
      "description": "Result columns the monitor exposes. Omitted: every column the query returns."
    },
    "columns": {
      "additionalProperties": {
        "$ref": "#/$defs/ColumnMetricsConfig"
      },
      "type": "object",
      "title": "Columns",
      "description": "Checks per column, keyed by any stable id. Empty: the query has no checks.",
      "default": {}
    },
    "emptyResult": {
      "anyOf": [
        {
          "$ref": "#/$defs/EmptyResultPolicy"
        },
        {
          "type": "null"
        }
      ],
      "description": "Whether a run with no rows, or NULL for every check, is healthy (`pass`) or alerts (`alert`). Omitted on an update: the monitor keeps its setting."
    }
  },
  "type": "object",
  "required": [
    "connectorId",
    "name",
    "query"
  ],
  "$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"
    },
    "EmptyResultPolicy": {
      "type": "string",
      "enum": [
        "pass",
        "alert"
      ],
      "title": "EmptyResultPolicy",
      "description": "What a monitor run that returns no rows, or NULL for every check, means to the customer."
    },
    "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"
    }
  }
}