{
  "openapi": "3.0.3",
  "info": {
    "title": "Intly Chat API",
    "version": "0.1.0",
    "description": "Server-to-server API собственного чата. Храните ключ на сервере и передавайте его в Authorization: Bearer <chat_key>; ключ начинается с chat_. Смена или отзыв ключа может прервать незавершённую генерацию. При статусе unknown обратитесь к владельцу подключения или в поддержку: автоматический повтор операции недопустим."
  },
  "servers": [
    {
      "url": "https://api.intly.ru/api/v1/chat"
    }
  ],
  "security": [
    {
      "ChatKey": []
    }
  ],
  "paths": {
    "/sessions/": {
      "post": {
        "summary": "Создать сессию",
        "responses": {
          "201": {
            "description": "Сессия создана.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                },
                "example": {
                  "id": "93a9ef66-21eb-4687-9831-e05a67f7db53",
                  "status": "open",
                  "mode": "ai",
                  "created_at": "2026-11-09T10:00:00Z"
                }
              }
            }
          },
          "200": {
            "description": "Идентичный повтор создания сессии.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                },
                "example": {
                  "id": "93a9ef66-21eb-4687-9831-e05a67f7db53",
                  "status": "open",
                  "mode": "ai",
                  "created_at": "2026-11-09T10:00:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Некорректное тело запроса или ключ Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ключ отсутствует, недействителен, отозван или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Подключение или агент недоступны.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Конфликт идентификатора или сессия закрыта.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Тело запроса превышает 65536 байт.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов; интервал ожидания указан в Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Сервис временно недоступен.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "unsupported_media_type — отправляйте application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSession"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128,
              "pattern": "^[!-~]+$"
            },
            "description": "Обязательный ключ создания: 1–128 печатных ASCII-символов без пробелов; область действия — подключение."
          }
        ],
        "operationId": "createChatSession",
        "description": "Создаёт сессию. Повтор с тем же Idempotency-Key и тем же нормализованным телом возвращает исходную сессию с кодом 200, даже если она закрыта. Другое тело с тем же ключом вызывает 409 idempotency_conflict. Лимит подключения: 120 запросов в минуту."
      }
    },
    "/sessions/{session_id}/": {
      "parameters": [
        {
          "name": "session_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "summary": "Состояние сессии",
        "responses": {
          "200": {
            "description": "Состояние сессии.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                },
                "example": {
                  "id": "93a9ef66-21eb-4687-9831-e05a67f7db53",
                  "status": "open",
                  "mode": "ai",
                  "created_at": "2026-11-09T10:00:00Z"
                }
              }
            }
          },
          "401": {
            "description": "Ключ отсутствует, недействителен, отозван или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Подключение или агент недоступны.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Сессия или операция не найдена для данного подключения.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Тело запроса превышает 65536 байт.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов; интервал ожидания указан в Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Сервис временно недоступен.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "getChatSession",
        "description": "Возвращает состояние доступной сессии. Лимиты чтения: 6000 запросов в минуту на подключение и 120 на сессию."
      }
    },
    "/sessions/{session_id}/close/": {
      "parameters": [
        {
          "name": "session_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "summary": "Закрыть сессию",
        "responses": {
          "200": {
            "description": "Сессия закрыта.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                },
                "example": {
                  "id": "93a9ef66-21eb-4687-9831-e05a67f7db53",
                  "status": "closed",
                  "mode": "ai",
                  "created_at": "2026-11-09T10:00:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Тело запроса должно быть пустым.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ключ отсутствует, недействителен, отозван или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Подключение или агент недоступны.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Сессия или операция не найдена для данного подключения.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Тело запроса превышает 65536 байт.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов; интервал ожидания указан в Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Сервис временно недоступен.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "unsupported_media_type — отправляйте application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Empty"
              }
            }
          }
        },
        "operationId": "closeChatSession",
        "description": "Закрывает сессию; запрос с пустым телом или {}. Повторное закрытие допустимо. Новые сообщения после закрытия не принимаются; идентичный повтор ранее принятого сообщения возвращает его операцию."
      }
    },
    "/sessions/{session_id}/messages/": {
      "parameters": [
        {
          "name": "session_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "summary": "Принять сообщение",
        "responses": {
          "202": {
            "description": "Сообщение принято в обработку; ответ ещё может быть не готов.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Operation"
                },
                "example": {
                  "operation_id": "b4a53a19-96d4-4e75-8ecd-5596fa813056",
                  "message_id": "5580eb6b-72a7-4b97-96a7-a6be3284e64d",
                  "client_message_id": "message-001",
                  "processing_status": "queued",
                  "response_message_ids": [],
                  "error_code": null,
                  "updated_at": "2026-11-09T10:00:00Z"
                }
              }
            }
          },
          "200": {
            "description": "Идентичный повтор ранее принятого сообщения.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Operation"
                },
                "example": {
                  "operation_id": "b4a53a19-96d4-4e75-8ecd-5596fa813056",
                  "message_id": "5580eb6b-72a7-4b97-96a7-a6be3284e64d",
                  "client_message_id": "message-001",
                  "processing_status": "queued",
                  "response_message_ids": [],
                  "error_code": null,
                  "updated_at": "2026-11-09T10:00:00Z"
                }
              }
            }
          },
          "400": {
            "description": "Некорректное тело запроса или отсутствует требуемый контакт (contact_required).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ключ отсутствует, недействителен, отозван или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Подключение или агент недоступны.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Сессия или операция не найдена для данного подключения.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Конфликт идентификатора или сессия закрыта.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Тело запроса превышает 65536 байт.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов; интервал ожидания указан в Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Сервис временно недоступен.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "unsupported_media_type — отправляйте application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendMessage"
              }
            }
          }
        },
        "operationId": "sendChatMessage",
        "description": "Принимает сообщение в обработку. 202 означает принятие, а не готовый ответ: проверяйте processing_status операции и историю. Повтор с тем же client_message_id и нормализованным телом возвращает операцию с 200 даже после закрытия сессии; другое тело вызывает 409 idempotency_conflict. Новое сообщение в закрытой сессии вызывает 409 session_closed. Лимиты отправки: 600 в минуту на подключение и 30 на сессию."
      },
      "get": {
        "summary": "Читать опубликованные события",
        "responses": {
          "200": {
            "description": "Страница опубликованных событий.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Page"
                },
                "example": {
                  "messages": [
                    {
                      "id": "5580eb6b-72a7-4b97-96a7-a6be3284e64d",
                      "event_id": "86b91a6f-7661-4b30-9ec5-8a50633034d2",
                      "role": "user",
                      "operation_id": "b4a53a19-96d4-4e75-8ecd-5596fa813056",
                      "content": "Здравствуйте!",
                      "created_at": "2026-11-09T10:00:00Z"
                    }
                  ],
                  "next_cursor": "<непрозрачный курсор>",
                  "has_more": false
                }
              }
            }
          },
          "400": {
            "description": "Некорректный cursor или limit.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Ключ отсутствует, недействителен, отозван или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Подключение или агент недоступны.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Сессия или операция не найдена для данного подключения.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Тело запроса превышает 65536 байт.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов; интервал ожидания указан в Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Сервис временно недоступен.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Значение next_cursor предыдущего ответа для этой сессии; без параметра чтение начинается с начала."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "description": "Размер страницы; по умолчанию 50."
          }
        ],
        "operationId": "listChatMessages",
        "description": "Возвращает опубликованные события в порядке публикации. Для следующего запроса передавайте cursor=<next_cursor>. Курсор непрозрачен и привязан к сессии. После has_more=false продолжайте периодический опрос с последним next_cursor: новые ответы могут появиться позже. Лимиты чтения: 6000 в минуту на подключение и 120 на сессию."
      }
    },
    "/sessions/{session_id}/operations/{operation_id}/": {
      "parameters": [
        {
          "name": "session_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        },
        {
          "name": "operation_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "summary": "Состояние операции",
        "responses": {
          "200": {
            "description": "Состояние операции.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Operation"
                },
                "example": {
                  "operation_id": "b4a53a19-96d4-4e75-8ecd-5596fa813056",
                  "message_id": "5580eb6b-72a7-4b97-96a7-a6be3284e64d",
                  "client_message_id": "message-001",
                  "processing_status": "completed",
                  "response_message_ids": [
                    "e9762206-e53e-4e5c-9f0a-efbe5de7d329"
                  ],
                  "error_code": null,
                  "updated_at": "2026-11-09T10:00:05Z"
                }
              }
            }
          },
          "401": {
            "description": "Ключ отсутствует, недействителен, отозван или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Подключение или агент недоступны.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Сессия или операция не найдена для данного подключения.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Тело запроса превышает 65536 байт.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов; интервал ожидания указан в Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Сервис временно недоступен.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "getChatOperation",
        "description": "Возвращает processing_status и опубликованные идентификаторы ответов операции. При unknown обратитесь к владельцу подключения или в поддержку; не запускайте операцию повторно автоматически."
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ChatKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Серверный ключ подключения chat_… в заголовке Authorization: Bearer. Не раскрывайте его клиентскому приложению."
      }
    },
    "schemas": {
      "Contact": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 100
          },
          "phone": {
            "type": "string",
            "maxLength": 31,
            "pattern": "^(?:|\\+?[0-9 ()-]{5,30})$"
          },
          "email": {
            "type": "string",
            "maxLength": 254,
            "anyOf": [
              {
                "enum": [
                  ""
                ]
              },
              {
                "format": "email"
              }
            ],
            "description": "Пустая строка или корректный email."
          }
        },
        "description": "Необязательный объект без null. Все поля необязательны и допускают пустую строку. Неизвестные поля отклоняются.",
        "example": {
          "name": "Анна",
          "phone": "",
          "email": "anna@example.com"
        }
      },
      "Session": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "closed"
            ]
          },
          "mode": {
            "type": "string",
            "enum": [
              "ai",
              "operator"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "status",
          "mode",
          "created_at"
        ],
        "example": {
          "id": "93a9ef66-21eb-4687-9831-e05a67f7db53",
          "status": "open",
          "mode": "ai",
          "created_at": "2026-11-09T10:00:00Z"
        }
      },
      "Operation": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "operation_id": {
            "type": "string",
            "format": "uuid"
          },
          "message_id": {
            "type": "string",
            "format": "uuid"
          },
          "client_message_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[!-~]+$"
          },
          "processing_status": {
            "type": "string",
            "enum": [
              "queued",
              "processing",
              "completed",
              "waiting_operator",
              "filtered",
              "failed",
              "unknown"
            ],
            "description": "queued и processing: ожидает или выполняется; completed: завершено; waiting_operator: ожидается оператор; filtered: ответ отфильтрован; failed: ошибка; unknown: результат исполнения неизвестен, требуется обращение к владельцу или в поддержку, автоматический повтор запрещён."
          },
          "response_message_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Идентификаторы опубликованных ответов, связанных с операцией; массив может быть пустым."
          },
          "error_code": {
            "type": "string",
            "nullable": true
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "operation_id",
          "message_id",
          "client_message_id",
          "processing_status",
          "response_message_ids",
          "error_code",
          "updated_at"
        ],
        "description": "Состояние обработки принятого сообщения. Статус возвращается в поле processing_status.",
        "example": {
          "operation_id": "b4a53a19-96d4-4e75-8ecd-5596fa813056",
          "message_id": "5580eb6b-72a7-4b97-96a7-a6be3284e64d",
          "client_message_id": "message-001",
          "processing_status": "queued",
          "response_message_ids": [],
          "error_code": null,
          "updated_at": "2026-11-09T10:00:00Z"
        }
      },
      "Event": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "event_id": {
            "type": "string",
            "format": "uuid"
          },
          "role": {
            "type": "string",
            "enum": [
              "user",
              "assistant"
            ],
            "description": "user — посетитель; assistant — ответ ИИ или оператора."
          },
          "operation_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "content": {
            "type": "string",
            "description": "Текст сообщения; для вложения без текста возвращается «Вложение»."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "event_id",
          "role",
          "operation_id",
          "content",
          "created_at"
        ]
      },
      "Error": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "error": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          },
          "request_id": {
            "type": "string",
            "format": "uuid",
            "description": "Идентификатор запроса для обращения в поддержку."
          }
        },
        "required": [
          "error",
          "request_id"
        ],
        "example": {
          "error": {
            "code": "contact_required",
            "message": "Contact required."
          },
          "request_id": "b6e65c57-22bc-49f8-b761-27cdaf94dd1c"
        }
      },
      "CreateSession": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "contact": {
            "$ref": "#/components/schemas/Contact"
          },
          "referrer": {
            "type": "string",
            "maxLength": 500,
            "description": "Пустая строка или корректный HTTP(S) URL страницы."
          }
        },
        "description": "Неизвестные поля отклоняются. Контакт можно передать здесь или при отправке сообщения.",
        "example": {
          "contact": {
            "name": "Анна",
            "email": "anna@example.com"
          },
          "referrer": "https://example.com/"
        }
      },
      "SendMessage": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "message": {
            "type": "string",
            "minLength": 1,
            "maxLength": 8000,
            "description": "Непустой текст после удаления пробелов по краям."
          },
          "client_message_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[!-~]+$",
            "description": "Идентификатор сообщения в пределах сессии; 1–128 печатных ASCII-символов без пробелов."
          },
          "contact": {
            "$ref": "#/components/schemas/Contact"
          }
        },
        "required": [
          "message",
          "client_message_id"
        ],
        "description": "Неизвестные поля отклоняются. contact необязателен и не может быть null; при его отсутствии используются контакты сессии. Если для подключения требуется телефон или email, при первом сообщении без нужного контакта возвращается 400 contact_required.",
        "example": {
          "message": "Здравствуйте!",
          "client_message_id": "message-001"
        }
      },
      "Page": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Event"
            }
          },
          "next_cursor": {
            "type": "string",
            "description": "Непрозрачный курсор, привязанный к сессии. Передавайте его значение в query-параметре cursor следующего запроса."
          },
          "has_more": {
            "type": "boolean",
            "description": "Есть ли другие опубликованные события сейчас; false не означает, что новые события больше не появятся."
          }
        },
        "required": [
          "messages",
          "next_cursor",
          "has_more"
        ],
        "example": {
          "messages": [
            {
              "id": "5580eb6b-72a7-4b97-96a7-a6be3284e64d",
              "event_id": "86b91a6f-7661-4b30-9ec5-8a50633034d2",
              "role": "user",
              "operation_id": "b4a53a19-96d4-4e75-8ecd-5596fa813056",
              "content": "Здравствуйте!",
              "created_at": "2026-11-09T10:00:00Z"
            }
          ],
          "next_cursor": "<непрозрачный курсор>",
          "has_more": false
        }
      },
      "Empty": {
        "type": "object",
        "additionalProperties": false,
        "properties": {}
      }
    }
  }
}
