接口描述
创建一个 Agent 会话,返回会话 ID 与可用的聊天接入点。
POST /v2/enterprises/{enterpriseId}/managedagent/agents/{agentId}/sessions输入参数
路径参数
参数 | 类型 | 说明 |
enterpriseId | string | WorkBuddy 企业 ID |
agentId | string | 等价于请求体字段 AgentId |
查询参数
无
请求体
字段 | 类型 | 说明 |
AgentId | string | AgentId Agent 业务 ID(必填)。 |
VersionId | string | VersionId 指定版本 ID(可选)。非空且合法时固定使用该版本,跳过路由权重挑选; 未传或为空时保留默认路由逻辑。指定版本需归属同一 Agent 且状态为 ENABLED。 |
输出参数
(
201,业务出参包装在 code / data / msg / requestId 中)CreateAgentSessionResponse 对应 /CreateAgentSession 响应体。
字段 | 类型 | 说明 |
sessionId | string | SessionId 新建会话的 ID,后续对话与查询均以它定位。 |
endpointSet | EndpointSet 可用的聊天接入点列表(至少含一个公网接入点)。 空路由输出空数组而非省略字段;私网接入点与 VPC 属性为后续纯增量, 对象数组新增字段不影响既有调用方。 |
示例
输入示例
POST /v2/enterprises/{enterpriseId}/managedagent/agents/{agentId}/sessionsAuthorization: Bearer pt_<YOUR_APP_KEY>Content-Type: application/json{"AgentId": "736918300000000001","VersionId": "2087791755109965825"}
输出示例
{"code": 0,"data": {"endpointSet": [{"endpointType": "PUBLIC","url": "https://example.com/download/pkg-001.zip"}],"sessionId": "736918300000000002"},"msg": "OK","requestId": "3c6d138e-1234-5678-9abc-def012345678"}
错误码
说明:
错误码 | 说明 |
FailedOperation.WMASessionPrecheckBlocked | 因欠费服务已停用,请结清账单后重试 |
InternalError.RuntimeCreateFailed | 调用 agentos 创建运行时失败 |
InternalError.SessionOperationFailed | 会话操作失败 |
InternalError.WMASessionPrecheckFailed | 创建会话前的计费状态校验失败 |
InvalidParameter.AgentIDRequired | 缺少 AgentId |
InvalidParameter.InvalidRequestBody | 请求体不合法 |
MissingParameter.UinRequired | 公共参数中缺少 Uin |
ResourceNotFound.Agent | Agent 不存在 |
ResourceNotFound.Version | 版本不存在 |
ResourceUnavailable.RuntimeAPIUnavailable | 未配置 agentos 运行时 API |
UnauthorizedOperation.UnprovisionedTenant | 租户未开通,或企业不存在 |