业务平台 · Agent 列表 API

供运营管理后台等业务系统查询聊天机器人已配置的 hqharness Agent 列表。 响应中不包含 api_key,仅返回 id、名称、连接参数等元数据。 鉴权方式与 用户同步聊天记录 API 一致, 使用 X-Chatbot-Webhook-Secret 请求头。

接口基址:/api/public/chatbot/agents

鉴权

请求头必填说明
X-Chatbot-Webhook-Secret 与聊天机器人「用户同步」配置的 Webhook 密钥一致(环境变量 PLATFORM_SYNC_WEBHOOK_SECRET 或管理页保存的值)

查询 Agent 列表

GET /api/public/chatbot/agents

Query 参数

参数类型说明
enabled 可选 boolean 按启用状态过滤:true 仅返回已启用 Agent;false 仅返回已禁用;不传则返回全部。

响应字段

字段类型说明
agentsarrayAgent 列表,按 id 升序
agents[].idlongAgent ID,跟进人 Agent 配置与默认兜底绑定均引用此 id
agents[].namestring显示名称
agents[].hoststringhqharness 主机
agents[].prefixstring通道 prefix
agents[].appIdstring应用 ID
agents[].restSchemestringREST 协议,如 https
agents[].wsSchemestringWebSocket 协议,如 wss
agents[].defaultGroupstring | null默认 group
agents[].defaultModelstring | null默认 model
agents[].enabledboolean是否启用
agents[].hasApiKeyboolean是否已配置 api_key(不返回密钥本身)

响应示例

{
  "agents": [
    {
      "id": 1,
      "name": "客服 Agent",
      "host": "hqh.baidehealth.com",
      "prefix": "chatbot",
      "appId": "chatbot",
      "restScheme": "https",
      "wsScheme": "wss",
      "defaultGroup": null,
      "defaultModel": null,
      "enabled": true,
      "hasApiKey": true
    }
  ]
}

请求示例

curl -sS -G 'https://<chatbot-host>/api/public/chatbot/agents' \
  -H 'X-Chatbot-Webhook-Secret: <your-secret>'

仅查询已启用 Agent

curl -sS -G 'https://<chatbot-host>/api/public/chatbot/agents' \
  -H 'X-Chatbot-Webhook-Secret: <your-secret>' \
  --data-urlencode 'enabled=true'

错误码

HTTP说明
401缺少或错误的 X-Chatbot-Webhook-Secret
503Webhook 未配置

前置条件

相关页面:跟进人 Agent(按企微跟进人指定 Agent); 内部管理接口为 /api/bindings(需登录,含增删改)。