玲声开放平台 · 文档

回调

通话结束时把结果推到你的服务器。登记、推送格式、验签。

事件:call.ended、call.summarized。每通最多推 3 次(立刻、2 秒后、8 秒后),你回 2xx 就算送到;跳转(3xx)算失败。

登记回调

POSThttps://aicall.lingshengai.com/api/v1/webhooks

仅开发者身份可用;数据按组织和项目隔离。

请求体(JSON)

字段类型必填说明
projectIdstring否项目编号;省略使用默认项目,项目令牌不能跨项目。
urlstring是HTTPS 公网回调地址;内网与回环地址拒绝。
eventsstring[]否订阅 call.ended / call.summarized。

返回

字段类型说明
idstring回调编号。
projectIdstring | null项目编号;省略使用默认项目,项目令牌不能跨项目。
urlstringHTTPS 公网回调地址;内网与回环地址拒绝。
eventsstring[]订阅 call.ended / call.summarized。
activeboolean是否启用。
createdAtstring创建时间(UTC)。
updatedAtstring更新时间(UTC)。
secretstring验签密钥,仅创建时返回,请妥善保存。
登记一个回调地址
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:

字段类型说明
callIdstring这通电话的编号。
statusstringscheduled / queued / in_progress / ended / failed / rejected。
scheduled_atstring | null含时区的 ISO 时间,未来 30 天内;不在可拨时段直接拒绝。空表示立即拨打。
projectIdstring项目编号;省略使用默认项目,项目令牌不能跨项目。
customerRefstring你自己的客户标识,只在本组织内使用。
terminalboolean通话是否已进入终态;结果抽取可能仍在处理中。
codestring预约或拨号失败原因码。
phonestring目标手机号。
answeredAtstring | null接通时间(UTC),未接通为 null。
endedAtstring | null结束时间(UTC),未结束为 null。
billableMinutesinteger | null计费分钟;账未生成时为 null。
costFeninteger | null费用,单位分;账未生成时为 null。
summarystring预留摘要,当前为空;使用结构化 answers 和 transcript。
transcriptobject[]逐句转写,speaker / text / startMs / endMs。
recordingUrlstring | null短时签名录音地址,录音未到时为 null。
extraction_statusstringready / pending / not_applicable / unavailable;没接通不抽取,失败会有界重试。
outcomestring | null从允许的标签中选择;尚未抽取或没有适用标签时为 null。
answersobject[]逐项 {key, answered, value, quote};quote 为对方原话,没答到时 value=null、quote=""。未接通为空数组。
call_outcomestring线路返回的原始结局。
eventstringcall.ended:通话结束;call.summarized:结构化结果就绪。
pendingboolean结果仍在抽取;完成后会推 call.summarized(需订阅)。
detailUrlstring用开发者令牌查询这通结果的地址。

验签

  1. 取请求头 X-Lingsheng-Timestamp 的值和原始请求体(别先解析再序列化)。
  2. 用登记时拿到的 secret,对「时间戳 + . + 请求体」算 HMAC-SHA256,得到十六进制串。
  3. 和请求头 X-Lingsheng-Signature 去掉 sha256= 之后的部分比较,一致才处理。

管理回调

GEThttps://aicall.lingshengai.com/api/v1/webhooks

仅开发者身份可用;数据按组织和项目隔离。

返回

字段类型说明
itemsobject[]本组织或项目的条目。

GEThttps://aicall.lingshengai.com/api/v1/webhooks/{hook_id}

仅开发者身份可用;数据按组织和项目隔离。

参数

字段类型必填说明
hook_id路径string是回调编号。

返回

字段类型说明
idstring回调编号。
projectIdstring | null项目编号;省略使用默认项目,项目令牌不能跨项目。
urlstringHTTPS 公网回调地址;内网与回环地址拒绝。
eventsstring[]订阅 call.ended / call.summarized。
activeboolean是否启用。
createdAtstring创建时间(UTC)。
updatedAtstring更新时间(UTC)。

PATCHhttps://aicall.lingshengai.com/api/v1/webhooks/{hook_id}

仅开发者身份可用;数据按组织和项目隔离。

参数

字段类型必填说明
hook_id路径string是回调编号。

请求体(JSON)

字段类型必填说明
urlstring | null否HTTPS 公网回调地址;内网与回环地址拒绝。
eventsstring[] | null否订阅 call.ended / call.summarized。
activeboolean | null否是否启用。

返回

字段类型说明
idstring回调编号。
projectIdstring | null项目编号;省略使用默认项目,项目令牌不能跨项目。
urlstringHTTPS 公网回调地址;内网与回环地址拒绝。
eventsstring[]订阅 call.ended / call.summarized。
activeboolean是否启用。
createdAtstring创建时间(UTC)。
updatedAtstring更新时间(UTC)。

DELETEhttps://aicall.lingshengai.com/api/v1/webhooks/{hook_id}

仅开发者身份可用;数据按组织和项目隔离。

参数

字段类型必填说明
hook_id路径string是回调编号。