{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/nuance-labs/json-schema/nuance-labs-session-events-schema.json",
  "title": "SessionEvents",
  "description": "A conversation's events after the request's `after`.",
  "x-generated": "2026-11-12",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/nuance-labs-openapi.yml#/components/schemas/SessionEvents",
  "type": "object",
  "properties": {
    "events": {
      "items": {
        "oneOf": [
          {
            "$ref": "#/$defs/QueuedEvent"
          },
          {
            "$ref": "#/$defs/PreparingEvent"
          },
          {
            "$ref": "#/$defs/AdmittedEvent"
          },
          {
            "$ref": "#/$defs/StartedEvent"
          },
          {
            "$ref": "#/$defs/EndedEvent"
          }
        ]
      },
      "type": "array",
      "description": "Oldest first, each with an increasing `id`; empty when nothing happened while the request was held."
    }
  },
  "required": [
    "events"
  ],
  "$defs": {
    "AdmittedEvent": {
      "type": "object",
      "description": "The conversation's room is ready: join it.",
      "properties": {
        "type": {
          "const": "admitted",
          "default": "admitted",
          "type": "string",
          "description": "`admitted`."
        },
        "id": {
          "type": "integer",
          "description": "The event's id: pass the last one you saw as `after`."
        },
        "livekit_url": {
          "type": "string",
          "description": "The LiveKit server to join."
        },
        "token": {
          "type": "string",
          "description": "The participant token to join it with."
        }
      },
      "required": [
        "id",
        "livekit_url",
        "token",
        "type"
      ]
    },
    "EndedEvent": {
      "type": "object",
      "description": "The conversation is over. Nothing follows.",
      "properties": {
        "type": {
          "const": "ended",
          "default": "ended",
          "type": "string",
          "description": "`ended`."
        },
        "id": {
          "type": "integer",
          "description": "The event's id."
        },
        "reason": {
          "type": "string",
          "description": "Why: `time_limit`, `policy_violation`, `age_check`, `client_ended`, `client_silent` or another end."
        }
      },
      "required": [
        "id",
        "reason",
        "type"
      ]
    },
    "PreparingEvent": {
      "type": "object",
      "description": "A runtime is held for the conversation and is getting ready for it, which can take up to about half a minute; `admitted` follows. Sent once.",
      "properties": {
        "type": {
          "const": "preparing",
          "default": "preparing",
          "type": "string",
          "description": "`preparing`."
        },
        "id": {
          "type": "integer",
          "description": "The event's id: pass the last one you saw as `after`."
        }
      },
      "required": [
        "id",
        "type"
      ]
    },
    "QueuedEvent": {
      "type": "object",
      "description": "Waiting for a slot. A conversation started with an API key or a session token never waits in a queue, so it never gets this event: it may get `preparing`, then gets `admitted`.",
      "properties": {
        "type": {
          "const": "queued",
          "default": "queued",
          "type": "string",
          "description": "`queued`."
        },
        "id": {
          "type": "integer",
          "description": "The event's id: pass the last one you saw as `after`."
        },
        "position": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "description": "Its place in the queue, where 0 is next."
        },
        "estimated_wait_seconds": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "description": "Roughly how long until it is admitted, when known."
        }
      },
      "required": [
        "estimated_wait_seconds",
        "id",
        "position",
        "type"
      ]
    },
    "StartedEvent": {
      "type": "object",
      "description": "The persona has started the conversation. Sent again if its time limit changes.",
      "properties": {
        "type": {
          "const": "started",
          "default": "started",
          "type": "string",
          "description": "`started`."
        },
        "id": {
          "type": "integer",
          "description": "The event's id: pass the last one you saw as `after`."
        },
        "seconds_remaining": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "description": "How long the conversation may run, from when this answer arrived; null when it has no time limit."
        }
      },
      "required": [
        "id",
        "seconds_remaining",
        "type"
      ]
    }
  }
}