REST 接口
单通即时或预约拨号、带类型的结果、用量和号码验证。
接口地址 https://aicall.lingshengai.com。请求头为 Authorization: Bearer <开发者访问令牌>,请求体用 JSON。身份来自开发者 OAuth,字段用 projectId / customerRef;不接受商家的 tenant 字段。
出错时
参数或政策拒绝回 422,额度不足回 402,幂等键冲突回 409,未授权回 401,权限不足回 403,跨组织或项目的记录回 404。政策错误的 detail 包含 code 和 message;参数错误包含字段位置。5xx 表示服务暂时不可用,不表示任务已受理;重试沿用幂等键。
拨一通
POSThttps://aicall.lingshengai.com/api/v1/calls
真实拨打并计费。即时或预约单通,受理回 202;政策拒绝回 422,额度不足回 402。
请求体(JSON)
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
to | string | 是 | 国内手机号,缺省只能拨已验证号码。 |
projectId | string | 否 | 项目编号;省略使用默认项目,项目令牌不能跨项目。 |
customerRef | string | 否 | 你自己的客户标识,只在本组织内使用。 |
instructions | string | 是 | 这一通要办的事(最多 2000 字),服务端审核后使用。 |
greeting | string | 否 | 接通后的任务开场白,始终接在服务端固定的 AI 身份声明后。 |
callerName | string | 否 | 委托人的称呼。 |
voice | string | 否 | 音色名称;不填使用缺省音色。 |
questions | object[] | 否 | 带类型的问题数组,格式见下方示例。 |
outcomes | string[] | 否 | 允许的结果标签列表;AI 只能选其中一个。省略用内置标签。 |
max_duration_s | integer | 否 | 总时长上限,缺省 180 秒,30–600 秒。 |
silence_hangup_s | integer | 否 | 对方静默挂断秒数,缺省 30,5–120 秒,与总时长独立。 |
voicemail | string | 否 | 识别到语音信箱后 hangup(缺省)或 leave_message。 |
scheduled_at | string | null | 否 | 含时区的 ISO 时间,未来 30 天内;不在可拨时段直接拒绝。空表示立即拨打。 |
idempotency_key | string | 是 | 同一次任务重试保持此键;同键不同内容回 409。 |
返回
| 字段 | 类型 | 说明 |
|---|---|---|
callId | string | 这通电话的编号。 |
status | string | scheduled / queued / in_progress / ended / failed / rejected。 |
scheduled_at | string | null | 含时区的 ISO 时间,未来 30 天内;不在可拨时段直接拒绝。空表示立即拨打。 |
curl -X POST https://aicall.lingshengai.com/api/v1/calls \
-H "Authorization: Bearer lsd_你的令牌" \
-H "Content-Type: application/json" \
-d '{
"to": "13800000000",
"idempotency_key": "first-call-001",
"instructions": "提醒对方今晚八点吃药,确认一声就挂",
"greeting": "您好,是张先生吗?"
}'回来的 callId 拿去查这一通:GET /api/v1/calls/{callId}。
问题与结果
{
"to": "13800000000",
"instructions": "确认明天营业时间,以及是否需要预约",
"idempotency_key": "opening-hours-001",
"questions": [
{"key": "open", "question": "明天是否营业?", "type": "boolean", "choices": [], "example": true, "required": true},
{"key": "booking", "question": "需要预约吗?", "type": "choice", "choices": ["需要", "不需要"], "example": "需要", "required": true}
],
"outcomes": ["已确认", "需本人跟进"],
"max_duration_s": 180,
"silence_hangup_s": 30,
"voicemail": "hangup"
}type 支持 text / choice / boolean / number。choice 必须给 choices;example 的类型要吻合。get_call 逐项返回 {key, answered, value, quote},没答到时 value 为 null、quote 为空。quote 只能引用对方原话。没接通不做抽取,answers 为空数组。
不传 outcomes 时使用:问到了 / 没问到 / 待确认 / 对方要求回电 / 无人接 / 语音信箱。传自定标签后,AI 只能选其中一项;尚未抽取或未接通且没有适用标签时 outcome 为 null。
总时长与静默时长各自封顶;对方要求不再来电会结束通话并进入号码黑名单。识别到语音信箱时,hangup 直接挂断,leave_message 简短留言后挂断。识别依赖对方提示语的转写,不能保证识别所有语音信箱。
预约一通
可加 scheduled_at,例如 2026-12-01T10:00:00+08:00(请换成未来 30 天内的时间)。只有到点才进入外呼队列,时段仍为北京时间 09:00–21:00(不含 21:00);窗口外直接拒绝,不自动顺延。到点再次检查号码验证、组织状态、额度、黑名单与时段,失败会在通话结果中说明。
没受理的原因
| code | HTTP | 意思 |
|---|---|---|
outside_call_window | 422 | 开发者外呼仅限北京时间 09:00–21:00(不含 21:00) |
not_verified | 422 | 请先验证这个号码;其他号码须经审批 |
account_disabled | 422 | 开发者账号已停用 |
blocked | 422 | 对方已要求不再拨打 |
duplicate_24h | 422 | 同一个号码 24 小时内已有通话或预约 |
quota_exhausted | 402 | 组织剩余分钟不足(含已预约的分钟) |
global_daily | 422 | 当日外呼上限已满 |
line_unknown | 422 | 线路状态暂时查不到,请稍后重试 |
line_not_open | 422 | 外呼线路未开通 |
查一通
GEThttps://aicall.lingshengai.com/api/v1/calls/{call_id}
仅开发者身份可用;数据按组织和项目隔离。
参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
call_id路径 | string | 是 | 创建时返回的 callId。 |
返回
| 字段 | 类型 | 说明 |
|---|---|---|
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 | 线路返回的原始结局。 |
列出通话
GEThttps://aicall.lingshengai.com/api/v1/calls
仅开发者身份可用;数据按组织和项目隔离。
参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
projectId查询参数 | string | 否 | 项目编号;省略使用默认项目,项目令牌不能跨项目。 |
customerRef查询参数 | string | 否 | 你自己的客户标识,只在本组织内使用。 |
before查询参数 | string | 否 | 上一页返回的 next。 |
limit查询参数 | integer | 否 | 每页条数,缺省 20,最多 100。 |
返回
| 字段 | 类型 | 说明 |
|---|---|---|
items | object[] | 本组织或项目的条目。 |
next | string | null | 下一页游标,用作 before;没有下一页时为 null。 |
看用量
GEThttps://aicall.lingshengai.com/api/v1/usage
仅开发者身份可用;数据按组织和项目隔离。
参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
projectId查询参数 | string | 否 | 项目编号;省略使用默认项目,项目令牌不能跨项目。 |
返回
| 字段 | 类型 | 说明 |
|---|---|---|
projectId | string | null | 项目编号;省略使用默认项目,项目令牌不能跨项目。 |
minutes | integer | 已使用的计费分钟。 |
grantedMinutes | integer | 组织累计获赠或购买的分钟。 |
remaining | integer | 组织累计剩余分钟,不按月重置;预约会预留额度。 |
unitPriceFen | integer | 每分钟单价,单位分。 |
quotaScope | string | organization_lifetime,表示组织累计额度。 |
curl https://aicall.lingshengai.com/api/v1/usage \ -H "Authorization: Bearer lsd_你的令牌"
验证号码
GEThttps://aicall.lingshengai.com/api/developer/verified-numbers
仅开发者身份可用;数据按组织和项目隔离。
返回
| 字段 | 类型 | 说明 |
|---|---|---|
items | object[] | 本组织或项目的条目。 |
POSThttps://aicall.lingshengai.com/api/developer/verified-numbers/code
仅开发者身份可用;数据按组织和项目隔离。
请求体(JSON)
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
phone | string | 是 | 目标手机号。 |
返回
| 字段 | 类型 | 说明 |
|---|---|---|
sent | boolean | 短信是否发送成功。 |
POSThttps://aicall.lingshengai.com/api/developer/verified-numbers/confirm
仅开发者身份可用;数据按组织和项目隔离。
请求体(JSON)
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
phone | string | 是 | 目标手机号。 |
code | string | 是 | 短信验证码。 |
返回
| 字段 | 类型 | 说明 |
|---|---|---|
verified | boolean | 号码是否验证成功。 |
phone | string | 目标手机号。 |
DELETEhttps://aicall.lingshengai.com/api/developer/verified-numbers/{phone}
仅开发者身份可用;数据按组织和项目隔离。
参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
phone路径 | string | 是 | 目标手机号。 |
返回
| 字段 | 类型 | 说明 |
|---|---|---|
removed | boolean | 是否已移除验证。 |