{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/smartwebchat-eu/json-schema/smartwebchat-eu-event-page-schema.json",
  "title": "EventPage",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/smartwebchat-eu-api-openapi.json#/components/schemas/EventPage",
  "type": "object",
  "required": [
    "events",
    "nextCursor",
    "catalogVersion"
  ],
  "properties": {
    "events": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "type",
          "version",
          "occurredAt",
          "chatbotId",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Stable per event: <type>:<source id>."
          },
          "type": {
            "type": "string",
            "enum": [
              "lead.created",
              "handover.requested",
              "quota.threshold",
              "payment.failed",
              "job.completed",
              "job.failed"
            ]
          },
          "version": {
            "type": "string"
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time"
          },
          "chatbotId": {
            "type": [
              "string",
              "null"
            ]
          },
          "data": {
            "description": "Identifiers only, never contents. Read contents with the same key via the read path of the event type.",
            "oneOf": [
              {
                "title": "lead.created",
                "type": "object",
                "properties": {
                  "leadId": {
                    "type": "string"
                  }
                },
                "required": [
                  "leadId"
                ],
                "additionalProperties": false
              },
              {
                "title": "handover.requested",
                "type": "object",
                "properties": {
                  "handoverRequestId": {
                    "type": "string"
                  }
                },
                "required": [
                  "handoverRequestId"
                ],
                "additionalProperties": false
              },
              {
                "title": "quota.threshold",
                "type": "object",
                "properties": {
                  "thresholdPercent": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100
                  },
                  "period": {
                    "type": "string"
                  }
                },
                "required": [
                  "thresholdPercent",
                  "period"
                ],
                "additionalProperties": false
              },
              {
                "title": "payment.failed",
                "type": "object",
                "properties": {},
                "additionalProperties": false
              },
              {
                "title": "job.completed",
                "type": "object",
                "properties": {
                  "jobId": {
                    "type": "string"
                  },
                  "jobType": {
                    "type": "string",
                    "enum": [
                      "knowledge_crawl",
                      "knowledge_source"
                    ]
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "succeeded",
                      "partially_succeeded"
                    ]
                  },
                  "errorCode": {
                    "type": "null"
                  }
                },
                "required": [
                  "jobId",
                  "jobType",
                  "status",
                  "errorCode"
                ],
                "additionalProperties": false
              },
              {
                "title": "job.failed",
                "type": "object",
                "properties": {
                  "jobId": {
                    "type": "string"
                  },
                  "jobType": {
                    "type": "string",
                    "enum": [
                      "knowledge_crawl",
                      "knowledge_source"
                    ]
                  },
                  "status": {
                    "type": "string",
                    "const": "failed"
                  },
                  "errorCode": {
                    "type": "string"
                  }
                },
                "required": [
                  "jobId",
                  "jobType",
                  "status",
                  "errorCode"
                ],
                "additionalProperties": false
              }
            ]
          }
        }
      }
    },
    "nextCursor": {
      "type": [
        "string",
        "null"
      ],
      "description": "Pass as cursor to get newer events; null means nothing newer yet."
    },
    "catalogVersion": {
      "type": "string",
      "const": "1.0"
    }
  }
}