{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/vatfind-com/json-schema/vatfind-com-monitor-schema.json",
  "title": "Monitor",
  "x-generated": "2026-11-27",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/vatfind-com-openapi.yml#/components/schemas/Monitor",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "object",
    "environment",
    "status",
    "health",
    "identifier",
    "cadence",
    "watched_fields",
    "baseline_check_id",
    "latest_check_id",
    "latest_snapshot",
    "last_checked_at",
    "next_check_at",
    "failure_count",
    "estimated_monthly_checks",
    "created_at",
    "updated_at"
  ],
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^mon_[A-Za-z0-9_-]{16,80}$"
    },
    "object": {
      "const": "vat_monitor"
    },
    "environment": {
      "type": "string",
      "enum": [
        "live",
        "sandbox"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "paused",
        "attention"
      ]
    },
    "health": {
      "type": "string",
      "enum": [
        "healthy",
        "source_degraded",
        "needs_credits"
      ]
    },
    "identifier": {
      "$ref": "#/$defs/Identifier"
    },
    "company_name": {
      "type": "string"
    },
    "client_reference": {
      "type": "string"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      }
    },
    "cadence": {
      "$ref": "#/$defs/MonitorCadence"
    },
    "watched_fields": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "$ref": "#/$defs/MonitorWatchedField"
      }
    },
    "webhook_url": {
      "type": "string",
      "format": "uri",
      "pattern": "^https://"
    },
    "baseline_check_id": {
      "type": "string",
      "pattern": "^chk_[A-Za-z0-9_-]{16,80}$"
    },
    "latest_check_id": {
      "type": "string",
      "pattern": "^chk_[A-Za-z0-9_-]{16,80}$"
    },
    "latest_snapshot": {
      "$ref": "#/$defs/MonitorSnapshot"
    },
    "last_checked_at": {
      "type": "string",
      "format": "date-time"
    },
    "next_check_at": {
      "type": "string",
      "format": "date-time"
    },
    "last_event_at": {
      "type": "string",
      "format": "date-time"
    },
    "failure_count": {
      "type": "integer",
      "minimum": 0
    },
    "last_error_code": {
      "type": "string"
    },
    "estimated_monthly_checks": {
      "type": "integer",
      "enum": [
        1,
        5,
        30
      ]
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "CompanyLegalStatus": {
      "type": "string",
      "enum": [
        "active",
        "inactive",
        "dissolved",
        "liquidation",
        "insolvency",
        "unknown",
        "unavailable",
        "not_applicable",
        "not_supported",
        "not_checked"
      ]
    },
    "CountryCode": {
      "type": "string",
      "pattern": "^[A-Z]{2}$"
    },
    "Identifier": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "input",
        "normalized",
        "country_code"
      ],
      "properties": {
        "type": {
          "$ref": "#/$defs/IdentifierType"
        },
        "input": {
          "type": "string"
        },
        "normalized": {
          "type": "string"
        },
        "country_code": {
          "$ref": "#/$defs/CountryCode"
        }
      }
    },
    "IdentifierType": {
      "type": "string",
      "enum": [
        "vat_number",
        "tax_identifier",
        "registration_number"
      ]
    },
    "MonitorCadence": {
      "type": "string",
      "enum": [
        "daily",
        "weekly",
        "monthly"
      ]
    },
    "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"
      ]
    }
  }
}