{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/usewrit-app/json-schema/usewrit-app-monitor-schema.json",
  "title": "Monitor",
  "description": "A monitor (`targets` row). `setup_steps` is credential-REDACTED on every response: its `credentials` sub-object is replaced with the sentinel string `«redacted»` (an unparsable stored payload collapses to the bare sentinel string). List/get responses are additionally enriched with live state (`state`, `last_checked_at`, `status_code`, `is_up`, `last_change_at`, `state_updated_at`) and counts (`changes_count`, `selector_count`); create/update responses are the bare row.",
  "x-generated": "2026-10-31",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/writ-agent.yaml#/components/schemas/Monitor",
  "type": "object",
  "required": [
    "id",
    "url",
    "check_type",
    "enabled",
    "requires_playwright",
    "on_change_enabled",
    "on_change_in_session",
    "created_at"
  ],
  "properties": {
    "id": {
      "type": "integer",
      "format": "int64"
    },
    "url": {
      "type": "string"
    },
    "check_type": {
      "type": "string",
      "description": "`content` | `uptime`."
    },
    "selector": {
      "type": [
        "string",
        "null"
      ]
    },
    "ignore_regex": {
      "type": [
        "string",
        "null"
      ]
    },
    "check_period_ms": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64"
    },
    "expected_status_code": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64"
    },
    "timeout_ms": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64"
    },
    "max_response_time_ms": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64"
    },
    "check_ssl": {
      "type": [
        "integer",
        "null"
      ],
      "description": "0/1 integer flag."
    },
    "enabled": {
      "type": "integer",
      "description": "0/1 integer flag."
    },
    "requires_playwright": {
      "type": "integer",
      "description": "0/1 integer flag (JS/Playwright path vs plain HTML fetch)."
    },
    "baseline_hash": {
      "type": [
        "string",
        "null"
      ]
    },
    "baseline_content": {
      "type": [
        "string",
        "null"
      ]
    },
    "baseline_fetched_at": {
      "type": [
        "string",
        "null"
      ]
    },
    "pre_check_workflow_id": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64"
    },
    "setup_steps": {
      "description": "Redacted setup-steps manifest: an object whose `credentials` is the string `«redacted»`, the bare sentinel string, or null.",
      "type": [
        "object",
        "string",
        "null"
      ]
    },
    "on_change_workflow_id": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64"
    },
    "on_change_enabled": {
      "type": "integer",
      "description": "0/1 integer flag."
    },
    "on_change_conditions": {
      "type": [
        "string",
        "null"
      ],
      "description": "JSON-TEXT (returned as the stored string)."
    },
    "on_change_in_session": {
      "type": "integer",
      "description": "0/1 integer flag."
    },
    "persona_id": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64"
    },
    "auth_session_encrypted": {
      "type": [
        "string",
        "null"
      ],
      "description": "Sealed session blob (opaque; present as stored)."
    },
    "notification_providers": {
      "type": [
        "string",
        "null"
      ]
    },
    "provider_notification_settings": {
      "type": [
        "string",
        "null"
      ]
    },
    "notification_title": {
      "type": [
        "string",
        "null"
      ]
    },
    "notification_message": {
      "type": [
        "string",
        "null"
      ]
    },
    "notification_priority": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64"
    },
    "next_run_at": {
      "type": [
        "string",
        "null"
      ]
    },
    "schedule_kind": {
      "type": [
        "string",
        "null"
      ],
      "description": "`interval` (default) | `daily` | `weekly`."
    },
    "schedule_time": {
      "type": [
        "string",
        "null"
      ]
    },
    "schedule_days": {
      "type": [
        "string",
        "null"
      ],
      "description": "JSON array string of ISO weekday ints."
    },
    "schedule_tz": {
      "type": [
        "string",
        "null"
      ]
    },
    "created_at": {
      "type": "string"
    },
    "updated_at": {
      "type": [
        "string",
        "null"
      ]
    },
    "state": {
      "type": [
        "string",
        "null"
      ],
      "description": "Enrichment (list/get only): live check state (`unchanged`, `changed`, `error`, `checking`, …)."
    },
    "last_checked_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "Enrichment (list/get only)."
    },
    "status_code": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Enrichment (list/get only)."
    },
    "is_up": {
      "type": [
        "boolean",
        "null"
      ],
      "description": "Enrichment (list/get only)."
    },
    "last_change_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "Enrichment (list/get only)."
    },
    "state_updated_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "Enrichment (list/get only) — the live-state row's own update stamp."
    },
    "changes_count": {
      "type": "integer",
      "description": "Enrichment (list/get only)."
    },
    "selector_count": {
      "type": "integer",
      "description": "Enrichment (list/get only)."
    }
  }
}