{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "event": {
          "type": "string",
          "enum": [
            "bundle.created",
            "bundle.updated",
            "bundle.resolved",
            "improvement_bundle.created"
          ]
        },
        "occurred_at": {
          "type": "string",
          "format": "date-time"
        },
        "project_id": {
          "type": "string",
          "minLength": 1
        },
        "bundle_id": {
          "type": "string",
          "minLength": 1
        },
        "bundle_type": {
          "type": "string",
          "enum": [
            "failure",
            "improvement"
          ]
        },
        "severity": {
          "type": "string",
          "enum": [
            "low",
            "medium",
            "high",
            "critical"
          ]
        },
        "service": {
          "type": "string",
          "minLength": 1
        },
        "environment": {
          "type": "string",
          "minLength": 1
        },
        "verification": {
          "type": "boolean"
        },
        "summary": {
          "type": "string",
          "minLength": 1
        },
        "links": {
          "type": "object",
          "properties": {
            "bundle": {
              "type": "string",
              "minLength": 1
            },
            "reproduction": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "bundle"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "event",
        "occurred_at",
        "project_id",
        "bundle_id",
        "bundle_type",
        "severity",
        "service",
        "environment",
        "verification",
        "summary",
        "links"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "event_type": {
          "type": "string",
          "enum": [
            "bundle.reopened",
            "incident.spike_detected"
          ]
        },
        "incident_id": {
          "type": "string",
          "minLength": 1
        },
        "project_id": {
          "type": "string",
          "minLength": 1
        },
        "occurred_at": {
          "type": "string",
          "format": "date-time"
        },
        "service_name": {
          "type": "string",
          "minLength": 1
        },
        "environment": {
          "type": "string",
          "minLength": 1
        },
        "severity": {
          "type": "string",
          "enum": [
            "low",
            "medium",
            "high",
            "critical"
          ]
        },
        "regression_after_deploy": {
          "type": "boolean"
        },
        "deploy_version": {
          "type": [
            "string",
            "null"
          ]
        },
        "deploy_commit_sha": {
          "type": [
            "string",
            "null"
          ]
        },
        "deploy_branch": {
          "type": [
            "string",
            "null"
          ]
        },
        "deploy_deployed_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ]
        },
        "minutes_since_deploy": {
          "type": [
            "number",
            "null"
          ]
        }
      },
      "required": [
        "event_type",
        "incident_id",
        "project_id",
        "occurred_at",
        "service_name",
        "environment",
        "severity",
        "regression_after_deploy",
        "deploy_version",
        "deploy_commit_sha",
        "deploy_branch",
        "deploy_deployed_at",
        "minutes_since_deploy"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "delivery_id": {
          "type": "string",
          "minLength": 1
        },
        "event": {
          "type": "string",
          "enum": [
            "verification.passed",
            "verification.failed"
          ]
        },
        "event_type": {
          "type": "string",
          "enum": [
            "verification.passed",
            "verification.failed"
          ]
        },
        "occurred_at": {
          "type": "string",
          "format": "date-time"
        },
        "project_id": {
          "type": "string",
          "minLength": 1
        },
        "webhook_id": {
          "type": "string",
          "minLength": 1
        },
        "incident_id": {
          "type": "string",
          "minLength": 1
        },
        "test": {
          "type": "boolean",
          "const": true
        },
        "data": {
          "type": "object",
          "properties": {
            "message": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "message"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "delivery_id",
        "event",
        "event_type",
        "occurred_at",
        "project_id",
        "webhook_id",
        "incident_id",
        "test",
        "data"
      ],
      "additionalProperties": false
    }
  ],
  "$schema": "https://json-schema.org/draft/2020-12/schema#",
  "$id": "https://debugbundle.com/schemas/webhook-events.json",
  "title": "DebugBundle Webhook Event Payload Schema"
}
