{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Webhook event notification",
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "v": {
          "type": "number",
          "const": 1
        },
        "feed": {
          "type": "string",
          "const": "events"
        },
        "type": {
          "type": "string",
          "enum": [
            "placement_acquired",
            "placement_recovered",
            "placement_changed",
            "placement_lost",
            "source_unavailable",
            "watch.checked",
            "watch.state_changed",
            "watch.check_quality_changed"
          ]
        },
        "id": {
          "type": "string"
        },
        "sequence": {
          "type": "integer",
          "minimum": 1
        },
        "workspace_id": {
          "type": "string"
        },
        "project_id": {
          "type": "string"
        },
        "subject_id": {
          "type": "string"
        },
        "created_at": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T.*(?:Z|[+-]\\d{2}:\\d{2})$"
        },
        "transition": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "unknown",
                "present",
                "suspected_missing",
                "confirmed_missing",
                "source_unavailable"
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "previous": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "unknown",
                "present",
                "suspected_missing",
                "confirmed_missing",
                "source_unavailable"
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "uncertain": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ]
        },
        "checked_at": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}T.*(?:Z|[+-]\\d{2}:\\d{2})$"
            },
            {
              "type": "null"
            }
          ]
        },
        "observation_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "evidence_key": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "resume": {
          "type": "object",
          "properties": {
            "feed": {
              "type": "string",
              "const": "events"
            },
            "after_sequence": {
              "type": "integer",
              "minimum": 1
            },
            "endpoint": {
              "type": "string",
              "const": "/v1/events"
            }
          },
          "required": [
            "feed",
            "after_sequence",
            "endpoint"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "v",
        "feed",
        "type",
        "id",
        "sequence",
        "workspace_id",
        "project_id",
        "subject_id",
        "created_at",
        "transition",
        "previous",
        "uncertain",
        "checked_at",
        "observation_id",
        "evidence_key",
        "resume"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "v": {
          "type": "number",
          "const": 1
        },
        "feed": {
          "type": "string",
          "const": "target_events"
        },
        "type": {
          "type": "string",
          "enum": [
            "target_healthy",
            "target_recovered",
            "target_unavailable",
            "target.checked",
            "target.state_changed",
            "target.check_quality_changed"
          ]
        },
        "id": {
          "type": "string"
        },
        "sequence": {
          "type": "integer",
          "minimum": 1
        },
        "workspace_id": {
          "type": "string"
        },
        "project_id": {
          "type": "string"
        },
        "subject_id": {
          "type": "string"
        },
        "created_at": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T.*(?:Z|[+-]\\d{2}:\\d{2})$"
        },
        "transition": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "unknown",
                "healthy",
                "suspected_unavailable",
                "unavailable"
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "previous": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "unknown",
                "healthy",
                "suspected_unavailable",
                "unavailable"
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "uncertain": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ]
        },
        "checked_at": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}T.*(?:Z|[+-]\\d{2}:\\d{2})$"
            },
            {
              "type": "null"
            }
          ]
        },
        "observation_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "evidence_key": {
          "type": "null"
        },
        "resume": {
          "type": "object",
          "properties": {
            "feed": {
              "type": "string",
              "const": "target_events"
            },
            "after_sequence": {
              "type": "integer",
              "minimum": 1
            },
            "endpoint": {
              "type": "string",
              "const": "/v1/target-events"
            }
          },
          "required": [
            "feed",
            "after_sequence",
            "endpoint"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "v",
        "feed",
        "type",
        "id",
        "sequence",
        "workspace_id",
        "project_id",
        "subject_id",
        "created_at",
        "transition",
        "previous",
        "uncertain",
        "checked_at",
        "observation_id",
        "evidence_key",
        "resume"
      ],
      "additionalProperties": false
    }
  ]
}
