发起通话
主叫方调用本接口发起通话,服务端创建通话会话并返回 RTC 接入参数,主叫方凭此参数加入 RTC 频道。
| 项目 | 内容 |
|---|---|
| Method | POST |
| URL | /api/calls/session |
| 鉴权 | 是,Bearer Token |
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| conversation_id | int | 是 | 会话 ID |
| target_user_id | int | 是 | 被叫用户 ID |
| call_type | string | 是 | 通话类型,取值 audio(纯音频)或 video(音视频) |
| biz_type | string | 是 | 业务类型,取值 single(单人通话) |
| terminal_id | string | 是 | 主叫终端标识,最长 64 字符 |
curl -X POST "/api/calls/session" \ -H "Authorization: Bearer your_token_here" \ -H "Content-Type: application/json" \ -d '{ "conversation_id": 1001, "target_user_id": 2002, "call_type": "video", "biz_type": "single", "terminal_id": "client-android-abc123" }'| 字段 | 类型 | 说明 |
|---|---|---|
| code | int | 状态码,0 表示成功 |
| message | string | 提示信息 |
| data.call_id | int | 通话 ID |
| data.conversation_id | int | 会话 ID |
| data.call_type | string | 通话类型 |
| data.biz_type | string | 业务类型 |
| data.status | string | 当前状态,固定为 calling |
| data.timeout_seconds | int | 振铃超时秒数,默认 30 |
| data.version | int | 数据版本号 |
| data.channel_name | string | RTC 频道名 |
| data.app_id | string | RTC 应用 ID |
| data.caller_uid | string | 主叫 RTC 用户标识 |
| data.rtc_token | string | RTC 接入令牌 |
| data.expire_at | string|null | 令牌过期时间(ISO 8601),可为空 |
{ "code": 0, "message": "success", "data": { "call_id": 5001, "conversation_id": 1001, "call_type": "video", "biz_type": "single", "status": "calling", "timeout_seconds": 30, "version": 1, "channel_name": "call_5001_1001", "app_id": "xxxxxxxxxxxxxxxx", "caller_uid": "10001", "rtc_token": "xxxxxxxxxxxxxxxxxxxxxx", "expire_at": "2026-07-05T12:30:00Z" }}{ "code": 41003, "message": "对方忙线", "data": null}{ "code": 41010, "message": "权限或关系校验失败", "data": null}