{
  "openapi": "3.1.1",
  "info": {
    "title": "KFF Server API",
    "version": "1.6.0",
    "description": "站点后端与KFF通讯的稳定v1契约。浏览器不得携带站点密钥。兼容性策略见 /docs#versioning。"
  },
  "servers": [
    {
      "url": "/"
    }
  ],
  "security": [
    {
      "SiteKey": []
    }
  ],
  "tags": [
    {
      "name": "接入验证"
    },
    {
      "name": "会话"
    },
    {
      "name": "消息"
    },
    {
      "name": "事件"
    },
    {
      "name": "评价与已读"
    }
  ],
  "paths": {
    "/api/v1/me": {
      "get": {
        "operationId": "get_api_v1_me",
        "summary": "验证站点密钥",
        "tags": [
          "接入验证"
        ],
        "description": "capabilities.message_cycle_precondition为true表示服务器实际执行消息轮次前置条件。客户端不能仅发送未知字段并假定旧服务器会校验。 capabilities.reception_v1 为 true 时支持可选的接待扩展。",
        "parameters": [],
        "responses": {
          "200": {
            "description": "成功；幂等重试返回已有对象",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "site": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": true
                        },
                        "api_version": {
                          "type": "string",
                          "const": "1"
                        },
                        "version": {
                          "type": "string"
                        },
                        "capabilities": {
                          "type": "object",
                          "properties": {
                            "message_cycle_precondition": {
                              "type": "boolean"
                            },
                            "reception_v1": {
                              "type": "boolean",
                              "description": "为 true 时支持接待可用性、会话接待投影及接待方式。是否可留言以当时可用性为准。"
                            }
                          },
                          "additionalProperties": true
                        }
                      },
                      "additionalProperties": true
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "next_cursor": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "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"
                }
              }
            }
          },
          "409": {
            "description": "版本冲突或幂等ID的内容不同",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "速率限制，请按Retry-After退避",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "暂时不可用，保留原请求标识后查询确认",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "服务忙或数据库暂不可用，保留原幂等标识并退避重试；并发上限拒绝时可能无JSON正文",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/conversations": {
      "post": {
        "operationId": "post_api_v1_conversations",
        "summary": "幂等创建咨询",
        "tags": [
          "会话"
        ],
        "description": "同external_conversation_id与相同初始请求可重试；首次创建的身份与metadata应持久化，不要在重试时重新计算。 省略 reception_mode 时保留旧建单规则。选择 live 或 async 前应检查接待能力。接待方式是建单幂等载荷的一部分。",
        "parameters": [],
        "responses": {
          "200": {
            "description": "成功；幂等重试返回已有对象",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Conversation"
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "next_cursor": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "创建成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Conversation"
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "next_cursor": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "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"
                }
              }
            }
          },
          "409": {
            "description": "版本冲突或幂等ID的内容不同",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "JSON请求超过64KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Content-Type必须为application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "速率限制，请按Retry-After退避",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "暂时不可用，保留原请求标识后查询确认",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "服务忙或数据库暂不可用，保留原幂等标识并退避重试；并发上限拒绝时可能无JSON正文",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateConversation"
              }
            }
          }
        }
      },
      "get": {
        "operationId": "get_api_v1_conversations",
        "summary": "按本站咨询ID查询",
        "tags": [
          "会话"
        ],
        "description": "",
        "parameters": [
          {
            "name": "external_conversation_id",
            "in": "query",
            "required": false,
            "description": "站点内咨询ID",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；幂等重试返回已有对象",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Conversation"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "next_cursor": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "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"
                }
              }
            }
          },
          "409": {
            "description": "版本冲突或幂等ID的内容不同",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "速率限制，请按Retry-After退避",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "暂时不可用，保留原请求标识后查询确认",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "服务忙或数据库暂不可用，保留原幂等标识并退避重试；并发上限拒绝时可能无JSON正文",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/conversations/{id}": {
      "get": {
        "operationId": "get_api_v1_conversations__id_",
        "summary": "查询会话当前状态",
        "tags": [
          "会话"
        ],
        "description": "返回当前会话与queue/inactivity投影。需要排队展示时，站点后端每5秒读取并缓存给已验证归属的访客；继续独立消费events同步消息及关闭结果。已有客户端可以忽略新增字段。",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "KFF conversation ID"
          },
          {
            "name": "include_reception",
            "in": "query",
            "required": false,
            "description": "为 true 时附带 reception 投影。先检查 /me 的 reception_v1 能力。",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；幂等重试返回已有对象",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Conversation"
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "next_cursor": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "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"
                }
              }
            }
          },
          "409": {
            "description": "版本冲突或幂等ID的内容不同",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "速率限制，请按Retry-After退避",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "暂时不可用，保留原请求标识后查询确认",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "服务忙或数据库暂不可用，保留原幂等标识并退避重试；并发上限拒绝时可能无JSON正文",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/conversations/{id}/messages": {
      "post": {
        "operationId": "post_api_v1_conversations__id__messages",
        "summary": "幂等发送客户、自动回复或系统消息及附件",
        "tags": [
          "消息"
        ],
        "description": "需要跨轮次安全的接入方必须验证能力并持久保存expected_service_cycle，不能临发送时取最新轮次。幂等回执先于当前轮次/结束状态校验；原请求中没有该字段的未知尝试不得升级payload。service_cycle_conflict只阻止原载荷，不能自动重开或把旧消息改投新轮。",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "KFF conversation ID"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；幂等重试返回已有对象",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Message"
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "next_cursor": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "创建成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Message"
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "next_cursor": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "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"
                }
              }
            }
          },
          "409": {
            "description": "idempotency_conflict原ID载荷不一致；service_cycle_conflict原目标轮次变化；conversation_resolved目标轮次已结束。必须按error.code处理，不能自动替换轮次或ID。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "JSON请求超过64KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Content-Type必须为application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "速率限制，请按Retry-After退避",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "暂时不可用，保留原请求标识后查询确认",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "服务忙或数据库暂不可用，保留原幂等标识并退避重试；并发上限拒绝时可能无JSON正文",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateMessage"
              }
            }
          }
        }
      },
      "get": {
        "operationId": "get_api_v1_conversations__id__messages",
        "summary": "增量读取公开消息",
        "tags": [
          "消息"
        ],
        "description": "不返回内部备注。收到消息不等于用户已读。",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "KFF conversation ID"
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "最后已持久化的消息seq，起始0",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "每页数量；以has_more/next_cursor继续",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "client_message_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "按原消息ID确认不确定的发送结果"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；幂等重试返回已有对象",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Message"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "next_cursor": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "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"
                }
              }
            }
          },
          "409": {
            "description": "版本冲突或幂等ID的内容不同",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "速率限制，请按Retry-After退避",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "暂时不可用，保留原请求标识后查询确认",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "服务忙或数据库暂不可用，保留原幂等标识并退避重试；并发上限拒绝时可能无JSON正文",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/conversations/{id}/status": {
      "post": {
        "operationId": "post_api_v1_conversations__id__status",
        "summary": "结束或重新排队",
        "tags": [
          "会话"
        ],
        "description": "version_conflict 后读取当前状态再确认操作意图，禁止盲目覆盖。建议使用固定 client_operation_id；也支持 Idempotency-Key 请求头作为其默认值。相同操作ID必须保持整个请求（含version）不变。queued 可能被自动路由立即变为 open，必须使用响应中的实际 status/version。",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "KFF conversation ID"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "description": "可选持久操作ID；body.client_operation_id存在时以body为准"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；幂等重试返回已有对象",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Conversation"
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "next_cursor": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "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"
                }
              }
            }
          },
          "409": {
            "description": "版本冲突或幂等ID的内容不同",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "JSON请求超过64KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Content-Type必须为application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "速率限制，请按Retry-After退避",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "暂时不可用，保留原请求标识后查询确认",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "服务忙或数据库暂不可用，保留原幂等标识并退避重试；并发上限拒绝时可能无JSON正文",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StatusUpdate"
              }
            }
          }
        }
      }
    },
    "/api/v1/events": {
      "get": {
        "operationId": "get_api_v1_events",
        "summary": "增量读取公开事件",
        "tags": [
          "事件"
        ],
        "description": "消息和事件有各自游标，不要混用。先持久化本地业务变更再提交游标；重复事件按id去重。",
        "parameters": [
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "已持久化的事件游标，起始0",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "每页数量",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；幂等重试返回已有对象",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Event"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "next_cursor": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "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"
                }
              }
            }
          },
          "409": {
            "description": "版本冲突或幂等ID的内容不同",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "速率限制，请按Retry-After退避",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "暂时不可用，保留原请求标识后查询确认",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "服务忙或数据库暂不可用，保留原幂等标识并退避重试；并发上限拒绝时可能无JSON正文",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/conversations/{id}/events": {
      "get": {
        "operationId": "get_api_v1_conversations__id__events",
        "summary": "增量读取公开事件",
        "tags": [
          "事件"
        ],
        "description": "消息和事件有各自游标，不要混用。先持久化本地业务变更再提交游标；重复事件按id去重。",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "KFF conversation ID"
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "已持久化的事件游标，起始0",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "每页数量",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功；幂等重试返回已有对象",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Event"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "next_cursor": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "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"
                }
              }
            }
          },
          "409": {
            "description": "版本冲突或幂等ID的内容不同",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "速率限制，请按Retry-After退避",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "暂时不可用，保留原请求标识后查询确认",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "服务忙或数据库暂不可用，保留原幂等标识并退避重试；并发上限拒绝时可能无JSON正文",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/conversations/{id}/read": {
      "post": {
        "operationId": "post_api_v1_conversations__id__read",
        "summary": "提交访客已读水位",
        "tags": [
          "评价与已读"
        ],
        "description": "",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "KFF conversation ID"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；幂等重试返回已有对象",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "next_cursor": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "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"
                }
              }
            }
          },
          "409": {
            "description": "版本冲突或幂等ID的内容不同",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "JSON请求超过64KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Content-Type必须为application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "速率限制，请按Retry-After退避",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "暂时不可用，保留原请求标识后查询确认",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "服务忙或数据库暂不可用，保留原幂等标识并退避重试；并发上限拒绝时可能无JSON正文",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Read"
              }
            }
          }
        }
      }
    },
    "/api/v1/conversations/{id}/rating": {
      "post": {
        "operationId": "post_api_v1_conversations__id__rating",
        "summary": "提交或修改指定接待轮次评价",
        "tags": [
          "评价与已读"
        ],
        "description": "相同会话和cycle更新已有评分，不新增样本；首次评分保存该轮最近人工回复的归属，此后修改不改归属。",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "KFF conversation ID"
          }
        ],
        "responses": {
          "200": {
            "description": "成功；幂等重试返回已有对象",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "next_cursor": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "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"
                }
              }
            }
          },
          "409": {
            "description": "版本冲突或幂等ID的内容不同",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "JSON请求超过64KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Content-Type必须为application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "速率限制，请按Retry-After退避",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "暂时不可用，保留原请求标识后查询确认",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "服务忙或数据库暂不可用，保留原幂等标识并退避重试；并发上限拒绝时可能无JSON正文",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Rating"
              }
            }
          }
        }
      }
    },
    "/api/v1/statistics": {
      "get": {
        "operationId": "get_site_statistics",
        "summary": "读取本站服务统计",
        "tags": [
          "评价与已读"
        ],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "UTC开始日，默认近30天"
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "UTC结束日，包含该日，最大366天"
          },
          {
            "name": "include_test",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "是否包括验收咨询"
          }
        ],
        "responses": {
          "200": {
            "description": "仅此密钥所属站点的统计",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "from": {
                          "type": "string"
                        },
                        "to": {
                          "type": "string"
                        },
                        "timezone": {
                          "const": "UTC"
                        },
                        "totals": {
                          "type": "object"
                        },
                        "by_site": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        },
                        "by_agent": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "description": "客服表现：按会话创建日期（UTC）、平台权限及 include_test 过滤。回复发生在日期范围外仍归入原会话；响应按服务轮次隔离，归属实际回复客服。原 totals/by_site 首响保持会话首次回复口径。",
                            "properties": {
                              "response_samples": {
                                "type": "integer",
                                "minimum": 0,
                                "description": "可测量的客户消息批次响应数；首次与后续样本之和。"
                              },
                              "average_response_seconds": {
                                "type": [
                                  "number",
                                  "null"
                                ],
                                "minimum": 0,
                                "description": "全部有效响应样本的平均秒数；无样本为 null。连续客户消息按首条至下一次人工回复计一批。"
                              },
                              "first_response_samples": {
                                "type": "integer",
                                "minimum": 0,
                                "description": "各服务轮次首次回应的有效样本数，归实际回复客服。"
                              },
                              "average_first_response_seconds": {
                                "type": [
                                  "number",
                                  "null"
                                ],
                                "minimum": 0,
                                "description": "每个服务轮次首次客户消息批次至首次人工回应的平均秒数，包含排队等待；无样本为 null。"
                              },
                              "followup_response_samples": {
                                "type": "integer",
                                "minimum": 0,
                                "description": "同一服务轮次首次回应之后的有效响应批次数。"
                              },
                              "average_followup_response_seconds": {
                                "type": [
                                  "number",
                                  "null"
                                ],
                                "minimum": 0,
                                "description": "后续客户连续发言首条至下一次人工回复的平均秒数，转接按实际回复客服归属；无样本为 null。"
                              }
                            },
                            "additionalProperties": true
                          }
                        }
                      },
                      "additionalProperties": true
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "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"
                }
              }
            }
          },
          "429": {
            "description": "速率限制，请按Retry-After退避",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "暂时不可用，保留原请求标识后查询确认",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "服务忙或数据库暂不可用，保留原幂等标识并退避重试；并发上限拒绝时可能无JSON正文",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/conversations/{id}/attachments": {
      "post": {
        "operationId": "uploadConversationAttachment",
        "summary": "幂等上传会话图片或视频",
        "tags": [
          "附件"
        ],
        "description": "原始二进制上传，无 Base64 包装，必须发送唯一 Content-Length，不支持 Transfer-Encoding。JPEG/PNG/GIF/WebP 每个最多 10 MiB，MP4/WebM 每个最多 30 MiB。服务端检查 MIME、文件签名与容器结构，不做完整解码、转码或病毒扫描。client_upload_id 在同会话内唯一；相同文件字节、文件名、MIME 和可见性重试返回原附件，不同内容返回 409。会话结束后原上传仍可回放，新上传须先重开。上传成功后另发消息关联附件 ID。未关联附件超过 24 小时由每小时维护清理，已关联历史附件保留。上传最多 2 个并发；媒体总配额默认 1 GiB，并预留至少 1 GiB 磁盘空间。",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "KFF会话或附件的不透明ID"
          },
          {
            "name": "client_upload_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "description": "首次上传前保存，重试使用原值与原文件字节"
          },
          {
            "name": "X-Filename",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "建议提供 encodeURIComponent 编码的原始文件名，解码后最多180字符，不允许目录或控制字符；省略时为 attachment"
          },
          {
            "name": "Content-Length",
            "in": "header",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 31457280
            },
            "description": "原始文件字节数，必须且只能出现一次；图片上限10485760字节"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "image/jpeg": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "image/png": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "image/gif": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "image/webp": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "video/mp4": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "video/webm": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "同ID幂等重放",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Attachment"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "201": {
            "description": "上传已持久保存",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Attachment"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "参数、文件名、Content-Length 或容器结构不正确（invalid_media 等）",
            "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"
                }
              }
            }
          },
          "408": {
            "description": "upload_timeout：上传读取超时，保留原上传 ID 和字节后重试",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "idempotency_conflict：同上传ID的文件、文件名或MIME不同；conversation_resolved：已结束会话不能新上传",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "附件超过大小限制",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "unsupported_media_type：声明的 MIME 不在支持列表",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "速率限制，请按Retry-After退避",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "暂时不可用，保留原请求标识后查询确认",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "upload_busy 或暂时不可用；最大两个并发上传，保留原 ID 退避重试",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "507": {
            "description": "storage_quota_exceeded 或 insufficient_storage：媒体总配额或磁盘保留空间不足，由管理员处理后重试",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/attachments/{id}/content": {
      "get": {
        "operationId": "downloadAttachmentContent",
        "summary": "受权下载图片或视频，支持单段Range",
        "tags": [
          "附件"
        ],
        "description": "验证同租户、同站点与会话归属；本站上传的公开草稿可读取，控制台上传的公开附件必须关联公开消息后才向站点开放，内部备注附件永不开放。GET 返回原始媒体字节，不使用 data 包装。响应 private, no-store 与 nosniff，无免鉴权公开链接。支持单段 Range 和 HEAD；接入站点后端须再次检查当前访客对会话的权限。",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "KFF会话或附件的不透明ID"
          },
          {
            "name": "Range",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "example": "bytes=0-1023",
            "description": "仅支持单段bytes范围，包含后缀范围"
          }
        ],
        "responses": {
          "200": {
            "description": "完整内容，Cache-Control: no-store",
            "headers": {
              "Content-Type": {
                "schema": {
                  "type": "string"
                }
              },
              "Content-Length": {
                "schema": {
                  "type": "integer"
                }
              },
              "Accept-Ranges": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/gif": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/webp": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "video/mp4": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "video/webm": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "206": {
            "description": "部分内容，响应Content-Range",
            "headers": {
              "Content-Range": {
                "schema": {
                  "type": "string"
                }
              },
              "Accept-Ranges": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/gif": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/webp": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "video/mp4": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "video/webm": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "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"
                }
              }
            }
          },
          "416": {
            "description": "range_not_satisfiable：不支持多段或无效范围；Content-Range 为 bytes */总长度",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Content-Range": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "速率限制，请按Retry-After退避",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "暂时不可用，保留原请求标识后查询确认",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "media_unavailable：历史记录存在但文件缺失或大小不符，请联系管理员",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "head": {
        "operationId": "headAttachmentContent",
        "summary": "读取受权附件响应头，不返回文件正文",
        "tags": [
          "附件"
        ],
        "description": "验证同租户、同站点与会话归属；本站上传的公开草稿可读取，控制台上传的公开附件必须关联公开消息后才向站点开放，内部备注附件永不开放。GET 返回原始媒体字节，不使用 data 包装。响应 private, no-store 与 nosniff，无免鉴权公开链接。支持单段 Range 和 HEAD；接入站点后端须再次检查当前访客对会话的权限。",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "KFF会话或附件的不透明ID"
          },
          {
            "name": "Range",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "example": "bytes=0-1023",
            "description": "仅支持单段bytes范围，包含后缀范围"
          }
        ],
        "responses": {
          "200": {
            "description": "完整内容，Cache-Control: no-store",
            "headers": {
              "Content-Type": {
                "schema": {
                  "type": "string"
                }
              },
              "Content-Length": {
                "schema": {
                  "type": "integer"
                }
              },
              "Accept-Ranges": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "206": {
            "description": "部分内容，响应Content-Range",
            "headers": {
              "Content-Range": {
                "schema": {
                  "type": "string"
                }
              },
              "Accept-Ranges": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "密钥不存在、失效或已吊销"
          },
          "403": {
            "description": "权限不足"
          },
          "404": {
            "description": "资源不存在或不属于此站点"
          },
          "416": {
            "description": "range_not_satisfiable：不支持多段或无效范围；Content-Range 为 bytes */总长度",
            "headers": {
              "Content-Range": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "速率限制，请按Retry-After退避"
          },
          "500": {
            "description": "暂时不可用，保留原请求标识后查询确认"
          },
          "503": {
            "description": "media_unavailable：历史记录存在但文件缺失或大小不符，请联系管理员"
          }
        }
      }
    },
    "/api/v1/analytics/events": {
      "post": {
        "operationId": "ingestKnowledgeAnalyticsEvents",
        "summary": "批量幂等上报知识服务事件",
        "tags": [
          "知识分析"
        ],
        "description": "独立分析日志，不创建人工排队会话。每批1–20条、整个JSON最多64KiB、每条data最多4096字节；原子提交，任何错误回滚全批。site/tenant仅从Bearer key取得。同站点event_id原内容回放；同实体revision不同内容或时间409。更低revision可晚到但不会覆盖高版本投影。时间为带时区ISO8601，session开始≤phase开始≤事件时间，最多允许未来5分钟。session.started_at/is_test/visitor_key和phase_started_at不可变。只接收定义的结构化字段，拒绝原始查询、回答全文和任意用户资料。",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnalyticsBatch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "事务已提交，accepted为新增事件数，duplicates为event_id精确重放数",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AnalyticsAcknowledgement"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "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"
                }
              }
            }
          },
          "409": {
            "description": "event_id、session/phase固定字段、entity/revision或人工轮次关联冲突；批次全量回滚",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "JSON请求超过64KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "速率限制，按Retry-After等待",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "数据库或服务暂不可用；保留原event_id与原事件重试，过载响应可能无JSON正文",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/report": {
      "get": {
        "operationId": "getKnowledgeAnalyticsReport",
        "summary": "读取本站自助与人工后续聚合",
        "tags": [
          "知识分析"
        ],
        "description": "按咨询阶段开始日期建cohort，晚到结果更新历史cohort。未反馈不当作失败或成功；自助解决须最终明确确认且该阶段从未转人工。输出definitions说明分母、样本及人工关闭并非业务解决。人工数据来自已关联KFF真实消息、服务轮次与评分；旧/statistics语义不变。 knowledge_phases排除仅disabled的阶段；反馈覆盖率分母为answered，包含选择候选后升级为answered的问题。",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "阶段开始日期，默认近30天；cohort按phase_started_at"
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "包含结束日，最多366个自然日"
          },
          {
            "name": "timezone",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "UTC",
                "Asia/Shanghai"
              ],
              "default": "UTC"
            },
            "description": "与offset_minutes互斥"
          },
          {
            "name": "offset_minutes",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": -840,
              "maximum": 840
            },
            "description": "固定UTC偏移，与timezone互斥"
          },
          {
            "name": "include_test",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "默认排除测试阶段"
          },
          {
            "name": "site_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "仅允许当前站点ID；省略即当前key所属站点"
          }
        ],
        "responses": {
          "200": {
            "description": "本站聚合、来源平台、每日cohort与转人工原因",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AnalyticsReport"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "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"
                }
              }
            }
          },
          "409": {
            "description": "event_id、session/phase固定字段、entity/revision或人工轮次关联冲突；批次全量回滚",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "JSON请求超过64KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "速率限制，按Retry-After等待",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "数据库或服务暂不可用；保留原event_id与原事件重试，过载响应可能无JSON正文",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/topics": {
      "get": {
        "operationId": "getKnowledgeAnalyticsTopics",
        "summary": "分页读取归一脱敏高频问题",
        "tags": [
          "知识分析"
        ],
        "description": "以site+normalizer_version+topic.key分组，不跨平台猜测合并。默认只展示存在miss或明确负反馈的问题，未选择候选或未反馈不是明确未解决。仅disabled的请求不进入知识问题分组。handoff_phases仅统计明确trigger_interaction_id关联。display是来源站点脱敏后的代表问法。",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "阶段开始日期，默认近30天；cohort按phase_started_at"
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "包含结束日，最多366个自然日"
          },
          {
            "name": "timezone",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "UTC",
                "Asia/Shanghai"
              ],
              "default": "UTC"
            },
            "description": "与offset_minutes互斥"
          },
          {
            "name": "offset_minutes",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": -840,
              "maximum": 840
            },
            "description": "固定UTC偏移，与timezone互斥"
          },
          {
            "name": "include_test",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "默认排除测试阶段"
          },
          {
            "name": "site_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "仅允许当前站点ID；省略即当前key所属站点"
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100000,
              "default": 1
            },
            "description": "页码"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            },
            "description": "每页条数"
          },
          {
            "name": "unresolved_only",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": true
            },
            "description": "仅有未解决样本的问题组"
          }
        ],
        "responses": {
          "200": {
            "description": "分页问题聚合；filters/as_of与data同层返回",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AnalyticsTopicMetric"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "page": {
                          "type": "integer"
                        },
                        "limit": {
                          "type": "integer"
                        },
                        "total": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      },
                      "required": [],
                      "additionalProperties": false
                    },
                    "filters": {
                      "$ref": "#/components/schemas/AnalyticsFilters"
                    },
                    "as_of": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "data",
                    "meta",
                    "filters",
                    "as_of"
                  ]
                }
              }
            }
          },
          "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"
                }
              }
            }
          },
          "409": {
            "description": "event_id、session/phase固定字段、entity/revision或人工轮次关联冲突；批次全量回滚",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "JSON请求超过64KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "速率限制，按Retry-After等待",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "数据库或服务暂不可用；保留原event_id与原事件重试，过载响应可能无JSON正文",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reception": {
      "get": {
        "operationId": "get_api_v1_reception",
        "summary": "读取本站接待可用性",
        "tags": [
          "会话"
        ],
        "description": "用于渲染访客入口。提交时重新核验营业时间和实时队列。",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ReceptionAvailability"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "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"
                }
              }
            }
          },
          "429": {
            "description": "速率限制，请按Retry-After退避",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "暂时不可用，保留原请求标识后查询确认",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "服务忙或数据库暂不可用，保留原幂等标识并退避重试；并发上限拒绝时可能无JSON正文",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/conversations/{id}/reception": {
      "post": {
        "operationId": "post_api_v1_conversations_reception",
        "summary": "切换未分配会话的接待方式",
        "tags": [
          "会话"
        ],
        "description": "仅未分配的排队会话可切换，保留会话和服务轮次。用原 client_operation_id、version 和 reception_mode 幂等重试。live_unavailable 或 async_unavailable 的 details 返回本站可用性。",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ReceptionModeReceipt"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "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"
                }
              }
            }
          },
          "409": {
            "description": "版本冲突或幂等ID的内容不同",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "速率限制，请按Retry-After退避",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "暂时不可用，保留原请求标识后查询确认",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "服务忙或数据库暂不可用，保留原幂等标识并退避重试；并发上限拒绝时可能无JSON正文",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "资源不存在或不属于此站点",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "KFF conversation ID"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChangeReceptionMode"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "SiteKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "控制台中为单站点生成的密钥；只显示一次，可独立吊销"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "description": "稳定错误码"
              },
              "message": {
                "type": "string",
                "description": "可读错误信息"
              },
              "details": {
                "type": "object",
                "properties": {
                  "expected_service_cycle": {
                    "type": "integer"
                  },
                  "current_service_cycle": {
                    "type": "integer"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "queued",
                      "open",
                      "resolved"
                    ]
                  }
                },
                "additionalProperties": true,
                "description": "可选机器可读错误详情；service_cycle_conflict提供原目标与当前轮次，不包含其它站点数据。"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "additionalProperties": false
          },
          "request_id": {
            "type": "string",
            "description": "排查请求编号"
          }
        },
        "required": [
          "error",
          "request_id"
        ],
        "additionalProperties": false
      },
      "User": {
        "type": "object",
        "properties": {
          "external_user_id": {
            "type": "string",
            "description": "由接入站点后端提供的用户或访客ID",
            "maxLength": 200
          },
          "display_name": {
            "type": "string",
            "description": "展示名称",
            "maxLength": 100
          },
          "email": {
            "type": "string",
            "description": "可选联系邮箱",
            "maxLength": 254
          },
          "identity_verified": {
            "type": "boolean",
            "description": "仅站点后端校验真实登录后允许true；前端声明不能当认证"
          },
          "metadata": {
            "type": "object",
            "description": "JSON对象，序列化后最大8192字节，禁止秘密。"
          }
        },
        "required": [
          "external_user_id"
        ],
        "additionalProperties": true
      },
      "Conversation": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "稳定标识，不解析内部格式"
          },
          "site_id": {
            "type": "string",
            "description": "稳定标识，不解析内部格式"
          },
          "external_conversation_id": {
            "type": "string",
            "description": "站点内唯一咨询ID"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "open",
              "resolved"
            ]
          },
          "version": {
            "type": "integer"
          },
          "assigned_to": {
            "type": [
              "string",
              "null"
            ]
          },
          "user": {
            "$ref": "#/components/schemas/User"
          },
          "title": {
            "type": "string",
            "description": "标题"
          },
          "metadata": {
            "type": "object"
          },
          "is_test": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "description": "UTC ISO 8601",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "description": "UTC ISO 8601",
            "format": "date-time"
          },
          "service_cycle": {
            "type": "integer",
            "minimum": 1,
            "description": "接待轮次，重开后递增"
          },
          "queue": {
            "$ref": "#/components/schemas/ReceptionQueue"
          },
          "inactivity": {
            "$ref": "#/components/schemas/CustomerInactivity"
          },
          "resolution_reason": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "manual",
              "customer_inactive",
              null
            ],
            "description": "结束原因；旧数据可能为null。自动结束保留消息及接待轮次。"
          },
          "reception": {
            "$ref": "#/components/schemas/ConversationReception"
          }
        },
        "required": [
          "id",
          "site_id",
          "status",
          "version"
        ],
        "additionalProperties": true
      },
      "Message": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "稳定标识，不解析内部格式"
          },
          "seq": {
            "type": "integer",
            "description": "单调递增游标，允许不连续"
          },
          "conversation_id": {
            "type": "string",
            "description": "稳定标识，不解析内部格式"
          },
          "client_message_id": {
            "type": "string",
            "description": "调用方固定消息ID"
          },
          "role": {
            "type": "string",
            "enum": [
              "user",
              "bot",
              "agent"
            ]
          },
          "content": {
            "type": "string",
            "description": "纯文本内容"
          },
          "created_at": {
            "type": "string",
            "description": "UTC ISO 8601",
            "format": "date-time"
          },
          "received_at": {
            "type": "string",
            "format": "date-time"
          },
          "agent": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "display_name": {
                "type": "string"
              }
            },
            "additionalProperties": true
          },
          "service_cycle": {
            "type": "integer"
          },
          "category": {
            "type": "string",
            "enum": [
              "user",
              "agent",
              "automatic",
              "system"
            ],
            "description": "可选的消息分类；自动回复automatic、系统通知system。API v1系统通知保持role=bot兼容旧站点。未知分类按role安全呈现。"
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Attachment"
            },
            "description": "可选附件元数据；旧消息可能没有此字段。"
          }
        },
        "required": [
          "id",
          "seq",
          "content"
        ],
        "additionalProperties": true
      },
      "Event": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "seq": {
            "type": "integer"
          },
          "conversation_id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "description": "忽略未知事件类型"
          },
          "data": {
            "type": "object",
            "additionalProperties": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [],
        "additionalProperties": true
      },
      "CreateConversation": {
        "type": "object",
        "properties": {
          "external_conversation_id": {
            "type": "string",
            "description": "首次发送前持久保存，重试不可更换",
            "maxLength": 200
          },
          "user": {
            "$ref": "#/components/schemas/User"
          },
          "title": {
            "type": "string",
            "description": "咨询主题",
            "maxLength": 200
          },
          "metadata": {
            "type": "object"
          },
          "is_test": {
            "type": "boolean",
            "default": false
          },
          "reception_mode": {
            "$ref": "#/components/schemas/ReceptionMode"
          }
        },
        "required": [
          "external_conversation_id",
          "user"
        ],
        "additionalProperties": false
      },
      "CreateMessage": {
        "type": "object",
        "properties": {
          "client_message_id": {
            "type": "string",
            "description": "首次发送前持久保存；同ID同内容返回原消息，同ID不同内容409",
            "maxLength": 200
          },
          "content": {
            "type": "string",
            "description": "纯文本，不解析HTML；emoji使用Unicode。附件非空时允许空正文。",
            "minLength": 0,
            "maxLength": 8000
          },
          "role": {
            "type": "string",
            "enum": [
              "user",
              "bot",
              "system"
            ],
            "default": "user"
          },
          "created_at": {
            "type": "string",
            "description": "UTC ISO 8601",
            "format": "date-time"
          },
          "attachments": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 10,
            "description": "已上传且属于本次会话的附件ID；重试必须保持顺序和原ID。",
            "uniqueItems": true
          },
          "expected_service_cycle": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647,
            "description": "可选但推荐。首次发送前冻结真实目标服务轮次，属于原始幂等载荷，重试不得修改/补加/删除。已存在相同完整载荷先返回原消息及原轮次；未保存且与当前轮次不同返回409 service_cycle_conflict，零消息/事件写入。省略保留旧v1按实际保存时轮次写入的行为，不提供跨轮次保护。使用前必须验证/me capabilities.message_cycle_precondition=true。"
          }
        },
        "required": [
          "client_message_id"
        ],
        "additionalProperties": false,
        "anyOf": [
          {
            "required": [
              "content"
            ],
            "properties": {
              "content": {
                "type": "string",
                "minLength": 1
              }
            }
          },
          {
            "required": [
              "attachments"
            ],
            "properties": {
              "attachments": {
                "type": "array",
                "minItems": 1
              }
            }
          }
        ]
      },
      "StatusUpdate": {
        "type": "object",
        "properties": {
          "version": {
            "type": "integer",
            "description": "GET会话返回的当前版本"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "resolved"
            ]
          },
          "reason": {
            "type": "string",
            "description": "变更原因"
          },
          "client_operation_id": {
            "type": "string",
            "maxLength": 200,
            "description": "建议持久保存的状态操作ID，超时后同请求可幂等重放"
          }
        },
        "required": [
          "version",
          "status"
        ],
        "additionalProperties": false
      },
      "Rating": {
        "type": "object",
        "properties": {
          "score": {
            "type": "integer",
            "minimum": 1,
            "maximum": 5
          },
          "comment": {
            "type": "string",
            "description": "评价文字",
            "maxLength": 2000
          },
          "cycle": {
            "type": "integer",
            "minimum": 1,
            "default": 1,
            "maximum": 100000,
            "description": "不大于会话service_cycle；支持修改已结束轮次的评分，建议显式提供，省略仍按v1兼容默认1处理"
          }
        },
        "required": [
          "score"
        ],
        "additionalProperties": false
      },
      "Read": {
        "type": "object",
        "properties": {
          "last_seq": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "last_seq"
        ],
        "additionalProperties": false
      },
      "Attachment": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "conversation_id": {
            "type": "string"
          },
          "filename": {
            "type": "string"
          },
          "mime_type": {
            "type": "string"
          },
          "size": {
            "type": "integer",
            "description": "字节数"
          },
          "media_type": {
            "type": "string",
            "enum": [
              "image",
              "video"
            ]
          },
          "sha256": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "download_url": {
            "type": "string",
            "description": "受权API相对路径，必须由本站后端代理访问，不包含站点密钥"
          },
          "visibility": {
            "type": "string",
            "enum": [
              "public"
            ],
            "description": "公开站点API只返回public；internal仅控制台可见"
          }
        },
        "required": [
          "id",
          "mime_type",
          "size",
          "media_type",
          "download_url"
        ],
        "additionalProperties": true
      },
      "AnalyticsSession": {
        "type": "object",
        "properties": {
          "external_session_id": {
            "type": "string",
            "maxLength": 200,
            "description": "站点内稳定咨询标识，不要求先创建人工会话"
          },
          "started_at": {
            "type": "string",
            "format": "date-time"
          },
          "is_test": {
            "type": "boolean"
          },
          "visitor_key": {
            "type": "string",
            "maxLength": 200,
            "description": "可选的不透明访客标识；同会话必须保持一致，不是身份认证"
          }
        },
        "required": [
          "external_session_id",
          "started_at",
          "is_test"
        ],
        "additionalProperties": false
      },
      "AnalyticsTopic": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "maxLength": 128,
            "description": "归一脱敏后生成的稳定hash/key，不上传原始查询"
          },
          "display": {
            "type": "string",
            "maxLength": 160,
            "description": "脱敏代表问法，不包含凭据或完整用户资料"
          },
          "normalizer_version": {
            "type": "string",
            "maxLength": 64
          }
        },
        "required": [
          "key",
          "display",
          "normalizer_version"
        ],
        "additionalProperties": false
      },
      "AnalyticsArticle": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "maxLength": 200
          },
          "revision": {
            "type": "string",
            "maxLength": 100,
            "description": "字符串形式的知识条目版本"
          },
          "title": {
            "type": "string",
            "maxLength": 160
          }
        },
        "required": [],
        "additionalProperties": false
      },
      "KnowledgeInteraction": {
        "type": "object",
        "properties": {
          "interaction_id": {
            "type": "string",
            "maxLength": 200
          },
          "revision": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000000
          },
          "decision": {
            "type": "string",
            "enum": [
              "answered",
              "suggested",
              "miss",
              "disabled",
              "error"
            ]
          },
          "answer_id": {
            "type": "string",
            "maxLength": 200
          },
          "article": {
            "$ref": "#/components/schemas/AnalyticsArticle"
          },
          "match_method": {
            "type": "string",
            "enum": [
              "exact",
              "keyword",
              "fuzzy",
              "no_match"
            ]
          },
          "match_score": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "maximum": 1,
            "description": "来源检索器的相似度，不是统一概率"
          },
          "algorithm_version": {
            "type": "string",
            "maxLength": 100
          },
          "selected": {
            "type": "boolean",
            "default": false
          },
          "topic": {
            "$ref": "#/components/schemas/AnalyticsTopic"
          },
          "sequence": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 2147483647,
            "description": "建议提供来源站点持久问题序号；同阶段唯一、同问题跨revision不变。用于同秒及乱序判断最新问题；缺失时同秒多问题结果保守为未知。"
          }
        },
        "required": [
          "interaction_id",
          "revision",
          "decision",
          "match_method"
        ],
        "additionalProperties": false
      },
      "KnowledgeFeedback": {
        "type": "object",
        "properties": {
          "interaction_id": {
            "type": "string",
            "maxLength": 200
          },
          "revision": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000000
          },
          "answer_helpful": {
            "type": "boolean"
          },
          "answer_id": {
            "type": "string",
            "maxLength": 200,
            "description": "建议指定；不匹配当前答案的反馈不进入当前有用率"
          }
        },
        "required": [
          "interaction_id",
          "revision",
          "answer_helpful"
        ],
        "additionalProperties": false
      },
      "KnowledgeOutcome": {
        "type": "object",
        "properties": {
          "revision": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000000
          },
          "interaction_id": {
            "type": "string",
            "maxLength": 200
          },
          "outcome": {
            "type": "string",
            "enum": [
              "resolved",
              "unresolved"
            ]
          },
          "is_final": {
            "type": "boolean"
          },
          "score": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 5,
            "description": "独立自助满意度，不写入人工rating"
          }
        },
        "required": [
          "revision",
          "interaction_id",
          "outcome",
          "is_final"
        ],
        "additionalProperties": false
      },
      "KnowledgeHandoff": {
        "type": "object",
        "properties": {
          "handoff_id": {
            "type": "string",
            "maxLength": 200
          },
          "reason": {
            "type": "string",
            "enum": [
              "manual",
              "round_limit",
              "unmatched",
              "kb_disabled",
              "media",
              "explicit_unresolved",
              "ambiguous",
              "other"
            ]
          },
          "trigger_interaction_id": {
            "type": "string",
            "maxLength": 200
          },
          "bot_turns": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 100000
          },
          "elapsed_seconds": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "maximum": 31536000
          },
          "policy_snapshot": {
            "type": "object",
            "properties": {
              "round_limit": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100000
              },
              "handoff_on_miss": {
                "type": "boolean"
              },
              "knowledge_enabled": {
                "type": "boolean"
              }
            },
            "required": [],
            "additionalProperties": false
          }
        },
        "required": [
          "handoff_id",
          "reason"
        ],
        "additionalProperties": false
      },
      "KnowledgeConversationLink": {
        "type": "object",
        "properties": {
          "handoff_id": {
            "type": "string",
            "maxLength": 200
          },
          "conversation_id": {
            "type": "string",
            "maxLength": 200,
            "description": "必须属于当前API key站点，并与分析阶段is_test一致"
          },
          "service_cycle": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100000
          }
        },
        "required": [
          "handoff_id",
          "conversation_id",
          "service_cycle"
        ],
        "additionalProperties": false
      },
      "KnowledgeInteractionEvent": {
        "type": "object",
        "properties": {
          "event_id": {
            "type": "string",
            "maxLength": 200,
            "description": "站点内唯一，首次入outbox前持久保存；重试不可改ID、时间或内容"
          },
          "type": {
            "const": "knowledge.interaction"
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time"
          },
          "session": {
            "$ref": "#/components/schemas/AnalyticsSession"
          },
          "bot_phase": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100000
          },
          "phase_started_at": {
            "type": "string",
            "format": "date-time",
            "description": "phase1省略时使用session.started_at；后续phase必填。开始时间不可改变。"
          },
          "data": {
            "$ref": "#/components/schemas/KnowledgeInteraction"
          }
        },
        "required": [
          "event_id",
          "type",
          "occurred_at",
          "session",
          "bot_phase",
          "data"
        ],
        "additionalProperties": false
      },
      "KnowledgeFeedbackEvent": {
        "type": "object",
        "properties": {
          "event_id": {
            "type": "string",
            "maxLength": 200,
            "description": "站点内唯一，首次入outbox前持久保存；重试不可改ID、时间或内容"
          },
          "type": {
            "const": "knowledge.feedback"
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time"
          },
          "session": {
            "$ref": "#/components/schemas/AnalyticsSession"
          },
          "bot_phase": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100000
          },
          "phase_started_at": {
            "type": "string",
            "format": "date-time",
            "description": "phase1省略时使用session.started_at；后续phase必填。开始时间不可改变。"
          },
          "data": {
            "$ref": "#/components/schemas/KnowledgeFeedback"
          }
        },
        "required": [
          "event_id",
          "type",
          "occurred_at",
          "session",
          "bot_phase",
          "data"
        ],
        "additionalProperties": false
      },
      "KnowledgeOutcomeEvent": {
        "type": "object",
        "properties": {
          "event_id": {
            "type": "string",
            "maxLength": 200,
            "description": "站点内唯一，首次入outbox前持久保存；重试不可改ID、时间或内容"
          },
          "type": {
            "const": "knowledge.outcome"
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time"
          },
          "session": {
            "$ref": "#/components/schemas/AnalyticsSession"
          },
          "bot_phase": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100000
          },
          "phase_started_at": {
            "type": "string",
            "format": "date-time",
            "description": "phase1省略时使用session.started_at；后续phase必填。开始时间不可改变。"
          },
          "data": {
            "$ref": "#/components/schemas/KnowledgeOutcome"
          }
        },
        "required": [
          "event_id",
          "type",
          "occurred_at",
          "session",
          "bot_phase",
          "data"
        ],
        "additionalProperties": false
      },
      "KnowledgeHandoffEvent": {
        "type": "object",
        "properties": {
          "event_id": {
            "type": "string",
            "maxLength": 200,
            "description": "站点内唯一，首次入outbox前持久保存；重试不可改ID、时间或内容"
          },
          "type": {
            "const": "handoff.requested"
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time"
          },
          "session": {
            "$ref": "#/components/schemas/AnalyticsSession"
          },
          "bot_phase": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100000
          },
          "phase_started_at": {
            "type": "string",
            "format": "date-time",
            "description": "phase1省略时使用session.started_at；后续phase必填。开始时间不可改变。"
          },
          "data": {
            "$ref": "#/components/schemas/KnowledgeHandoff"
          }
        },
        "required": [
          "event_id",
          "type",
          "occurred_at",
          "session",
          "bot_phase",
          "data"
        ],
        "additionalProperties": false
      },
      "KnowledgeConversationLinkEvent": {
        "type": "object",
        "properties": {
          "event_id": {
            "type": "string",
            "maxLength": 200,
            "description": "站点内唯一，首次入outbox前持久保存；重试不可改ID、时间或内容"
          },
          "type": {
            "const": "conversation.linked"
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time"
          },
          "session": {
            "$ref": "#/components/schemas/AnalyticsSession"
          },
          "bot_phase": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100000
          },
          "phase_started_at": {
            "type": "string",
            "format": "date-time",
            "description": "phase1省略时使用session.started_at；后续phase必填。开始时间不可改变。"
          },
          "data": {
            "$ref": "#/components/schemas/KnowledgeConversationLink"
          }
        },
        "required": [
          "event_id",
          "type",
          "occurred_at",
          "session",
          "bot_phase",
          "data"
        ],
        "additionalProperties": false
      },
      "AnalyticsEvent": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/KnowledgeInteractionEvent"
          },
          {
            "$ref": "#/components/schemas/KnowledgeFeedbackEvent"
          },
          {
            "$ref": "#/components/schemas/KnowledgeOutcomeEvent"
          },
          {
            "$ref": "#/components/schemas/KnowledgeHandoffEvent"
          },
          {
            "$ref": "#/components/schemas/KnowledgeConversationLinkEvent"
          }
        ]
      },
      "AnalyticsBatch": {
        "type": "object",
        "properties": {
          "events": {
            "type": "array",
            "minItems": 1,
            "maxItems": 20,
            "items": {
              "$ref": "#/components/schemas/AnalyticsEvent"
            }
          }
        },
        "required": [
          "events"
        ],
        "additionalProperties": false
      },
      "AnalyticsReceipt": {
        "type": "object",
        "properties": {
          "event_id": {
            "type": "string",
            "maxLength": 200
          },
          "id": {
            "type": "string"
          },
          "duplicate": {
            "type": "boolean"
          },
          "received_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "event_id",
          "id",
          "duplicate",
          "received_at"
        ],
        "additionalProperties": false
      },
      "AnalyticsAcknowledgement": {
        "type": "object",
        "properties": {
          "accepted": {
            "type": "integer"
          },
          "duplicates": {
            "type": "integer"
          },
          "receipts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AnalyticsReceipt"
            }
          }
        },
        "required": [
          "accepted",
          "duplicates",
          "receipts"
        ],
        "additionalProperties": false
      },
      "AnalyticsMetrics": {
        "type": "object",
        "properties": {
          "phases": {
            "type": "integer"
          },
          "knowledge_phases": {
            "type": "integer"
          },
          "interactions": {
            "type": "integer"
          },
          "answered": {
            "type": "integer"
          },
          "suggested": {
            "type": "integer"
          },
          "misses": {
            "type": "integer"
          },
          "disabled": {
            "type": "integer"
          },
          "errors": {
            "type": "integer"
          },
          "matched_interactions": {
            "type": "integer"
          },
          "match_rate": {
            "type": [
              "number",
              "null"
            ]
          },
          "feedback_samples": {
            "type": "integer"
          },
          "helpful": {
            "type": "integer"
          },
          "unhelpful": {
            "type": "integer"
          },
          "helpful_percent": {
            "type": [
              "number",
              "null"
            ]
          },
          "feedback_coverage_percent": {
            "type": [
              "number",
              "null"
            ]
          },
          "known_outcomes": {
            "type": "integer"
          },
          "self_resolved": {
            "type": "integer"
          },
          "self_unresolved": {
            "type": "integer"
          },
          "unknown_outcomes": {
            "type": "integer"
          },
          "self_resolution_percent": {
            "type": [
              "number",
              "null"
            ]
          },
          "known_resolution_percent": {
            "type": [
              "number",
              "null"
            ]
          },
          "self_score_samples": {
            "type": "integer"
          },
          "self_average_score": {
            "type": [
              "number",
              "null"
            ]
          },
          "self_satisfaction_percent": {
            "type": [
              "number",
              "null"
            ]
          },
          "handoff_phases": {
            "type": "integer"
          },
          "knowledge_handoff_phases": {
            "type": "integer"
          },
          "direct_handoff_phases": {
            "type": "integer"
          },
          "handoff_rate": {
            "type": [
              "number",
              "null"
            ]
          },
          "kff_linked_handoffs": {
            "type": "integer"
          },
          "human_replied": {
            "type": "integer"
          },
          "human_closed": {
            "type": "integer"
          },
          "human_closed_without_reply": {
            "type": "integer"
          },
          "human_rating_samples": {
            "type": "integer"
          },
          "human_average_rating": {
            "type": [
              "number",
              "null"
            ]
          },
          "human_satisfaction_percent": {
            "type": [
              "number",
              "null"
            ]
          },
          "handoff_to_first_agent_seconds": {
            "type": [
              "number",
              "null"
            ]
          },
          "handoff_to_first_agent_samples": {
            "type": "integer"
          }
        },
        "additionalProperties": true
      },
      "AnalyticsFilters": {
        "type": "object",
        "properties": {
          "from": {
            "type": "string",
            "format": "date"
          },
          "to": {
            "type": "string",
            "format": "date"
          },
          "timezone": {
            "type": "string"
          },
          "offset_minutes": {
            "type": "integer"
          },
          "site_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "include_test": {
            "type": "boolean"
          },
          "cohort": {
            "const": "phase_started_at"
          },
          "unresolved_only": {
            "type": "boolean"
          }
        },
        "additionalProperties": true
      },
      "AnalyticsReport": {
        "type": "object",
        "properties": {
          "filters": {
            "$ref": "#/components/schemas/AnalyticsFilters"
          },
          "as_of": {
            "type": "string",
            "format": "date-time"
          },
          "totals": {
            "$ref": "#/components/schemas/AnalyticsMetrics"
          },
          "by_site": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/AnalyticsMetrics"
                },
                {
                  "type": "object",
                  "properties": {
                    "site_id": {
                      "type": "string"
                    },
                    "site_name": {
                      "type": "string"
                    },
                    "group_name": {
                      "type": "string"
                    }
                  }
                }
              ]
            }
          },
          "daily": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/AnalyticsMetrics"
                },
                {
                  "type": "object",
                  "properties": {
                    "date": {
                      "type": "string",
                      "format": "date"
                    }
                  }
                }
              ]
            }
          },
          "handoff_reasons": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "reason": {
                  "type": "string"
                },
                "phases": {
                  "type": "integer"
                },
                "requests": {
                  "type": "integer"
                }
              },
              "required": [],
              "additionalProperties": false
            }
          },
          "definitions": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        },
        "additionalProperties": true
      },
      "AnalyticsTopicMetric": {
        "type": "object",
        "properties": {
          "site_id": {
            "type": "string"
          },
          "site_name": {
            "type": "string"
          },
          "topic_key": {
            "type": "string"
          },
          "display": {
            "type": "string"
          },
          "normalizer_version": {
            "type": "string"
          },
          "last_seen_at": {
            "type": "string"
          },
          "interactions": {
            "type": "integer"
          },
          "phases": {
            "type": "integer"
          },
          "answered": {
            "type": "integer"
          },
          "suggested": {
            "type": "integer"
          },
          "misses": {
            "type": "integer"
          },
          "negative_feedback": {
            "type": "integer"
          },
          "handoff_phases": {
            "type": "integer"
          },
          "unresolved_interactions": {
            "type": "integer"
          }
        },
        "additionalProperties": true
      },
      "ReceptionQueue": {
        "type": "object",
        "description": "当前队列状态。按 poll_interval_seconds 重新读取会话。队列变化不保证有独立事件。排位和估时缺少可信观测时均返回 null。",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "waiting",
              "assigned",
              "not_queued"
            ]
          },
          "reason": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "manual",
              "no_agents",
              "no_online",
              "capacity",
              "dispatch_pending",
              null
            ]
          },
          "ahead_count": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "前方等待数。无法确定精确排位时为 null。"
          },
          "estimated_wait_seconds": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "预计等待秒数。样本不足时为 null，且非服务承诺。"
          },
          "estimated": {
            "type": "boolean",
            "const": true
          },
          "scope": {
            "type": "string",
            "const": "shared_agent_pool"
          },
          "observed_at": {
            "type": "string",
            "format": "date-time"
          },
          "poll_interval_seconds": {
            "type": "integer",
            "const": 5
          }
        },
        "required": [
          "state",
          "reason",
          "ahead_count",
          "estimated_wait_seconds",
          "estimated",
          "scope",
          "observed_at",
          "poll_interval_seconds"
        ],
        "additionalProperties": true
      },
      "CustomerInactivity": {
        "type": "object",
        "description": "全平台共享的客户未回复计时。只有新版启用后人工客服公开回复才开始等待；排队、等待首次客服回复、系统消息和内部备注不启动计时。客户回复和重开清除等待。旧会话不回填历史等待时间。",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "awaiting_customer",
              "inactive"
            ]
          },
          "waiting_since": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "deadline_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "timeout_seconds": {
            "type": "integer",
            "minimum": 60,
            "description": "后台全平台统一设置，默认1800秒。"
          },
          "observed_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "state",
          "waiting_since",
          "deadline_at",
          "timeout_seconds",
          "observed_at"
        ],
        "additionalProperties": true
      },
      "ReceptionMode": {
        "type": "string",
        "enum": [
          "live",
          "async"
        ]
      },
      "ReceptionAvailability": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "accepting",
              "waiting_for_staff",
              "outside_hours",
              "queue_full"
            ]
          },
          "live_available": {
            "type": "boolean"
          },
          "async_available": {
            "type": "boolean"
          },
          "next_open_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "message_response_minutes": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1
          }
        },
        "required": [
          "state",
          "live_available",
          "async_available",
          "next_open_at",
          "message_response_minutes"
        ]
      },
      "ConversationReception": {
        "type": "object",
        "properties": {
          "mode": {
            "$ref": "#/components/schemas/ReceptionMode"
          },
          "state": {
            "type": "string",
            "enum": [
              "waiting",
              "message_pending",
              "awaiting_first_reply",
              "coordinating",
              "replied",
              "resolved"
            ]
          },
          "reply_state": {
            "type": "string",
            "enum": [
              "awaiting_first_reply",
              "replied"
            ]
          },
          "offer_message": {
            "type": "boolean"
          },
          "next_open_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "message_response_minutes": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1
          }
        },
        "required": [
          "mode",
          "state",
          "reply_state",
          "offer_message",
          "next_open_at",
          "message_response_minutes"
        ]
      },
      "ChangeReceptionMode": {
        "type": "object",
        "properties": {
          "client_operation_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "version": {
            "type": "integer",
            "minimum": 1
          },
          "reception_mode": {
            "$ref": "#/components/schemas/ReceptionMode"
          }
        },
        "required": [
          "client_operation_id",
          "version",
          "reception_mode"
        ],
        "additionalProperties": false
      },
      "ReceptionModeReceipt": {
        "type": "object",
        "properties": {
          "conversation_id": {
            "type": "string"
          },
          "reception_mode": {
            "$ref": "#/components/schemas/ReceptionMode"
          },
          "version": {
            "type": "integer",
            "minimum": 1
          },
          "client_operation_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          }
        },
        "required": [
          "conversation_id",
          "reception_mode",
          "version",
          "client_operation_id"
        ]
      }
    }
  }
}
