{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/vatfind-com/json-schema/vatfind-com-monitor-event-schema.json",
  "title": "MonitorEvent",
  "x-generated": "2026-11-27",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/vatfind-com-openapi.yml#/components/schemas/MonitorEvent",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "object",
    "monitor_id",
    "type",
    "severity",
    "changes",
    "delivery",
    "created_at"
  ],
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^evt_[A-Za-z0-9_-]{16,80}$"
    },
    "object": {
      "const": "vat_monitor_event"
    },
    "monitor_id": {
      "type": "string",
      "pattern": "^mon_[A-Za-z0-9_-]{16,80}$"
    },
    "type": {
      "type": "string",
      "enum": [
        "vat.monitor.change_detected",
        "vat.monitor.source_degraded",
        "vat.monitor.source_restored",
        "vat.monitor.needs_credits",
        "vat.monitor.paused",
        "vat.monitor.resumed"
      ]
    },
    "severity": {
      "type": "string",
      "enum": [
        "info",
        "warning",
        "high"
      ]
    },
    "changes": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/MonitorChange"
      }
    },
    "check_id": {
      "type": "string",
      "pattern": "^chk_[A-Za-z0-9_-]{16,80}$"
    },
    "snapshot": {
      "$ref": "#/$defs/MonitorSnapshot"
    },
    "delivery": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "status",
        "attempts"
      ],
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "not_configured",
            "pending",
            "delivered",
            "retrying",
            "failed"
          ]
        },
        "attempts": {
          "type": "integer",
          "minimum": 0
        },
        "delivered_at": {
          "type": "string",
          "format": "date-time"
        },
        "response_status": {
          "type": "integer",
          "minimum": 100,
          "maximum": 599
        }
      }
    },
    "acknowledged_at": {
      "type": "string",
      "format": "date-time"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "CompanyLegalStatus": {
      "type": "string",
      "enum": [
        "active",
        "inactive",
        "dissolved",
        "liquidation",
        "insolvency",
        "unknown",
        "unavailable",
        "not_applicable",
        "not_supported",
        "not_checked"
      ]
    },
    "MonitorChange": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "field",
        "previous",
        "current"
      ],
      "properties": {
        "field": {
          "$ref": "#/$defs/MonitorWatchedField"
        },
        "previous": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            {
              "type": "null"
            }
          ]
        },
        "current": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            {
              "type": "null"
            }
          ]
        }
      }
    },
    "MonitorSnapshot": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "check_id",
        "observed_at",
        "registry_match_status",
        "company_legal_status",
        "legal_name",
        "registration_number",
        "vat_numbers",
        "registered_address"
      ],
      "properties": {
        "check_id": {
          "type": "string",
          "pattern": "^chk_[A-Za-z0-9_-]{16,80}$"
        },
        "observed_at": {
          "type": "string",
          "format": "date-time"
        },
        "registry_match_status": {
          "$ref": "#/$defs/RegistryMatchStatus"
        },
        "company_legal_status": {
          "$ref": "#/$defs/CompanyLegalStatus"
        },
        "legal_name": {
          "type": [
            "string",
            "null"
          ]
        },
        "registration_number": {
          "type": [
            "string",
            "null"
          ]
        },
        "vat_numbers": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "registered_address": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "MonitorWatchedField": {
      "type": "string",
      "enum": [
        "registry_match_status",
        "company_legal_status",
        "legal_name",
        "registration_number",
        "vat_numbers",
        "registered_address"
      ]
    },
    "RegistryMatchStatus": {
      "type": "string",
      "enum": [
        "matched",
        "not_matched",
        "ambiguous",
        "unavailable",
        "not_supported",
        "not_checked"
      ]
    }
  }
}