{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Webhook digest notification",
  "type": "object",
  "properties": {
    "v": {
      "type": "number",
      "const": 1
    },
    "kind": {
      "type": "string",
      "const": "digest"
    },
    "workspace_id": {
      "type": "string"
    },
    "window": {
      "type": "object",
      "properties": {
        "opened_at": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T.*(?:Z|[+-]\\d{2}:\\d{2})$"
        },
        "closed_at": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T.*(?:Z|[+-]\\d{2}:\\d{2})$"
        }
      },
      "required": [
        "opened_at",
        "closed_at"
      ],
      "additionalProperties": false
    },
    "computed": {
      "type": "boolean",
      "const": true
    },
    "totals": {
      "type": "object",
      "properties": {
        "subjects": {
          "type": "integer",
          "minimum": 0
        },
        "events": {
          "type": "integer",
          "minimum": 0
        },
        "changed": {
          "type": "integer",
          "minimum": 0
        }
      },
      "required": [
        "subjects",
        "events",
        "changed"
      ],
      "additionalProperties": false
    },
    "subjects": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "subject_id": {
            "type": "string"
          },
          "project_id": {
            "type": "string"
          },
          "previous": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "unknown",
                  "present",
                  "suspected_missing",
                  "confirmed_missing",
                  "source_unavailable"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "state": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "unknown",
                  "present",
                  "suspected_missing",
                  "confirmed_missing",
                  "source_unavailable"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "uncertain": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ]
          },
          "events": {
            "type": "integer",
            "minimum": 1
          },
          "types": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "placement_acquired",
                "placement_recovered",
                "placement_changed",
                "placement_lost",
                "source_unavailable",
                "watch.checked",
                "watch.state_changed",
                "watch.check_quality_changed"
              ]
            },
            "uniqueItems": true,
            "minItems": 1
          },
          "first_seen_at": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T.*(?:Z|[+-]\\d{2}:\\d{2})$"
          },
          "last_seen_at": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T.*(?:Z|[+-]\\d{2}:\\d{2})$"
          },
          "checked_at": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^\\d{4}-\\d{2}-\\d{2}T.*(?:Z|[+-]\\d{2}:\\d{2})$"
              },
              {
                "type": "null"
              }
            ]
          },
          "evidence_key": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "subject_id",
          "project_id",
          "previous",
          "state",
          "uncertain",
          "events",
          "types",
          "first_seen_at",
          "last_seen_at",
          "checked_at",
          "evidence_key"
        ],
        "additionalProperties": false
      },
      "maxItems": 200
    },
    "truncated": {
      "type": "boolean"
    },
    "events_truncated": {
      "type": "boolean"
    },
    "resume": {
      "type": "object",
      "properties": {
        "feed": {
          "type": "string",
          "const": "events"
        },
        "after_sequence": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "endpoint": {
          "type": "string",
          "const": "/v1/events"
        }
      },
      "required": [
        "feed",
        "after_sequence",
        "endpoint"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "v",
    "kind",
    "workspace_id",
    "window",
    "computed",
    "totals",
    "subjects",
    "truncated",
    "events_truncated",
    "resume"
  ],
  "additionalProperties": false
}
