{
  "$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
    },
    {
      "type": "object",
      "properties": {
        "v": {
          "type": "number",
          "const": 1
        },
        "feed": {
          "type": "string",
          "const": "citation_events"
        },
        "type": {
          "type": "string",
          "enum": [
            "citation.declined",
            "citation.grown"
          ]
        },
        "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})$"
        },
        "data": {
          "type": "object",
          "properties": {
            "cell_id": {
              "type": "string"
            },
            "current": {
              "type": "object",
              "properties": {
                "epoch_id": {
                  "type": "string"
                },
                "k": {
                  "type": "integer",
                  "minimum": 0
                },
                "n": {
                  "type": "integer",
                  "minimum": 0
                },
                "unknowns": {
                  "type": "integer",
                  "minimum": 0
                },
                "at": {
                  "type": "string",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}T.*(?:Z|[+-]\\d{2}:\\d{2})$"
                }
              },
              "required": [
                "epoch_id",
                "k",
                "n",
                "unknowns",
                "at"
              ],
              "additionalProperties": false
            },
            "baseline": {
              "type": "object",
              "properties": {
                "epoch_id": {
                  "type": "string"
                },
                "k": {
                  "type": "integer",
                  "minimum": 0
                },
                "n": {
                  "type": "integer",
                  "minimum": 0
                },
                "unknowns": {
                  "type": "integer",
                  "minimum": 0
                },
                "at": {
                  "type": "string",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}T.*(?:Z|[+-]\\d{2}:\\d{2})$"
                }
              },
              "required": [
                "epoch_id",
                "k",
                "n",
                "unknowns",
                "at"
              ],
              "additionalProperties": false
            },
            "comparison": {
              "type": "object",
              "properties": {
                "verdict": {
                  "type": "string",
                  "enum": [
                    "declined",
                    "grown"
                  ]
                },
                "interval": {
                  "type": "array",
                  "items": {
                    "type": "number"
                  },
                  "minItems": 2,
                  "maxItems": 2
                },
                "alpha": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "maximum": 1
                },
                "comparisons": {
                  "type": "number",
                  "const": 1
                },
                "method": {
                  "type": "string",
                  "const": "fixed-n-hoeffding-difference"
                },
                "ordinal": {
                  "type": "integer",
                  "minimum": 1
                },
                "family_alpha": {
                  "type": "number",
                  "const": 0.05
                },
                "correction": {
                  "type": "string",
                  "const": "workspace-alpha-spending"
                },
                "assumptions": {
                  "type": "string"
                }
              },
              "required": [
                "verdict",
                "interval",
                "alpha",
                "comparisons",
                "method",
                "ordinal",
                "family_alpha",
                "correction",
                "assumptions"
              ],
              "additionalProperties": false
            },
            "evidence": {
              "type": "object",
              "properties": {
                "retained_observations_endpoint": {
                  "type": "string",
                  "const": "/v1/commands/list_citation_observations"
                },
                "project_id": {
                  "type": "string"
                },
                "epoch_id": {
                  "type": "string"
                }
              },
              "required": [
                "retained_observations_endpoint",
                "project_id",
                "epoch_id"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "cell_id",
            "current",
            "baseline",
            "comparison",
            "evidence"
          ],
          "additionalProperties": false
        },
        "resume": {
          "type": "object",
          "properties": {
            "feed": {
              "type": "string",
              "const": "citation_events"
            },
            "after_sequence": {
              "type": "integer",
              "minimum": 1
            },
            "endpoint": {
              "type": "string",
              "const": "/v1/citation-events"
            }
          },
          "required": [
            "feed",
            "after_sequence",
            "endpoint"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "v",
        "feed",
        "type",
        "id",
        "sequence",
        "workspace_id",
        "project_id",
        "subject_id",
        "created_at",
        "data",
        "resume"
      ],
      "additionalProperties": false
    }
  ]
}
