{
  "openapi": "3.1.0",
  "info": {
    "title": "Databek Lens API",
    "version": "1.0.0",
    "description": "Cameras, recording schedules, AI analyses (child safety, lesson quality), incidents, clips, teacher dashboards and webhooks of one organization. Step-by-step flows: docs/api/lens/GUIDE.md.\n\nAuthentication: `Authorization: Bearer lens_…` (Sozlamalar → API kalitlar). Scope `read` for GET, `write` for everything else.\n\nErrors: `{code, message, field?}` with an HTTP status. Lists: `?limit=&cursor=` → `{items, next_cursor}`. Times: ISO 8601 UTC. Every API answer carries `X-Request-ID` (send your own to correlate; a signed clip download does not). Unknown request fields are ignored.",
    "contact": {
      "name": "Databek",
      "url": "https://databek.com"
    }
  },
  "servers": [
    {
      "url": "https://lens.databek.com/api/v1"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "tags": [
    {
      "name": "Organization"
    },
    {
      "name": "Portfolios"
    },
    {
      "name": "Schedule"
    },
    {
      "name": "Cameras"
    },
    {
      "name": "Media"
    },
    {
      "name": "Analyses"
    },
    {
      "name": "Results"
    },
    {
      "name": "Teachers"
    },
    {
      "name": "Webhooks"
    }
  ],
  "paths": {
    "/me": {
      "get": {
        "operationId": "getMe",
        "summary": "The key and its organization",
        "tags": [
          "Organization"
        ],
        "x-scope": "read",
        "responses": {
          "200": {
            "description": "The key and its organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Me"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/portfolios": {
      "get": {
        "operationId": "listPortfolios",
        "summary": "List portfolios (newest first)",
        "tags": [
          "Portfolios"
        ],
        "x-scope": "read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "List portfolios (newest first)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortfolioPage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "operationId": "createPortfolio",
        "summary": "Create a portfolio with its rooms",
        "tags": [
          "Portfolios"
        ],
        "x-scope": "write",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PortfolioCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Create a portfolio with its rooms",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Portfolio"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadJson"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "415": {
            "$ref": "#/components/responses/Unsupported"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/portfolios/{id}": {
      "get": {
        "operationId": "getPortfolio",
        "summary": "Get a portfolio",
        "tags": [
          "Portfolios"
        ],
        "x-scope": "read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Get a portfolio",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Portfolio"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "patch": {
        "operationId": "updatePortfolio",
        "summary": "Change a portfolio",
        "tags": [
          "Portfolios"
        ],
        "x-scope": "write",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PortfolioUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Change a portfolio",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Portfolio"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadJson"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "415": {
            "$ref": "#/components/responses/Unsupported"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "delete": {
        "operationId": "deletePortfolio",
        "summary": "Delete a portfolio with its rooms, cameras and schedule",
        "tags": [
          "Portfolios"
        ],
        "x-scope": "write",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/portfolios/{id}/schedule": {
      "get": {
        "operationId": "getSchedule",
        "summary": "Get the working hours",
        "tags": [
          "Schedule"
        ],
        "x-scope": "read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Get the working hours",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Schedule"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "put": {
        "operationId": "putSchedule",
        "summary": "Replace the working hours (and the date exceptions when sent)",
        "tags": [
          "Schedule"
        ],
        "x-scope": "write",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScheduleInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replace the working hours (and the date exceptions when sent)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Schedule"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadJson"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "415": {
            "$ref": "#/components/responses/Unsupported"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/lesson-slots": {
      "get": {
        "operationId": "listLessonSlots",
        "summary": "List lesson slots",
        "tags": [
          "Schedule"
        ],
        "x-scope": "read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "portfolio_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "room_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List lesson slots",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LessonSlotPage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "operationId": "createLessonSlot",
        "summary": "Create a lesson slot",
        "tags": [
          "Schedule"
        ],
        "x-scope": "write",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LessonSlotCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Create a lesson slot",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LessonSlot"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadJson"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "415": {
            "$ref": "#/components/responses/Unsupported"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/lesson-slots/{id}": {
      "get": {
        "operationId": "getLessonSlot",
        "summary": "Get a lesson slot",
        "tags": [
          "Schedule"
        ],
        "x-scope": "read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Get a lesson slot",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LessonSlot"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "patch": {
        "operationId": "updateLessonSlot",
        "summary": "Change a lesson slot",
        "tags": [
          "Schedule"
        ],
        "x-scope": "write",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LessonSlotUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Change a lesson slot",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LessonSlot"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadJson"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "415": {
            "$ref": "#/components/responses/Unsupported"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "delete": {
        "operationId": "deleteLessonSlot",
        "summary": "Delete a lesson slot",
        "tags": [
          "Schedule"
        ],
        "x-scope": "write",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/cameras": {
      "get": {
        "operationId": "listCameras",
        "summary": "List cameras",
        "tags": [
          "Cameras"
        ],
        "x-scope": "read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "portfolio_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "room_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "ok",
                "offline",
                "auth_failed",
                "unreachable",
                "blocked"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List cameras",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CameraPage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "operationId": "createCamera",
        "summary": "Connect a camera (secrets are write-only)",
        "tags": [
          "Cameras"
        ],
        "x-scope": "write",
        "description": "Refused with `camera_host_blocked` when the source resolves to a private, loopback, link-local, CGNAT, multicast or Docker address (unless the platform admin allowed private sources).",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CameraCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Connect a camera (secrets are write-only)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CameraWithPush"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadJson"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "415": {
            "$ref": "#/components/responses/Unsupported"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/cameras/{id}": {
      "get": {
        "operationId": "getCamera",
        "summary": "Get a camera",
        "tags": [
          "Cameras"
        ],
        "x-scope": "read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Get a camera",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Camera"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "patch": {
        "operationId": "updateCamera",
        "summary": "Change a camera",
        "tags": [
          "Cameras"
        ],
        "x-scope": "write",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CameraUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Change a camera",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CameraWithPush"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadJson"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "415": {
            "$ref": "#/components/responses/Unsupported"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "delete": {
        "operationId": "deleteCamera",
        "summary": "Delete a camera",
        "tags": [
          "Cameras"
        ],
        "x-scope": "write",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/cameras/{id}/probe": {
      "post": {
        "operationId": "probeCamera",
        "summary": "Probe the source now (ffprobe, up to 15 s)",
        "tags": [
          "Cameras"
        ],
        "x-scope": "write",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Probe the source now (ffprobe, up to 15 s)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProbeAnswer"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/cameras/{id}/push-key": {
      "post": {
        "operationId": "rotatePushKey",
        "summary": "New push key for a push camera (the old one stops)",
        "tags": [
          "Cameras"
        ],
        "x-scope": "write",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "New push key for a push camera (the old one stops)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CameraWithPush"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/media": {
      "get": {
        "operationId": "listMedia",
        "summary": "List media",
        "tags": [
          "Media"
        ],
        "x-scope": "read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "fetching",
                "ready",
                "failed"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List media",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MediaPage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "operationId": "createMedia",
        "summary": "Upload a video, or give a source_url",
        "tags": [
          "Media"
        ],
        "x-scope": "write",
        "description": "Send the file as the raw body with its Content-Type (video/mp4, video/quicktime, video/webm, video/x-matroska, video/mp2t, video/x-msvideo, audio/mpeg, audio/mp4, audio/wav or application/octet-stream), at most LENS_MEDIA_MAX_BYTES (2 GiB by default). Or send JSON `{source_url}`. The answer is 202: poll GET /media/{id} until `ready` (or `failed`). Idempotency-Key is not used here (neither for a file nor for a source_url).",
        "parameters": [
          {
            "name": "name",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "description": "A name for the upload."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "video/*": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "audio/*": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "application/octet-stream": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MediaFromUrl"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted; the worker probes (and fetches) it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Media"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadJson"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "Larger than the cap (`media_too_large`), or the organisation's media storage is full (`media_quota_reached`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Unsupported Content-Type (`unsupported_media_type`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "description": "The server is short of disk space for media (`storage_full`); retry later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/media/{id}": {
      "get": {
        "operationId": "getMedia",
        "summary": "Get a media file's status",
        "tags": [
          "Media"
        ],
        "x-scope": "read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Get a media file's status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Media"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "delete": {
        "operationId": "deleteMedia",
        "summary": "Delete a media file",
        "tags": [
          "Media"
        ],
        "x-scope": "write",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/analyses": {
      "get": {
        "operationId": "listAnalyses",
        "summary": "List analyses (without results)",
        "tags": [
          "Analyses"
        ],
        "x-scope": "read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "kind",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "safety_daily",
                "lesson"
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "queued",
                "waiting_ai",
                "running",
                "done",
                "failed",
                "superseded"
              ]
            }
          },
          {
            "name": "room_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "teacher_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "parent_analysis_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "starts_at ≥ from"
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "starts_at ≤ to"
          }
        ],
        "responses": {
          "200": {
            "description": "List analyses (without results)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnalysisPage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "operationId": "createAnalysis",
        "summary": "Request an analysis",
        "tags": [
          "Analyses"
        ],
        "x-scope": "write",
        "description": "Status `queued`, or `waiting_ai` while the tier's provider has no key (it starts by itself later). Poll GET /analyses/{id} or use the analysis.completed webhook.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnalysisCreate"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Request an analysis",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Analysis"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadJson"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "description": "The org's monthly AI budget is used up (`budget_exceeded`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "A live analysis already covers this scope (`analysis_exists`, with `existing_id`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "415": {
            "$ref": "#/components/responses/Unsupported"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/analyses/{id}": {
      "get": {
        "operationId": "getAnalysis",
        "summary": "Get an analysis with its result",
        "tags": [
          "Analyses"
        ],
        "x-scope": "read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Get an analysis with its result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Analysis"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/analyses/{id}/force": {
      "post": {
        "operationId": "forceAnalysis",
        "summary": "Re-run an analysis (the old one becomes superseded)",
        "tags": [
          "Analyses"
        ],
        "x-scope": "write",
        "description": "Allowed only when the platform admin enabled force for the organization (`force_not_allowed` otherwise).",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ForceInput"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Re-run an analysis (the old one becomes superseded)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Analysis"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadJson"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "description": "Budget used up (`budget_exceeded`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "415": {
            "$ref": "#/components/responses/Unsupported"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/incidents": {
      "get": {
        "operationId": "listIncidents",
        "summary": "List incidents with their clips",
        "tags": [
          "Results"
        ],
        "x-scope": "read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "new",
                "released",
                "dismissed"
              ]
            }
          },
          {
            "name": "analysis_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "room_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "portfolio_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "min_severity",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "1",
                "2",
                "3",
                "4",
                "5"
              ]
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List incidents with their clips",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IncidentPage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/incidents/{id}": {
      "get": {
        "operationId": "getIncident",
        "summary": "Get an incident with its clips",
        "tags": [
          "Results"
        ],
        "x-scope": "read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Get an incident with its clips",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Incident"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/clips/{id}": {
      "get": {
        "operationId": "getClip",
        "summary": "Get a clip with a signed file URL (10 minutes)",
        "tags": [
          "Results"
        ],
        "x-scope": "read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Get a clip with a signed file URL (10 minutes)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClipLink"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/clips/{id}/file": {
      "get": {
        "operationId": "getClipFile",
        "summary": "The clip MP4 behind a signed link (no API key; Range supported)",
        "tags": [
          "Results"
        ],
        "security": [],
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          },
          {
            "name": "org",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "exp",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "sig",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Range",
            "in": "header",
            "schema": {
              "type": "string",
              "examples": [
                "bytes=0-1048575"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The whole file.",
            "content": {
              "video/mp4": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "206": {
            "description": "A byte range.",
            "content": {
              "video/mp4": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "403": {
            "description": "Link expired or invalid (text/plain)."
          },
          "404": {
            "description": "No such ready clip."
          },
          "416": {
            "description": "Range not satisfiable."
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/teachers": {
      "get": {
        "operationId": "listTeachers",
        "summary": "List teachers",
        "tags": [
          "Teachers"
        ],
        "x-scope": "read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "List teachers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeacherPage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/teachers/{id}": {
      "get": {
        "operationId": "getTeacher",
        "summary": "Get a teacher",
        "tags": [
          "Teachers"
        ],
        "x-scope": "read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Get a teacher",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Teacher"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/teachers/{id}/dashboard": {
      "get": {
        "operationId": "getTeacherDashboard",
        "summary": "A teacher's dashboard cards as data",
        "tags": [
          "Teachers"
        ],
        "x-scope": "read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "A teacher's dashboard cards as data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Dashboard"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/webhooks": {
      "get": {
        "operationId": "listWebhooks",
        "summary": "List webhooks",
        "tags": [
          "Webhooks"
        ],
        "x-scope": "read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "List webhooks",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookPage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "operationId": "createWebhook",
        "summary": "Create a webhook (the signing secret is returned once)",
        "tags": [
          "Webhooks"
        ],
        "x-scope": "write",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Create a webhook (the signing secret is returned once)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookWithSecret"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadJson"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "415": {
            "$ref": "#/components/responses/Unsupported"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/webhooks/{id}": {
      "get": {
        "operationId": "getWebhook",
        "summary": "Get a webhook",
        "tags": [
          "Webhooks"
        ],
        "x-scope": "read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Get a webhook",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Webhook"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "patch": {
        "operationId": "updateWebhook",
        "summary": "Change a webhook",
        "tags": [
          "Webhooks"
        ],
        "x-scope": "write",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Change a webhook",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Webhook"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadJson"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "415": {
            "$ref": "#/components/responses/Unsupported"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "delete": {
        "operationId": "deleteWebhook",
        "summary": "Delete a webhook and its delivery log",
        "tags": [
          "Webhooks"
        ],
        "x-scope": "write",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/webhooks/{id}/deliveries": {
      "get": {
        "operationId": "listDeliveries",
        "summary": "A webhook's delivery log",
        "tags": [
          "Webhooks"
        ],
        "x-scope": "read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "delivered",
                "failed"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A webhook's delivery log",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeliveryPage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/webhooks/{id}/test": {
      "post": {
        "operationId": "testWebhook",
        "summary": "Send a `ping` delivery to this webhook (also when paused)",
        "tags": [
          "Webhooks"
        ],
        "x-scope": "write",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "202": {
            "description": "Send a `ping` delivery to this webhook (also when paused)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "delivery_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "delivery_id"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    }
  },
  "webhooks": {
    "analysis.completed": {
      "post": {
        "summary": "analysis.completed",
        "description": "An analysis finished; `data.analysis` (without result: GET it).",
        "operationId": "on_analysis_completed",
        "parameters": [
          {
            "name": "Lens-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "examples": [
                "t=1764600000,v1=5f2b…"
              ]
            },
            "description": "t = unix seconds; v1 = hex HMAC-SHA256 of `<t>.<raw body>` with the webhook's secret."
          },
          {
            "name": "Lens-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Lens-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EventEnvelope"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Received. Anything else (or no answer in 10 s) is retried: 30 s, doubling to 1 hour, 10 attempts in all. Redirects are not followed."
          }
        }
      }
    },
    "analysis.failed": {
      "post": {
        "summary": "analysis.failed",
        "description": "An analysis failed; `data.analysis.error_code` says why.",
        "operationId": "on_analysis_failed",
        "parameters": [
          {
            "name": "Lens-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "examples": [
                "t=1764600000,v1=5f2b…"
              ]
            },
            "description": "t = unix seconds; v1 = hex HMAC-SHA256 of `<t>.<raw body>` with the webhook's secret."
          },
          {
            "name": "Lens-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Lens-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EventEnvelope"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Received. Anything else (or no answer in 10 s) is retried: 30 s, doubling to 1 hour, 10 attempts in all. Redirects are not followed."
          }
        }
      }
    },
    "incident.created": {
      "post": {
        "summary": "incident.created",
        "description": "A safety_daily analysis found an incident; `data.incident` with its clips. Sent for every incident at once (parents see only released ones).",
        "operationId": "on_incident_created",
        "parameters": [
          {
            "name": "Lens-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "examples": [
                "t=1764600000,v1=5f2b…"
              ]
            },
            "description": "t = unix seconds; v1 = hex HMAC-SHA256 of `<t>.<raw body>` with the webhook's secret."
          },
          {
            "name": "Lens-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Lens-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EventEnvelope"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Received. Anything else (or no answer in 10 s) is retried: 30 s, doubling to 1 hour, 10 attempts in all. Redirects are not followed."
          }
        }
      }
    },
    "camera.offline": {
      "post": {
        "summary": "camera.offline",
        "description": "A recording camera sent no frames for 5 minutes; `data.camera`.",
        "operationId": "on_camera_offline",
        "parameters": [
          {
            "name": "Lens-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "examples": [
                "t=1764600000,v1=5f2b…"
              ]
            },
            "description": "t = unix seconds; v1 = hex HMAC-SHA256 of `<t>.<raw body>` with the webhook's secret."
          },
          {
            "name": "Lens-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Lens-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EventEnvelope"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Received. Anything else (or no answer in 10 s) is retried: 30 s, doubling to 1 hour, 10 attempts in all. Redirects are not followed."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "lens_<43 characters>"
      }
    },
    "parameters": {
      "Id": {
        "name": "id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "Limit": {
        "name": "limit",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 200,
          "default": 50
        }
      },
      "Cursor": {
        "name": "cursor",
        "in": "query",
        "schema": {
          "type": "string"
        },
        "description": "`next_cursor` of the previous page."
      },
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "schema": {
          "type": "string",
          "pattern": "^[\\x21-\\x7e]{1,200}$"
        },
        "description": "Optional. The same key and the same request within 24 hours replay the first 2xx answer (header `Idempotent-Replayed: true`); a different request under the same key is refused (422 `idempotency_mismatch`). Not used by POST /media."
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Missing, unknown or revoked key (`unauthorized`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "The key has no write scope (`insufficient_scope`), or an action is not allowed (`force_not_allowed`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "No such object in this organization (`not_found`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Invalid": {
        "description": "Invalid input (`validation_failed` or a specific code); `field` names the input.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "TooMany": {
        "description": "Rate limited (`rate_limited`): 600 requests a minute per key, 120 uploads an hour.",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "BadJson": {
        "description": "The body is not valid JSON (`invalid_json`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "TooLarge": {
        "description": "The JSON body is over 1 MB (`body_too_large`), or over 2 MiB at the edge proxy (`request.too_large`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unsupported": {
        "description": "The body is not JSON (`unsupported_media_type`): send `Content-Type: application/json`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "ServerError": {
        "description": "Something went wrong (`internal_error`); retry later with backoff and quote `X-Request-ID`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable machine code, e.g. `analysis_exists`, `validation_failed`."
          },
          "message": {
            "type": "string",
            "description": "English text for a developer."
          },
          "field": {
            "type": "string",
            "description": "The input at fault (JSON path or header name), when there is one."
          },
          "existing_id": {
            "type": "string",
            "format": "uuid",
            "description": "Only with 409 `analysis_exists`: the live analysis of the same scope."
          },
          "media_id": {
            "type": "string",
            "format": "uuid"
          },
          "parent_analysis_id": {
            "type": "string",
            "format": "uuid"
          }
        },
        "additionalProperties": false,
        "required": [
          "code",
          "message"
        ]
      },
      "Me": {
        "type": "object",
        "properties": {
          "organization": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "name": {
                "type": "string"
              },
              "kind": {
                "type": "string",
                "enum": [
                  "kindergarten",
                  "school",
                  "university",
                  "other"
                ]
              },
              "timezone": {
                "type": "string"
              }
            },
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "kind",
              "timezone"
            ]
          },
          "key": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "name": {
                "type": "string"
              },
              "prefix": {
                "type": "string"
              },
              "scopes": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "read",
                    "write"
                  ]
                }
              }
            },
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "prefix",
              "scopes"
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "organization",
          "key"
        ]
      },
      "Room": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "name"
        ]
      },
      "Portfolio": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "timezone": {
            "type": "string"
          },
          "profiles": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "safety_daily",
                "lesson"
              ]
            }
          },
          "default_tier": {
            "type": "string",
            "enum": [
              "economy",
              "standard",
              "deep"
            ]
          },
          "continuous": {
            "type": "boolean"
          },
          "lesson_sampling": {
            "type": "string",
            "enum": [
              "all",
              "every_nth",
              "per_week",
              "manual"
            ]
          },
          "lesson_sampling_n": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "parents_enabled": {
            "type": "boolean"
          },
          "rooms": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Room"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "timezone",
          "profiles",
          "default_tier",
          "continuous",
          "lesson_sampling",
          "lesson_sampling_n",
          "parents_enabled",
          "rooms",
          "created_at"
        ]
      },
      "PortfolioCreate": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "timezone": {
            "type": "string",
            "default": "Asia/Tashkent",
            "description": "IANA zone from Lens's list.",
            "enum": [
              "Asia/Tashkent",
              "Asia/Samarkand",
              "Asia/Almaty",
              "Asia/Bishkek",
              "Asia/Dushanbe",
              "Asia/Ashgabat",
              "Asia/Baku",
              "Europe/Moscow",
              "UTC"
            ]
          },
          "profiles": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "safety_daily",
                "lesson"
              ]
            },
            "minItems": 1,
            "default": [
              "safety_daily"
            ]
          },
          "default_tier": {
            "type": "string",
            "enum": [
              "economy",
              "standard",
              "deep"
            ],
            "default": "standard"
          },
          "continuous": {
            "type": "boolean",
            "default": false,
            "description": "Run analyses automatically (safety daily; lessons by the sampling policy)."
          },
          "lesson_sampling": {
            "type": "string",
            "enum": [
              "all",
              "every_nth",
              "per_week",
              "manual"
            ],
            "default": "manual"
          },
          "lesson_sampling_n": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 1,
                "maximum": 100
              },
              {
                "type": "null"
              }
            ]
          },
          "parents_enabled": {
            "type": "boolean",
            "default": true
          },
          "rooms": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 60
            },
            "maxItems": 100,
            "default": [],
            "description": "Room names, unique within the portfolio."
          }
        },
        "required": [
          "name"
        ]
      },
      "PortfolioUpdate": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "timezone": {
            "type": "string",
            "enum": [
              "Asia/Tashkent",
              "Asia/Samarkand",
              "Asia/Almaty",
              "Asia/Bishkek",
              "Asia/Dushanbe",
              "Asia/Ashgabat",
              "Asia/Baku",
              "Europe/Moscow",
              "UTC"
            ]
          },
          "profiles": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "safety_daily",
                "lesson"
              ]
            },
            "minItems": 1
          },
          "default_tier": {
            "type": "string",
            "enum": [
              "economy",
              "standard",
              "deep"
            ]
          },
          "continuous": {
            "type": "boolean"
          },
          "lesson_sampling": {
            "type": "string",
            "enum": [
              "all",
              "every_nth",
              "per_week",
              "manual"
            ]
          },
          "lesson_sampling_n": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 1,
                "maximum": 100
              },
              {
                "type": "null"
              }
            ]
          },
          "parents_enabled": {
            "type": "boolean"
          },
          "rooms": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 60
            },
            "maxItems": 100,
            "description": "The FULL list of room names: names not in it are deleted (their cameras stay, without a room)."
          }
        }
      },
      "ClockRange": {
        "type": "object",
        "properties": {
          "start": {
            "type": "string",
            "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$|^24:00$",
            "examples": [
              "08:00"
            ]
          },
          "end": {
            "type": "string",
            "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$|^24:00$",
            "examples": [
              "08:00"
            ]
          }
        },
        "required": [
          "start",
          "end"
        ]
      },
      "Schedule": {
        "type": "object",
        "properties": {
          "portfolio_id": {
            "type": "string",
            "format": "uuid"
          },
          "timezone": {
            "type": "string"
          },
          "weekly": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "weekday": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 7,
                  "description": "1 = Monday … 7 = Sunday"
                },
                "ranges": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClockRange"
                  }
                }
              },
              "additionalProperties": false,
              "required": [
                "weekday",
                "ranges"
              ]
            }
          },
          "exceptions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "date": {
                  "type": "string",
                  "format": "date"
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "closed",
                    "open"
                  ]
                },
                "ranges": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClockRange"
                  }
                },
                "note": {
                  "type": "string"
                }
              },
              "additionalProperties": false,
              "required": [
                "date",
                "kind",
                "ranges",
                "note"
              ]
            }
          }
        },
        "additionalProperties": false,
        "required": [
          "portfolio_id",
          "timezone",
          "weekly",
          "exceptions"
        ]
      },
      "ScheduleInput": {
        "type": "object",
        "properties": {
          "weekly": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "weekday": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 7
                },
                "ranges": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClockRange"
                  },
                  "maxItems": 12
                }
              },
              "required": [
                "weekday",
                "ranges"
              ]
            },
            "maxItems": 7,
            "description": "Replaces the weekly hours. A weekday left out is a day off. Ranges of one day must not overlap."
          },
          "exceptions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "date": {
                  "type": "string",
                  "format": "date"
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "closed",
                    "open"
                  ]
                },
                "ranges": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClockRange"
                  },
                  "maxItems": 12,
                  "default": []
                },
                "note": {
                  "type": "string",
                  "maxLength": 200,
                  "default": ""
                }
              },
              "required": [
                "date",
                "kind"
              ]
            },
            "maxItems": 366,
            "description": "When sent, replaces all date exceptions; when left out, they stay."
          }
        },
        "required": [
          "weekly"
        ]
      },
      "LessonSlot": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "portfolio_id": {
            "type": "string",
            "format": "uuid"
          },
          "room_id": {
            "type": "string",
            "format": "uuid"
          },
          "weekday": {
            "type": "integer",
            "minimum": 1,
            "maximum": 7
          },
          "start": {
            "type": "string",
            "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$|^24:00$",
            "examples": [
              "08:00"
            ]
          },
          "end": {
            "type": "string",
            "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$|^24:00$",
            "examples": [
              "08:00"
            ]
          },
          "teacher_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "teacher_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "topic": {
            "type": "string"
          },
          "valid_from": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ]
          },
          "valid_to": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "portfolio_id",
          "room_id",
          "weekday",
          "start",
          "end",
          "teacher_id",
          "teacher_name",
          "topic",
          "valid_from",
          "valid_to"
        ]
      },
      "LessonSlotCreate": {
        "type": "object",
        "properties": {
          "portfolio_id": {
            "type": "string",
            "format": "uuid"
          },
          "room_id": {
            "type": "string",
            "format": "uuid"
          },
          "weekday": {
            "type": "integer",
            "minimum": 1,
            "maximum": 7
          },
          "start": {
            "type": "string",
            "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$|^24:00$",
            "examples": [
              "08:00"
            ]
          },
          "end": {
            "type": "string",
            "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$|^24:00$",
            "examples": [
              "08:00"
            ]
          },
          "teacher_name": {
            "type": "string",
            "maxLength": 120,
            "default": "",
            "description": "Matched to the org's teacher by normalised name; a new name makes a teacher."
          },
          "topic": {
            "type": "string",
            "maxLength": 200,
            "default": ""
          },
          "valid_from": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ]
          },
          "valid_to": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "portfolio_id",
          "room_id",
          "weekday",
          "start",
          "end"
        ]
      },
      "LessonSlotUpdate": {
        "type": "object",
        "properties": {
          "portfolio_id": {
            "type": "string",
            "format": "uuid"
          },
          "room_id": {
            "type": "string",
            "format": "uuid"
          },
          "weekday": {
            "type": "integer",
            "minimum": 1,
            "maximum": 7
          },
          "start": {
            "type": "string",
            "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$|^24:00$",
            "examples": [
              "08:00"
            ]
          },
          "end": {
            "type": "string",
            "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$|^24:00$",
            "examples": [
              "08:00"
            ]
          },
          "teacher_name": {
            "type": "string",
            "maxLength": 120
          },
          "topic": {
            "type": "string",
            "maxLength": 200
          },
          "valid_from": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ]
          },
          "valid_to": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "Preset": {
        "type": "object",
        "properties": {
          "brand": {
            "type": "string",
            "enum": [
              "hikvision",
              "dahua",
              "uniview",
              "generic"
            ]
          },
          "host": {
            "type": "string",
            "maxLength": 253
          },
          "port": {
            "type": "integer",
            "minimum": 1,
            "maximum": 65535,
            "default": 554
          },
          "channel": {
            "type": "integer",
            "minimum": 1,
            "maximum": 256,
            "default": 1
          },
          "stream": {
            "type": "string",
            "enum": [
              "sub",
              "main"
            ],
            "default": "sub"
          },
          "path": {
            "type": "string",
            "maxLength": 300,
            "default": "",
            "description": "Required for `generic`: the RTSP path."
          }
        },
        "additionalProperties": false,
        "required": [
          "brand",
          "host"
        ]
      },
      "Probe": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "error": {
            "type": "string"
          },
          "video": {
            "type": "object",
            "properties": {
              "codec": {
                "type": "string"
              },
              "width": {
                "type": "integer"
              },
              "height": {
                "type": "integer"
              },
              "fps": {
                "type": "number"
              }
            },
            "additionalProperties": false
          },
          "audio": {
            "type": "boolean"
          },
          "at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "required": [
          "ok",
          "at"
        ]
      },
      "Camera": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "portfolio_id": {
            "type": "string",
            "format": "uuid"
          },
          "room_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "connection": {
            "type": "string",
            "enum": [
              "url",
              "url_auth",
              "preset",
              "push"
            ]
          },
          "source_host": {
            "anyOf": [
              {
                "type": "string",
                "description": "Host of the source; the URL, login and password are never returned."
              },
              {
                "type": "null"
              }
            ]
          },
          "preset": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Preset"
              },
              {
                "type": "null"
              }
            ]
          },
          "record": {
            "type": "boolean"
          },
          "live_for_parents": {
            "type": "boolean"
          },
          "record_fps": {
            "type": "integer",
            "minimum": 1,
            "maximum": 15
          },
          "status": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "ok",
                  "offline",
                  "auth_failed",
                  "unreachable",
                  "blocked"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "status_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "probe": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Probe"
              },
              {
                "type": "null"
              }
            ]
          },
          "probed_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_frame_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "portfolio_id",
          "room_id",
          "connection",
          "source_host",
          "preset",
          "record",
          "live_for_parents",
          "record_fps",
          "status",
          "status_at",
          "probe",
          "probed_at",
          "last_frame_at",
          "created_at"
        ]
      },
      "PushUrls": {
        "type": "object",
        "properties": {
          "rtmp": {
            "type": "string",
            "examples": [
              "rtmp://lens.databek.com/live/Xk3qP0aZ8Lmn?key=…"
            ]
          },
          "srt": {
            "type": "string",
            "examples": [
              "srt://lens.databek.com:8890?streamid=publish:live/Xk3qP0aZ8Lmn:lens:…"
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "rtmp",
          "srt"
        ],
        "description": "Publish addresses with the camera's key: shown only in this answer."
      },
      "CameraWithPush": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "portfolio_id": {
            "type": "string",
            "format": "uuid"
          },
          "room_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "connection": {
            "type": "string",
            "enum": [
              "url",
              "url_auth",
              "preset",
              "push"
            ]
          },
          "source_host": {
            "anyOf": [
              {
                "type": "string",
                "description": "Host of the source; the URL, login and password are never returned."
              },
              {
                "type": "null"
              }
            ]
          },
          "preset": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Preset"
              },
              {
                "type": "null"
              }
            ]
          },
          "record": {
            "type": "boolean"
          },
          "live_for_parents": {
            "type": "boolean"
          },
          "record_fps": {
            "type": "integer",
            "minimum": 1,
            "maximum": 15
          },
          "status": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "ok",
                  "offline",
                  "auth_failed",
                  "unreachable",
                  "blocked"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "status_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "probe": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Probe"
              },
              {
                "type": "null"
              }
            ]
          },
          "probed_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_frame_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "push": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/PushUrls"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "portfolio_id",
          "room_id",
          "connection",
          "source_host",
          "preset",
          "record",
          "live_for_parents",
          "record_fps",
          "status",
          "status_at",
          "probe",
          "probed_at",
          "last_frame_at",
          "created_at",
          "push"
        ]
      },
      "CameraCreate": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "portfolio_id": {
            "type": "string",
            "format": "uuid"
          },
          "room_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "connection": {
            "type": "string",
            "enum": [
              "url",
              "url_auth",
              "preset",
              "push"
            ]
          },
          "url": {
            "type": "string",
            "maxLength": 2000,
            "description": "rtsp://, rtmp://, http(s):// (HLS or MJPEG). Write-only."
          },
          "username": {
            "type": "string",
            "maxLength": 200,
            "description": "Write-only."
          },
          "password": {
            "type": "string",
            "maxLength": 200,
            "description": "Write-only."
          },
          "preset": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Preset"
              },
              {
                "type": "null"
              }
            ]
          },
          "record": {
            "type": "boolean",
            "default": true
          },
          "live_for_parents": {
            "type": "boolean",
            "default": false
          },
          "record_fps": {
            "type": "integer",
            "minimum": 1,
            "maximum": 15,
            "default": 5
          }
        },
        "required": [
          "name",
          "portfolio_id",
          "connection"
        ]
      },
      "CameraUpdate": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "portfolio_id": {
            "type": "string",
            "format": "uuid"
          },
          "room_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "connection": {
            "type": "string",
            "enum": [
              "url",
              "url_auth",
              "preset",
              "push"
            ]
          },
          "url": {
            "type": "string",
            "maxLength": 2000,
            "description": "Leave out (or empty) to keep the stored source."
          },
          "username": {
            "type": "string",
            "maxLength": 200
          },
          "password": {
            "type": "string",
            "maxLength": 200,
            "description": "Leave out to keep the stored password."
          },
          "preset": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Preset"
              },
              {
                "type": "null"
              }
            ]
          },
          "record": {
            "type": "boolean"
          },
          "live_for_parents": {
            "type": "boolean"
          },
          "record_fps": {
            "type": "integer",
            "minimum": 1,
            "maximum": 15
          }
        }
      },
      "ProbeAnswer": {
        "type": "object",
        "properties": {
          "probe": {
            "$ref": "#/components/schemas/Probe"
          },
          "camera": {
            "$ref": "#/components/schemas/Camera"
          }
        },
        "additionalProperties": false,
        "required": [
          "probe",
          "camera"
        ]
      },
      "Media": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "enum": [
              "upload",
              "url"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "fetching",
              "ready",
              "failed"
            ]
          },
          "content_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "size_bytes": {
            "type": "integer"
          },
          "duration_ms": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "sha256": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "error_code": {
            "anyOf": [
              {
                "type": "string",
                "description": "`media_unreadable`, `media_too_large`, `media_quota_reached`, `storage_full`, `media_fetch_failed`, `media_host_blocked`, `media_host_unresolved`, `media_url_invalid`"
              },
              {
                "type": "null"
              }
            ]
          },
          "expires_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "source",
          "status",
          "content_type",
          "size_bytes",
          "duration_ms",
          "sha256",
          "error_code",
          "expires_at",
          "created_at"
        ]
      },
      "MediaFromUrl": {
        "type": "object",
        "properties": {
          "source_url": {
            "type": "string",
            "maxLength": 2000,
            "description": "http(s) URL Lens downloads (it may carry a token; it is stored sealed and never returned). Must resolve to a public address."
          },
          "name": {
            "type": "string",
            "maxLength": 200,
            "default": ""
          }
        },
        "required": [
          "source_url"
        ]
      },
      "SafetyDailyResult": {
        "type": "object",
        "properties": {
          "schema": {
            "type": "string",
            "const": "safety_daily.v1"
          },
          "summary": {
            "type": "string",
            "description": "Short day summary in the analysis language."
          },
          "incidents": {
            "type": "integer"
          },
          "max_severity": {
            "type": "integer"
          },
          "clips": {
            "type": "integer"
          },
          "cameras": {
            "type": "integer"
          },
          "baseline": {
            "type": "object",
            "properties": {
              "loudness": {
                "type": "number"
              },
              "motion": {
                "type": "number"
              }
            },
            "additionalProperties": false
          },
          "windows": {
            "type": "integer"
          },
          "listen_events": {
            "type": "integer"
          },
          "look_observations": {
            "type": "integer"
          },
          "audio_seconds": {
            "type": "integer"
          },
          "sent_audio_seconds": {
            "type": "integer"
          }
        },
        "additionalProperties": true,
        "required": [
          "schema",
          "summary",
          "incidents",
          "max_severity",
          "clips",
          "cameras"
        ]
      },
      "QuoteAt": {
        "type": "object",
        "properties": {
          "t_s": {
            "type": "integer"
          },
          "quote": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "t_s",
          "quote"
        ]
      },
      "LessonResult": {
        "type": "object",
        "properties": {
          "schema": {
            "type": "string",
            "const": "lesson.v1"
          },
          "lesson": {
            "type": "object",
            "properties": {
              "starts_at": {
                "type": "string",
                "format": "date-time"
              },
              "ends_at": {
                "type": "string",
                "format": "date-time"
              },
              "duration_s": {
                "type": "integer"
              }
            },
            "additionalProperties": false
          },
          "topic": {
            "type": "object",
            "properties": {
              "given": {
                "type": "string"
              },
              "detected": {
                "type": "string"
              },
              "coverage_pct": {
                "anyOf": [
                  {
                    "type": "integer"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "additionalProperties": false
          },
          "timeline": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "phase": {
                  "type": "string",
                  "enum": [
                    "intro",
                    "explanation",
                    "practice",
                    "discussion",
                    "summary",
                    "other"
                  ]
                },
                "start_s": {
                  "type": "integer"
                },
                "end_s": {
                  "type": "integer"
                }
              },
              "additionalProperties": false
            }
          },
          "talk": {
            "type": "object",
            "properties": {
              "teacher_pct": {
                "type": "integer"
              },
              "student_pct": {
                "type": "integer"
              },
              "silence_pct": {
                "type": "integer"
              }
            },
            "additionalProperties": false
          },
          "teacher_questions": {
            "type": "object",
            "properties": {
              "open": {
                "type": "integer"
              },
              "closed": {
                "type": "integer"
              },
              "total": {
                "type": "integer"
              }
            },
            "additionalProperties": false
          },
          "student_questions": {
            "type": "integer"
          },
          "interactions": {
            "type": "integer"
          },
          "engagement": {
            "type": "object",
            "properties": {
              "score": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100
              },
              "evidence": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "additionalProperties": false
          },
          "pace": {
            "type": "string",
            "enum": [
              "slow",
              "good",
              "fast"
            ]
          },
          "clarity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 5
          },
          "board_use": {
            "type": "string",
            "enum": [
              "none",
              "some",
              "much"
            ]
          },
          "punctuality": {
            "type": "object",
            "properties": {
              "late_start_min": {
                "type": "integer"
              },
              "early_end_min": {
                "type": "integer"
              }
            },
            "additionalProperties": false
          },
          "language": {
            "type": "object",
            "properties": {
              "shouting": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/QuoteAt"
                }
              },
              "insults": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/QuoteAt"
                }
              },
              "swear_words": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/QuoteAt"
                }
              }
            },
            "additionalProperties": false
          },
          "key_moments": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "t_s": {
                  "type": "integer"
                },
                "text": {
                  "type": "string"
                }
              },
              "additionalProperties": false
            }
          },
          "strengths": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "improvements": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "rubric": {
            "type": "object",
            "properties": {
              "structure": {
                "type": "integer",
                "minimum": 1,
                "maximum": 5
              },
              "clarity": {
                "type": "integer",
                "minimum": 1,
                "maximum": 5
              },
              "engagement": {
                "type": "integer",
                "minimum": 1,
                "maximum": 5
              },
              "interaction": {
                "type": "integer",
                "minimum": 1,
                "maximum": 5
              },
              "pace": {
                "type": "integer",
                "minimum": 1,
                "maximum": 5
              },
              "language": {
                "type": "integer",
                "minimum": 1,
                "maximum": 5
              }
            },
            "additionalProperties": false
          },
          "overall": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          }
        },
        "additionalProperties": true,
        "required": [
          "schema",
          "overall"
        ]
      },
      "LessonBlockResult": {
        "type": "object",
        "properties": {
          "schema": {
            "type": "string",
            "const": "lesson_block.v1"
          },
          "lessons": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "analysis_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "starts_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "ends_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "teacher_id": {
                  "anyOf": [
                    {
                      "type": "string",
                      "format": "uuid"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "overall": {
                  "type": "integer"
                }
              },
              "additionalProperties": false
            }
          }
        },
        "additionalProperties": false,
        "required": [
          "schema",
          "lessons"
        ],
        "description": "A long block split into lessons: each lesson is its own analysis (parent_analysis_id = this one)."
      },
      "Analysis": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "type": "string",
            "enum": [
              "safety_daily",
              "lesson"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "waiting_ai",
              "running",
              "done",
              "failed",
              "superseded"
            ]
          },
          "tier": {
            "type": "string",
            "enum": [
              "economy",
              "standard",
              "deep"
            ]
          },
          "portfolio_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "room_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "camera_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "media_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "starts_at": {
            "type": "string",
            "format": "date-time"
          },
          "ends_at": {
            "type": "string",
            "format": "date-time"
          },
          "topic": {
            "type": "string"
          },
          "teacher_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "language": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "parent_analysis_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "forced": {
            "type": "boolean"
          },
          "superseded_by": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "requested_via": {
            "type": "string",
            "enum": [
              "ui",
              "api",
              "schedule"
            ]
          },
          "cost_uzs": {
            "type": "number",
            "description": "AI cost so far, in so'm."
          },
          "error_code": {
            "anyOf": [
              {
                "type": "string",
                "description": "When failed: `budget_exceeded`, `no_media`, `media_failed`, `ai_<code>`, `failed`."
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "started_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "finished_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "result": {
            "description": "Only on GET /analyses/{id}; null until done.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/SafetyDailyResult"
              },
              {
                "$ref": "#/components/schemas/LessonResult"
              },
              {
                "$ref": "#/components/schemas/LessonBlockResult"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "kind",
          "status",
          "tier",
          "portfolio_id",
          "room_id",
          "camera_ids",
          "media_ids",
          "starts_at",
          "ends_at",
          "topic",
          "teacher_id",
          "language",
          "parent_analysis_id",
          "forced",
          "superseded_by",
          "requested_via",
          "cost_uzs",
          "error_code",
          "created_at",
          "started_at",
          "finished_at"
        ]
      },
      "AnalysisCreate": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "safety_daily",
              "lesson"
            ]
          },
          "room_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid",
                "description": "Every camera of the room (all angles of one space)."
              },
              {
                "type": "null"
              }
            ]
          },
          "camera_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "maxItems": 50,
            "description": "Cameras of one portfolio."
          },
          "media_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "maxItems": 20,
            "description": "Ready media (integration mode)."
          },
          "starts_at": {
            "type": "string",
            "format": "date-time",
            "description": "Required for rooms and cameras. For media: when the video starts on the wall clock (optional; default: the video ends at its upload time)."
          },
          "ends_at": {
            "type": "string",
            "format": "date-time",
            "description": "Required for rooms and cameras (past, at most 24 h after starts_at). Ignored for media (start + longest duration)."
          },
          "tier": {
            "type": "string",
            "enum": [
              "economy",
              "standard",
              "deep"
            ],
            "description": "Default: the portfolio's tier, else the org's."
          },
          "topic": {
            "type": "string",
            "maxLength": 300,
            "description": "Lessons only."
          },
          "teacher_id": {
            "type": "string",
            "format": "uuid",
            "description": "Lessons only."
          },
          "teacher_name": {
            "type": "string",
            "maxLength": 120,
            "description": "Lessons only: matched by normalised name, made on first use."
          },
          "language": {
            "type": "string",
            "enum": [
              "uz",
              "ru",
              "en"
            ]
          },
          "batch": {
            "type": "boolean",
            "default": false,
            "description": "May wait for the provider's batch API (half price, results later)."
          },
          "force": {
            "type": "boolean",
            "default": false,
            "description": "Re-run a live scope (needs the org's force flag and `reason`)."
          },
          "reason": {
            "type": "string",
            "maxLength": 500
          }
        },
        "required": [
          "kind"
        ],
        "description": "Give exactly one of room_id, camera_ids, media_ids."
      },
      "ForceInput": {
        "type": "object",
        "properties": {
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          }
        },
        "required": [
          "reason"
        ]
      },
      "Clip": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "incident_id": {
            "type": "string",
            "format": "uuid"
          },
          "camera_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "starts_at": {
            "type": "string",
            "format": "date-time"
          },
          "ends_at": {
            "type": "string",
            "format": "date-time"
          },
          "size_bytes": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "ready",
              "failed"
            ]
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "incident_id",
          "camera_id",
          "starts_at",
          "ends_at",
          "size_bytes",
          "status",
          "expires_at"
        ]
      },
      "ClipLink": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "incident_id": {
            "type": "string",
            "format": "uuid"
          },
          "camera_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "starts_at": {
            "type": "string",
            "format": "date-time"
          },
          "ends_at": {
            "type": "string",
            "format": "date-time"
          },
          "size_bytes": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "ready",
              "failed"
            ]
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "url": {
            "anyOf": [
              {
                "type": "string",
                "description": "Signed MP4 link, no API key needed, Range supported. Valid 10 minutes."
              },
              {
                "type": "null"
              }
            ]
          },
          "url_expires_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "incident_id",
          "camera_id",
          "starts_at",
          "ends_at",
          "size_bytes",
          "status",
          "expires_at",
          "url",
          "url_expires_at"
        ]
      },
      "Incident": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "analysis_id": {
            "type": "string",
            "format": "uuid"
          },
          "portfolio_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "room_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "type": {
            "type": "string",
            "enum": [
              "shouting",
              "crying",
              "insult",
              "swearing",
              "threat",
              "hitting_sound",
              "begging",
              "hitting",
              "pushing",
              "restraint",
              "locking",
              "forced_feeding",
              "isolation",
              "left_alone",
              "child_harm_ignored",
              "inappropriate_touching",
              "rough_handling",
              "other"
            ]
          },
          "severity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 5
          },
          "confidence": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "starts_at": {
            "type": "string",
            "format": "date-time"
          },
          "ends_at": {
            "type": "string",
            "format": "date-time"
          },
          "camera_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "description": {
            "type": "string"
          },
          "quotes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "new",
              "released",
              "dismissed"
            ]
          },
          "released_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "dismissed_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "dismiss_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "clips": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Clip"
            }
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "analysis_id",
          "portfolio_id",
          "room_id",
          "type",
          "severity",
          "confidence",
          "starts_at",
          "ends_at",
          "camera_ids",
          "description",
          "quotes",
          "status",
          "released_at",
          "dismissed_at",
          "dismiss_reason",
          "created_at",
          "clips"
        ]
      },
      "Teacher": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "lessons": {
            "type": "integer",
            "description": "Analysed lessons."
          },
          "merged_into": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid",
                "description": "GET only: the teacher this one was merged into."
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "created_at"
        ]
      },
      "Card": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "examples": [
              "overall"
            ]
          },
          "title": {
            "type": "object",
            "properties": {
              "uz": {
                "type": "string"
              },
              "ru": {
                "type": "string"
              },
              "en": {
                "type": "string"
              }
            },
            "additionalProperties": false,
            "required": [
              "uz",
              "ru",
              "en"
            ]
          },
          "chart": {
            "type": "string",
            "enum": [
              "number",
              "bar",
              "line",
              "list"
            ]
          },
          "unit": {
            "type": "string",
            "enum": [
              "score",
              "pct",
              "count",
              "min",
              "text",
              "rating"
            ]
          },
          "lessons": {
            "type": "integer",
            "description": "Lessons that had this metric."
          },
          "value": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "description": "number: the value. line: the change of the last week against the week before (null with fewer than 2 weeks). bar, list: null."
          },
          "series": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "week": {
                  "type": "string",
                  "examples": [
                    "2026-W48"
                  ]
                },
                "value": {
                  "type": "number"
                }
              },
              "additionalProperties": false,
              "required": [
                "week",
                "value"
              ]
            }
          },
          "buckets": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "count": {
                  "type": "integer"
                }
              },
              "additionalProperties": false,
              "required": [
                "key",
                "count"
              ]
            }
          },
          "items": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "title",
          "chart",
          "unit",
          "lessons",
          "value"
        ]
      },
      "Dashboard": {
        "type": "object",
        "properties": {
          "teacher_id": {
            "type": "string",
            "format": "uuid"
          },
          "cards": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Card"
            }
          }
        },
        "additionalProperties": false,
        "required": [
          "teacher_id",
          "cards"
        ]
      },
      "Webhook": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "url": {
            "type": "string"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "analysis.completed",
                "analysis.failed",
                "incident.created",
                "camera.offline"
              ]
            }
          },
          "active": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "url",
          "events",
          "active",
          "created_at"
        ]
      },
      "WebhookWithSecret": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "url": {
            "type": "string"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "analysis.completed",
                "analysis.failed",
                "incident.created",
                "camera.offline"
              ]
            }
          },
          "active": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "secret": {
            "type": "string",
            "description": "Signing secret (`whsec_…`): shown only in this answer."
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "url",
          "events",
          "active",
          "created_at",
          "secret"
        ]
      },
      "WebhookCreate": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "maxLength": 2000,
            "description": "https URL resolving to a public address."
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "analysis.completed",
                "analysis.failed",
                "incident.created",
                "camera.offline"
              ]
            },
            "minItems": 1
          },
          "active": {
            "type": "boolean",
            "default": true
          }
        },
        "required": [
          "url",
          "events"
        ]
      },
      "WebhookUpdate": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "maxLength": 2000
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "analysis.completed",
                "analysis.failed",
                "incident.created",
                "camera.offline"
              ]
            },
            "minItems": 1
          },
          "active": {
            "type": "boolean"
          }
        }
      },
      "Delivery": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "webhook_id": {
            "type": "string",
            "format": "uuid"
          },
          "event": {
            "type": "string",
            "enum": [
              "analysis.completed",
              "analysis.failed",
              "incident.created",
              "camera.offline",
              "ping"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "delivered",
              "failed"
            ]
          },
          "attempts": {
            "type": "integer"
          },
          "response_status": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "response_ms": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "next_attempt_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "delivered_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "payload": {
            "$ref": "#/components/schemas/EventEnvelope"
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "webhook_id",
          "event",
          "status",
          "attempts",
          "response_status",
          "response_ms",
          "error",
          "next_attempt_at",
          "delivered_at",
          "created_at",
          "payload"
        ]
      },
      "EventEnvelope": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The delivery id (also in the Lens-Delivery header): deduplicate on it."
          },
          "event": {
            "type": "string",
            "enum": [
              "analysis.completed",
              "analysis.failed",
              "incident.created",
              "camera.offline",
              "ping"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "org_id": {
            "type": "string",
            "format": "uuid"
          },
          "data": {
            "type": "object",
            "properties": {
              "analysis": {
                "$ref": "#/components/schemas/Analysis"
              },
              "incident": {
                "$ref": "#/components/schemas/Incident"
              },
              "camera": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "name": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string",
                    "const": "offline"
                  },
                  "last_frame_at": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "additionalProperties": false
              },
              "webhook_id": {
                "type": "string",
                "format": "uuid"
              }
            },
            "additionalProperties": false,
            "description": "`analysis` for analysis.*, `incident` for incident.created, `camera` for camera.offline, `webhook_id` for ping."
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "event",
          "created_at",
          "org_id",
          "data"
        ]
      },
      "PortfolioPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Portfolio"
            }
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string",
                "description": "Pass as `cursor` for the next page; null on the last page."
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "items",
          "next_cursor"
        ]
      },
      "LessonSlotPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LessonSlot"
            }
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string",
                "description": "Pass as `cursor` for the next page; null on the last page."
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "items",
          "next_cursor"
        ]
      },
      "CameraPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Camera"
            }
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string",
                "description": "Pass as `cursor` for the next page; null on the last page."
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "items",
          "next_cursor"
        ]
      },
      "MediaPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Media"
            }
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string",
                "description": "Pass as `cursor` for the next page; null on the last page."
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "items",
          "next_cursor"
        ]
      },
      "AnalysisPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Analysis"
            }
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string",
                "description": "Pass as `cursor` for the next page; null on the last page."
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "items",
          "next_cursor"
        ]
      },
      "IncidentPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Incident"
            }
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string",
                "description": "Pass as `cursor` for the next page; null on the last page."
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "items",
          "next_cursor"
        ]
      },
      "TeacherPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Teacher"
            }
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string",
                "description": "Pass as `cursor` for the next page; null on the last page."
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "items",
          "next_cursor"
        ]
      },
      "WebhookPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Webhook"
            }
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string",
                "description": "Pass as `cursor` for the next page; null on the last page."
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "items",
          "next_cursor"
        ]
      },
      "DeliveryPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Delivery"
            }
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string",
                "description": "Pass as `cursor` for the next page; null on the last page."
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "items",
          "next_cursor"
        ]
      }
    }
  }
}
