{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openteesheet.com/schemas/bay-session.schema.json",
  "title": "OpenTeeSheet bay session (open format v1)",
  "description": "A booking's simulator session on the bay: scheduled, armed when the door lets the golfer in, started and stopped as the bay agent (or the owner) reports, and reconciled after the booking ends with how it ended.",
  "type": "object",
  "properties": {
    "object": {
      "const": "bay_session"
    },
    "booking_id": {
      "type": "string",
      "format": "uuid"
    },
    "bay_id": {
      "type": "string",
      "format": "uuid"
    },
    "venue_id": {
      "type": "string",
      "format": "uuid"
    },
    "state": {
      "type": "string",
      "enum": [
        "scheduled",
        "armed",
        "started",
        "stopped",
        "failed",
        "missed_start",
        "reconciled"
      ]
    },
    "started_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "stopped_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "last_error": {
      "type": [
        "string",
        "null"
      ]
    },
    "updated_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "armed_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "reconciled_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "end_reason": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "booking_end",
        "early_stop",
        "no_stop_report",
        "never_started",
        "no_show",
        "not_started",
        "failed",
        "missed_start",
        null
      ]
    }
  },
  "required": [
    "object",
    "booking_id",
    "bay_id",
    "venue_id",
    "state"
  ],
  "additionalProperties": false
}
