回调
通话结束时把结果推到你的服务器。登记、推送格式、验签。
事件:call.ended、call.summarized。每通最多推 3 次(立刻、2 秒后、8 秒后),你回 2xx 就算送到;跳转(3xx)算失败。
登记回调
POSThttps://aicall.lingshengai.com/api/v1/webhooks
仅开发者身份可用;数据按组织和项目隔离。
请求体(JSON)
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
projectId | string | 否 | 项目编号;省略使用默认项目,项目令牌不能跨项目。 |
url | string | 是 | HTTPS 公网回调地址;内网与回环地址拒绝。 |
events | string[] | 否 | 订阅 call.ended / call.summarized。 |
返回
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 回调编号。 |
projectId | string | null | 项目编号;省略使用默认项目,项目令牌不能跨项目。 |
url | string | HTTPS 公网回调地址;内网与回环地址拒绝。 |
events | string[] | 订阅 call.ended / call.summarized。 |
active | boolean | 是否启用。 |
createdAt | string | 创建时间(UTC)。 |
updatedAt | string | 更新时间(UTC)。 |
secret | string | 验签密钥,仅创建时返回,请妥善保存。 |
curl -X POST https://aicall.lingshengai.com/api/v1/webhooks \
-H "Authorization: Bearer lsd_你的令牌" \
-H "Content-Type: application/json" \
-d '{
"url": "https://你的域名/hooks/lingsheng",
"events": ["call.ended"]
}'回来的 secret 用来验签:X-Lingsheng-Signature 是 sha256=<hex>,hex 是用 secret 对「X-Lingsheng-Timestamp 的值 + . + 原始 body」算的 HMAC-SHA256。摘要有时比挂机晚一点 —— 那一条会先带 pending,就绪后再推一条。
推送的内容
请求头 X-Lingsheng-Event 是事件名。请求体是 JSON:
| 字段 | 类型 | 说明 |
|---|---|---|
callId | string | 这通电话的编号。 |
status | string | scheduled / queued / in_progress / ended / failed / rejected。 |
scheduled_at | string | null | 含时区的 ISO 时间,未来 30 天内;不在可拨时段直接拒绝。空表示立即拨打。 |
projectId | string | 项目编号;省略使用默认项目,项目令牌不能跨项目。 |
customerRef | string | 你自己的客户标识,只在本组织内使用。 |
terminal | boolean | 通话是否已进入终态;结果抽取可能仍在处理中。 |
code | string | 预约或拨号失败原因码。 |
phone | string | 目标手机号。 |
answeredAt | string | null | 接通时间(UTC),未接通为 null。 |
endedAt | string | null | 结束时间(UTC),未结束为 null。 |
billableMinutes | integer | null | 计费分钟;账未生成时为 null。 |
costFen | integer | null | 费用,单位分;账未生成时为 null。 |
summary | string | 预留摘要,当前为空;使用结构化 answers 和 transcript。 |
transcript | object[] | 逐句转写,speaker / text / startMs / endMs。 |
recordingUrl | string | null | 短时签名录音地址,录音未到时为 null。 |
extraction_status | string | ready / pending / not_applicable / unavailable;没接通不抽取,失败会有界重试。 |
outcome | string | null | 从允许的标签中选择;尚未抽取或没有适用标签时为 null。 |
answers | object[] | 逐项 {key, answered, value, quote};quote 为对方原话,没答到时 value=null、quote=""。未接通为空数组。 |
call_outcome | string | 线路返回的原始结局。 |
event | string | call.ended:通话结束;call.summarized:结构化结果就绪。 |
pending | boolean | 结果仍在抽取;完成后会推 call.summarized(需订阅)。 |
detailUrl | string | 用开发者令牌查询这通结果的地址。 |
验签
- 取请求头
X-Lingsheng-Timestamp的值和原始请求体(别先解析再序列化)。 - 用登记时拿到的
secret,对「时间戳 +.+ 请求体」算 HMAC-SHA256,得到十六进制串。 - 和请求头
X-Lingsheng-Signature去掉sha256=之后的部分比较,一致才处理。
管理回调
GEThttps://aicall.lingshengai.com/api/v1/webhooks
仅开发者身份可用;数据按组织和项目隔离。
返回
| 字段 | 类型 | 说明 |
|---|---|---|
items | object[] | 本组织或项目的条目。 |
GEThttps://aicall.lingshengai.com/api/v1/webhooks/{hook_id}
仅开发者身份可用;数据按组织和项目隔离。
参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
hook_id路径 | string | 是 | 回调编号。 |
返回
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 回调编号。 |
projectId | string | null | 项目编号;省略使用默认项目,项目令牌不能跨项目。 |
url | string | HTTPS 公网回调地址;内网与回环地址拒绝。 |
events | string[] | 订阅 call.ended / call.summarized。 |
active | boolean | 是否启用。 |
createdAt | string | 创建时间(UTC)。 |
updatedAt | string | 更新时间(UTC)。 |
PATCHhttps://aicall.lingshengai.com/api/v1/webhooks/{hook_id}
仅开发者身份可用;数据按组织和项目隔离。
参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
hook_id路径 | string | 是 | 回调编号。 |
请求体(JSON)
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
url | string | null | 否 | HTTPS 公网回调地址;内网与回环地址拒绝。 |
events | string[] | null | 否 | 订阅 call.ended / call.summarized。 |
active | boolean | null | 否 | 是否启用。 |
返回
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 回调编号。 |
projectId | string | null | 项目编号;省略使用默认项目,项目令牌不能跨项目。 |
url | string | HTTPS 公网回调地址;内网与回环地址拒绝。 |
events | string[] | 订阅 call.ended / call.summarized。 |
active | boolean | 是否启用。 |
createdAt | string | 创建时间(UTC)。 |
updatedAt | string | 更新时间(UTC)。 |
DELETEhttps://aicall.lingshengai.com/api/v1/webhooks/{hook_id}
仅开发者身份可用;数据按组织和项目隔离。
参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
hook_id路径 | string | 是 | 回调编号。 |