REST API文档
呼叫管理
路由管理
路由信息说明如下:
参数 | 说明 |
---|---|
name | 路由名称,必填 |
description | 路由描述 |
prefix | 匹配起始号码 |
max_length | 最大匹配长度,必填 |
context | 呼叫源,必填 |
dnc | 被叫号码变换 |
sdnc | 主叫号码变换 |
dest_type | 目的地类型 (FS_DEST_GATEWAY,IVRBLOCK,FS_DEST_CONFERENCE)等,必填 |
dest_uuid | 保存 IVR 等具体任务的 ID |
auto_record | 自动录音,默认 0 不录音,1-录音 |
bill_rate | 费率 |
blacklist | 是否启用黑名单 |
body | 文本 |
params | 参数列表 |
proxy_media | 是否媒体透传,默认 1-不透传 0-透传 |
route_type | 呼叫权限 0: 紧急呼叫 1:本局呼叫,2:本地呼叫,3:国内呼叫,4:国际呼叫 |
media_codec | 编码类型 |
disabled | 是否禁用,默认 0-开启 1-禁用 |
目的类型英文 | 中文说明 |
---|---|
FS_DEST_USER | 本地用户 |
FS_DEST_GATEWAY | 网关 |
FS_DEST_USERGW | 分机网关 |
FS_DEST_SYSTEM | 系统 |
FS_DEST_IP | IP 地址 |
FS_DEST_IVRBLOCK | 积木 |
FS_DEST_CONFERENCE | 同号码会议室 |
FS_DEST_CONFERENCE_ROOM | 指定会议室 |
FS_DEST_MEETING | 预约会议 |
FS_DEST_MEETING_ROOM | 指定预约会议 |
FS_DEST_USER_CONFERENCE | 临时会议 |
FS_DEST_DISTRIBUTORS | 分配器 |
FS_DEST_CTI | 呼叫中心 |
FS_DEST_NUM_QUEUE | 加入与被叫号码相同的队列 |
FS_DEST_SCRIPT | 脚本 |
FS_DEST_IVR | IVR |
FS_DEST_CLUSTER_TRUNK | 集群中继 |
FS_DEST_CLUSTER_TRUNK_GROUP | 集群中继组 |
FS_DEST_SEQ_EXTNS | 顺振分机组 |
FS_DEST_RING_EXTNS | 同振分机组 |
查询路由目的类型所有值
请求 URL:
/api/dicts?realm=DEST
返回所有目的类型值(参考数据字典)请求方式:
GET
返回值: 路由 JSON 对象,如果找不到会返回 HTTP 状态码
404
。curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" "192.168.1.100:8081/api/dicts?realm=DEST"
返回 :
[ { "updated_at": "2022-05-11 10:57:39", "k": "FS_DEST_USER", "o": 1, "id": 88, "d": "", "v": "USER", "deleted_at": "", "created_at": "2022-05-11 10:57:39", "realm": "DEST" }, { "updated_at": "2022-05-11 10:57:39", "k": "FS_DEST_RING_EXTNS", "o": 2, "id": 89, "d": "", "v": "RING_ALL_EXTN", "deleted_at": "", "created_at": "2022-05-11 10:57:39", "realm": "DEST" } ]
创建路由
- 请求 URL:
/api/routes
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见路由信息说明。
参数 | 说明 |
---|---|
name | 路由名称,必填 |
max_length | 最大匹配长度,必填 |
context | 呼叫源,必填 |
dest_type | 目的地类型 (FS_DEST_GATEWAY,IVRBLOCK,FS_DEST_CONFERENCE)等,必填 |
dest_uuid | 目的地类型为 FS_DEST_GATEWAY、FS_DEST_USERGW、FS_DEST_IVRBLOCK 、FS_DEST_MEETING_ROOM、FS_DEST_CONFERENCE_ROOM、FS_DEST_CTI、FS_DEST_IVR、FS_DEST_DISTRIBUTORS、FS_DEST_CLUSTER_TRUNK、FS_DEST_CLUSTER_TRUNK_GROUP 时为必填 |
prefix | 被叫字冠 比如10 非必填 |
特别注意
路由名称不可重复,且名称不重复的情况下,被叫字冠和最大长度不可和已存在的数据重复,否则创建失败。
- 返回值:
状态 | 返回值 |
---|---|
成功 | 路由 JSON Object。 |
失败 | -ERR Cannot execute script |
- IVR:
Body :
{ "context": "context-1", "dest_type": "FS_DEST_IVR", "max_length": "11", "name": "IVR test", "prefix": "1", "dest_uuid": "1" }
返回 :
{ "code": 200, "message": "success", "data": { "outdest_type": "", "bill_rate": "0.00", "id": 17, "proxy_media": 1, "updated_at": "2023-03-17 07:29:02", "dest_type": "FS_DEST_IVR", "deleted_at": "", "blacklist": "", "created_at": "2023-03-17 07:29:02", "disabled": 0, "auto_record": 0, "media_codec": "", "body": "IVR示例1", "sdnc": "", "prefix": "1", "max_length": 11, "context": "context-1", "cid_number": "", "description": "", "dest_uuid": "1", "name": "IVR test", "dnc": "", "route_type": 4 } }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"name": "IVR test","prefix": "1","max_length": "11", "context": "context-1","dest_type": "FS_DEST_IVR","dest_uuid": "1"}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/routes"
- 临时会议:
Body :
{ "context": "context-1", "dest_type": "FS_DEST_USER_CONFERENCE", "dest_uuid": "1", "max_length": "12", "name": "cccc", "prefix": "5" }
返回 :
{ "message": "success", "data": { "cid_number": "", "prefix": "5", "outdest_type": "", "blacklist": "", "updated_at": "2022-05-11 13:48:06", "id": 31, "max_length": "12", "proxy_media": "1", "dest_uuid": "1", "disabled": "0", "media_codec": "", "body": "", "created_at": "2022-05-11 13:48:06", "sdnc": "", "deleted_at": "", "dnc": "", "name": "cccc", "description": "", "bill_rate": "0.00", "context": "context-1", "auto_record": "0", "dest_type": "FS_DEST_USER_CONFERENCE", "route_type": "4" }, "code": 200 }
- 网关路由:
Body :
{ "name": "qing", "prefix": "78900", "max_length": "12", "context": "context-1", "dest_type": "FS_DEST_GATEWAY", "dest_uuid": "2" }
- dest_type:网关
- dest_uuid:网关 id
返回:
{ "code": 200, "message": "success", "data": { "description": "", "dnc": "", "sdnc": "", "body": "example", "updated_at": "2022-05-11 13:54:25", "created_at": "2022-05-11 13:54:25", "auto_record": "0", "context": "default", "deleted_at": "", "blacklist": "", "bill_rate": "0.00", "disabled": "0", "name": "qing", "proxy_media": "1", "route_type": "4", "id": 33, "media_codec": "", "max_length": "12", "cid_number": "", "prefix": "78900", "dest_type": "FS_DEST_GATEWAY", "dest_uuid": "1" } }
删除路由
- 请求 URL:
/api/routes/$id
- 请求方式:
DELETE
- 消息头: 无
- 返回值:
状态 | 返回值 |
---|---|
成功 | 空 JSON {} |
失败 | 404 |
- 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE "http://192.168.1.100:8081/api/routes/33"
返回:
{ "message": "success", "code": 200, "data": "33" }
修改指定路由
- 请求 URL:
/api/routes/$id
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息: 参见路由信息说明。
- 返回值:
状态 | 返回值 |
---|---|
成功 | JSON {"message": "success","data": "33","code": 200} |
失败 | -ERR Cannot execute script |
- 示例:
Body:
{ "auto_record": "1", "context": "context-1", "description": "1", "dest_type": "FS_DEST_GATEWAY", "dest_uuid": "1", "max_length": 12, "name": "test", "prefix": "78900", "route_type": "4" }
返回:
{ "message": "success", "data": "33", "code": 200 }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"auto_record":"1","context":"context-1","description":"test dialplan","dest_type":"FS_DEST_CONFERENCE","dest_uuid":"2","max_length":"10","name": "test","prefix": "32432","route_type": "4"}' \ "http://192.168.1.100:8081/api/routes/33"
批量修改路由
- 请求 URL:
/api/routes
在body中通过route参数设置需要修改的路由id - 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息: 仅支持批量编辑如下参数。
参数 | 说明 |
---|---|
auto_record | 自动录音 |
media_codec | 媒体编码 |
route_type | 呼叫类型(紧急、本地、国内、国际等) |
proxy_media | 代理媒体 |
bill_rate | 费率 |
blacklist | 黑白名单ID |
did_enabled | 是否启动DID外显 |
- 返回值:
状态 | 返回值 |
---|---|
成功 | JSON |
失败 | -ERR Cannot execute script |
- 示例:
Body:
{ "auto_record": "1", "media_codec": ["PCMU","PCMA"], "route" : ["1","2"] }
返回:
{ "data": [], "code": 200, "message": "update rows 2" }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"auto_record":"1","media_codec": ["PCMU","PCMA"],"route" : ["1","2"]}' \ "http://192.168.1.100:8081/api/routes"
查询路由
请求 URL:
/api/routes
返回所有路由信息请求 URL:
/api/routes?destNumber=15666&context=context-1&destType=FS_DEST_USER&dest=xx
根据被叫号码或呼叫源活目的类型或目的地查询(其中destNumber为被叫号码,context为呼叫源,destType为目的类型,dest为目的地)请求 URL:
/api/routes/$id
返回指定 ID 的路由信息请求方式:
GET
返回值: 路由 JSON 对象,如果找不到会返回 HTTP 状态码
404
。curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" http://192.168.1.100:8081/api/routes
返回
{ "page": 1, "rowCount": 17, "pageCount": 1, "data": [ { "blacklist": "", "route_type": 4, "sdnc": "", "media_codec": "", "cid_number": "", "dnc": "", "dest_type": "FS_DEST_GATEWAY", "name": "test", "dest_uuid": "1", "updated_at": "2023-03-17 07:46:21", "max_length": 12, "context": "context-1", "proxy_media": 1, "deleted_at": "", "id": 1, "description": "1", "disabled": 0, "bill_rate": "0.00", "created_at": "2023-03-16 09:24:44", "prefix": "78900", "auto_record": 1, "body": "example" }, ... { "blacklist": "", "route_type": 4, "sdnc": "", "media_codec": "", "cid_number": "", "dnc": "", "dest_type": "FS_DEST_IVR", "name": "IVR test", "dest_uuid": "1", "updated_at": "2023-03-17 07:29:02", "max_length": 12, "context": "context-1", "proxy_media": 1, "deleted_at": "", "id": 17, "description": "", "disabled": 0, "bill_rate": "0.00", "created_at": "2023-03-17 07:29:02", "prefix": "1", "auto_record": 0, "body": "IVR示例1" } ] }
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/routes/14
返回:
{ "prefix": "78900", "deleted_at": "", "max_length": 12, "created_at": "2023-03-16 09:24:44", "bill_rate": "0.00", "body": "example", "updated_at": "2023-03-17 07:46:21", "description": "1", "name": "test", "disabled": 0, "media_codec": "", "route_type": 4, "proxy_media": 1, "dnc": "", "blacklist": "", "auto_record": 1, "id": 1, "dest_type": "FS_DEST_GATEWAY", "dest_uuid": "1", "sdnc": "", "cid_number": "", "context": "context-1" }
查询指定路由下的参数
参数 | 说明 |
---|---|
realm | 固定为 ROUTE |
v | Application 参数 |
k | 设置 Application 对应的值 |
disabled | 是否启用该参数,0 启用 1 禁用 |
请求 URL:
/api/routes/$id/params
返回指定路由下的 application 信息请求方式:
GET
curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" http://192.168.1.100:8081/api/routes/20/params
返回:
[ { "updated_at": "2023-03-17 07:56:27", "id": 26, "deleted_at": "", "disabled": 0, "created_at": "2023-03-17 07:56:27", "realm": "ROUTE", "k": "set", "ref_id": 1, "v": "effective_caller_id_number=1xxx", "o": 1 } ]
验证路由是否正确
参数 | 说明 |
---|---|
destNumber | 需要查询的被叫号码,比如呼叫 1001 走哪条路由 |
context | 需要哪条呼叫源对应的路由,比如 1002 呼叫 1001 走哪条路由,呼叫源则写 1001 对应的 context-1 |
请求 URL:
/api/routes?destNumber=1001&context=context-1
返回所有路由信息请求方式:
GET
返回值: 路由 JSON 对象,如果找不到会返回 HTTP 状态码
404
。curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" http://192.168.1.100:8081/api/routes?destNumber=1001&context=context-1
返回
{ "data": [ { "route_type": "4", "outdest_uuid": "", "context": "context-1", "body": "", "description": "本地分机", "outdest_type": "", "deleted_at": "", "bill_rate": "0.00", "updated_at": "2023-03-16 09:24:44", "blacklist": "", "prefix": "1", "dest_uuid": "", "dnc": "", "outbody": "", "created_at": "2023-03-16 09:24:44", "dest_type": "FS_DEST_USER", "disabled": "0", "id": "2", "media_codec": "", "proxy_media": "1", "sdnc": "", "auto_record": "0", "work_time": "", "cid_number": "", "max_length": "12", "name": "User" } ], "pageCount": 1, "page": 1, "rowCount": 1 }
路由中添加参数(Application)
- 请求 URL:
/api/routes/$id/params
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见路由信息说明。
- 返回值: 添加 params 的 id
Body:
{ "k": "set", "v": "a=2222" }
返回:
{ "data": 26, "code": 200, "message": "success" }
- curl 示例:
curl -POST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"k": "set","v": "a=2222"}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/routes/23/params"
编辑参数(Application)
- 请求 URL:
/api/routes/$id/params/$id
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息: 参见路由信息说明。
- 返回值: 编辑参数的信息
Body:
{ "k": "set", "v": "a=3333" }
返回:
{ "message": "success", "code": 200, "data": { "ref_id": 1, "o": 1, "k": "set", "realm": "ROUTE", "deleted_at": "", "updated_at": "2023-03-17 07:56:27", "v": "a=3333", "id": 26, "created_at": "2023-03-17 07:56:27", "disabled": 0 } }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"k": "set","v": "a=3333"}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/routes/23/params"
删除路由中参数(Application)
- 请求 URL:
/api/routes/$id/param/$id
- 请求方式:
DELETE
- 消息头:
Content-Type: application/json
- Body 信息: 无。
- 返回值:
状态 | 返回值 |
---|---|
成功 | JSON {xxxx} |
失败 | 404 |
返回:
{ "message": "success", "data": 1, "code": 200 }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE http://192.168.1.100:8081/api/routes/23/param/3
路由时间段
路由时间段是指,在一个指定时间段内通话走指定的路由。
获取路由的时间段信息
请求 URL:
/api/time_recurrence/route/$id
获取指定路由的时间段信息请求方式:
GET
curl 示例:
curl -XGET -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" "http://192.168.1.100:8081/api/time_recurrence/route/1"
- 返回值:
{ "data": [ { "updated_at": "2023-03-17 08:52:44", "body": "IVR示例1", "id": 2, "created_at": "2023-03-17 08:52:44", "deleted_at": "", "dest_type": "FS_DEST_IVR", "dest_uuid": "1", "time_recurrence": "20230305T170000|PT6H0.06S|daily||1|MO,TU,WE,TH,FR", "route_id": 2 } ], "message": "ok", "code": 200 }
增加路由时间段信息
- 请求 URL:
/api/time_recurrence
- 请求方法:
POST
- POST 请求参数:
参数 | 必选 | 说明 |
---|---|---|
route_id | true | 路由 id |
time_recurrence | true | 时间段字符串 |
dest_type | true | 目的地类型 |
body | false | 目的地额外信息 |
dest_uuid | false | 目的地 uuid |
body:
[ { "dest_type": "FS_DEST_USER", "dest_uuid": "", "route_id": "24", "time_recurrence": "20220502T000000|PT59M59.696S|daily||1|MO" } ]
- curl 示例:
curl -POST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"dest_type": "FS_DEST_USER","dest_uuid": "","route_id": "24","time_recurrence":"20220502T000000|PT59M59.696S|daily||1|MO"}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/time_recurrence"
返回:
//success http code 200 [ { "id": 2 } ] //failed http code 500 { "message":"error reason" }
更新时间段信息
- 请求 URL:
/api/time_recurrence
- 请求方法:
PUT
- 请求参数:
请求参数为一个数组
参数 | 必选 | 说明 |
---|---|---|
id | true | 时间段记录 id |
time_recurrence | false | 时间段字符串 |
dest_type | false | 目的地类型 |
body | false | 目的地额外信息 |
dest_uuid | false | 目的地 uuid |
route_id | false | 路由 id |
- 请求参数示例:
[ { "dest_type": "FS_DEST_USER", "dest_uuid": "", "route_id": "24", "time_recurrence": "20220502T000000|PT1H59M59S|daily||1|MO", "id": "5" } ]
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"dest_type":"FS_DEST_USER","dest_uuid":"","route_id":"24","time_recurrence":"20220502T000000|PT1H59M59S|daily||1|MO","id":"5"}' \ "http://192.168.1.100:8081/api/time_recurrence"
- 返回数据
//success http code 200 [ { "id": "5" } ] //failed http code 500 { "message":"error reason" }
删除指定时间段信息
请求 URL:
/api/time_recurrence/$id
指定时间段 ID 删除数据请求方法:
DELETE
请求参数: 无
curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE http://192.168.1.100:8081/api/time_recurrence/1
- 返回数据
//success http code 200 { "id": "1" } //failed http code 500 { "message": "delete error" }
删除指定路由时间段信息
请求 URL:
/api/time_recurrence/route/$id
指定路由 id 进行删除请求方法:
DELETE
请求参数: 无
curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE http://192.168.1.100:8081/api/time_recurrence/route/1
- 返回数据
//success http code 200 { "id": "1" } //failed http code 500 { "message":"error reason" }
获取时间段模板
请求 URL:
/api/time_recurrence/templates
请求方法:
GET
请求参数:
page
:页码perPage
:每页数量
curl 示例:
curl -XGET -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" "http://192.168.1.100:8081/api/time_recurrence/templates?perPage=100"
- 返回数据
{ "data": { "pageCount": 1, "rowCount": 2, "data": [ { "deleted_at": "", "description": "", "updated_at": "2022-05-11 10:57:41", "id": 1, "created_at": "2022-05-11 10:57:41", "name": "示例一" }, { "deleted_at": "", "description": "", "updated_at": "2022-05-11 10:57:41", "id": 2, "created_at": "2022-05-11 10:57:41", "name": "示例二" } ], "page": 1 }, "code": 200, "message": "ok" }
创建时间段模板
- 请求 URL:
/api/time_recurrence/templates
- 请求方法:
POST
- 消息头:
Content-Type: application/json
- BODY 信息:
[ { "name": "template_11", "description": "desc 1" } //... ]
- curl 示例:
curl -POST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '[{"name":"template_11","description" : "desc 1"}]' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/time_recurrence/templates"
- 返回值
{ "data": [ { "deleted_at": "", "description": "desc 1", "name": "template_11", "updated_at": "2022-05-11 14:53:12", "id": 6, "created_at": "2022-05-11 14:53:12" } ], "message": "ok", "code": 200 }
创建时间模板时间数据
- 创建时间段模板数据
- 请求 URL:
api/time_recurrence/templates/time_recurrences
- 请求方法:
POST
- 消息头:
Content-Type: application/json
- BODY 信息:
template_id
:模板 idtime_recurrence
:模板时间段字符串
[ { "template_id": 6, "time_recurrence": "20100101T010101|PT10H||daily" }, { "template_id": 6, "time_recurrence": "20100102T010101|PT10H||daily" } ]
- 返回值
{ "message": "ok", "data": [ { "id": 6, "time_recurrences": [ { "id": "1458", "time_recurrence": "20100101T010101|PT10H||daily" }, { "id": "1459", "time_recurrence": "20100102T010101|PT10H||daily" } ] } ], "code": 200 }
更新时间段模板
- 请求 URL:
/api/time_recurrence/templates
- 请求方法:
PUT
- 消息头:
Content-Type: application/json
- BODY 信息:
id
:模板 id
body:
[ { "id": 3, "name": "tempalte_333", "description": "desc333" } ]
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '[{"id":3,"name":"tempalte_333","description":"desc333"}]' \ "http://192.168.1.100:8081/api/time_recurrence/templates"
- 返回值:
{ "data": [ { "id": 3 } ], "code": 200, "message": "ok" }
更新时间段模板
- 更新时间段模板字符串数据
- 请求 URL:
/api/time_recurrence/templates/time_recurrences
- 请求方法:
PUT
- 消息头:
Content-Type: application/json
- BODY 信息:
[ { "id": "1257", "time_recurrence": "20770101T010101|PT10H||daily" } ]
其中id
为time_recurrence
的 id
- 返回
{ "message": "ok", "code": 200, "data": { "id": "1468" } }
删除时间段模板
- 请求 URL:
/api/time_recurrence/templates
- 请求方法:
DELETE
- 消息头:
Content-Type: application/json
- BODY 信息:
内容为需要删除的 id 数组
[1, 2, 3]
- 返回值
{ "data": [ { "id": 1 }, { "id": 2 }, { "id": 3 } ], "code": 200, "message": "ok" }
获取指定 id 的时间段模板详细信息
- 请求 URL:
/api/time_recurrence/templates/$1
其中$1
为模板 id - 请求方法:
GET
- 参数信息: 无
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" http://192.168.1.100:8081/api/time_recurrence/templates/4
- 返回值:
{ "message": "ok", "code": 200, "data": { "name": "tempalte_333", "deleted_at": "", "time_recurrences": [ { "id": 1457, "time_recurrence": "20211231T000000|PT47H59M59S|yearly||1|" } ], "updated_at": "2022-05-11 14:53:38", "created_at": "2022-05-11 10:57:41", "description": "desc333", "id": 4 } }
删除单条模板指定数据
删除单条模板字符串数据
请求 URL:
api/time_recurrence/templates/time_recurrences/$id
删除$id
的模板字符串数据请求方法:
DELETE
请求参数: 无
返回数据
{ "data": { "id": "1468" }, "code": 200, "message": "ok" }
删除多条模板指定数据
- 删除多条模板字符串数据
- 请求 URL:
api/time_recurrence/templates/time_recurrences
- 请求方法:
DELETE
- 消息头:
Content-Type: application/json
- BODY 信息:
内容为 id 数组
[1, 2, 3]
- 返回值
{ "message": "ok", "data": [ { "id": 1 }, { "id": 2 }, { "id": 3 } ], "code": 200 }
呼叫源
参数 | 说明 |
---|---|
hotline_enabled | 是否启动 DID,0-不启动,1-启动 |
name | 呼叫源名称 |
key | 标识符,实际真正使用的值 |
domain | 域名,目前不实际使用 |
查看呼叫源列表
请求 URL:
/api/contexts
请求方式:
GET
Body 信息:无
返回值:
curl 示例:
curl -XGET -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" "http://192.168.1.100:8081/api/contexts"
{ "pageCount": 1, "rowCount": 4, "data": [ { "name": "销售部", "deleted_at": "", "created_at": "2023-03-16 09:24:38", "updated_at": "2023-03-16 09:24:38", "key": "context-4", "hotline_enabled": "0", "id": "4", "domain": "", "description": "(示例)销售部发起的呼叫" }, { "name": "技术部", "deleted_at": "", "created_at": "2023-03-16 09:24:38", "updated_at": "2023-03-16 09:24:38", "key": "context-3", "hotline_enabled": "0", "id": "3", "domain": "", "description": "(示例)技术部发起的呼叫" }, { "name": "外部", "deleted_at": "", "created_at": "2023-03-16 09:24:38", "updated_at": "2023-03-16 09:24:38", "key": "context-2", "hotline_enabled": "0", "id": "2", "domain": "", "description": "外部中继发起的呼叫" }, { "name": "分机", "deleted_at": "", "created_at": "2023-03-16 09:24:38", "updated_at": "2023-03-16 09:24:38", "key": "context-1", "hotline_enabled": "0", "id": "1", "domain": "", "description": "本地分机发起的呼叫" } ], "page": 1 }
查看指定呼叫源
请求 URL:
/api/contexts/$id
请求方式:
GET
Body 信息:无
返回值:
curl 示例:
curl -XGET -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" "http://192.168.1.100:8081/api/contexts/1"
{ "key": "context-1", "hotline_enabled": 0, "name": "分机", "created_at": "2023-03-16 09:24:38", "updated_at": "2023-03-16 09:24:38", "deleted_at": "", "domain": "", "description": "本地分机发起的呼叫", "id": 1 }
创建新的呼叫源
- 请求 URL:
/api/contexts
- 请求方式:
POST
- Body 信息:
{ "name": "test", "description": "测试" }
- curl 示例:
curl -POST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"name": "test","description": "测试"}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/contexts"
- 返回值:
{ "message": "success", "data": 5, "code": 200 }
修改指定呼叫源配置
- 请求 URL:
/api/contexts/$id
- 请求方式:
PUT
- Body 信息:
{ "description": "For Internal Call", "hotline_enabled": "1" }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"description": "For Internal Call","hotline_enabled": "1"}' \ "http://192.168.1.100:8081/api/contexts/4"
- 返回值:
{ "data": "4", "message": "success", "code": 200 }
删除指定呼叫源
- 请求 URL:
/api/contexts/$id
- 请求方式:
DELETE
- Body 信息:
{ "message": "success", "code": 200, "data": "3" }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE http://192.168.1.100:8081/api/contexts/5
- 返回值:
{ "data": "5", "message": "success", "code": 200 }
路由码
路由码页面已被隐藏,如有使用,可咨询工作人员。
获取路由码
请求 URL:
/api/route_codes
请求 URL:
api/route_codes/$1
返回指定 ID 路由码信息请求方式:
GET
请求参数示例:
参数 说明 page 当前页码 perPage 每页条数 curl 示例:
curl -XGET -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" "http://192.168.1.100:8081/api/route_codes?perPage=10&page=1"
- 返回示例
- 返回全部
{ "pageCount": 1, "page": 1, "data": [ { "code": "code00", "description": "des00", "id": 1, "tg_id": 1 } ], "rowCount": 1 }
- 返回单个
{ "description": "des00", "id": 1, "tg_id": 1, "code": "code00" }
更新路由码
请求 URL:
/api/route_codes/$1
$1 为路由码 ID请求方式:
PUT
请求参数示例:
参数 说明 code 路由码 最大 8 字符 tg_id 中继 id description 描述
body:
{ "description": "des00", "tg_id": "1", "code": "code00" }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"code":"testcode","description": "test","tg_id":"1"}' \ "http://192.168.1.100:8081/api/route_codes/1"
返回值
- 成功
{ "message": "success", "data": "1", "code": 200 }
- 失败
{ "data": "{}", "message": "error ", "code": 500 }
删除路由码
- 请求 URL:
/api/route_codes
删除所有 - 请求 URL:
api/route_codes\$1
删除 id 为$1 的路由码 - 请求方法:
DELETE
- curl 示例:
curl -XDELETE -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" "192.168.1.100:8081/api/route_codes"
返回值示例
- 成功
{ "code": 200, "data": "1", "message": "success" }
- 失败
{ "data": "{}", "message": "error ", "code": 500 }
增加单个路由码
请求 URL:
/api/route_codes
请求方式:
POST
请求参数示例: 请求参数
参数 说明 code 路由码 最大 8 字符 tg_id 中继 id description 描述
{ "tg_id": 1, "code": "code1", "description": "des1" }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"code":"code1","description": "desc1","tg_id":"1"}' \ "http://192.168.1.100:8081/api/route_codes"
返回值示例
- 成功
{ "code": 200, "data": "1", "message": "success" }
- 失败
{ "data": "{}", "message": "error ", "code": 500 }
IVR
IVR 信息说明如下:
参数 | 说明 |
---|---|
name | 名称 |
description | 描述 |
greet_long | 欢迎音 |
greet_short | 欢迎音简短提示,重复播放 |
invalid_sound | 错键提示音 |
exit_sound | 挂断音 |
transfer_sound | 转接音 |
timeout | 超时时长,默认 15000,15 秒 |
max_failures | 最大失败次数,默认 3 |
max_timeouts | 最大超时次数,默认 4 |
exec_on_max_failures | 超过最大失败数后执行什么 |
exec_on_max_timeouts | 超过最大超时数后执行什么 |
confirm_key | 确认键 |
confirm_macro | 确认语音宏 |
tts_engine | TTS 引擎,比如 baidu |
tts_voice | TTS 发音人,比如 Ting-Ting |
confirm_attempts | 尝试次数 |
digit_len | 最大收号数,默认 1 |
inter_digit_timeout | 两次按键最大间隔,默认 3000 毫秒 |
pin | IVR 密码,设置了该参数,进入 IVR 后需要输入密码 |
pin_file | 密码输入提示音 |
bad_pin_file | IVR 密码输入错误提示音 |
查看所有 IVR
- 请求 URL:
/api/ivrs
- 请求 URL:
/api/ivrs/$id
返回指定 ID 的 IVR 信息 - 请求方式:
GET
- Body 信息:参见信息说明。
- 返回值: code(200 即为正常),msg
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/ivrs
- 返回 IVR 信息(示例):
{ "pageCount": 1, "data": [ { "invalid_sound": "", "exec_on_max_failures": "", "exec_on_max_timeouts": "", "timeout": "15000", "pin": "", "count_actions": "1", "deleted_at": "", "pin_file": "", "id": "2", "description": "欢迎致电,销售请按1,客服请按2,技术支持请按3", "digit_len": "1", "updated_at": "2023-03-16 09:24:43", "key": "ivr-2", "bad_pin_file": "", "max_failures": "3", "inter_digit_timeout": "3000", "created_at": "2023-03-16 09:24:43", "tts_voice": "", "confirm_attempts": "", "tts_engine": "", "greet_long": { "media_path": "phrase:welcome@xui", "media_type": "SYSTEM", "media_id": 204 }, "name": "IVR示例2", "transfer_sound": "", "confirm_key": "", "confirm_macro": "", "greet_short": { "media_path": "phrase:welcome_short@xui", "media_type": "SYSTEM", "media_id": 205 }, "max_timeouts": "4", "exit_sound": "" }, { "invalid_sound": "", "exec_on_max_failures": "", "exec_on_max_timeouts": "", "timeout": "15000", "pin": "", "count_actions": "5", "deleted_at": "", "pin_file": "", "id": "1", "description": "欢迎致电,请直拨分机号,查号请拨0", "digit_len": "4", "updated_at": "2023-03-16 09:24:43", "key": "ivr-1", "bad_pin_file": "", "max_failures": "3", "inter_digit_timeout": "3000", "created_at": "2023-03-16 09:24:43", "tts_voice": "", "confirm_attempts": "", "tts_engine": "", "greet_long": { "media_path": "$${sound_prefix}/ivr/ivr-generic_greeting.wav", "media_type": "SYSTEM", "media_id": 130 }, "name": "IVR示例1", "transfer_sound": "", "confirm_key": "", "confirm_macro": "", "greet_short": "", "max_timeouts": "4", "exit_sound": "" } ], "rowCount": 2, "page": 1 }
查看指定 IVR
- 请求 URL:
/api/ivrs/$id
- 请求方式:
GET
- Body 信息:参见信息说明。
- 返回值: code(200 即为正常),msg
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/ivrs/1
- 返回 IVR 信息(示例):
{ "timeout": 15000, "greet_short": "", "pin": "", "confirm_key": "", "max_failures": 3, "tts_engine": "", "name": "welcome_example2", "exec_on_max_timeouts": "", "transfer_sound": "", "description": "", "key": "ivr-2", "digit_len": 1, "deleted_at": "", "updated_at": "2022-05-11 10:57:40", "created_at": "2022-05-11 10:57:40", "bad_pin_file": "", "id": 2, "confirm_macro": "", "max_timeouts": 4, "confirm_attempts": "", "inter_digit_timeout": 3000, "exec_on_max_failures": "", "exit_sound": "", "pin_file": "", "invalid_sound": "", "tts_voice": "", "greet_long": { "media_id": 1, "media_path": "/usr/local/freeswitch/storage/upload/welcome_ivr_example.mp3", "media_type": "UPLOAD" } }
查看指定 IVR 的所有动作
IVR 动作信息说明如下:
参数 | 说明 |
---|---|
ivr_menu_id | 所属 IVR ID |
digits | 按键信息 |
action | 动作 |
match_prefix | 是否启用匹配前缀,0-不启用,1-启用;默认 0 |
args | IVR 动作对应的选项值,比如队列 ID |
body | 挂断音 |
IVR 动作参数(action) | 说明 |
---|---|
IVR_EXTENSION | 转分机,如果根据按键转对应分机,则开启号码匹配,args 为空即可 |
IVR_QUEUE | 转队列,如果根据按键转对应队列,则则开启号码匹配,args 为空即可 |
IVR_MEETING_ROOM | 转预约会议,如果根据按键转对应队列,则开启号码匹配,则 args 为空即可 |
IVR_CONFERENCE_ROOM | 转会议室,如果根据按键转对应队列,则开启号码匹配,则 args 为空即可 |
IVR_CONFERENCE | 转临时会议 |
IVR_SCRIPT | 转脚本 |
IVR_SYSTEM | 高级指令,执行 FS 内部 app 指令 |
IVR_ROUTE | 转路由,可指定呼叫源及被叫号码,如果 args 及 body 为空则默认走 context-1,被叫为按键信息 |
IVR_PLAY | 播放语音文件 |
IVR_TTS | 播放 TTS 语音 |
IVR_SUB | 转下级菜单 |
IVR_TOP | 返回上级菜单 |
IVR_BACK | 返回主菜单 |
IVR_EXIT | 退出 |
- 请求 URL:
/api/ivrs/$id/actions
- 请求方式:
GET
- Body 信息:参见信息说明。
- 返回值: code(200 即为正常),msg
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/ivrs/1/actions
- 返回 IVR 信息(示例):
[ { "ivr_menu_id": 1, "action": "IVR_PLAY", "created_at": "2022-05-11 10:57:40", "id": 7, "deleted_at": "", "args": "tone_stream://%(1000,0,640)", "updated_at": "2022-05-11 10:57:40", "body": "BEEP", "digits": "0", "match_prefix": 0 }, { "ivr_menu_id": 1, "action": "IVR_SUB", "created_at": "2022-05-11 10:57:40", "id": 8, "deleted_at": "", "args": "2", "updated_at": "2022-05-11 10:57:40", "body": "welcome_example2", "digits": "1", "match_prefix": 0 } ]
查看指定 IVR 的指定动作
- 请求 URL:
/api/ivrs/$id/actions/$action_id
- 请求方式:
GET
- Body 信息:参见信息说明。
- 返回值: code(200 即为正常),msg
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/ivrs/1/actions/7
- 返回 IVR 信息(示例):
[ { "updated_at": "2022-05-11 10:57:40", "action": "IVR_PLAY", "match_prefix": 0, "args": "tone_stream://%(1000,0,640)", "digits": "0", "ivr_menu_id": 1, "created_at": "2022-05-11 10:57:40", "body": "BEEP", "deleted_at": "", "id": 7 } ]
创建 IVR
- 请求 URL:
/api/ivrs
- 请求方式:
POST
- Body 信息:参见信息说明。
- 返回值: code(200 即为正常),IVR id
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -d '{"name":"welcome"}' -XPOST 192.168.1.100:8081/api/ivrs
body 为:
{ "name": "welcome" }
其中 body 里 name 为必填项,其他信息可以采取默认配置。
- 返回 IVR id(示例):
{ "message": "success", "code": 200, "data": 3 }
修改指定 IVR 欢迎音
修改长欢迎音
- 请求 URL:
/api/ivrs/$id
$id IVR id - 请求方式:
PUT
- Body 信息:参见信息说明。
- 返回值: code(200 即为正常),IVR id
body 为:
{ "id": "5", "greet_long": "{\"media_id\":217,\"media_path\":\"/usr/local/freeswitch/storage/upload/upload-20230318103616-6bb13245-325f-499e-8e79-4b90b1abf4e5.wav\",\"media_type\":\"UPLOAD\"}" }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -d '{"greet_long":"{\"media_id\":217,\"media_path\":\"/usr/local/freeswitch/storage/upload/upload-20230318103616-6bb13245-325f-499e-8e79-4b90b1abf4e5.wav\",\"media_type\":\"UPLOAD\"}"}' -XPUT 192.168.1.100:8081/api/ivrs/3
- 返回 IVR id(示例):
{ "message": "success", "code": 200, "data": "3" }
修改短欢迎音
- 请求 URL:
/api/ivrs/$id
$id IVR id - 请求方式:
PUT
- Body 信息:参见信息说明。
- 返回值: code(200 即为正常),IVR id
body 为:
{ "id": "5", "greet_short": "{\"media_id\":255,\"media_path\":\"/usr/local/freeswitch/storage/upload/upload-20240708170248-01909194-d3bd-707f-92ad-4d98445a36a3.wav\",\"media_type\":\"UPLOAD\"}" }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -d '{"greet_short":"{\"media_id\":255,\"media_path\":\"/usr/local/freeswitch/storage/upload/upload-20240708170248-01909194-d3bd-707f-92ad-4d98445a36a3.wav\",\"media_type\":\"UPLOAD\"}"}' -XPUT 192.168.1.100:8081/api/ivrs/3
- 返回 IVR id(示例):
{ "message": "success", "code": 200, "data": "3" }
修改错键提示音
- 请求 URL:
/api/ivrs/$id
$id IVR id - 请求方式:
PUT
- Body 信息:参见信息说明。
- 返回值: code(200 即为正常),IVR id
body 为:
{ "id": "5", "invalid_sound": "{\"media_id\":255,\"media_path\":\"/usr/local/freeswitch/storage/upload/upload-20240708170248-01909194-d3bd-707f-92ad-4d98445a36a3.wav\",\"media_type\":\"UPLOAD\"}" }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -d '{"invalid_sound":"{\"media_id\":255,\"media_path\":\"/usr/local/freeswitch/storage/upload/upload-20240708170248-01909194-d3bd-707f-92ad-4d98445a36a3.wav\",\"media_type\":\"UPLOAD\"}"}' -XPUT 192.168.1.100:8081/api/ivrs/3
- 返回 IVR id(示例):
{ "message": "success", "code": 200, "data": "3" }
修改挂断提示音
- 请求 URL:
/api/ivrs/$id
$id IVR id - 请求方式:
PUT
- Body 信息:参见信息说明。
- 返回值: code(200 即为正常),IVR id
body 为:
{ "id": "5", "exit_sound": "{\"media_id\":255,\"media_path\":\"/usr/local/freeswitch/storage/upload/upload-20240708170248-01909194-d3bd-707f-92ad-4d98445a36a3.wav\",\"media_type\":\"UPLOAD\"}" }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -d '{"exit_sound":"{\"media_id\":255,\"media_path\":\"/usr/local/freeswitch/storage/upload/upload-20240708170248-01909194-d3bd-707f-92ad-4d98445a36a3.wav\",\"media_type\":\"UPLOAD\"}"}' -XPUT 192.168.1.100:8081/api/ivrs/3
- 返回 IVR id(示例):
{ "message": "success", "code": 200, "data": "3" }
修改转接提示音
- 请求 URL:
/api/ivrs/$id
$id IVR id - 请求方式:
PUT
- Body 信息:参见信息说明。
- 返回值: code(200 即为正常),IVR id
body 为:
{ "id": "5", "transfer_sound": "{\"media_id\":255,\"media_path\":\"/usr/local/freeswitch/storage/upload/upload-20240708170248-01909194-d3bd-707f-92ad-4d98445a36a3.wav\",\"media_type\":\"UPLOAD\"}" }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -d '{"transfer_sound":"{\"media_id\":255,\"media_path\":\"/usr/local/freeswitch/storage/upload/upload-20240708170248-01909194-d3bd-707f-92ad-4d98445a36a3.wav\",\"media_type\":\"UPLOAD\"}"}' -XPUT 192.168.1.100:8081/api/ivrs/3
- 返回 IVR id(示例):
{ "message": "success", "code": 200, "data": "3" }
创建指定 IVR 动作
- 请求 URL:
/api/ivrs/$id/actions
- 请求方式:
POST
- Body 信息:参见信息说明。
- 返回值: code(200 即为正常),IVR id
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -d '{"digits": "333","match_prefix": "0","action": "IVR_QUEUE","args": "5","ivr_menu_id": "5"}' -XPOST 192.168.1.100:8081/api/ivrs/5/actions
body 为:
{ "digits": "333", "match_prefix": "0", "action": "IVR_QUEUE", "args": "5", "ivr_menu_id": "5" }
- 返回 IVR 动作 id(示例):
{ "code": 200, "message": "success", "data": 22 }
修改指定 IVR 动作
- 请求 URL:
/api/ivrs/$id/actions/$actions_id
$id IVR ID $actions_id 动作 ID - 请求方式:
PUT
- Body 信息:参见信息说明。
- 返回值: code(200 即为正常),动作 id
body 为:
{ "digits": "0", "match_prefix": "0", "action": "IVR_PLAY", "args": 257, "id": 24 }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -d '{"digits": "0","match_prefix": "0","action": "IVR_PLAY","args": 257,"id": 24}' -XPUT 192.168.1.100:8081/api/ivrs/6/actions/24
- 返回 IVR id(示例):
{ "message": "success", "code": 200, "data": "24" }
删除指定 IVR
- 请求 URL:
/api/ivrs/$id
- 请求方式:
DELETE
- Body 信息:参见信息说明。
- 返回值: code(200 即为正常)
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE 192.168.1.100:8081/api/ivrs/3
- 返回(示例):
{ "message": "success", "data": "3", "code": 200 }
删除指定 IVR 的指定动作
- 请求 URL:
/api/ivrs/$id/actions/$action_id
- 请求方式:
DELETE
- Body 信息:参见信息说明。
- 返回值: code(200 即为正常)
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE 192.168.1.100:8081/api/ivrs/2/actions/6
- 返回(示例):
{ "data": "6", "message": "success", "code": 200 }
时间管理
时间管理信息说明如下:
参数 | 说明 |
---|---|
name | 名称 |
description | 描述 |
获取时间管理
- 请求 URL:
/api/time_recurrence/templates
返回所有时间管理信息 - 请求 URL:
/api/time_recurrence/templates/$id
返回指定 ID 的时间管理信息 - 请求方式:
GET
- 返回值: 路由 JSON 对象,如果找不到会返回 HTTP 状态码
404
。 - curl 示例 1:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" http://192.168.1.100:8081/api/time_recurrence/templates
返回:
{ "data": { "page": 1, "pageCount": 1, "rowCount": 6, "data": [ { "updated_at": "2022-05-23 09:45:23", "id": 1, "deleted_at": "", "description": "", "name": "示例一", "created_at": "2022-05-23 09:45:23" } ... ] }, "message": "ok", "code": 200 }
- curl 示例 2:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/time_recurrence/templates/4
返回:
{ "code": 200, "message": "ok", "data": { "time_recurrences": [ { "time_recurrence": "20211231T000000|PT47H59M59S|yearly||1|", "id": 1457 } ], "name": "示例四", "created_at": "2022-05-23 09:45:23", "description": "", "deleted_at": "", "id": 4, "updated_at": "2022-05-23 09:45:23" } }
创建时间管理
- 请求 URL:
/api/time_recurrence/templates
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见时间管理信息说明。
- 返回值: 创建时间管理的 id
Body:
[ { "name": "asd", "description": "test" } ]
返回:
{ "code": 200, "message": "ok", "data": [ { "deleted_at": "", "id": "9", "description": "test", "name": "asd", "created_at": "2022-05-23 21:02:58", "updated_at": "2022-05-23 21:02:58" } ] }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"name": "test","description":"test"}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/time_recurrence/templates"
修改时间管理
- 请求 URL:
/api/time_recurrence/templates
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息: 参见时间管理信息说明。
- 示例:
Body:
[ { "name": "test", "id": 1, "description": "test" } ]
返回:
{ "code": 200, "data": [ { "id": 1 } ], "message": "ok" }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"name":"test","description": "test","id":"1"}' \ "http://192.168.1.100:8081/api/time_recurrence/templates"
删除时间管理
请求 URL:
/api/time_recurrence/templates
请求方式:
DELETE
消息头: 无
示例: body
[7]
返回:
{ "code": 200, "message": "ok", "data": [ { "id": 7 } ] }
创建工作日和节假日
请求 URL:
/api/time_recurrence/templates/time_recurrences
请求方式:
POST
消息头:
Content-Type: application/json
Body 信息: 参见时间管理信息说明。
示例
template_id
:模板 idtime_recurrence
:增加工作日,第一个表示星期日的 07:00:00-07:59:59,第二个表示 5 月 11 日 00:00:00 - 5 月 15 日 23:59:59
Body:
[ { "template_id": "8", "time_recurrence": "20220503T070000|PT59M59.464S|daily||1|SU" }, { "template_id": "8", "time_recurrence": "20220511T000000|PT119H59M59S|yearly||1|" } ]
返回:
{ "data": [ { "time_recurrences": [ { "time_recurrence": "20220503T070000|PT59M59.464S|daily||1|SU", "id": "1469" }, { "time_recurrence": "20220511T000000|PT119H59M59S|yearly||1|", "id": "1470" } ], "id": "8" } ], "code": 200, "message": "ok" }
修改工作日和节假日
请求 URL:
/api/time_recurrence/templates/time_recurrences
请求方式:
PUT
消息头:
Content-Type: application/json
Body 信息: 参见时间管理信息说明。
示例
Body:
[ { "template_id": "8", "time_recurrence": "20220503T070000|PT2H|daily||1|SU", "id": 1469 }, { "template_id": "8", "time_recurrence": "20220511T000000|PT119H59M59S|yearly||1|", "id": 1470 } ]
返回:
{ "code": 200, "message": "ok", "data": [ { "id": 1469 }, { "id": 1470 } ] }
删除工作日或节假日
请求 URL:
/api/time_recurrence/templates/time_recurrences/$id
请求方式:
DELETE
消息头:
Content-Type: application/json
Body 信息: 参见时间管理信息说明。
示例
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE https://192.168.3.222/api/time_recurrence/templates/time_recurrences/1470
返回:
{ "code": 200, "message": "ok", "data": { "id": "1470" } }
功能码管理
功能码信息说明如下:
参数 | 说明 | 必选 |
---|---|---|
func_code | 按键号码 | 是 |
func_type | 功能类型 | 是 |
description | 功能码描述 | 否 |
功能类型说明如下:
功能类型 | 说明 |
---|---|
FS_DEST_FUNC_CALL_FORWARDING | 设置无条件前转 |
FS_DEST_FUNC_CALL_FORWARDING_CANCEL | 取消无条件前转 |
FS_DEST_FUNC_CALL_FORWARD_BUSY | 设置遇忙前转 |
FS_DEST_FUNC_CALL_FORWARD_BUSY_CANCEL | 取消遇忙前转 |
FS_DEST_FUNC_CALL_FORWARD_WITHOUT_RESPONSE | 设置无应答前转 |
FS_DEST_FUNC_CALL_FORWARD_WITHOUT_RESPONSE_CANCEL | 取消无应答前转 |
FS_DEST_FUNC_CALL_DND | 设置免打扰 |
FS_DEST_FUNC_CALL_DND_CANCEL | 取消免打扰 |
FS_DEST_FORCE_INSERT | 强插 |
FS_DEST_FORCE_BREAKDOWN | 强拆 |
FS_DEST_EAVESDROP | 监听 |
FS_DEST_LAST_INTERCEPT | 代答最近号码 |
FS_DEST_DEST_INTERCEPT | 代答指定号码 |
FS_DEST_FUNC_CALL_VOICEMAIL | 听取留言 |
FS_DEST_FUNC_CALL_FIFO_BACK | 取回停泊号码 |
FS_DEST_FUNC_CALL_RECORD | 录音 |
FS_DEST_TIMELY_MEETING | 立即会议接入码 |
FS_DEST_MCASTS | 组播 |
创建功能码
请求 URL:
/api/func_code
请求方式:
POST
消息头:
Content-Type: application/json
Body 信息: 功能码信息说明。
返回值:正常返回一个 JSON Object。包含新建的功能码 ID。
示例:
Body :
{ "func_code": "*123", "func_type": "FS_DEST_FUNC_CALL_FORWARDING", "description": "test" }
返回 :
{ "message": "success", "data": 37, "code": 200 }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"func_code": "*123", "func_type": "FS_DEST_FUNC_CALL_FORWARDING", "description": "test"}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/func_code"
查看功能码
- 请求 URL:
/api/func_code
返回全部的功能码信息 - 请求 URL:
/api/func_code/$id
返回指定 ID 的功能码信息 - 请求方式:
GET
- 请求 URL 参数说明:
参数 | 说明 |
---|---|
id | 指定查看的功能码 ID |
- Body 信息:无
- 返回全部功能码信息:
curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/func_code
返回值
{ "rowCount": 19, "page": 1, "pageCount": 1, "data": [ { "updated_at": "2023-03-20 10:59:53", "description": "test", "deleted_at": "", "disabled": "0", "func_code": "*123", "created_at": "2023-03-20 10:59:53", "id": "37", "func_type": "FS_DEST_FUNC_CALL_FORWARDING" }, { "updated_at": "2023-03-03 02:46:43", "description": "组播", "deleted_at": "", "disabled": "0", "func_code": "*79", "created_at": "2023-03-03 02:46:43", "id": "18", "func_type": "FS_DEST_MCASTS" }, { "updated_at": "2023-03-03 02:46:43", "description": "立即会议接入码", "deleted_at": "", "disabled": "0", "func_code": "*86", "created_at": "2023-03-03 02:46:43", "id": "17", "func_type": "FS_DEST_TIMELY_MEETING" }, ... ] }
- 返回指定 ID 功能码信息:
curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/func_code/37
返回值
{ "id": 37, "disabled": 0, "created_at": "2023-03-20 10:59:53", "deleted_at": "", "func_type": "FS_DEST_FUNC_CALL_FORWARDING", "updated_at": "2023-03-20 10:59:53", "func_code": "*123", "description": "test" }
修改指定 ID 的功能码
- 请求 URL:
/api/func_code/$id
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- 请求 URL 参数说明:
参数 | 说明 |
---|---|
id | 修改功能码的 ID |
- Body 信息:
修改启用状态
参数 | 说明 |
---|---|
action | 变更启用状态,固定为"toggle" |
修改功能码信息
参数 | 说明 | 必选 |
---|---|---|
func_code | 按键号码 | 是 |
func_type | 功能类型 | 是 |
description | 功能码描述 | 否 |
返回值: 正常返回一个 JSON Object,包含修改成功的功能码 ID
示例:
Body:
// 修改启用状态 { "action":"toggle" } // 修改功能码信息 { "func_code": "$VeryGoodPassw0rd", "func_type": "FS_DEST_MCASTS", "description": "test1" }
返回:
{ "code": 200, "data": "37", "message": "success" }
- curl 示例:
// 修改启用状态 curl -XPUT -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"action":"toggle"}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/func_code/37" // 修改功能码信息 curl -XPUT -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"func_code": "*1234", "func_type": "FS_DEST_MCASTS", "description": "test1"}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/func_code/37"
删除指定 ID 的功能码
- 请求 URL:
/api/func_code/$id
- 请求方式:
DELETE
- 消息头:无
- 返回值: 正常返回一个 JSON Object,包含删除功能码的 ID。
- curl 示例:
curl -0 -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE 192.168.1.100:8081/api/func_code/37
返回值
{ "code": 200, "message": "success", "data": "37" }
网关管理
网关信息说明如下:
参数 | 说明 |
---|---|
name | 网关名称 |
username | 注册账号 |
password | 网关注册密码 |
profile_id | SIP Profile 的 ID |
realm | 注册服务器 |
register | 是否注册(yes 则注册,no 则不注册) |
description | 网关描述 |
template | 选择参数模板 |
创建网关
请求 URL:
/api/gateways
请求方式:
POST
消息头:
Content-Type: application/json
Body 信息: 参见网关信息说明。
返回值:正常返回一个 JSON Object。包含新建网关 ID。
示例:
Body :
{ "name": "test123", "realm": "192.168.1.100:7000", "username": "test", "password": "$VeryGoodPassw0rd", "description": "", "profile_id": "1", "register": "yes", "template": "default" }
返回 :
{ "message": "success", "data": 2, "code": 200 }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"realm":"192.168.1.100:7000","name":"test","username":"1001","password":"$VeryGoodPassw0rd"}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/gateways"
创建网关参数
- 请求 URL:
/api/gateways/$id/params
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息:
字段 | 必选 | 类型 | 备注 |
---|---|---|---|
k | 是 | string | 参数名称 |
v | 是 | string | 参数值 |
disabled | 是 | string | 是否启用,0 启用,1 不启用 |
- 返回值:
正常返回一个 JSON Object,包含新增的参数 id。
- 示例:
Body :
{ "k": "auth-username", "v": "cluecon", "disabled": "0" }
返回 :
{ "message": "success", "code": 200, "data": 1471 }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"k": "auth-username","v": "cluecon","disabled": "0"}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/gateways/3/params"
创建网关变量
- 请求 URL:
/api/gateways/$id/variables
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见网关信息说明。
- 参数值:
参数 | 说明 |
---|---|
id | 网关的 ID |
k | 网关参数名称 |
v | 网关参数值 |
direction | 方向,0:两个方向均支持,1:inbound, 2:outbound |
disabled | 是否启动,0 是,1 不启用 |
- 示例:
Body :
{ "k": "test_var", "v": "xui", "disabled": "0", "direction": "1" }
返回 :
{ "data": 7, "message": "success", "code": 200 }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"k": "test","v": "xyt","disabled": "0","direction":"inbound"}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/gateways/3/variables"
删除网关
- 请求 URL:
/api/gateways/$id
- 请求方式:
DELETE
- 消息头:无
- 返回值:
状态 | 返回值 |
---|---|
成功 | {"code":200,"text":"OK"} |
失败 | {"code": 500,"message": "Internal Server Error"} |
- 示例:
curl -0 -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE 192.168.1.100:8081/api/gateways/2
返回:
{ "code": 200, "data": "2", "message": "success" }
删除网关参数
- 请求 URL:
/api/gateways/$id/param/$param_id
- 请求方式:
DELETE
- 消息头:无
- 返回值:正常返回一个 JSON Object,包含删除成功的参数数量
- 请求 URL 参数说明:
参数 | 说明 |
---|---|
id | 网关 id |
param_id | 网关参数 id |
- 示例:
curl -0 -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE 192.168.1.100:8081/api/gateways/3/param/1127
返回:
{ "message": "success", "code": 200, "data": 1 }
删除网关变量
- 请求 URL:
/api/gateways/$id/variable/$variable_id
- 请求方式:
DELETE
- 消息头:无
- 返回值:正常返回一个 JSON Object,包含删除成功的变量数量
- 请求 URL 参数说明:
参数 | 说明 |
---|---|
id | 网关 id |
variable_id | 网关变量 id |
- 示例:
curl -0 -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE 192.168.1.100:8081/api/gateways/3/variable/1127
返回:
{ "code": 200, "data": 1, "message": "success" }
修改网关
- 请求 URL:
/api/gateways/$id
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- 请求 URL 参数说明:
参数 | 说明 |
---|---|
id | 修改网关的 ID |
- Body 信息:
参数 | 说明 |
---|---|
name | 网关名称 |
username | 注册账号 |
password | 网关注册密码 |
profile_id | SIP Profile 的 ID |
realm | 注册服务器 |
register | 是否注册(yes 则注册,no 则不注册) |
description | 网关描述 |
返回值: 正常返回一个 JSON Object,包含修改成功的网关 ID
示例:
PUT http://192.168.1.100:8081/api/gateways/8
Body:
{ "realm": "192.168.1.100:7000", "username": "1005", "password": "$VeryGoodPassw0rd" }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"realm":"192.168.1.100:7000","username":"1005","password":"$VeryGoodPassw0rd"}' \ "192.168.1.100:8081/api/gateways/8"
返回:
{ "data": "8", "code": 200, "message": "success" }
修改网关参数
- 请求 URL:
/api/gateways/$id/params/$param_id
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- 请求 URL 参数说明:
参数 | 说明 |
---|---|
id | 修改网关的 ID |
param_id | 修改网关参数的 ID |
- Body 信息:
参数 | 说明 |
---|---|
k | 网关参数名称 |
v | 网关参数值 |
disabled | 可选,是否启动,0 是,1 不启用 |
Body:
{ "k": "auth-username", "v": "clueconn" }
- 返回值:
{ "code": 200, "data": { "ref_id": 8, "updated_at": "2022-05-11 17:28:30", "id": 1473, "v": "clueconn", "created_at": "2022-05-11 17:27:56", "disabled": 0, "k": "auth-username", "realm": "GATEWAY", "deleted_at": "" }, "message": "success" }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"k": "auth-username","v": "clueconn"}' \ "192.168.1.100:8081/api/gateways/3/params/1147"
修改网关变量
- 请求 URL:
/api/gateways/$id/variables/$variable_id
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- 请求 URL 参数说明:
参数 | 说明 |
---|---|
id | 修改网关的 ID |
variable_id | 修改网关变量的 ID |
- Body 信息:
参数 | 说明 |
---|---|
k | 网关参数名称 |
v | 网关参数值 |
disabled | 是否启动,0 是,1 不启用 |
direction | 0:两个方向, 1: inbound, 2: outbound |
Body:
{ "k": "test_var", "v": "xui" }
- 返回值:
{ "data": { "disabled": 0, "created_at": "2022-05-11 17:19:03", "gateway_id": 1, "v": "xui", "updated_at": "2022-05-11 17:19:03", "k": "test_var", "id": 5, "deleted_at": "", "direction": 0 }, "code": 200, "message": "success" }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"k": "test_var","v": "xui"}' \ "192.168.1.100:8081/api/gateways/2/variables/5"
查看网关
请求 URL:
/api/gateways
返回所有网关信息请求 URL:
/api/gateways/$id
返回指定 ID 的网关信息及网关参数信息请求方式:
GET
返回值: 网关对象,如果找不到会返回 HTTP 状态码
404
。curl 示例 1:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/gateways
返回:
{ "page": 1, "data": [ { "id": "1", "password": "", "profile_id": "2", "updated_at": "2022-05-11 10:57:41", "realm": "example.com", "created_at": "2022-05-11 10:57:41", "username": "admin", "description": "", "register": "no", "name": "example", "deleted_at": "" } ], "pageCount": 1, "rowCount": 1 }
- curl 示例 2:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/gateways/1
返回:
{ "params": [ { "k": "908-retry-seconds", "realm": "GATEWAY", "v": "90", "deleted_at": "", "disabled": 1, "id": 1171, "updated_at": "2022-05-11 10:57:41", "created_at": "2022-05-11 10:57:41", "ref_id": 1 }, { "k": "auth-username", "realm": "GATEWAY", "v": "cluecon", "deleted_at": "", "disabled": 1, "id": 1172, "updated_at": "2022-05-11 10:57:41", "created_at": "2022-05-11 10:57:41", "ref_id": 1 } ], "updated_at": "2022-05-11 10:57:41", "profile_id": 2, "register": "no", "description": "", "variables": [ { "k": "123444", "v": "234", "deleted_at": "", "disabled": 0, "id": 4, "gateway_id": 1, "updated_at": "2022-05-11 17:18:42", "created_at": "2022-05-11 17:18:42", "direction": 0 }, { "k": "token-url1", "v": "1111", "deleted_at": "", "disabled": 0, "id": 6, "gateway_id": 1, "updated_at": "2022-05-11 17:19:27", "created_at": "2022-05-11 17:19:27", "direction": 0 } ], "deleted_at": "", "id": 1, "username": "admin", "realm": "example.com", "created_at": "2022-05-11 10:57:41", "name": "example" }
查看网关状态
- 请求 URL:
/api/gateways/list1
返回所有使用中的网关状态 - 请求方式:
GET
gateway_state | 说明 |
---|---|
NOREG | 不注册 |
TRYING | 注册尝试中 |
REGED | 注册成功 |
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/gateways/list1
返回:
[ { "gateway_status": "UP", "name": "example", "gateway_state": "NOREG" } ]
查看某网关参数
请求 URL:
/api/gateways/params/$id
返回指定网关 id 下的所有网关参数请求方式:
GET
curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/gateways/params/2
返回:
[ { "realm": "GATEWAY", "id": 1171, "k": "908-retry-seconds", "updated_at": "2022-05-11 10:57:41", "v": "90", "disabled": 1, "created_at": "2022-05-11 10:57:41", "ref_id": 1, "deleted_at": "" }, { "realm": "GATEWAY", "id": 1172, "k": "auth-username", "updated_at": "2022-05-11 10:57:41", "v": "cluecon", "disabled": 1, "created_at": "2022-05-11 10:57:41", "ref_id": 1, "deleted_at": "" } ... ]
查看某个网关下变量
请求 URL:
/api/gateways/variables/$id
返回指定网关 id 下的所有网关变量值请求方式:
GET
curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/gateways/variables/6
返回:
[ { "k": "token-url1", "direction": 0, "gateway_id": 1, "created_at": "2022-05-11 17:19:27", "v": "1111", "disabled": 0, "updated_at": "2022-05-11 17:19:27", "id": 6, "deleted_at": "" } ]
按网关名称控制网关状态
- 请求 URL:
/api/gateways/control
- 请求方式:
PUT
- Body 信息:
参数 | 说明 |
---|---|
action | 网关控制指令。start/killgw/register/unregister |
gwname | 网关名称 |
action 值 | 说明 |
---|---|
start | 开始 |
killgw | 停止 |
register | 注册 |
unregister | 注册 |
Body:
{ "action": "start", "gwname": "example" }
- 返回值:
状态 | 返回值 |
---|---|
成功 | 200 |
失败 | 404 |
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "content-type: application/json" \ -d '{"action":"start","gwname": "example"}' "192.168.1.100:8081/api/gateways/control"
返回:
{ "code": 200, "message": "success", "data": {} }
或按如下请求
停止网关
按 id 查询并关闭网关
请求 URL:
/api/gateways/control?gwname=example&action=start
请求方式:
PUT
返回值:
curl 请求示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "content-type: application/json" "192.168.1.100:8081/api/gateways/control?gwname=example&action=start"
返回:
{ "message": "success", "code": 200, "data": {} }
按网关 ID 控制网关状态
- 请求 URL:
/api/gateways/$id/control
激活指定 ID 网关 - 请求方式:
PUT
- Body 信息:
参数 | 说明 |
---|---|
action | 网关控制指令。开始-start, 停止-killgw, 注册-register 注销:unregister |
Body:
{ "action": "start" }
- 返回值:
状态 | 返回值 |
---|---|
成功 | 200 |
失败 | 404 |
例子:
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "content-type: application/json" \ -d '{"action":"start"}' "192.168.1.100:8081/api/gateways/1/control"
返回:
{ "message": "success", "data": "9", "code": 200 }
黑白名单
黑白名单信息说明如下:
参数 | 说明 |
---|---|
name | 名称-必填 |
description | 描述 |
list_type | 名单类型 0:黑名单, 1:白名单 必填 |
limit_user_type | 限制用户类型 0:主叫限制, 1:被叫限制, 2:主被叫限制 必填 |
参数 | 说明 |
---|---|
params{ k , v} | k:名称或说明, v:黑名单中号码 |
获取黑白名单
请求 URL:
/api/blacklists
返回所有黑名单信息请求 URL:
/api/blacklists/$id
返回指定 ID 的黑名单信息请求方式:
GET
返回值: 路由 JSON 对象,如果找不到会返回 HTTP 状态码
404
。curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" http://192.168.1.100:8081/api/blacklists
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/blacklists/1
返回:
{ "data": [ { "name": "hei", "limit_user_type": "1", "id": "2", "created_at": "2022-05-11 20:02:36", "description": "", "deleted_at": "", "updated_at": "2022-05-11 20:02:36", "list_type": "0" }, { "name": "bai", "limit_user_type": "0", "id": "1", "created_at": "2022-05-11 20:02:26", "description": "", "deleted_at": "", "updated_at": "2022-05-11 20:02:26", "list_type": "1" } ], "page": 1, "rowCount": 2, "pageCount": 1 }
新建黑白名单
- 请求 URL:
/api/blacklists
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见黑名单信息说明。
Body:
{ "name": "test", "description": "test", "limit_user_type": "1", "list_type": "1" }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"name": "test","description":"test","limit_user_type": "1","list_type": "1"}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/blacklists"
返回:
{ "message": "success", "code": 200, "data": 3 }
新建名单号码列表
- 请求 URL:
/api/blacklists/$id/lists
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见黑名单信息说明。
Body:
{ "k": "test", "v": "test" }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"k": "test","v":"test"}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/blacklists/1/lists"
返回:
{ "code": 200, "data": 1501, "message": "success" }
指定黑白名单下批量新建号码列表
- 请求 URL:
/api/blacklists/$id/import
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见黑名单信息说明。
k
:名称v
:号码
Body:
{ "data": [ { "k": "lili", "v": "1008" }, { "k": "lisi", "v": "1009" }, { "k": "1012", "v": "1012" } ] }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"data":[{"k": "lili","v": "1008"},{"k": "lisi","v": "1009"},{"k": "1012","v": "1012"}]}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/blacklists/3/import"
返回:
{ "message": "success", "data": [ { "id": 1502, "created_at": "2022-05-11 20:21:02", "v": "1008", "k": "lili", "deleted_at": "", "realm": "BLACKLIST", "updated_at": "2022-05-11 20:21:02", "ref_id": 3, "disabled": 0 }, { "id": 1503, "created_at": "2022-05-11 20:21:02", "v": "1009", "k": "lisi", "deleted_at": "", "realm": "BLACKLIST", "updated_at": "2022-05-11 20:21:02", "ref_id": 3, "disabled": 0 }, { "id": 1504, "created_at": "2022-05-11 20:21:02", "v": "1012", "k": "1012", "deleted_at": "", "realm": "BLACKLIST", "updated_at": "2022-05-11 20:21:02", "ref_id": 3, "disabled": 0 } ], "code": 200 }
直接导入黑白名单号码数据
通过 Excel 文件导入黑白名单及对应的号码列表。
- 请求 URL:
/api/blacklists/import
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息:
Body 信息由 Excel 文件解析而来,Excel 格式与导出格式一致。 key 为 Excel 的字段名。
{ "lists": [ { "名称": "import_1", "名单类型": 1, "限制用户类型": 1, "号码名称": "hello", "起始号码": "123" }, { "名称": "import_1", "名单类型": 1, "限制用户类型": 1, "号码名称": "hello1", "起始号码": "12345" } ] }
- 返回值:
{ "message": "success", "data": [ { "list_type": 1, "name": "import_1", "limit_user_type": 1, "description": "", "id": 4 } ], "code": 200 }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"lists":[{"名称":"import_1","名单类型":1,"限制用户类型":1,"号码名称":"hello","起始号码":"123"},{"名称":"import_1","名单类型":1,"限制用户类型":1,"号码名称":"hello1","起始号码":"12345"}]}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/blacklists/import"
修改黑白名单
- 请求 URL:
/api/blacklists/$id
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息: 参见黑名单信息说明。
- 返回值:
状态 | 返回值 |
---|---|
成功 | "code": 200 |
失败 | -ERR Cannot execute script |
- 示例:
Body:
{ "name": "test01", "id": "2", "limit_user_type": "1", "list_type": "1", "description": "test01" }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"name":"test","description": "test","id":"1"}' \ "http://192.168.1.100:8081/api/blacklists/2"
返回:
{ "code": 200, "data": "2", "message": "success" }
修改号码列表
- 请求 URL:
/api/blacklists/$id/lists/$id
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息: 参见黑名单信息说明。
- 返回值:
状态 | 返回值 |
---|---|
成功 | "code": 200 |
失败 | "code": 500 |
- 示例:
Body:
{ "k": "test", "v": "1008" }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"k":"test","v": "1008"}' \ "http://192.168.1.100:8081/api/blacklists/1/lists/1502"
返回:
{ "message": "success", "data": "1502", "code": 200 }
批量修改名单下的号码列表
- 请求 URL:
/api/blacklists/$id/multimodify
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息: 参见黑名单信息说明。
- 返回值:
状态 | 返回值 |
---|---|
成功 | 返回最后一个修改值信息 |
失败 | "code": 500 |
- 示例:
参数 | 说明 |
---|---|
k | 名称 |
v | 号码数 |
id | id 为号码列表的id,必填项 |
Body:
{ "data": [ { "k": "xiaoyang", "v": "1003", "id": 1501 }, { "k": "xiaoyang1", "v": "1004", "id": 1502 } ] }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"data":[{"k": "lili","v": "1001"},{"k": "xiaoyang","v": "1003"}]}' \ "http://192.168.1.100:8081/api/blacklists/3/multimodify"
返回:
{ "code": 200, "data": { "disabled": 0, "ref_id": 3, "updated_at": "2022-05-11 20:24:58", "deleted_at": "", "realm": "BLACKLIST", "v": "1003", "created_at": "2022-05-11 20:19:45", "id": 1501, "k": "xiaoyang" }, "message": "success" }
删除黑白名单
- 请求 URL:
/api/blacklists/$id
- 请求方式:
DELETE
- 消息头: 无
- 返回值:
状态 | 返回值 |
---|---|
成功 | "code": 200 |
失败 | 404 |
- 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE http://192.168.1.100:8081/api/blacklists/3
返回:
{ "data": "3", "code": 200, "message": "success" }
删除号码列表
- 请求 URL:
/api/blacklists/$id/lists/$id
- 请求方式:
DELETE
- 消息头: 无
- 返回值:
状态 | 返回值 |
---|---|
成功 | "code": 200 |
失败 | 404 |
- 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE http://192.168.1.100:8081/api/blacklists/4/lists/1120
返回:
{ "message": "success", "code": 200, "data": "1120" }
积木管理
积木管理信息说明如下:
参数 | 说明 |
---|---|
name | 名称 |
description | 描述 |
获取积木
请求 URL:
/api/blocks
返回所有积木信息请求 URL:
/api/blocks/$id
返回指定 ID 的积木信息请求方式:
GET
返回值: 路由 JSON 对象,如果找不到会返回 HTTP 状态码
404
。curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" http://192.168.1.100:8081/api/blocks
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/blocks/1
返回
{ "rowCount": 1, "data": [ { "created_at": "2023-03-16 09:24:38", "description": "办公常用IVR示例", "updated_at": "2023-03-16 09:24:38", "name": "example2", "xml": "<xml xmlns=\"http://www.w3.org/1999/xhtml\">...</xml>", "ivr_menu_id": "", "deleted_at": "", "id": "2", "js": "", "ver": "", "lua": "" } ], "pageCount": 1, "page": 1 }
新建积木
- 请求 URL:
/api/blocks
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见积木信息说明。
Body:
{ "name": "test", "description": "test" }
返回:
{ "code": 200, "message": "success", "data": 3 }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"name": "test","description":"test"}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/blocks"
修改积木
请求 URL:
/api/blocks/$id
请求方式:
PUT
消息头:
Content-Type: application/json
Body 信息: 参见积木信息说明。
示例:
Body:
{ "name": "test", "description": "test" }
返回:
{ "message": "success", "data": "1", "code": 200 }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"name":"test","description": "test"}' \ "http://192.168.1.100:8081/api/blocks/1"
删除积木
- 请求 URL:
/api/blocks/$id
- 请求方式:
DELETE
- 消息头: 无
- 返回值:
状态 | 返回值 |
---|---|
成功 | "code": 200 |
失败 | 404 |
- 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE http://192.168.1.100:8081/api/blocks/3
返回:
{ "data": "3", "code": 200, "message": "success" }
中继管理
该页面默认不显示,如需使用可咨询工作人员。
分配器信息说明如下:
参数 | 说明 |
---|---|
name | 名称 |
type | 类型 |
description | 描述 |
address | 中继地址 |
获取中继
- 请求 URL:
/api/trunks
返回所有中继信息 - 请求方式:
GET
- 请求参数:
名称 | 是否必须 | 描述 |
---|---|---|
page | 可选 | 当前页数 |
perPage | 可选 | 每页显示的个数 |
sortField | 可选 | 排序的关键字字段 |
sortOrder | 可选 | 升序或降序 |
searchField | 可选 | 搜寻的关键字所在字段 |
searchKey | 可选 | 搜寻的关键字 |
- 返回值: 路由 JSON 对象,如果找不到会返回 HTTP 状态码
404
。
{ "pageCount": 1, "rowCount": 1, "data": [ { "description": "123", "params": "", "updated_at": "2022-05-12 10:52:10", "enabled": true, "id": 1, "type": "INOUT", "register": false, "deleted_at": "", "name": "trunk_111", "media_codec": "", "local_addr": "5.5.5.5", "remote_addr": "1.2.3.4", "created_at": "2022-05-12 10:52:10", "protocol": "UDP", "source": "context-2" } ], "page": 1 }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" http://192.168.1.100:8081/api/trunks
请求 URL:
/api/trunks/$ID
返回 ID 的中继信息请求方式:
GET
返回信息
{ "local_addr": "5.5.5.5", "protocol": "UDP", "type": "INOUT", "trunk_groups": [], "description": "123", "name": "trunk_111", "remote_addr": "1.2.3.4", "updated_at": "2022-05-12 10:52:10", "created_at": "2022-05-12 10:52:10", "source": "context-2", "deleted_at": "", "register": false, "media_codec": "", "enabled": true, "id": 1, "params": "" } //Failed HTTP Code 404 { "code": 404, "data": "{}", "message": "not found" }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/trunks/1
新建中继
- 请求 URL:
/api/trunks
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见中继信息说明。
Body:
{ "name": "trunk_111", "description": "123", "remote_addr": "1.2.3.4", "local_addr": "5.5.5.5", "type": "INOUT", "protocol": "UDP", "source": "context-2" }
返回:
{ "message": "success", "code": 200, "data": "1" }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"name": "test","type":"INOUT","protocol":"UDP","description":"test","remote_addr":"sip:192.168.1.100:8081","local_addr":"sip:192.168.1.200:8081"}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/trunks"
删除中继
- 请求 URL:
/api/trunks/$id
- 请求方式:
DELETE
- 消息头: 无
- 返回值:
状态 | 返回值 |
---|---|
成功 | 空 JSON {} |
失败 | 404 |
- 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE http://192.168.1.100:8081/api/trunks/1
返回:
{ "code": 200, "data": "1", "message": "success" }
修改中继
请求 URL:
/api/trunks/$id
请求方式:
PUT
消息头:
Content-Type: application/json
Body 信息: 参见中继信息说明。
示例:
Body:
{ "name": "trunk_111", "description": "12355", "local_addr": "5.5.5.5", "remote_addr": "1.2.3.4", "type": "INOUT", "protocol": "UDP", "source": "context-2" }
返回:
//Success HTTP Code 200 { "code": 200, "data": "1", "message": "success" } //Failed HTTP Code 500 { "data": "{}", "code": 500, "message": "error " }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"name":"trunk_111","description":"12355","local_addr":"5.5.5.5","remote_addr":"1.2.3.4","type":"INOUT","protocol":"UDP"}' \ "http://192.168.1.100:8081/api/trunks/1"
导入中继
- 请求 URL:
/api/trunks/import
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: Body 信息由 excel 文件解析而来,excel 格式与导出格式一致。 key 为 excel 的字段名。
{ "trunks": [ { "中继名称": "trunk_import", "描述": "import desc", "类型": "INOUT", "本地地址": "", "远端地址": "1.2.3.4:9999", "协议": "UDP", "是否注册": "f", "呼叫源": "code:from", "是否启用": "t", "参数": "{}" } //... ] }
- 返回数据
{ "code": 200, "data": [ { "params": "{}", "deleted_at": "", "enabled": "t", "updated_at": "2022-05-12 10:57:58", "name": "trunk_import", "created_at": "2022-05-12 10:57:58", "type": "INOUT", "register": "f", "protocol": "UDP", "media_codec": "", "id": "2", "source": "code:from", "remote_addr": "1.2.3.4:9999", "description": "import desc", "local_addr": "" } ], "message": "success" }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"trunks":[{"中继名称":"trunk_import","描述":"import desc","类型":"INOUT","本地地址":"","远端地址":"1.2.3.4:9999","协议":"UDP","是否注册":"f","呼叫源":"code:from","是否启用":"t","参数":"{}"}]}' \ "http://192.168.1.100:8081/api/trunks/import"
中继组管理
获取中继组
- 请求 URL:
/api/trunk_groups
返回所有中继组信息 - 请求方式:
GET
- 请求参数:
名称 | 是否必须 | 描述 |
---|---|---|
page | 可选 | 当前页数 |
perPage | 可选 | 每页显示的个数 |
sortField | 可选 | 排序的关键字字段 |
sortOrder | 可选 | 升序或降序 |
searchField | 可选 | 搜寻的关键字所在字段 |
searchKey | 可选 | 搜寻的关键字 |
- 返回值: 路由 JSON 对象,如果找不到会返回 HTTP 状态码
404
。
{ "pageCount": 1, "page": 1, "rowCount": 1, "data": [ { "strategy": "RR", "created_at": "2022-05-12 10:59:19", "description": "desc", "id": 100, "params": "", "updated_at": "2022-05-12 10:59:19", "deleted_at": "", "name": "t_group9" } ] }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" http://192.168.1.100:8081/api/trunk_groups
获取指定中继组
请求 URL:
/api/trunks/$id
返回指定 ID 的中继信息请求方式:
GET
返回信息
//Sucess HTTP Code 200 { "description": "desc", "created_at": "2022-05-12 10:59:19", "id": 100, "name": "t_group9", "deleted_at": "", "strategy": "RR", "params": "", "updated_at": "2022-05-12 10:59:19", "route_codes": [] } //Failed HTTP Code 404 { "data": "{}", "message": "not found", "code": 404 }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/trunk_groups/100
获取中继状态
- 请求 URL:
/api/trunk_groups/status
返回所有中继组信息 - 请求方式:
GET
- 请求参数:
名称 | 是否必须 | 描述 |
---|---|---|
page | 可选 | 当前页数 |
perPage | 可选 | 每页显示的个数 |
- 返回值: 路由 JSON 对象,如果找不到会返回 HTTP 状态码
404
。
{ "pageCount": 1, "rowCount": 4, "page": 1, "data": [{ "description": "", "group_name": "", "status": "Active", "group_id": "134", "priority": "0", "remote_addr": "sip:10.11.120.168:5061;transport=UDP", "dflags": "AX", "ping": "disabled", "flags": "0", "attrs": "cc=1;" }, { "description": "", "group_name": "avaya", "status": "Active", "group_id": "23", "priority": "0", "remote_addr": "sip:10.11.244.46;transport=UDP", "dflags": "AX", "ping": "disabled", "flags": "0", "attrs": "cc=1;" }, { "description": "", "group_name": "avaya", "status": "Active", "group_id": "23", "priority": "0", "remote_addr": "sip:10.11.244.45;transport=UDP", "dflags": "AX", "ping": "disabled", "flags": "0", "attrs": "cc=1;" }, { "description": "", "group_name": "Media-Server", "status": "Active", "group_id": "1", "priority": "0", "remote_addr": "sip:192.168.208.3:10080;transport=UDP", "dflags": "AX", "ping": "disabled", "flags": "0", "attrs": "cc=1;" }]
其中中继状态status
的状态值有active
、inactive
、trying
、disabled
等值,ping
的值有enabled
和disabled
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" http://192.168.1.100:8081/api/trunk_groups/status
新建中继组
- 请求 URL:
/api/trunk_groups
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见中继信息说明。
Body:
{ "name": "t_group9", "description": "desc", "strategy": "RR" }
返回:
{ "data": "100", "message": "success", "code": 200 }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{ "name": "t_group9", "description": "desc", "strategy": "RR" }' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/trunks"
删除中继组
- 请求 URL:
/api/trunk_groups/$id
- 请求方式:
DELETE
- 消息头: 无
- 返回值:
状态 | 返回值 |
---|---|
成功 | 空 JSON {} |
失败 | 404 |
- 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE http://192.168.1.100:8081/api/trunk_groups/100
返回:
{ "data": "100", "message": "success", "code": 200 }
修改中继组
请求 URL:
/api/trunk_groups/$id
请求方式:
PUT
消息头:
Content-Type: application/json
Body 信息: 参见中继信息说明。
示例:
Body:
{ "name": "trunk goup2", "description": "gggggggggggggggggg", "strategy": "WEIGHT", "id": "22" }
返回:
//Success HTTP Code 200 {"id":"22"} //Failed HTTP Code 500 {}
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{ "name": "trunk goup2", "description": "gggggggggggggggggg", "strategy": "WEIGHT", "id": "22" }' \ "http://192.168.1.100:8081/api/trunks/1"
热线号码(DID)
热线号码信息说明如下:
参数 | 说明 |
---|---|
line_number | DID号码(外线号码) |
numbers | 对应分机号码 |
type | 业务类型,该参数暂时不启用,不需要填写 |
ref_id | 和业务类型关联 ID,该参数暂时不启用,不需要填写 |
获取热线号码
请求 URL:
/api/hotlines?page=1&perPage=1000
按分页返回所需 DID 信息请求 URL:
/api/hotlines?numbers=1001
支持按分机号码查询请求 URL:
/api/hotlines?page=1&perPage=10&line_number=12345
支持按线路号码查询请求 URL:
/api/hotlines/$id
返回指定 ID 的 DID 信息请求方式:
GET
返回值: 路由 JSON 对象,如果找不到会返回 HTTP 状态码
404
。curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" http://192.168.1.100:8081/api/hotlines
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" http://192.168.1.100:8081/api/hotlines?numbers=1001
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/hotlines/1
返回:
{ "data": [ { "ref_id": "", "deleted_at": "", "numbers": "1001", "updated_at": "2023-03-18 08:53:47", "description": "", "id": "1", "created_at": "2023-03-18 08:53:47", "line_number": "6753997", "type": "" } ], "pageCount": 1, "page": 1, "rowCount": 1 }
新建热线号码
- 请求 URL:
/api/hotlines
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见信息说明。
Body:
{ "numbers": "1005", "line_number": "6553998" }
返回:
{ "code": 200, "message": "success", "data": 5 }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"numbers": "1005","line_number": "6553998"}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/hotlines"
修改热线号码
请求 URL:
/api/hotlines/$id
请求方式:
PUT
消息头:
Content-Type: application/json
Body 信息: 参见信息说明。
示例:
Body:
{ "numbers": "1009", "line_number": "6553998" }
返回:
{ "data": "1", "message": "success", "code": 200 }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"numbers": "1009", "line_number": "6553998"}' \ "http://192.168.1.100:8081/api/hotlines/1"
删除热线号码
- 请求 URL:
/api/hotlines/$id
- 请求方式:
DELETE
- 消息头: 无
- 返回值:
状态 | 返回值 |
---|---|
成功 | "code": 200 |
失败 | 404 |
- 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE http://192.168.1.100:8081/api/hotlines/1
返回:
{ "data": "1", "message": "success", "code": 200 }
DOD
DOD 号码信息说明如下:
参数 | 说明 |
---|---|
extn_id | 分机 ID |
extn | 分机号码 |
line_number | 线路号码 |
type | GATEWAY 或 DISTRIBUTORS,网关或分配器 |
ref_id | 网关或分配器 ID |
name | 网关或分配器名称 |
获取 DOD 列表
请求 URL:
/api/dods
返回 DOD 信息请求 URL:
/api/dods?extn=1001
支持按分机号码查询请求 URL:
/api/dods?page=1&perPage=10&line_number=12345
支持按线路号码查询请求 URL:
/api/dods/$id
返回指定 ID 的 DOD 信息请求方式:
GET
返回值: 路由 JSON 对象,如果找不到会返回 HTTP 状态码
404
。curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" http://192.168.1.100:8081/api/dods
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" http://192.168.1.100:8081/api/dods?page=1&perPage=10&line_number=12345
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/dods/1
返回:
{ "data": [ { "name": "example", "id": "1", "type": "GATEWAY", "extn_id": "3", "created_at": "2023-03-18 09:00:31", "line_number": "86201858", "updated_at": "2023-03-18 09:00:31", "deleted_at": "", "extn": "1001", "ref_id": "1" } ], "page": 1, "rowCount": 1, "pageCount": 1 }
新建 DOD 号码
- 请求 URL:
/api/dods
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见 DOD 信息说明。
Body:
{ "line_number": "6553998", "extn": "1005", "type": "GATEWAY", "name": "example" }
返回:
{ "data": 3, "message": "success", "code": 200 }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"type": "GATEWAY","extn": "1005","line_number": "6553998","name": "example" }' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/dods"
批量导入DOD
通过 Excel 文件导入DOD。
- 请求 URL:
/api/dods/import
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息:
Body 信息由 Excel 文件解析而来,Excel 格式与导出格式一致。 key 为 Excel 的字段名。
{ "dods": [ { "分机": "1001", "线路号码": "12345688", "资源类型": "GATEWAY", "资源名": "example" }, { "分机": "1000", "线路号码": "56799999", "资源类型": "GATEWAY", "资源名": "example" } ] }
- 返回值:
{ "message": "success", "code": 200, "data": [ { "type": "GATEWAY", "extn": "1001", "extn_id": 3, "line_number": "12345688", "id": 4, "ref_id": 1, "updated_at": "2024-07-12 08:08:51", "name": "example", "deleted_at": "", "created_at": "2024-07-12 08:08:51" }, { "type": "GATEWAY", "extn": "1000", "extn_id": 2, "line_number": "56799999", "id": 5, "ref_id": 1, "updated_at": "2024-07-12 08:08:51", "name": "example", "deleted_at": "", "created_at": "2024-07-12 08:08:51" } ] }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"dods":[{"分机": "1001","线路号码": "12345688","资源类型": "GATEWAY","资源名": "example"},{"分机": "1000","线路号码": "56799999","资源类型": "GATEWAY","资源名": "example"}]}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/dods/import"
修改 DOD 号码
请求 URL:
/api/dods/$id
请求方式:
PUT
消息头:
Content-Type: application/json
Body 信息: 参见 DOD 信息说明。
示例:
Body:
{ "name": "gw2" }
返回:
{ "data": "3", "code": 200, "message": "success" }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"name": "gw2"}' \ "http://192.168.1.100:8081/api/dods/1"
删除 DOD 号码
请求 URL:
/api/dods/$id
请求方式:
DELETE
消息头: 无
返回值:
示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE http://192.168.1.100:8081/api/dods/1
返回:
{ "data": "1", "message": "success", "code": 200 }
IP黑名单
IP黑名单说明如下:
参数 | 说明 |
---|---|
target_ip | 限制源IP地址 |
target_name | 名称 |
target_port | 限制端口 |
target_protocol | 协议 |
获取IP黑名单
请求 URL:
/api/iptables
返回被限制的ip及端口等信息请求方式:
GET
返回值: 路由 JSON 对象,如果找不到会返回 HTTP 状态码
404
。curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" http://192.168.1.100:8081/api/iptables
返回
{ "code": 200, "message": "success", "data": [ { "chain": "-A", "rule_spec": "INPUT -s 1.1.21.12/32 -p udp -m udp --dport 21345 -m comment --comment test -j DROP" }, { "chain": "-A", "rule_spec": "INPUT -s 1.1.1.12/32 -p udp -m udp --dport 2345 -m comment --comment test -j DROP" } ] }
新建IP黑名单
- 请求 URL:
/api/iptables/add_rule
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见IP黑名单信息说明。
Body:
{ "target_ip": "1.1.21.12", "target_name": "test", "target_port": "21345", "target_protocol": "udp" }
返回:
{ "code": 200, "data": true, "message": "success" }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"target_ip": "1.1.21.12","target_name": "test","target_port": "21345","target_protocol": "udp"}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/iptables/add_rule"
删除IP黑名单
- 请求 URL:
/api/iptables/clean_drop_rule
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见IP黑名单信息说明。
Body:
{ "target_ip": "1.1.21.12", "target_name": "test", "target_port": "21345", "target_protocol": "udp" }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"target_ip": "1.1.21.12","target_name": "test","target_port": "21345","target_protocol": "udp"}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/iptables/clean_drop_rule"
返回:
{ "code": 200, "data": true, "message": "success" }
号码变换表
号码变换表信息说明如下:
参数 | 说明 |
---|---|
name | 名称-必填 |
description | 描述 |
type | 类型 exact:严格匹配, prefix:前缀匹配 必填 |
参数 | 说明 |
---|---|
nts_number | 新号码 |
original_number | 原始号码 |
获取号码变换表
请求 URL:
/api/number_translation
返回所有黑名单信息请求 URL:
/api/number_translation/$id
返回指定 ID 的黑名单信息请求方式:
GET
返回值: 路由 JSON 对象,如果找不到会返回 HTTP 状态码
404
。curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" http://192.168.1.100:8081/api/number_translation
返回:
{ "page": 1, "rowCount": 2, "pageCount": 1, "data": [ { "updated_at": "2024-07-12 14:42:10", "id": "4", "created_at": "2024-07-12 06:21:05", "deleted_at": "", "description": "test", "type": "prefix", "name": "test1" }, { "updated_at": "2024-07-12 06:20:10", "id": "3", "created_at": "2024-07-12 06:20:10", "deleted_at": "", "description": "", "type": "exact", "name": "test2" } ] }
获取指定号码变换表下号码信息
请求 URL:
/api/number_translation/$id/numbers
返回所有黑名单信息请求方式:
GET
返回值: 路由 JSON 对象,如果找不到会返回 HTTP 状态码
404
。curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" http://192.168.1.100:8081/api/number_translation/3/numbers
返回:
{ "nts_numbers": { "data": [ { "created_at": "2024-07-12 07:14:42", "nts_number": "81002", "deleted_at": "", "original_number": "1002", "updated_at": "2024-07-12 07:14:42", "id": "2" }, { "created_at": "2024-07-12 07:14:34", "nts_number": "91001", "deleted_at": "", "original_number": "1001", "updated_at": "2024-07-12 07:14:34", "id": "1" } ], "rowCount": 2, "pageCount": 1, "page": 1 }, "number_translation_info": [ { "name": "test2", "description": "", "type": "exact" } ] }
新建号码变换表
- 请求 URL:
/api/number_translation
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见号码变换表信息说明。
Body:
{ "name": "test", "type": "exact" }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"name": "test","type":"exact"}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/number_translation"
返回:
{ "message": "success", "code": 200, "data": 3 }
新建号码列表
- 请求 URL:
/api/number_translation/$id/numbers
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见黑名单信息说明。
Body:
{ "original_number": "10001", "nts_number": "901001" }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '{"original_number": "10001","nts_number": "901001"}' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/number_translation/1/numbers"
返回:
{ "code": 200, "data": 2, "message": "success" }
指定号码变换表下批量新建号码列表
- 请求 URL:
/api/number_translation/$id/import
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见号码变换表信息说明。
Body:
[ { "nts_number": "10001", "original_number": "901001" }, { "nts_number": "1002", "original_number": "811002" } ]
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 69ee9c54-734b-11e7-a262-b5df20245f60" \ -d '[{"nts_number": "10001","original_number": "901001"},{"nts_number": "1002","original_number": "811002"}]' \ -H "Content-Type: application/json" "http://192.168.1.100:8081/api/number_translation/6/import"
返回:
{ "code": 200, "data": 6, "message": "success" }
修改号码变换表
- 请求 URL:
/api/number_translation/$id
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息: 仅支持修改name(名称)和description(描述)
- 返回值:
状态 | 返回值 |
---|---|
成功 | "code": 200 |
失败 | -ERR Cannot execute script |
- 示例:
Body:
{ "name": "test01", "description": "test01" }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"name":"test","description": "test","id":"1"}' \ "http://192.168.1.100:8081/api/number_translation/2"
返回:
{ "code": 200, "data": "2", "message": "success" }
修改变换表中变换号码数值
- 请求 URL:
/api/number_translation/$id/$nts_id
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息: 参见号码变换表信息说明。
- 返回值:
状态 | 返回值 |
---|---|
成功 | "code": 200 |
失败 | "code": 500 |
- 示例:
Body:
{ "nts_number": "1112", "original_number": "1004" }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"k":"test","v": "1008"}' \ "http://192.168.1.100:8081/api/number_translation/1/6"
返回:
{ "message": "success", "data": "6", "code": 200 }
删除号码变换表
- 请求 URL:
/api/number_translation/$id
- 请求方式:
DELETE
- 消息头: 无
- 返回值:
状态 | 返回值 |
---|---|
成功 | "code": 200 |
失败 | 404 |
- 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE http://192.168.1.100:8081/api/number_translation/3
返回:
{ "data": "3", "code": 200, "message": "success" }
删除号码变换表中某号码
- 请求 URL:
/api/number_translation/$id/$nts_id
- 请求方式:
DELETE
- 消息头: 无
- 返回值:
状态 | 返回值 |
---|---|
成功 | "code": 200 |
失败 | 404 |
- 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE http://192.168.1.100:8081/api/number_translation/4/2
返回:
{ "message": "success", "code": 200, "data": "2" }
外呼
外呼接口支持两种参数请求方式,URL 字符串(www-form-urlencoded
)方式和 JSON 方式。如:
curl -XPOST -d destNumber=1000 192.168.1.100:8081/api/channels
或:
curl -XPOST -H 'Content-Type: application/json' \ -d '{"destNumber": "1000"}' "192.168.1.100:8081/api/channels"
默认外呼后 Channel 会进入 Park 状态。如果想外呼后执行其它动作,需要执行一个 App。如,外呼后播放音乐:
curl -XPOST -d "destNumber=1000&app=playback&args=/wav/vacation.wav" \ "192.168.1.100:8081/api/channels"
返回值: uuid 为 Channel 的 UUID。如:
{ "result": "ok", "uuid": "2119feac-4cb5-499d-b5e8-6a39e2830ec0" }
注意: 复杂的功能只能通过 JSON 方式请求,如,需要执行多个 App 的情况。
参数说明
参数 | 说明 |
---|---|
app | 呼叫成功后本端需要执行的 App(见 APP 列表) |
args | App 的参数 |
autoAnswer | 呼叫账号是否自动应答 |
earlyMedia | 默认值:true。取值为 true 或 false。当 earlyMedia 为 false 时,API 直到对应回 EarlyMedia(SIP 的 183 或 200)时才返回 |
cidName | 对外显示的主叫名称 |
cidNumber | 对外显示的主叫号码 |
destNumber | 被叫号码 |
userGateway | 用户网关 |
async | 默认值为 false。值为 true 是使用异步方式调用 API,呼叫立即返回,但无呼叫结果 |
以下参数仅支持 JSON 格式:
- apps: 多个 App 列表
App 与 Args 列表
参数 | 说明 |
---|---|
playback($file) | 播放指定文件 |
transfer($destNumber) | 转移到某号码(重新路由) |
bridge($dialstr) | 桥接到某一呼叫字符串 |
呼叫分机再转外线
呼叫分机再转外线,坐席话机自动应答
curl -XPOST -d "autoAnswer=true&destNumber=1000&app=transfer&args=186xxxxxxxx" 192.168.1.100:8081/api/channels
如果为 JSON 内容格式如下:
{ "autoAnswer": "true", "destNumber": "1000", "app": "transfer", "args": "186xxxxxxxx" }
呼叫分机再转外线(录音)
curl -XPOST -H "Content-Type: application/json" -d $JSON 192.168.1.100:8081/api/channels
其中 JSON 内容格式如下:
{ "autoAnswer": "true", "destNumber": "1000", "apps": [ { "app": "set", "args": "RECORD_ANSWER_REQ=true" }, { "app": "record_session", "args": "/tmp/test.wav" }, { "app": "transfer", "args": "186xxxxxxxx" } ] }
用户网关外呼
用户网关外呼然后播放文件
curl -XPOST -d "destNumber=8000&userGateway=5005&app=playback&args=/tmp/test.wav" 192.168.1.100:8081/api/channels
其中 JSON 内容格式如下:
{ "destNumber": "8000", "userGateway": "5005", "app": "playback", "args": "/tmp/test.mp3" }
三方通话
- 请求 URL:
/api/channels
- 请求方式:
POST
参数 | 说明 |
---|---|
destNumber | 被叫号码 |
app | three_way,三方通话 |
args | 原通话 UUID |
curl -XPOST -d "destNumber=1000&app=three_way&args=12srsf-dcsdfxxxxxxxx" 192.168.1.100:8081/api/channels
如果为 JSON 内容格式如下:
{ "app": "three_way", "destNumber": "1007", "args": "channeluuid" }
返回:
{ "result": "ok", "uuid": "664160d7-787a-412e-aff3-f17c6862ae27" }
监听
- 请求 URL:
/api/channels
- 请求方式:
POST
curl -XPOST -d "destNumber=1000&app=eavesdrop&args=12srsf-dcsdfxxxxxxxx" 192.168.1.100:8081/api/channels
如果为 JSON 内容格式如下:
{ "app": "eavesdrop", //监听 "destNumber": "1007", //被叫号码 "args": "channeluuid" //原通话UUID }
强插
在响铃的过程中,采用强插的方式进行抢接。
- 请求 URL:
/api/channels
- 请求方式:
POST
curl -XPOST -d "destNumber=1000&app=eavesdrop&args=12srsf-dcsdfxxxxxxxx" 192.168.1.100:8081/api/channels
如果为 JSON 内容格式如下:
{ "app": "intercept", //强插 "destNumber": "1007", //被叫号码 "args": "channeluuid" //原通话UUID }
强拆/挂机
在响铃的过程中,采用强插的方式进行抢接。url 中带着需要挂机的 UUID。
- 请求 URL:
/api/channels/$channel_uuid
- 请求方式:
DELETE
curl -XDELETE -H "X-XTRA-AUTH-ID: cde1f2e1-4930-41c1-a883-0bca35de7ea6" 192.168.1.100:8081/api/channels/018bf099-7d93-7274-b75c-5686e037456b
通话事件通知
由mod_ai
模块 提供来电、接听、挂机事件推送到业务平台功能。 10.10.10.10 为 接收服务器地址
- 配置推送目的 URL:
post-event-url
。
<configuration name="ai.conf" description="HT-TAPI Hypertext Telephony API"> <settings> <param name="debug" value="true"/> <param name="file-not-found-expires" value="300"/> <param name="file-cache-ttl" value="300"/> <param name="post-event-url" value="http://10.10.10.10"/> ...
- 呼入需配置执行触发事件通知的 APP
<extension name="ai"> <condition field="destination_number" expression="^(10[01][0-9])$"> <action application="set" data="execute_on_originate=ai_channel_state_originate"/> <action application="set" data="execute_on_ring=ai_channel_state_ring"/> <action application="set" data="execute_on_media=ai_channel_state_media"/> <action application="set" data="execute_on_answer=ai_channel_state_answer"/> <action application="bridge" data="user/$1"/> </condition> </extension>
- 事件类型
来电或正在呼出: Answer-State
为 ringing
或 early
。
{ "Event-Subclass": "ai::channel-state", "Event-Name": "CUSTOM", "Core-UUID": "ced11ed6-aab7-11e8-89ea-9985022773cf", "FreeSWITCH-Hostname": "host", "FreeSWITCH-Switchname": "host", "FreeSWITCH-IPv4": "192.168.1.100", ... "Channel-Presence-ID": "1002@192.168.1.100", "Channel-Call-UUID": "52b0fda2-ac57-11e8-a827-9985022773cf", "Answer-State": "early", "Channel-Read-Codec-Name": "PCMA", "Channel-Read-Codec-Rate": "8000", ... }
接听: Answer-State
为 answered
。
{ "Event-Subclass": "ai::channel-state", "Event-Name": "CUSTOM", "Core-UUID": "ced11ed6-aab7-11e8-89ea-9985022773cf", "FreeSWITCH-Hostname": "host", "FreeSWITCH-Switchname": "host", "FreeSWITCH-IPv4": "192.168.1.100", ... "Unique-ID": "52b0fda2-ac57-11e8-a827-9985022773cf", "Call-Direction": "inbound", "Presence-Call-Direction": "inbound", "Channel-HIT-Dialplan": "true", "Channel-Presence-ID": "1002@192.168.1.100", "Channel-Call-UUID": "52b0fda2-ac57-11e8-a827-9985022773cf", "Answer-State": "answered", "Channel-Read-Codec-Name": "PCMA", "Channel-Read-Codec-Rate": "8000", ... }
挂机: Answer-State
为 hangup
。
{ "Event-Subclass": "ai::channel-state", "Event-Name": "CUSTOM", "Core-UUID": "ced11ed6-aab7-11e8-89ea-9985022773cf", "FreeSWITCH-Hostname": "host", "FreeSWITCH-Switchname": "host", "FreeSWITCH-IPv4": "192.168.1.100", ... "Call-Direction": "inbound", "Presence-Call-Direction": "inbound", "Channel-HIT-Dialplan": "true", "Channel-Presence-ID": "1002@192.168.1.100", "Channel-Call-UUID": "52b0fda2-ac57-11e8-a827-9985022773cf", "Answer-State": "hangup", "Hangup-Cause": "NORMAL_CLEARING", ... "Channel-Write-Codec-Bit-Rate": "64000", "Caller-Direction": "inbound", "Caller-Logical-Direction": "inbound", "Caller-Username": "1002", "Caller-Dialplan": "XML", ... }
呼叫相关接口
获取通话 Channel 信息
- 请求 URL:
/api/channels
- 请求方式:
GET
- curl 示例:
curl -X GET \ http://192.168.3.59:8081/api/channels \ -H 'X-XTRA-AUTH-ID: 4c377997-52f5-4812-abd5-e33bf12a4fb2' \
- 返回(示例):
[ { "uuid": "cfd41551-bec3-4fc6-bca0-c1a07784f207", "direction": "inbound", "created": "2022-05-18 14:09:00", "created_epoch": "1652854140", "name": "sofia/default/1003@192.168.3.222", "state": "CS_EXECUTE", "cid_name": "1003", "cid_num": "1003", "ip_addr": "192.168.3.192", "dest": "1001", "application": "bridge", "application_data": "{origination_callee_id_name=1001}user/1001", "dialplan": "XML", "context": "context-1", "read_codec": "PCMA", "read_rate": "8000", "read_bit_rate": "64000", "write_codec": "PCMA", "write_rate": "8000", "write_bit_rate": "64000", "secure": "", "hostname": "bob", "presence_id": "1003@192.168.3.222", "presence_data": "", "accountcode": "1003", "callstate": "ACTIVE", "callee_name": "1001", "callee_num": "1001", "callee_direction": "SEND", "call_uuid": "cfd41551-bec3-4fc6-bca0-c1a07784f207", "sent_callee_name": "1001", "sent_callee_num": "1001", "initial_cid_name": "1003", "initial_cid_num": "1003", "initial_ip_addr": "192.168.3.192", "initial_dest": "1001", "initial_dialplan": "XML", "initial_context": "context-1" }, { "uuid": "eb5ef9ee-16f0-4b39-8d00-ae442a33381b", "direction": "outbound", "created": "2022-05-18 14:09:00", "created_epoch": "1652854140", "name": "sofia/default/1001@192.168.3.192:53357", "state": "CS_EXCHANGE_MEDIA", "cid_name": "1003", "cid_num": "1003", "ip_addr": "192.168.3.192", "dest": "1001", "application": "", "application_data": "", "dialplan": "XML", "context": "context-1", "read_codec": "PCMA", "read_rate": "8000", "read_bit_rate": "64000", "write_codec": "PCMA", "write_rate": "8000", "write_bit_rate": "64000", "secure": "", "hostname": "bob", "presence_id": "1001@demo.xswitch.cn", "presence_data": "", "accountcode": "", "callstate": "ACTIVE", "callee_name": "1001", "callee_num": "1001", "callee_direction": "SEND", "call_uuid": "cfd41551-bec3-4fc6-bca0-c1a07784f207", "sent_callee_name": "1003", "sent_callee_num": "1003", "initial_cid_name": "1003", "initial_cid_num": "1003", "initial_ip_addr": "192.168.3.192", "initial_dest": "1001", "initial_dialplan": "XML", "initial_context": "context-1" } ]
静音接口
- 请求 URL:
/api/channels/$uuid
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息:
名称 | 说明 |
---|---|
action | 此接口固定为 deaf |
deaf | on:开启静音,off:关闭静音 |
Body:
{ "action": "deaf", "deaf": "on" }
成功返回:
{ "msg": "ok", "code": 200 }
失败返回:
{ "code": 400, "reason": "missing mute param in json body" }
录屏接口
- 请求 URL:
/api/channels/$uuid
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息:
名称 | 说明 |
---|---|
action | 此接口固定为 record |
record | on:开启录屏,off:关闭录屏 |
file_name | 录屏文件名称,以.mp4 结尾 |
Body:
{ "action": "record", "record": "on", "file_name": "test.mp4" }
成功返回:
{ "msg": "ok", "file": "/usr/local/freeswitch/storage/recordings/test.mp4", "code": 200 }
成功时返回消息内携带的file
为录屏文件在容器内详细信息
失败返回:
{ "reason": "record param should be on or off", "code": 400 }
截图接口
- 请求 URL:
/api/channels/$uuid
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息:
名称 | 说明 |
---|---|
action | 此接口固定为 snapshot |
png_name | 截屏文件名称 |
Body:
{ "action": "snapshot", "png_name": "test.png" }
成功返回:
{ "msg": "ok", "code": 200 }
失败返回:
{ "msg": "Could not locate session.", "code": 404 }
截屏产生的文件存储在容器内/usr/local/freeswitch/storage/snapshot
下