{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/fettle-sh/json-schema/fettle-sh-monitor-read-schema.json",
  "title": "MonitorRead",
  "description": "Response model for monitor reads and creates.",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/fettle-sh-api-openapi.json#/components/schemas/MonitorRead",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "title": "Id"
    },
    "user_id": {
      "type": "string",
      "format": "uuid",
      "title": "User Id"
    },
    "name": {
      "type": "string",
      "title": "Name"
    },
    "type": {
      "$ref": "#/$defs/CheckType"
    },
    "target": {
      "type": "string",
      "title": "Target"
    },
    "interval_seconds": {
      "type": "integer",
      "title": "Interval Seconds"
    },
    "timeout_seconds": {
      "type": "integer",
      "title": "Timeout Seconds"
    },
    "regions": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "title": "Regions"
    },
    "config": {
      "additionalProperties": true,
      "type": "object",
      "title": "Config"
    },
    "status": {
      "$ref": "#/$defs/MonitorStatus"
    },
    "last_checked_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Last Checked At"
    },
    "next_run_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Next Run At"
    },
    "confirmation_threshold": {
      "type": "integer",
      "title": "Confirmation Threshold"
    },
    "notification_cooldown_seconds": {
      "type": "integer",
      "title": "Notification Cooldown Seconds"
    },
    "ssl_expires_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Ssl Expires At"
    },
    "ssl_cert_info": {
      "anyOf": [
        {
          "$ref": "#/$defs/SslCertInfo"
        },
        {
          "type": "null"
        }
      ]
    },
    "is_active": {
      "type": "boolean",
      "title": "Is Active"
    },
    "badge_enabled": {
      "type": "boolean",
      "title": "Badge Enabled",
      "default": false
    },
    "tags": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "title": "Tags"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "title": "Created At"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "title": "Updated At"
    },
    "channel_ids": {
      "items": {
        "type": "string",
        "format": "uuid"
      },
      "type": "array",
      "title": "Channel Ids"
    },
    "region_statuses": {
      "items": {
        "$ref": "#/$defs/RegionStatusRead"
      },
      "type": "array",
      "title": "Region Statuses",
      "description": "Per-region latest status, sorted by region name.\n\nBuilt from ``region_snapshots``; ``job_id`` is dropped (internal\ndedup key) and malformed/partial snapshot rows are skipped rather\nthan failing the read.",
      "readOnly": true
    }
  },
  "additionalProperties": false,
  "type": "object",
  "required": [
    "id",
    "user_id",
    "name",
    "type",
    "target",
    "interval_seconds",
    "timeout_seconds",
    "regions",
    "config",
    "status",
    "last_checked_at",
    "next_run_at",
    "confirmation_threshold",
    "notification_cooldown_seconds",
    "ssl_expires_at",
    "is_active",
    "created_at",
    "updated_at",
    "region_statuses"
  ],
  "$defs": {
    "CheckResultStatus": {
      "type": "string",
      "enum": [
        "UP",
        "DEGRADED",
        "DOWN",
        "ERROR"
      ],
      "title": "CheckResultStatus",
      "description": "Outcome of a single probe execution reported in a :class:`CheckResult`.\n\n``DEGRADED`` means the resource responded / is working but in a degraded\nstate (e.g. partial ping packet loss, a TLS cert expiring soon). It counts\nas up for uptime — it never penalises uptime% and never opens an incident —\nbut is tracked separately so the UI can render it distinctly."
    },
    "CheckType": {
      "type": "string",
      "enum": [
        "HTTP",
        "PING",
        "SSL",
        "TCP",
        "DNS"
      ],
      "title": "CheckType",
      "description": "Type of probe a worker must run for a :class:`CheckJob`."
    },
    "MonitorStatus": {
      "type": "string",
      "enum": [
        "PENDING",
        "UP",
        "DEGRADED",
        "DOWN",
        "PAUSED"
      ],
      "title": "MonitorStatus",
      "description": "Aggregated state of a monitor as derived by the results state machine."
    },
    "RegionStatusRead": {
      "properties": {
        "region": {
          "type": "string",
          "title": "Region"
        },
        "status": {
          "$ref": "#/$defs/CheckResultStatus"
        },
        "checked_at": {
          "type": "string",
          "format": "date-time",
          "title": "Checked At"
        },
        "display_name": {
          "type": "string",
          "title": "Display Name"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "region",
        "status",
        "checked_at",
        "display_name"
      ],
      "title": "RegionStatusRead",
      "description": "Latest probe outcome for one region, derived from a monitor's snapshots.\n\nDrives the dashboard region grid and the per-region status dots. The\nstatus is a per-region :class:`CheckStatus` (``UP`` / ``DOWN`` / ``ERROR``);\nthe aggregate ``DEGRADED`` / ``PAUSED`` states live on the monitor itself,\nnot on a single region."
    },
    "SslCertInfo": {
      "properties": {
        "issuer": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Issuer"
        },
        "subject": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Subject"
        },
        "not_before": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Not Before"
        },
        "not_after": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Not After"
        },
        "valid": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Valid"
        }
      },
      "type": "object",
      "title": "SslCertInfo",
      "description": "Latest TLS certificate snapshot for an SSL monitor (У8).\n\nPromoted from an SSL probe's ``CheckResult.details`` onto the monitor row\nso the card/detail render \"what cert, valid until, issued by/when\" without\na per-check query. All fields are nullable — a partial worker blob or a\nnot-yet-probed monitor leaves them ``None``.\n\n``not_before`` / ``not_after`` are kept as the raw RFC3339 strings the\nworker reported (display echo). The canonical, typed expiry is the\nmonitor's top-level ``ssl_expires_at``; \"expires in N days\" is recomputed\nclient-side from it, never the worker's stale ``days_left``."
    }
  }
}