REST API文档
用户管理
用户
用户指人,可以登录到系统 Web 界面,或拥有一次资源(如分机)、操作权限等。
用户信息说明如下:
字段 | 必选 | 类型 | 备注 |
---|---|---|---|
id | 否 | string | 用户 ID,自动生成 |
login | 是 | string | 登录名,必填 |
name | 是 | string | 姓名 |
password | 是 | string | 密码 |
extn | 否 | string | 默认分机号 |
cid_name | 否 | string | 主叫名称,默认为$name |
cid_number | 否 | string | 主叫号码,默认为$extn |
context | 否 | string | 呼叫源,默认为context-1 |
domain | 否 | string | 域,多租户中必选 |
vm_password | 否 | string | VoiceMail 密码 |
否 | string | EMAIL,暂未用 | |
type | 否 | string | 用户类型,参加下面用户类型列表 |
tel | 否 | string | 关联的手机号 |
auto_record | 否 | init | 是否自动录音,默认为否 0,开启为 1 |
disabled | 否 | init | 禁止登录,分机失效 ,默认为 0, 禁用为 1 |
agent_info | 是 | JSONB | 当用户类型为坐席时,初始化坐席相关参数。默认为'{}' |
tel_enabled | 是 | init | 默认为 0 |
salt | 否 | string | 加盐 |
sha1 | 否 | string | sha1 加密后的值 |
is_super | 是 | init | 默认为 0 |
extn_id | 否 | init | 选择创建分机时,会向 extenion 中新增一条分机数据,该字段为分机 id |
last_login_at | 否 | timestamp | 只读,最后一次登录时间 |
created_at | 否 | timestamp | 只读,创建时间 |
updated_at | 否 | timestamp | 只读,最后更新时间 |
deleted_at | 否 | timestamp | 只读,删除时间 |
login_attempts | 否 | int | 登录尝试次数,默认 0,超过 5 次后会锁定 |
is_locked | 否 | int | 是否锁定,默认 0,1 为锁定 |
is_admin | 否 | int | 是否为管理员,默认 0,1 为管理员 |
first_login | 否 | timestamp | 只读,首次登录时间 |
last_login_attempt_at | 否 | timestamp | 只读,最后一次登录时间 |
idle_timeout | 否 | int | 只读,通话挂断后的最大通话时间,单位秒 |
NORMAL
:普通用户AGENT
:坐席,在呼叫中心中使用,坐席具有普通用户所有的权限CONFMAN
:会议管理员,能管理会议,具有普通用户所有的权限
特别注意
所有涉及密码的接口数据请自行修改为复杂密码,防止因为密码过于简单导致系统被攻击。
创建用户同时创建用户分机
创建用户信息说明如下:
字段 | 必选 | 类型 | 备注 |
---|---|---|---|
login | 是 | string | 登录名,必填 |
name | 是 | string | 姓名,必填 |
password | 是 | string | 密码,必填,由大写字母+小写字母+数字+特殊符号组成,且在 8-20 位之间 |
type | 否 | string | 用户类型,默认为NORMAL |
带有分机号用户信息说明如下:
字段 | 必选 | 类型 | 备注 |
---|---|---|---|
extn | 是 | string | 默认分机号或指定分机号码 |
context | 是 | string | 呼叫源,必填 |
extn_password | 是 | string | 分机号密码,必填,由大写字母+小写字母+数字组成,且在 8-20 位之间 |
mac_address | 否 | string | 分机 MAC 地址 |
extn_type | 否 | string | 分机类型,SIP WebRTC H323 GATEWAY SIP+WebRTC HK |
- 请求 URL:
/api/users
- 请求 URL:
/api/users/create
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见用户信息说明。如:
{ "login": "cherry", "name": "小樱桃", "password": "123!@#QWEqwe" }
- 返回值:
正常返回一个 JSON Object,data 中只包含id
。
返回字段 | 必选 | 类型 | 备注 |
---|---|---|---|
id | 是 | int | 用户 ID |
如果出错,返回 HTTP 状态码如403
、500
等,详见HTTP 状态码参考及JSON 返回格式参考相关内容。
- 其它说明:无
- curl 示例:
curl -0 -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"login":"cherry","name":"小樱桃","password":"123!@#QWEqwe"}' \ "192.168.0.1:8081/api/users"
或
curl -0 -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"login":"cherry","name":"小樱桃","password":"123!@#QWEqwe"}' \ "192.168.0.1:8081/api/users/create"
返回:
{ "code": 200, "data": 32, "message": "success" }
批量创建用户
批量创建用户信息说明如下:
字段 | 必选 | 类型 | 备注 |
---|---|---|---|
users_start | 是 | string | 开始号码,必填 |
users_end | 是 | string | 结束号码,必填 |
password | 是 | string | 密码,必填,由大写字母+小写字母+数字+特殊符号组成,且在 8-20 位之间 |
type | 否 | string | 用户类型,默认为NORMAL |
extn_password | 否 | string | 分机号密码,可选,若有值,则同时创建分机,由大写字母+小写字母+数字组成,且在 8-20 位之间 |
context | 否 | string | 呼叫源,可选 |
- 请求 URL:
/api/users/muti_add
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见分配器信息说明。
Body:
{ "users_start": 2011, "users_end": 2012, "password": "Xswitch.cn/6753997!Qqa", "type": "NORMAL", "context": "context-1", "extn_password": "123qaQQQ" }
返回:
{ "data": [ { "email": "", "tel_enabled": 0, "login": "2011", "deleted_at": "", "tel": "", "created_at": "2023-03-17 01:02:38", "agent_info": "{}", "updated_at": "2023-03-17 01:02:38", "last_login_at": "", "extn": "2011", "is_super": 0, "auto_record": 0, "type": "NORMAL", "password": "Xswitch.cn/6753997!Qqa", "ha1": "6b2f4520f0f925f8f08c1249e0c178c1", "name": "2011", "context": "context-1", "extn_id": 0, "vm_password": "", "ha1b": "2620139be102567d75de062931e58b15", "domain": "192.168.31.98", "cid_name": "", "id": 44, "cid_number": "" }, { "email": "", "tel_enabled": 0, "login": "2012", "deleted_at": "", "tel": "", "created_at": "2023-03-17 01:02:38", "agent_info": "{}", "updated_at": "2023-03-17 01:02:38", "last_login_at": "", "extn": "2012", "is_super": 0, "auto_record": 0, "type": "NORMAL", "password": "Xswitch.cn/6753997!Qqa", "ha1": "8bf8153d51fb13cba01a85670ac3cbcd", "name": "2012", "context": "context-1", "extn_id": 0, "vm_password": "", "ha1b": "32ce02f6c4daa7580dcc29c63d4cd2d8", "domain": "192.168.31.98", "cid_name": "", "id": 45, "cid_number": "" } ], "code": 200, "message": "success" }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -d '{"users_start": 2011,"users_end": 2012,"password": "Xswitch.cn/6753997!Qqa","type": "NORMAL","extn_password": "123qaQQQ","context":"context-1"}' -H "Content-Type: application/json" "http://192.168.31.98:8081/api/users/muti_add"
批量导入用户
字段 | 必选 | 类型 | 备注 |
---|---|---|---|
登录名 | 是 | string | 登录账号,必填 |
分机 | 否 | string | 用户分机号 |
名称 | 是 | string | 用户姓名,必填 |
密码 | 是 | string | 密码,必填,若配置了 secure_password ,需满足大写字母 + 小写字母 + 数字 + 特殊符号、8 - 20 位等规则(由 check_password 校验 ) |
呼叫源 | 否 | string | 呼叫源信息 |
域 | 是 | string | 所属域,必填 |
类型 | 否 | string | 用户类型 |
超级管理员 | 否 | string | 是否为超级管理员,填 是 或 否 ,会转成 1 或 0 存储 |
- 请求 URL:
/api/users/import
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见用户信息说明:
{ "users": [ { "登录名": "user001", "分机": "1001", "名称": "用户1", "密码": "123!@#QWEqwe", "呼叫源": "context-1", "域": "xswitch.cn", "类型": "NORMAL", "超级管理员": "否" } ] }
返回:
{ "data": [ { "login": "user001", "last_login_at": "", "deleted_at": "", "name": "用户1", "updated_at": "2025-08-18 05:32:03", "created_at": "2025-08-18 05:32:03", "tel_enabled": 0, "is_locked": false, "context": "context-1", "id": 25, "first_login": 0, "last_login_attempt_at": "", "idle_timeout": 60, "login_attempts": 0, "vm_password": "", "salt": "$1$x8DADcaA", "tel": "", "is_admin": false, "password": "123!@#QWEqwe", "agent_info": [], "cid_name": "", "sha1": "\\x42d68f5f4d5dbf62b0173ae44251e1373e06cc8e", "auto_record": 0, "cid_number": "", "email": "", "is_super": 0, "type": "NORMAL", "domain": "xswitch.cn", "extn": "1001" } ], "message": "success", "code": 200 }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" -d '{"users":[{"登录名": "user001","分机": "1001","名称": "用户1","密码": "123!@#QWEqwe","呼叫源": "context-1","域": "xswitch.cn"}]}' "http://192.168.31.98:8081/api/users/import"
批量导入企业微信关联用户
字段 | 必选 | 类型 | 备注 |
---|---|---|---|
userid | 是 | string | 用户唯一标识,必填,将作为 name login extn 的默认值 |
password | 否 | string | 用户密码,选填 |
is_admin | 否 | number | 是否为管理员,选填,0 表示否,1 表示是,默认 false |
context | 否 | string | 呼叫上下文,选填,默认 context-1 |
type | 否 | string | 用户类型,选填,默认 NORMAL |
domain | 否 | string | 所属域,选填,若配置 config.force_domain 则优先使用该配置,否则使用传入值 |
- 请求 URL:
/api/users/qyusers
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 包含 data 数组,数组元素为待导入的用户信息:
{ "data": [ { "userid": "qyuser001", "password": "Qy@123456", "is_admin": 1, "context": "context-2", "domain": "xswitch.cn" } ] }
- 响应示例:
{ "code": 200, "message": "success", "data": [ "qyuser001" ] }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" -d '{"data": [{"userid": "qyuser001","password": "Qy@123456","is_admin": 1,"context": "context-2","domain": "xswitch.cn"}]}' "http://192.168.31.98:8081/api/users/qyusers"
获取用户数量
- 请求 URL:
/api/users/total
- 请求方式:
GET
- 消息头:
Content-Type: application/json
- Body 信息: 无
- 响应示例:
{ "count": 15 }
- curl 示例:
curl -XGET -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" "http://192.168.31.98:8081/api/users/total"
获取网关用户信息
用于获取系统中类型为 GATEWAY 的用户信息及数量
- 请求 URL:
/api/users/gateway
- 请求方式:
GET
- 消息头:
Content-Type: application/json
- Body 信息: 无
- 响应示例:
{ "rowCount": 2, "data": [ { "id": 1, "type": "GATEWAY", "name": "GatewayUser1" }, { "id": 2, "type": "GATEWAY", "name": "GatewayUser2" } ] }
- curl 示例:
curl -0 -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" "http://192.168.31.98:8081/api/users/gateway"
获取当前用户信息
- 请求 URL:
/api/users/info
- 请求方式:
GET
- 消息头:
Content-Type: application/json
- Body 信息: 无
- 响应示例:
{ "vm_password": "", "deleted_at": "", "domain": "xswitch.cn", "login": "admin", "tel": "", "last_login_at": "2025-08-18 00:47:52", "is_super": 1, "cid_number": "", "created_at": "2025-08-08 03:15:20", "cid_name": "", "extn": "admin", "name": "Admin", "salt": "$1$p0htFRHX", "login_attempts": 0, "idle_timeout": 60, "last_login_attempt_at": "", "tel_enabled": 0, "is_locked": false, "context": "context-1", "id": 1, "first_login": 0, "updated_at": "2025-08-18 00:47:52", "is_admin": false, "email": "", "agent_info": [], "auto_record": 0, "type": "" }
- curl 示例:
curl -0 -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" "http://192.168.31.98:8081/api/users/info"
更新指定用户信息
用于更新指定用户(通过 id 标识)的信息,支持常规字段更新及分机号切换(toggle 动作)
字段 | 必选 | 类型 | 备注 |
---|---|---|---|
:id | 是 | string | 用户唯一标识 id |
request | 是 | object | 请求体参数,包含需更新的用户信息(部分字段会被过滤或特殊处理) |
request.action | 否 | string | 操作类型,可选值 toggle(用于切换分机号),不填则为常规更新 |
request.extn_id | 否 | number | 分机 id |
其他用户字段 | 否 | 需更新的用户信息(可选字段) |
- 请求 URL:
/api/users/:id
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息:
{ "name": "新用户名", "type": "AGENT" }
- 响应示例:
{ "message": "success", "code": 200, "data": "5" }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" -d '{"request":{"action":"toggle","extn_id":1}}' "http://192.168.31.98:8081/api/users/5"
获取默认域信息
用于获取系统配置的默认域信息
- 请求 URL:
/api/users/force_domain/default
- 请求方式:
GET
- 消息头:
Content-Type: application/json
- Body 信息: 无
- 响应示例:
{ "force_domain": "xswitch.cn" }
- curl 示例:
curl -0 -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" "http://192.168.31.98:8081/api/users/force_domain/default"
获取指定用户的分机信息
用于获取指定用户(通过 id 标识)的分机列表
- 请求 URL:
/api/users/:id/extensions
- 请求方式:
GET
- 消息头:
Content-Type: application/json
- 响应示例:
[ { "type": "SIP", "call_authority": 4, "extn": "admin", "display_order": "0", "enable_hotline": 0, "hotline_type": "", "boss_extn": false, "created_at": "2025-08-08 03:15:21", "force_insert": 0, "weblogin_disabled": 0, "enable_extn_time_recurrences": 0, "priority": "99", "codec": "", "cid_number": "", "dtmf_type": 0, "enable_t38": 0, "deleted_at": "", "called_limit": 1, "vm_password": "", "caller_display": 1, "ha1": "3737327c84bc4a3627053e431af87ba6", "hotline_address": "", "hotline_number": "", "domain": "xswitch.cn", "intercepted_group_name": "", "extn_cidr": "", "disabled": 0, "updated_at": "2025-08-08 03:15:21", "name": "Admin", "enable_cb_onbusy": 0, "mac_address": "", "ringback": "", "call_limit": 1, "id": 1, "enable_srtp": 0, "timeout": "", "eavesdropped": 0, "forced_breakdown": 0, "eavesdrop": 0, "forced_insert": 0, "context": "context-1", "force_breakdown": 0, "auto_record": 0, "ha1b": "ac7f0950fa459b6779098a090bcc6af6", "call_transfer_type": 0, "sync_enabled": 0, "password": "XSwitch.cn/6753997", "group_name": "", "cid_name": "", "secretary_extn": "", "intercept": 0, "connect_phone": "", "user_id": 1, "intercepted": 0, "description": "", "voicemail": 0, "enable_ringback": 0 } ]
- curl 示例:
curl -0 -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" -X "GET" "http://192.168.31.98:8081/api/users/1/extensions"
获取微信用户信息
用于获取当前登录用户的信息及关联的微信头像信息
- 请求 URL:
/api/users/wechat_info
- 请求方式:
GET
- 消息头:
Content-Type: application/json
- 响应示例:正常返回一个 JSON Object,data 中包含用户信息
{ "salt": "$1$p0htFRHX", "tel_enabled": 0, "id": 1, "domain": "xswitch.cn", "is_admin": false, "updated_at": "2025-08-18 00:47:52", "vm_password": "", "cid_name": "", "auto_record": 0, "created_at": "2025-08-08 03:15:20", "idle_timeout": 60, "last_login_attempt_at": "", "type": "", "is_locked": false, "context": "context-1", "cid_number": "", "first_login": 0, "last_login_at": "2025-08-18 00:47:52", "deleted_at": "", "is_super": 1, "login": "admin", "sha1": "\\xc329e666b2ba4840f7d0c798ad7e9a4a43e98371", "agent_info": [], "email": "", "name": "Admin", "tel": "", "extn": "admin", "login_attempts": 0 }
- curl 示例:
curl -0 -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" -d '' "http://192.168.31.98:8081/api/users/wechat_info"
下载用户信息列表
用于根据筛选条件查询用户信息并生成可下载的表格数据(支持中英文表头)
- 请求 URL:
/api/users/download
- 请求方式:
GET
- 消息头:
Content-Type: application/json
- 响应示例:
[ [ "User ID", "Login Name", "Extension", "Name", "Call Source", "Domain", "Type", "Super Admin", "Password" ], [ "1", "admin", "admin", "Admin", "context-1", "xswitch.cn", "NORMAL", "否" ], [ "2", "1000", "1000", "1000", "context-1", "xswitch.cn", "NORMAL", "否" ], [ "13", "cher", "1234", "小", "context-1", "xswitch.cn", "NORMAL", "否" ], [ "14", "2011", "2011", "2011", "context-1", "xswitch.cn", "NORMAL", "否" ], [ "15", "2012", "2012", "2012", "context-1", "xswitch.cn", "NORMAL", "否" ], ]
获取用户与微信绑定信息
用于获取用户及其关联的微信账号信息
- 请求 URL:
/api/users/bind
- 请求方式:
GET
- 消息头:
Content-Type: application/json
- 响应示例:
[ { "id": 2, "login": "user02", "name": "用户2", "wechat_id": null, "openid": null, "headimgurl": null, "nickname": null } ]
如果出错,返回对应内容: 无操作权限时返回 403 及提示 “no permission” 无数据时返回空数组 []
- curl 示例:
curl -0 -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" -d '' "http://192.168.31.98:8081/api/users/bind"
获取设备密钥信息
用于获取所有密钥信息
- 请求 URL:
/api/users/:id/dev_keys
- 请求方式:
GET
- 消息头:
Content-Type: application/json
- 响应示例:
[ { "k": "0198bbcc-42f9-7ee4-a466-103f54c362ea", "description": "11", "updated_at": "2025-08-18 06:09:43", "deleted_at": "", "created_at": "2025-08-18 06:09:43", "user_id": 5, "id": 1, "enabled": 0 }, { "k": "0198bbe1-cfd8-7242-9b0b-cb2894054c1f", "description": "密钥描述", "updated_at": "2025-08-18 06:33:15", "deleted_at": "", "created_at": "2025-08-18 06:33:15", "user_id": 5, "id": 2, "enabled": 1 } ]
- curl 示例:
curl -0 -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" -d '' "http://192.168.31.98:8081/api/users/5/dev_keys"
获取指定用户关联的微信账号信息
用于获取指定用户(通过 id 标识)关联的微信账号详细信息
- 请求 URL:
/api/users/:id/wechat_users
- 请求方式:
GET
- 消息头:
Content-Type: application/json
- 响应示例:
[ { "id": 5, "openid": "o6_bmjrPTlm6_2sgVt7hMZOPfL2M", "nickname": "微信用户1", "headimgurl": "https://example.com/avatar1.jpg" } ]
无关联微信账号时:
[]
- curl 示例:
curl -0 -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" -d '' "http://192.168.31.98:8081/api/users/5/wechat_users"
获取该坐席分配的队列类型
用于获取指定用户(通过 id 标识)关联的队列信息
- 请求 URL:
/api/users/:id/queue
- 请求方式:
GET
- 消息头:
Content-Type: application/json
- 响应示例:
{ "cti_template": "callcenter" }
- curl 示例:
curl -0 -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" -d '' "http://192.168.31.98:8081/api/users/5/queue"
为用户创建设备密钥
字段 | 必选 | 类型 | 备注 |
---|---|---|---|
:id | 是 | string | 用户 ID,必填 |
description | 否 | string | 密钥描述,选填 |
- 请求 URL:
/api/users/:id/dev_keys
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 包含设备密钥描述(可选)。示例:
{ "description": "密钥描述" }
- 响应示例:
{ "code": 200, "data": { "user_id": 5, "deleted_at": "", "description": "密钥描述", "id": 2, "created_at": "2025-08-18 06:33:15", "enabled": 1, "updated_at": "2025-08-18 06:33:15", "k": "0198bbe1-cfd8-7242-9b0b-cb2894054c1f" }, "message": "success" }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" -d '{"description": "密钥描述"}' "http://192.168.31.98:8081/api/users/qyuser001/dev_keys"
更新用户设备密钥
字段 | 必选 | 类型 | 备注 |
---|---|---|---|
:id | 是 | string | URL 路径参数,用户唯一标识 id,必填 |
:key_id | 是 | string | URL 路径参数,设备密钥唯一标识 key_id,必填 |
action | 否 | string | 请求体参数,操作类型,若为 toggle 则执行切换密钥状态操作;不填则执行更新密钥信息操作 |
其他字段 | 否 | string | 请求体参数,当 action 不填时,为待更新的密钥信息字段(具体字段取决于 m_user.update_dev_key 支持的参数) |
- 请求 URL:
/api/users/:id/dev_keys/:key_id
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息: 包含操作类型或待更新的密钥信息。示例:
{ "action": "toggle" }
- 返回值: 对象,包含更新后的用户信息。示例:
{ "code": 200, "data": { "updated_at": "2025-08-18 06:09:43", "k": "0198bbcc-42f9-7ee4-a466-103f54c362ea", "user_id": 5, "enabled": 0, "created_at": "2025-08-18 06:09:43", "deleted_at": "", "description": "11", "id": 1 }, "message": "success" }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" -d '{"action": "toggle"}' "http://192.168.0.198:18081/api/users/5/dev_keys/1"
删除用户设备密钥
字段 | 必选 | 类型 | 备注 |
---|---|---|---|
:id | 是 | string | 用户id,必填 |
:key_id | 是 | string | 设备密钥key_id,必填 |
- 请求 URL:
/api/users/:id/dev_keys/:key_id
- 请求方式:
DELETE
- 消息头:
Content-Type: application/json
- Body 信息: 无
- 返回值: 对象,包含被删除的密钥key_id。示例:
{ "message": "success", "data": "1", "code": 200 }
- curl 示例:
curl -XDELETE -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" -d '' "http://192.168.0.198:18081/api/users/5/dev_keys/1"
删除用户
- 请求 URL:
/api/users/$id
- 请求方式:
DELETE
- 消息头:无
- 返回值:对象,包含被删除用户的 ID,如
{"id": "3"}
。 - 示例:
curl -0 -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE 192.168.1.100:8081/api/users/3
返回: {"id": "3"}
删除用户
- 请求 URL:
/api/users/delete
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 包含待删除用户 id 的数组。示例:
[1, 2, 3]
- 返回值:正常返回一个 JSON Object,data 中包含删除成功的用户数量:
{ "code": 200, "data": 3, "message": "success" }
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" -d '[1, 2, 3]' 'http://192.168.31.98:8081/api/users/delete'
修改用户信息
- 请求 URL:
/api/users/$id
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息:参见用户信息说明
- 返回值: 对象,包含被修改的用户的 ID,如:
{"id": "3"}
- 示例:
PUT http://192.168.1.100:8081/api/users/3
Body:
{ "login": "36", "name": "36", "vm_password": "36", "domain": "xswitch.cn", "type": "NORMAL", "tel": "123456789", "auto_record": "0", "tel_enabled": "0" }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: applcation/json" -d '{"login": "36","name": "36","vm_password": "36","domain": "xswitch.cn","type": "NORMAL","tel": "1234567890000","auto_record": "0","tel_enabled": "0"}' "192.168.3.16:8081/api/users/49"
返回:
{ "data": "49", "message": "success", "code": 200 }
- 其它说明:
如果在请求参数中包含用户的 ID,则会被忽略。
修改用户密码
- 请求 URL:
/api/users/change_password
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息: 参见用户信息说明
- 返回值:
status 200 OK
- 示例:
PUT http://192.168.1.100:8081/api/users/change_password
Body:
{ "password": "1qazQAZ!@4", "old_password": "1qazQAZ!@5", "domain": "192.168.31.98", "id": "39" }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"id":"39","password":"1qazQAZ!@4","old_password": "1qazQAZ!@5","domain": "192.168.31.98"}' \ "192.168.1.100:8081/api/users/change_password"
返回:
{ "code": 200, "data": "{}", "message": "success" }
获取用户信息
- 请求 URL:
/api/users
返回所有用户 - 请求 URL:
/api/users?
返回所有用户 - 请求 URL:
/api/users?page=1&perPage=10&login=1001&name=张三&type=NORMAL
支持用户名、名称、类型等查询 - 请求 URL:
/api/users/$id
返回指定 ID 的用户 - 请求方式:
GET
- 返回值: 用户对象,如果找不到会返回 HTTP 状态码
404
。
返回值 | 结果 |
---|---|
JSON 字符串 | 成功 |
404 | 失败 |
- 示例:
GET /api/users/1
返回:
{ "extn": "admin", "cid_name": "", "context": "context-1", "ha1b": "747e17632f2443bfdbef0113eba4a266", "name": "Admin", "type": "", "last_login_at": "2022-05-11 09:44:44", "deleted_at": "", "id": 1, "login": "admin", "updated_at": "2022-05-11 09:44:44", "ha1": "fd4500fcb6ccd4ee87d5debac892ac59", "created_at": "2022-05-11 09:43:15", "is_super": 1, "auto_record": 0, "email": "", "tel_enabled": 0, "tel": "", "cid_number": "", "extn_id": 0, "domain": "demo.xswitch.cn", "vm_password": "" }
GET /api/users
返回
{ "data": [ { "cid_number": "", "ha1b": "", "auto_record": 0, "vm_password": "", "domain": "demo.xswitch.cn", "cid_name": "", "extn_id": 0, "extn": "", "tel": "", "deleted_at": "", "updated_at": "2022-05-11 09:43:16", "is_super": 0, "created_at": "2022-05-11 09:43:15", "last_login_at": "", "tel_enabled": 0, "context": "", "name": "SYSTEM", "ha1": "", "login": "system", "email": "", "type": "", "id": 0 }, { "cid_number": "", "ha1b": "747e17632f2443bfdbef0113eba4a266", "auto_record": 0, "vm_password": "", "domain": "demo.xswitch.cn", "cid_name": "", "extn_id": 0, "extn": "admin", "tel": "", "deleted_at": "", "updated_at": "2022-05-11 09:44:44", "is_super": 1, "created_at": "2022-05-11 09:43:15", "last_login_at": "2022-05-11 09:44:44", "tel_enabled": 0, "context": "context-1", "name": "Admin", "ha1": "fd4500fcb6ccd4ee87d5debac892ac59", "login": "admin", "email": "", "type": "", "id": 1 } ], "pageCount": 1, "rowCount": 2, "page": 1 }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/users/1
批量设置用户类型
- 请求 URL:
/api/users/
- 请求方式:
PUT
PUT /api/users/
Body:
{ "type": "AGENT", "idle_timeout": 60, "username": [ "9", "8", "7" ] }
返回值:
{ "code": 200, "data": [], "message": "update rows 3" }
- curl 示例:
curl --location --request PUT 'http://192.168.0.101:8081/api/users/' \ --header 'token: 01906d5e-28a0-7495-aa9f-0fdeb7212878' \ --header 'Content-Type: application/json' \ --header 'Cookie: freeswitch_xtra_session_id=01906d5e-28a0-7495-aa9f-0fdeb7212878' \ --data '{ "type": "AGENT", "idle_timeout": 60, "username": [ "9", "8", "7" ] }'
设置用户下指定分机为默认分机(用户下存在多个分机时)
- 请求 URL:
/api/users/:extnID
- 请求方式:
PUT
GET /api/users/4607
Body:
{ "action": "toggle", "extn_id": 2510 }
返回值:
{ "data": "4607", "message": "success", "code": 200 }
- curl 示例:
curl --location --request PUT 'http://192.168.0.101:8081/api/users/4607' \ --header 'token: 01906d5e-28a0-7495-aa9f-0fdeb7212878' \ --header 'Content-Type: application/json' \ --header 'Cookie: freeswitch_xtra_session_id=01906d5e-28a0-7495-aa9f-0fdeb7212878' \ --data '{ "action": "toggle", "extn_id": 2510 }'
解除用户与微信账号的关联
字段 | 必选 | 类型 | 备注 |
---|---|---|---|
id | 是 | string | 用户ID,必填 |
wechat_user_id | 是 | string | 微信账号ID,必填 |
- 请求 URL:
/api/users/:id/wechat_users/:wechat_user_id
- 请求方式:
DELETE
- 消息头:
Content-Type: application/json
- Body 信息: 无
- 返回值: 返回包含解除关联的微信用户 ID 的 JSON 对象
{ "code": 200, "data": "123", "message": "success" }
- curl 示例:
curl -XDELETE -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" "http://192.168.31.98:8081/api/users/1/wechat_users/123"
获取当前登录用户详情
用于获取当前登录用户的详细信息(包含自定义字段)
- 请求 URL:
/api/users/currentUser
- 请求方式:
GET
- 消息头:
Content-Type: application/json
- 响应示例:正常返回一个 JSON Object,data 中包含用户详情
{ "geographic": { "province": { "key": "256000", "label": "山东省" }, "city": { "key": "264000", "label": "烟台市" } }, "notifyCount": 0, "name": "Admin", "phone": "0535-6753997", "tags": [ { "label": "很有想法的", "key": "0" }, { "label": "专注设计", "key": "1" } ], "address": "烟台市", "userid": 1, "unreadCount": 0, "group": "小樱桃-技术部-UED", "title": "Admin", "email": "", "country": "China", "signature": "海纳百川,有容乃大", "avatar": "/assets/img/sit.png" }
如果出错,返回对应 HTTP 状态码: 无操作权限时返回 403 及提示 “no permission”
用户不存在时返回 404 及提示 “not found”
- curl 示例:
curl -0 -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" "http://192.168.31.98:8081/api/users/currentUser"
获取应用用户列表(分页)
用于分页获取与当前用户同域的用户列表信息
- 请求 URL:
/api/users/app
- 请求 URL:
/api/users/app?page=1&perPage=10
- 请求方式:
GET
- 消息头:
Content-Type: application/json
- 响应示例:正常返回一个 JSON Object,包含分页信息和用户数据列表。
{ "rowCount": 15, "data": [ { "name": "1000", "id": "2", "email": "", "extn": "1000" }, { "name": "1001", "id": "3", "email": "", "extn": "1001" }, { "name": "1234", "id": "19", "email": "", "extn": "1234" }, { "name": "小聪明", "id": "5", "email": "", "extn": "2000" }, { "name": "2011", "id": "14", "email": "", "extn": "2011" }, { "name": "2012", "id": "15", "email": "", "extn": "2012" }, { "name": "2013", "id": "16", "email": "", "extn": "" }, { "name": "2014", "id": "17", "email": "", "extn": "" }, { "name": "1234", "id": "22", "email": "", "extn": "1234" }, { "name": "Admin", "id": "1", "email": "", "extn": "admin" }, { "name": "小", "id": "13", "email": "", "extn": "1234" }, { "name": "小樱", "id": "8", "email": "", "extn": "" }, { "name": "1234", "id": "24", "email": "", "extn": "4589" }, { "name": "qyuser001", "id": "27", "email": "", "extn": "qyuser001" }, { "name": "SYSTEM", "id": "0", "email": "", "extn": "" } ], "page": 1, "pageCount": 1 }
- curl 示例:
curl -0 -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" -d '' "http://192.168.31.98:8081/api/users/app?page=1&perPage=10"
获取微信关联用户信息(已废弃)
警告:该接口已废弃(api/users/wechat is Deprecated!!),建议使用api/users/:id/wechat_users 接口。
获取该坐席被分配到哪些队列
用于获取指定用户(通过 id 标识)关联的队列信息
- 请求 URL:
/api/users/:id/queue/name
- 请求方式:
GET
- 消息头:
Content-Type: application/json
- 响应示例:
[ { "name": "test2" } ]
- curl 示例:
curl -0 -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" -d '' "http://192.168.31.98:8081/api/users/5/queue/name"
删除用户
- 请求 URL:
/api/users
- 请求方式:
DELETE
- 消息头:
Content-Type: application/json
- Body 信息:待删除用户 ID 数组,示例:
[4,5]
- 返回值:正常返回一个 JSON Object,data 中包含删除成功的用户数量:
{ "code": 200, "data": 2, "message": "success" }
- curl 示例:
curl -XDELETE -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" -d '[4,5]' 'http://192.168.31.98:8081/api/users'
删除用户
- 请求 URL:
/api/users/delete
- 请求方式:
DELETE
- 消息头:
Content-Type: application/json
- Body 信息:包含待删除用户extn。示例:
{ "extn":"444" }
- 返回值:正常返回一个 JSON Object,data 中包含删除成功的用户数量:
{ "code": 200, "data": 1, "message": "success" }
- curl 示例:
curl -XDELETE -H "X-XTRA-AUTH-ID: 790480b3-d930-435a-87c4-6990e01cafc9" -H "Content-Type: application/json" -d '{"extn":"444"}' 'http://192.168.31.98:8081/api/users/delete'
修改用户密码
- 请求 URL:
/api/users/:id/password
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息: 包含旧密码和新密码。
- 示例:
PUT /api/users/1/password
普通用户修改:
{ "old_password": "XSwitch.cn/6753997", "password": "New@456" }
管理员用户修改其他用户密码
{ "id": 5, "old_password": "Admin@123", // 管理员自身旧密码(部分场景需验证) "password": "New@456" }
- 返回值:正常返回一个 JSON Object,data 中包含被修改的用户的 ID。
{ "message": "success", "code": 200, "data": "5" }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -H "Content-Type: application/json" -d '{"old_password": "XSwitch.cn/6753997","password": "New@456"}' http://192.168.1.100:8081/api/users/5/password
获取用户分机注册情况
- 请求 URL:
/api/users/list
返回所有用户下分机在线状态 - 请求 URL:
/api/users/list?extn=$extn
返回指定分机号用户信息和注册信息 - 请求方式:
GET
GET /api/users/list
返回
[ { "extn": "admin", "status": "offline" }, { "extn": "1001", "status": "offline" }, { "extn": "1000", "status": "offline" } ]
GET /api/users/list?extn=1001
返回
{ "ha1b": "6238501df8a36fe9ee9cbb4855b651e1", "ha1": "f0ad0f1442d65643068a0f6faeea5208", "extn": "1001", "cid_number": "", "email": "", "login": "1001", "is_super": 0, "cid_name": "bob", "last_login_at": "", "password": "Xswitch.cn/6753997", "context": "context-1", "regs": [], "updated_at": "2022-05-11 09:50:56", "auto_record": 0, "vm_password": "1234", "id": 3, "created_at": "2022-05-11 09:43:15", "domain": "demo.xswitch.cn", "tel": "", "name": "5555", "extn_id": 0, "tel_enabled": 0, "agent_info": "{}", "type": "AGENT", "deleted_at": "" }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/users/list
获取分机注册和未注册情况
- 请求 URL:
/api/users/list1
返回所有分机在线以及未在线状态 - 请求方式:
GET
GET /api/users/list1
返回
{ "reg": { "row_count": 2, "rows": [ { "url": "sofia/default/sip:1003@192.168.3.107:5060;transport=tcp", "expires": "1666342728", "token": "678042420-5060-1@BJC.BGI.D.BAH", "reg_user": "1003", "network_proto": "tcp", "metadata": "", "hostname": "a7642d101231", "network_port": "58570", "realm": "xswitch.cn", "network_ip": "172.18.0.1" }, { "url": "sofia/default/sip:1002@172.18.0.1:62404;transport=UDP;rinstance=3c3795973a249e7d", "expires": "1666340706", "token": "2xrd5GUgSWnixoaYvD8Xpw..", "reg_user": "1002", "network_proto": "udp", "metadata": "", "hostname": "a7642d101231", "network_port": "62404", "realm": "xswitch.cn", "network_ip": "172.18.0.1" } ] }, "unreg": [ { "status": "offline", "extn": "admin" }, { "status": "offline", "extn": "1000" } ] }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/users/list1
分机管理
分机字段信息说明如下:
字段 | 类型 | 备注 |
---|---|---|
id | PRIMARY KEY | 分机 ID,自动生成 |
name | string | 分机名 |
domain | string | 域名 |
description | string | 描述 |
extn | string | 分机号码 |
password | string | 密码 |
vm_password | string | 语音邮箱密码 |
cid_number | string | 主叫号码 |
cid_name | string | 主叫名称 |
type | string | 分机类型,默认 'SIP' |
connect_phone | string | 联系方式 |
call_transfer_type | INTEGER | DEFAULT 0 -- 呼叫转接类型,0:无设置 1:共振 2:无应答转移 3:呼叫失败转 4:无条件前转 |
voicemail | INTEGER | DEFAULT 0, --语音邮箱,0:关闭,1:开启 |
ringback | string | 彩铃 |
timeout | string | 超时时长 |
enable_ringback | INTEGER | DEFAULT 0, --是否开启彩铃 0:不开启,1:开启 |
auto_record | INTEGER | DEFAULT 0, --是否录音 0:不录音 1:录音 |
call_limit | INTEGER | DEFAULT 1, -- 呼出权限 0:不允许 1:允许 |
called_limit | INTEGER | DEFAULT 1, -- 呼入权限 0:不允许 1:允许 |
call_authority | INTEGER | DEFAULT 4, --呼叫权限 0:紧急呼叫 1:本局呼叫,2:本地呼叫,3:国内呼叫,4:国际呼叫 |
intercept | INTEGER | DEFAULT 0, --代答功能,0:无代答,1:组代答,2:全局代答 |
group_name | string | --组代答组名 |
context | string | 呼叫源 |
user_id | INTEGER | DEFAULT 0 REFERENCES users(id) ON DELETE CASCADE |
force_insert | INTEGER | DEFAULT 0, --强插,0:关闭,1:开启 |
force_breakdown | INTEGER | DEFAULT 0, --强拆,0:关闭,1:开启 |
eavesdrop | INTEGER | DEFAULT 0, --监听,0:关闭,1:开启 |
extn_cidr | string | CIDR |
priority | string | DEFAULT 99, 优先级 |
weblogin_disabled | INTEGER | DEFAULT 0, 开启 web 登陆 |
ha1b | string | extn@domain+domain+password 三个字段的 md5 值 |
ha1 | string | extn+domain+password 三个字段的 md5 值 |
sync_enabled | INTEGER | DEFAULT 0 |
display_order | string | DEFAULT 0 |
disabled | INTEGER | DEFAULT 0, 是否启用 |
enable_srtp | INTEGER | DEFAULT 0, 是否开启srtp,0:关闭,1:开启 |
forced_insert | INTEGER | DEFAULT 0, 被强插,0:关闭,1:开启 |
eavesdropped | INTEGER | DEFAULT 0, 被监听,0:关闭,1:开启 |
intercepted | INTEGER | DEFAULT 0, 被代答,0:无代答,1:组代答,2 |
intercepted_group_name | VARCHAR | 被代答组名 |
codec | VARCHAR | 编码 |
mac_address | VARCHAR | 话机mac地址 |
enable_cb_onbusy | VARCHAR | 是否开启遇忙回呼 |
caller_display | INTEGER | DEFAULT 1, 呼叫来显 0:不显示 1:显示 |
hotline_number | VARCHAR | 热线号码 |
hotline_type | VARCHAR | 热线设备类型 |
hotline_address | VARCHAR | 热线设备地址 |
enable_hotline | INTEGER | DEFAULT 0, 是否开启热线 |
boss_extn | BOOLEAN | DEFAULT false |
secretary_extn | VARCHAR | DEFAULT 0, 是否开启热线 |
dtmf_type | INTEGER | DEFAULT 0, DTMF类型 0:不指定 1:info, 2:inband, 3:rfc2833 |
enable_extn_time_recurrences | INTEGER | DEFAULT 0, 分机被叫处时间管理 |
enable_t38 | INTEGER | DEFAULT 0, 启用t38 0:不启用 1:启用 |
forced_breakdown | INTEGER | DEFAULT 0, --被强拆,0:关闭,1:开启 |
created_at | TIMESTAMP(0) | DEFAULT now(), 创建时间 |
updated_at | TIMESTAMP(0) | DEFAULT now(), 更新时间 |
deleted_at | TIMESTAMP(0) | 删除时间 |
type 类型 | 说明 |
---|---|
GATEWAY | 网关 |
SIP | SIP |
HK | 海康摄像头 |
TDM | TDM |
WebRTC | WebRTC |
创建分机
创建单个分机号信息说明如下:
字段 | 必选 | 类型 | 备注 |
---|---|---|---|
login | 是 | string | 所属用户,必填 |
name | 是 | string | 姓名 |
password | 是 | string | 密码 |
extn | 是 | string | 分机号 |
context | 是 | string | 呼叫源 |
批量创建分机号信息说明如下:
字段 | 必选 | 类型 | 备注 |
---|---|---|---|
password | 是 | string | 密码 |
context | 是 | string | 呼叫源 |
extns_start | 是 | string | 开始号码,必填 |
extns_end | 是 | string | 结束号码,必填 |
user_id | 是 | int | 所属用户 ID,必填 |
- 请求 URL:
/api/extensions
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息:
{ "name": "lis", "extn": "889", "password": "123QWEqwe", "context": "context-1", "user_id": 6 }
name
: 分机名extn
:分机号码password
:分机注册密码,需由大写字母+小写字母+数字组合而成,且在 8-20 位之间context
:分机呼叫源
- curl 示例:
curl -0 -H "X-XTRA-AUTH-ID: 018fb7c0-5e52-79ed-92f4-6263b2835f1b" \ -d '{"name": "接口测试12","extn": "47789451001","context": "context-1","user_id": 6,"password": "XSwitch.cn/6753997"}' \ -H "Content-Type: application/json" "192.168.0.108:8081/api/extensions"
- 返回值:
{ "message": "success", "data": { "eavesdrop": 0, "tmf_type": 0, "extn": "47789451001", "mac_address": "", "called_limit": 1, "forced_insert": 0, "forced_breakdown": 0, "ringback": "", "name": "接口测试12", "boss_extn": false, "enable_srtp": 0, "weblogin_disabled": 0, "disabled": 0, "timeout": "", "enable_t38": 0, "enable_extn_time_recurrences": 0, "cid_number": "", "caller_display": 1, "dtmf_type": 0, "call_limit": 1, "eavesdropped": 0, "extn_cidr": "", "updated_at": "2024-05-27 10:02:19", "intercepted_group_name": "", "created_at": "2024-05-27 10:02:19", "group_name": "", "call_authority": 4, "auto_record": 0, "secretary_extn": "", "enable_hotline": 0, "hotline_address": "", "hotline_type": "", "force_breakdown": 0, "enable_cb_onbusy": 0, "sync_enabled": 0, "codec": "", "ha1": "dc093f09ebeb9a37283f22956e1d5b5e", "type": "SIP", "description": "", "password": "XSwitch.cn/6753997", "connect_phone": "", "domain": "xswitch.cn", "hotline_number": "", "vm_password": "", "call_transfer_type": 0, "force_insert": 0, "deleted_at": "", "user_id": 6, "intercepted": 0, "id": 2531, "priority": "99", "display_order": "0", "enable_ringback": 0, "intercept": 0, "voicemail": 0, "cid_name": "", "ha1b": "fe25bae9818d72a995af21faef3a3cae", "context": "context-1" }, "code": 200 }
批量创建分机
- 请求 URL:
/api/extensions/muti_add
- 请求方式:
POST
- 消息头:
Content-Type: application/json
- Body 信息: 参见分配器信息说明。
Body:
{ "extns_start": 100001, "extns_end": 100002, "password": "Lv1.rqdg6Un6ho4B", "context": "context-5", "user_id": 6 }
extns_start
:批量创建分机起始号码extns_start
:批量创建分机结束号码password
:分机注册密码,需由大写字母+小写字母+数字组合而成,且在 8-20 位之间user_id
:分机归属于此 ID 对应的用户,如 0 代表 system 用户context
:分机呼叫源
- curl 示例:
curl -XPOST -H "X-XTRA-AUTH-ID: 06d8b7cd-88ca-4910-a9f4-4b2c7abae23e" -d '{"extns_start": 9898959,"extns_end": 9898969,"password": "XSwitch.cn/6753997","context": "context-1","user_id": 6}' -H "Content-Type: application/json" "http://192.168.3.16:8081/api/extensions/muti_add"
- 返回值:
{ "data": [ { "tmf_type": 0, "password": "Lv1.rqdg6Un6ho4B", "cid_name": "", "weblogin_disabled": 0, "timeout": "", "group_name": "", "context": "context-5", "voicemail": 0, "enable_extn_time_recurrences": 0, "connect_phone": "", "enable_t38": 0, "enable_srtp": 0, "vm_password": "", "called_limit": 1, "deleted_at": "", "cid_number": "", "ha1b": "f6947385ed54ae16d7738d1314c533bf", "dtmf_type": 0, "description": "", "sync_enabled": 0, "id": 2554, "updated_at": "2024-05-31 09:29:51", "enable_ringback": 0, "secretary_extn": "", "priority": "99", "ringback": "", "display_order": "0", "call_limit": 1, "forced_insert": 0, "name": "100001", "boss_extn": false, "hotline_address": "", "force_breakdown": 0, "hotline_number": "", "caller_display": 1, "enable_cb_onbusy": 0, "disabled": 0, "mac_address": "", "codec": "", "force_insert": 0, "intercepted_group_name": "", "intercepted": 0, "type": "SIP", "eavesdropped": 0, "auto_record": 0, "hotline_type": "", "ha1": "342e2bf9f7b828814af3800ecf8ed73a", "intercept": 0, "eavesdrop": 0, "extn": "100001", "forced_breakdown": 0, "user_id": 6, "enable_hotline": 0, "domain": "xswitch.cn", "extn_cidr": "", "call_transfer_type": 0, "created_at": "2024-05-31 09:29:51", "call_authority": 4 }, { "tmf_type": 0, "password": "Lv1.rqdg6Un6ho4B", "cid_name": "", "weblogin_disabled": 0, "timeout": "", "group_name": "", "context": "context-5", "voicemail": 0, "enable_extn_time_recurrences": 0, "connect_phone": "", "enable_t38": 0, "enable_srtp": 0, "vm_password": "", "called_limit": 1, "deleted_at": "", "cid_number": "", "ha1b": "4b8bbfb59bcff8d3a80de2bb533812c9", "dtmf_type": 0, "description": "", "sync_enabled": 0, "id": 2555, "updated_at": "2024-05-31 09:29:51", "enable_ringback": 0, "secretary_extn": "", "priority": "99", "ringback": "", "display_order": "0", "call_limit": 1, "forced_insert": 0, "name": "100002", "boss_extn": false, "hotline_address": "", "force_breakdown": 0, "hotline_number": "", "caller_display": 1, "enable_cb_onbusy": 0, "disabled": 0, "mac_address": "", "codec": "", "force_insert": 0, "intercepted_group_name": "", "intercepted": 0, "type": "SIP", "eavesdropped": 0, "auto_record": 0, "hotline_type": "", "ha1": "42adeeb1dc2b16ad2d9846b93beb18a3", "intercept": 0, "eavesdrop": 0, "extn": "100002", "forced_breakdown": 0, "user_id": 6, "enable_hotline": 0, "domain": "xswitch.cn", "extn_cidr": "", "call_transfer_type": 0, "created_at": "2024-05-31 09:29:51", "call_authority": 4 } ], "code": 200, "message": "success" }
如果批量创建分机出现数据重复,例如创建 1106、1107 和 1008 三个分机,用户已被创建,则返回创建成功的值以及exit
已存在的值,如下:
请求 Body:
{ "extns_start": 66661, "extns_end": 66662, "password": "123QWEqwe", "context": "context-1", "user_id": 0 }
返回如下:
{ "message": "success", "code": 200, "data": { "exit": [ { "intercept": 2, "force_insert": 1, "sync_enabled": 0, "weblogin_disabled": 0, "group_name": "", "voicemail": 0, "context": "context-1", "eavesdrop": 1, "priority": "99", "force_breakdown": 1, "eavesdropped": 1, "type": "SIP", "display_order": "0", "vm_password": "", "call_authority": 4, "disabled": 0, "auto_record": 0, "description": "", "mac_address": "", "deleted_at": "", "updated_at": "2022-10-25 14:43:19", "created_at": "2022-10-25 14:43:19", "codec": "", "intercepted_group_name": "", "called_limit": 1, "cid_number": "", "intercepted": 2, "ha1b": "f7e216ff5b1818f9a74c2f25e11986ad", "forced_breakdown": 1, "forced_insert": 1, "extn_cidr": "", "id": 57, "cid_name": "", "enable_ringback": 0, "ha1": "ee181fedb87ae7542f372479d0475ce0", "domain": "xswitch.cn", "ringback": "", "timeout": "", "password": "123QWEqwe", "user_id": 0, "call_limit": 1, "connect_phone": "", "name": "66661", "extn": "66661", "call_transfer_type": 0 }, { "intercept": 2, "force_insert": 1, "sync_enabled": 0, "weblogin_disabled": 0, "group_name": "", "voicemail": 0, "context": "context-1", "eavesdrop": 1, "priority": "99", "force_breakdown": 1, "eavesdropped": 1, "type": "SIP", "display_order": "0", "vm_password": "", "call_authority": 4, "disabled": 0, "auto_record": 0, "description": "", "mac_address": "", "deleted_at": "", "updated_at": "2022-10-25 14:43:19", "created_at": "2022-10-25 14:43:19", "codec": "", "intercepted_group_name": "", "called_limit": 1, "cid_number": "", "intercepted": 2, "ha1b": "1f8c36b1d190dceb324b2393613f1d89", "forced_breakdown": 1, "forced_insert": 1, "extn_cidr": "", "id": 58, "cid_name": "", "enable_ringback": 0, "ha1": "cd250e3ba44cdf0227acd898a63dd8ce", "domain": "xswitch.cn", "ringback": "", "timeout": "", "password": "123QWEqwe", "user_id": 0, "call_limit": 1, "connect_phone": "", "name": "66662", "extn": "66662", "call_transfer_type": 0 } ] } }
查询所有分机信息
- 请求 URL:
/api/extensions
- 请求方式:
GET
- 消息头: 无
- 返回值:
{ "rowCount": 54, "data": [ { "vm_password": "", "extn": "admin", "force_insert": 0, "priority": "99", "timeout": "", "sync_enabled": 0, "status": "offline", "display_order": "0", "enable_t38": 0, "extn_cidr": "", "enable_extn_time_recurrences": 0, "domain": "xswitch.cn", "enable_srtp": 0, "call_transfer_type": 0, "intercepted_group_name": "", "cid_number": "", "context": "context-1", "voicemail": 0, "enable_cb_onbusy": 0, "tmf_type": 0, "enable_ringback": 0, "boss_extn": false, "updated_at": "2024-03-18 02:06:40", "created_at": "2024-03-18 02:06:40", "eavesdropped": 0, "mac_address": "", "deleted_at": "", "description": "", "caller_display": 1, "hotline_address": "", "hotline_type": "", "weblogin_disabled": 0, "disabled": 0, "name": "Admin", "user_id": 1, "enable_hotline": 0, "forced_insert": 0, "type": "SIP", "secretary_extn": "", "group_name": "", "called_limit": 1, "dtmf_type": 0, "connect_phone": "", "intercepted": 0, "call_authority": 4, "forced_breakdown": 0, "eavesdrop": 0, "force_breakdown": 0, "id": 1, "codec": "", "hotline_number": "", "call_limit": 1, "intercept": 0, "cid_name": "", "ringback": "", "auto_record": 0 } ... ], "page": 1, "hpack": false, "pageCount": 6 }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/extensions
返回指定分机号用户信息
请求 URL:
/api/extensions/:id
请求方式:
GET
消息头: 无
返回值:
示例:
GET /api/extensions/2
{ "group_name": "", "login": "1000", "call_authority": 4, "call_limit": 1, "user_id": 2, "id": 2, "context": "context-1", "display_order": "0", "forced_breakdown": 1, "connect_phone": "", "tmf_type": 0, "auto_record": 0, "sync_enabled": 0, "voicemail": 1, "timeout": "", "eavesdropped": 1, "cid_number": "1000", "extn": "1000", "created_at": "2024-03-18 02:06:40", "enable_extn_time_recurrences": 0, "caller_display": 1, "force_insert": 1, "disabled": 0, "dtmf_type": 2, "enable_hotline": 0, "deleted_at": "", "enable_t38": 1, "secretary_extn": "", "cid_name": "", "priority": "99", "boss_extn": false, "vm_password": "", "hotline_address": "", "eavesdrop": 1, "ringback": "", "enable_srtp": 1, "call_transfer_type": 0, "enable_cb_onbusy": 0, "mac_address": "", "codec": "", "intercepted_group_name": "", "hotline_number": "", "domain": "xswitch.cn", "intercepted": 2, "intercept": 2, "dids": [ { "updated_at": "2024-05-16 03:04:57", "line_number": "7889541", "id": 17, "numbers": "1000", "deleted_at": "", "description": "", "type": "", "created_at": "2024-05-16 03:04:57" } ], "force_breakdown": 1, "forced_insert": 1, "hotline_type": "", "extn_cidr": "", "updated_at": "2024-05-11 07:54:01", "description": "", "called_limit": 1, "weblogin_disabled": 0, "enable_ringback": 0, "type": "SIP", "name": "1000" }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/extensions/2
或根据分机号码查询分机详细信息,如下:
请求 URL:
/api/extensions?page=1&page_size=10&hpack=false&extn=:extn
请求方式:
GET
消息头: 无
返回值:
示例:
GET /api/extensions?page=1&page_size=10&hpack=false&extn=10010
返回
{ "hpack": false, "data": [ { "description": "", "hotline_number": "", "user_id": "9", "extn_cidr": "", "eavesdropped": "0", "vm_password": "", "updated_at": "2024-03-21 02:16:01", "context": "context-1", "codec": "", "timeout": "", "domain": "xswitch.cn", "ringback": "", "connect_phone": "", "sync_enabled": "0", "priority": "99", "enable_hotline": "0", "voicemail": "0", "call_authority": "4", "enable_extn_time_recurrences": "0", "enable_srtp": "0", "intercept": "0", "force_breakdown": "0", "tmf_type": "0", "deleted_at": "", "enable_ringback": "0", "created_at": "2024-03-21 02:16:01", "call_transfer_type": "0", "call_limit": "1", "boss_extn": "f", "enable_t38": "0", "extn": "10010", "forced_breakdown": "0", "hotline_type": "", "id": "9", "enable_cb_onbusy": "0", "called_limit": "1", "auto_record": "0", "disabled": "0", "mac_address": "", "intercepted_group_name": "", "caller_display": "1", "hotline_address": "", "name": "10010", "intercepted": "0", "forced_insert": "0", "eavesdrop": "0", "dtmf_type": "0", "weblogin_disabled": "0", "force_insert": "0", "cid_name": "", "secretary_extn": "", "display_order": "0", "status": "offline", "type": "SIP", "group_name": "", "cid_number": "" } ], "rowCount": 1, "page": 1, "pageCount": 1 }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" "192.168.1.100:8081/api/extensions?page=1&page_size=10&hpack=false&extn=10010"
修改指定分机号用户信息
- 请求 URL:
/api/extensions/:id
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息:
{ "extn": "10010", "name": "修改信息", "context": "context-1", "login": "10010", "type": "SIP", "domain": "xswitch.cn" }
- 特别说明:
extn
分机号不可修改。密码需由大写字母+小写字母+数字组合而成,且在 8-20 位之间。 - curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 018fcc41-6594-7398-9660-9e004ca2e956" \ -H "Content-Type: application/json" \ -d '{"extn": "10010","name": "修改信息","context": "context-1","login": "10010","type": "SIP","domain": "xswitch.cn"}' \ "192.168.0.103:8081/api/extensions/9"
- 返回值:
{ "data": { "caller_display": 1, "force_breakdown": 0, "weblogin_disabled": 0, "login": "10010", "eavesdropped": 0, "intercept": 0, "mac_address": "", "priority": "99", "enable_srtp": 0, "description": "", "extn_cidr": "", "dtmf_type": 0, "created_at": "2024-03-21 02:16:01", "cid_name": "", "hotline_address": "", "tmf_type": 0, "timeout": "", "id": 9, "deleted_at": "", "updated_at": "2024-05-31 10:08:24", "enable_ringback": 0, "secretary_extn": "", "context": "context-1", "voicemail": 0, "boss_extn": false, "codec": "", "call_transfer_type": 0, "call_authority": 4, "enable_hotline": 0, "user_id": 9, "forced_insert": 0, "hotline_type": "", "hotline_number": "", "enable_cb_onbusy": 0, "enable_extn_time_recurrences": 0, "ringback": "", "type": "SIP", "forced_breakdown": 0, "auto_record": 0, "intercepted": 0, "intercepted_group_name": "", "enable_t38": 0, "sync_enabled": 0, "vm_password": "", "cid_number": "", "name": "修改信息", "ha1": "213c6ec9297d8bb9e59bd84f2a72c16e", "force_insert": 0, "disabled": 0, "connect_phone": "", "display_order": "0", "extn": "10010", "call_limit": 1, "group_name": "", "eavesdrop": 0, "called_limit": 1, "domain": "xswitch.cn", "ha1b": "40cd157c2a318ed61163dc193175880a" }, "message": "success", "code": 200 }
更新指定分机留言状态
- 请求 URL:
/api/extensions/:id
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息:
{ "action": "read" }
或
{ "action": "unread" }
其中read
表示将留言状态设置为已读,unread
表示将留言状态设置为未读。
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"action":"read"}' "192.168.1.100:8081/api/extensions/1"
- 返回值:
{ "message": "success", "code": 200, "data": "1002" }
清空指定分机留言
- 请求 URL:
/api/extensions/:id:
- 请求方式:
PUT
- 消息头:
Content-Type: application/json
- Body 信息:
{ "action": "delete" }
- curl 示例:
curl -XPUT -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" \ -H "Content-Type: application/json" \ -d '{"action":"delete"}' "192.168.1.100:8081/api/extensions/1"
- 返回值:
{ "message": "success", "code": 200, "data": "1002" }
删除分机
- 请求 URL:
/api/extensions/:id
- 请求方式:
DELETE
- Body 信息:无
- 返回值
{ "code": 200, "message": "success", "data": "3" }
示例
curl -0 -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" -XDELETE 192.168.1.100:8081/api/extensions/3
导出分机信息
- 请求 URL:
/api/extensions/download
- 请求方式:
GET
- 消息头: 无
- 返回值:
分机ID,号码,名称,密码,呼叫源,主叫名称,主叫号码,域,类型 1,admin,Admin,1234!@#$,,,,192.168.3.70,SIP 2,1001,1001,1234!@#$,context-1,,,192.168.3.70,SIP 3,1002,1002,1234!@#$,context-1,,,192.168.3.70,SIP 4,1003,1003,1234!@#$,context-1,,,192.168.3.70,SIP 5,1004,1004,1234!@#$,context-1,,,192.168.3.70,SIP 6,1005,1005,1234!@#$,context-1,,,192.168.3.70,SIP 7,1006,1006,1234!@#$,context-1,,,192.168.3.70,SIP 8,1007,1007,1234!@#$,context-1,,,192.168.3.70,SIP
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" 192.168.1.100:8081/api/extensions/download
批量设置分机
- 请求 URL:
/api/extensions
- 请求方式:
PUT
- 消息头: 无
- 返回值:
GET /api/extensions
Body:
{ "context": "context-1", "type": "SIP+WebRTC", "call_limit": "1", "eavesdrop": "1", "call_authority": "4", "force_insert": "1", "force_breakdown": "1", "intercept": "2", "called_limit": "1", "caller_display": "1", "Voicemail": "0", "forced_insert": "1", "forced_breakdown": "1", "eavesdropped": "1", "intercepted": "2", "codec": [ "PCMA", "PCMU" ], "timeout": "60", "extns": [ "2527", "2526" ], "dods": { "line_number": "122334455678", "type": "GATEWAY", "ref_id": "3", "name": "demo" } }
- 返回值:
{ "data": [], "message": "update rows 2", "code": 200 }
- curl 示例:
curl --location --request PUT 'http://192.168.0.101:8081/api/extensions' \ --header 'token: 01906d5e-28a0-7495-aa9f-0fdeb7212878' \ --header 'Content-Type: application/json' \ --header 'Cookie: freeswitch_xtra_session_id=01906d5e-28a0-7495-aa9f-0fdeb7212878' \ --data '{ "context": "context-1", "type": "SIP+WebRTC", "call_limit": "1", "eavesdrop": "1", "call_authority": "4", "force_insert": "1", "force_breakdown": "1", "intercept": "2", "called_limit": "1", "caller_display": "1", "Voicemail": "0", "forced_insert": "1", "forced_breakdown": "1", "eavesdropped": "1", "intercepted": "2", "codec": [ "PCMA", "PCMU" ], "timeout": "60", "extns": [ "2527", "2526" ], "dods": { "line_number": "122334455678", "type": "GATEWAY", "ref_id": "3", "name": "demo" } }'
按照分机号码筛选分机
请求 URL:
/api/extensions?page=1&page_size=500&hpack=false&extn=:extn
请求方式:
GET
消息头: 无
返回值:
示例:
GET /api/extensions?page=1&page_size=500&hpack=false&extn=10008
- 返回值:
{ "pageCount": 1, "hpack": false, "rowCount": 1, "page": 1, "data": [ { "eavesdrop": "0", "sync_enabled": "0", "extn": "10008", "codec": "PCMA,PCMU,G722,opus,G729,vp8,H264", "id": "7", "description": "", "called_limit": "1", "domain": "xswitch.cn", "force_insert": "0", "secretary_extn": "", "voicemail": "0", "auto_record": "0", "updated_at": "2024-03-25 01:23:32", "status": "offline", "enable_t38": "0", "forced_breakdown": "0", "context": "context-1", "enable_extn_time_recurrences": "0", "enable_srtp": "0", "weblogin_disabled": "0", "enable_ringback": "0", "boss_extn": "f", "intercepted": "0", "dtmf_type": "0", "priority": "99", "tmf_type": "0", "vm_password": "", "deleted_at": "", "enable_hotline": "0", "name": "10008", "created_at": "2024-03-21 02:16:01", "call_limit": "1", "forced_insert": "0", "hotline_number": "", "user_id": "7", "enable_cb_onbusy": "0", "mac_address": "", "intercepted_group_name": "", "timeout": "", "caller_display": "1", "hotline_type": "", "cid_name": "", "connect_phone": "", "display_order": "0", "force_breakdown": "0", "eavesdropped": "0", "intercept": "0", "call_authority": "3", "disabled": "0", "group_name": "", "extn_cidr": "", "ringback": "", "type": "SIP", "call_transfer_type": "0", "cid_number": "", "hotline_address": "" } ] }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" "192.168.1.100:8081/api/extensions?page=1&page_size=500&hpack=false&extn=10008"
按照分机名称筛选分机
请求 URL:
/api/extensions?page=1&page_size=500&hpack=false&name=:name
请求方式:
GET
消息头: 无
返回值:
示例:
GET api/extensions?page=1&page_size=500&hpack=false&name=10006
- 返回值:
{ "rowCount": 1, "data": [ { "user_id": "5", "hotline_address": "", "name": "10006", "disabled": "0", "priority": "99", "force_insert": "0", "intercepted_group_name": "", "status": "offline", "tmf_type": "0", "cid_number": "", "eavesdrop": "1", "weblogin_disabled": "0", "description": "", "called_limit": "1", "boss_extn": "f", "ringback": "", "enable_cb_onbusy": "0", "dtmf_type": "0", "enable_t38": "0", "domain": "xswitch.cn", "call_limit": "1", "codec": "", "enable_ringback": "0", "deleted_at": "", "group_name": "", "extn_cidr": "", "created_at": "2024-03-21 02:16:01", "secretary_extn": "", "hotline_type": "", "enable_hotline": "0", "vm_password": "", "hotline_number": "", "call_authority": "4", "call_transfer_type": "0", "eavesdropped": "0", "caller_display": "1", "context": "context-1", "cid_name": "", "enable_srtp": "0", "id": "5", "force_breakdown": "0", "intercepted": "0", "forced_breakdown": "0", "forced_insert": "0", "mac_address": "", "connect_phone": "", "auto_record": "0", "extn": "10006", "sync_enabled": "0", "intercept": "0", "display_order": "0", "timeout": "", "type": "SIP", "voicemail": "0", "updated_at": "2024-04-07 07:15:45", "enable_extn_time_recurrences": "0" } ], "page": 1, "pageCount": 1, "hpack": false }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" "192.168.1.100:8081/api/extensions?page=1&page_size=500&hpack=false&name=10006"
按照分机在线状态筛选分机
请求 URL:
/api/extensions?page=1&page_size=500&hpack=false&status=:status
请求方式:
GET
消息头: 无
返回值:
示例:
GET /api/extensions?page=1&page_size=500&hpack=false&status=online
- 返回值:
{ "rowCount": 1, "pageCount": 1, "data": [ { "id": 2, "enable_ringback": 0, "domain": "xswitch.cn", "call_transfer_type": 0, "boss_extn": false, "secretary_extn": "", "call_limit": 1, "disabled": 0, "created_at": "2024-03-18 02:06:40", "call_authority": 4, "extn": "1000", "user_id": 2, "status": "online", "vm_password": "", "force_breakdown": 1, "enable_t38": 1, "enable_extn_time_recurrences": 0, "cid_number": "1000", "enable_srtp": 1, "voicemail": 1, "enable_hotline": 0, "dtmf_type": 2, "tmf_type": 0, "display_order": "0", "codec": "", "sync_enabled": 0, "called_limit": 1, "eavesdrop": 1, "type": "SIP", "deleted_at": "", "intercepted": 2, "weblogin_disabled": 0, "group_name": "", "priority": "99", "cid_name": "", "hotline_address": "", "hotline_type": "", "hotline_number": "", "caller_display": 1, "enable_cb_onbusy": 0, "mac_address": "", "intercepted_group_name": "", "connect_phone": "", "updated_at": "2024-05-11 07:54:01", "eavesdropped": 1, "intercept": 2, "ringback": "", "forced_insert": 1, "description": "", "force_insert": 1, "extn_cidr": "", "forced_breakdown": 1, "name": "1000", "auto_record": 0, "timeout": "", "context": "context-1" } ], "hpack": false, "page": 1 }
- curl 示例:
curl -H "X-XTRA-AUTH-ID: 62dd0173-4916-4b1c-b958-546e4d7c91fe" "192.168.1.100:8081/api/extensions?page=1&page_size=500&hpack=false&status=online
分组管理
字段 | 类型 | 备注 |
---|---|---|
id | PRIMARY KEY | 分组 ID,自动生成 |
name | string | 分组名 |
description | string | 描述 |
sort | int | 排序 |
realm | string | 所属域 |
level | int | 分组级别 |
group_id | string | 父级分组 ID |
group_type | int | 分组类型 |
created_at | TIMESTAMP(0) | DEFAULT now(), 创建时间 |
updated_at | TIMESTAMP(0) | DEFAULT now(), 更新时间 |
获取所有分组
- 请求 URL:
/api/groups
- 请求方式:
GET
- Body 信息:无
- 返回值
{ "pageCount": 1, "data": [ { "name": "All Extensions", "value": "1", "group_type": "1", "id": "1", "group_id": "", "realm": "xswitch.cn" }, { "name": "All Users", "value": "0", "group_type": "0", "id": "0", "group_id": "", "realm": "xswitch.cn" } ], "rowCount": 2, "page": 1 }
获取用户分组名
- 请求 URL:
/api/groups/build_group_options_tree
- 请求方式:
GET
- Body 信息:无
- 返回值
[ { "id": "0", "name": "All Users", "realm": "xswitch.cn", "value": "0" } ]
获取除指定分组外的其他分组
- 请求 URL:
/api/groups/build_group_options_tree/:id
- 请求方式:
GET
- Body 信息:无
- 返回值
[ { "value": 0, "name": "All Users" }, { "value": 1, "name": "All Extensions" } ]
获取未加入指定分组的用户成员
- 请求 URL:
/api/groups/:id/remain_members
- 请求方式:
GET
- Body 信息:无
- 返回值
{ "page": 1, "rowCount": 1, "pageCount": 1, "data": [ { "call_authority": "4", "voicemail": "0", "password": "XSwitch.cn/6753997", "forced_insert": "0", "call_transfer_type": "0", "group_name": "", "eavesdropped": "0", "caller_display": "1", "hotline_type": "", "description": "", "ha1": "1311b40ac665838273f5702e790a152a", "timeout": "", "enable_ringback": "0", "mac_address": "", "enable_t38": "0", "call_limit": "1", "enable_extn_time_recurrences": "0", "ringback": "", "created_at": "2024-06-27 02:22:04", "force_breakdown": "0", "cid_name": "", "hotline_address": "", "auto_record": "0", "tmf_type": "0", "forced_breakdown": "0", "dtmf_type": "0", "updated_at": "2024-06-27 02:22:04", "connect_phone": "", "type": "SIP", "enable_srtp": "0", "intercepted_group_name": "", "intercept": "0", "disabled": "0", "priority": "99", "user_id": "3", "boss_extn": "f", "enable_hotline": "0", "secretary_extn": "", "domain": "xswitch.cn", "enable_cb_onbusy": "0", "context": "context-1", "codec": "", "called_limit": "1", "sync_enabled": "0", "intercepted": "0", "weblogin_disabled": "0", "force_insert": "0", "deleted_at": "", "eavesdrop": "0", "id": "2568", "extn_cidr": "", "name": "test", "display_order": "0", "vm_password": "", "hotline_number": "", "cid_number": "", "ha1b": "3e769018cc2e719ef680c07f66ddfe88", "extn": "489748156" } ] }
获取未加入指定分组的分机号
- 请求 URL:
/api/groups/:id/remain_extns
- 请求方式:
GET
- Body 信息:无
- 返回值
{ "pageCount": 1, "page": 1, "rowCount": 7, "data": [ { "password": "XSwitch.cn/6753997", "display_order": "0", "extn_cidr": "", "call_limit": "1", "updated_at": "2025-08-19 08:52:11", "deleted_at": "", "enable_srtp": "0", "mac_address": "", "intercepted_group_name": "", "eavesdrop": "0", "enable_t38": "0", "enable_extn_time_recurrences": "0", "description": "", "dtmf_type": "0", "secretary_extn": "", "force_insert": "0", "enable_hotline": "0", "connect_phone": "", "hotline_address": "", "codec": "", "ha1b": "ac7f0950fa459b6779098a090bcc6af6", "hotline_type": "", "hotline_number": "", "call_authority": "4", "sync_enabled": "0", "caller_display": "1", "ha1": "3737327c84bc4a3627053e431af87ba6", "group_name": "", "type": "SIP", "vm_password": "", "call_transfer_type": "0", "created_at": "2025-08-19 08:52:11", "disabled": "0", "force_breakdown": "0", "user_id": "1", "extn": "admin", "timeout": "", "auto_record": "0", "intercepted": "0", "context": "context-1", "intercept": "0", "forced_insert": "0", "eavesdropped": "0", "forced_breakdown": "0", "boss_extn": "f", "name": "Admin", "domain": "xswitch.cn", "id": "1", "weblogin_disabled": "0", "voicemail": "0", "priority": "99", "called_limit": "1", "cid_name": "", "enable_ringback": "0", "ringback": "", "cid_number": "", "enable_cb_onbusy": "0" }, { "password": "XSwitch.cn/6753997", "display_order": "0", "extn_cidr": "", "call_limit": "1", "updated_at": "2025-08-19 08:52:11", "deleted_at": "", "enable_srtp": "0", "mac_address": "", "intercepted_group_name": "", "eavesdrop": "0", "enable_t38": "0", "enable_extn_time_recurrences": "0", "description": "", "dtmf_type": "0", "secretary_extn": "", "force_insert": "0", "enable_hotline": "0", "connect_phone": "", "hotline_address": "", "codec": "", "ha1b": "bea49893ddb6706b5d86075a7eabd0b9", "hotline_type": "", "hotline_number": "", "call_authority": "4", "sync_enabled": "0", "caller_display": "1", "ha1": "27ad917ae8d0d77bbede5d8f122e017c", "group_name": "", "type": "SIP", "vm_password": "", "call_transfer_type": "0", "created_at": "2025-08-19 08:52:11", "disabled": "0", "force_breakdown": "0", "user_id": "2", "extn": "1000", "timeout": "", "auto_record": "0", "intercepted": "0", "context": "context-1", "intercept": "0", "forced_insert": "0", "eavesdropped": "0", "forced_breakdown": "0", "boss_extn": "f", "name": "1000", "domain": "xswitch.cn", "id": "2", "weblogin_disabled": "0", "voicemail": "0", "priority": "99", "called_limit": "1", "cid_name": "", "enable_ringback": "0", "ringback": "", "cid_number": "", "enable_cb_onbusy": "0" }, { "password": "XSwitch.cn/6753997", "display_order": "0", "extn_cidr": "", "call_limit": "1", "updated_at": "2025-08-19 08:52:11", "deleted_at": "", "enable_srtp": "0", "mac_address": "", "intercepted_group_name": "", "eavesdrop": "0", "enable_t38": "0", "enable_extn_time_recurrences": "0", "description": "", "dtmf_type": "0", "secretary_extn": "", "force_insert": "0", "enable_hotline": "0", "connect_phone": "", "hotline_address": "", "codec": "", "ha1b": "c7f1dcc9ea65b0162f55187e71aed9ae", "hotline_type": "", "hotline_number": "", "call_authority": "4", "sync_enabled": "0", "caller_display": "1", "ha1": "cd37520c9b8e29b0cfa4fc46ff81da38", "group_name": "", "type": "SIP", "vm_password": "", "call_transfer_type": "0", "created_at": "2025-08-19 08:52:11", "disabled": "0", "force_breakdown": "0", "user_id": "3", "extn": "1001", "timeout": "", "auto_record": "0", "intercepted": "0", "context": "context-1", "intercept": "0", "forced_insert": "0", "eavesdropped": "0", "forced_breakdown": "0", "boss_extn": "f", "name": "1001", "domain": "xswitch.cn", "id": "3", "weblogin_disabled": "0", "voicemail": "0", "priority": "99", "called_limit": "1", "cid_name": "", "enable_ringback": "0", "ringback": "", "cid_number": "", "enable_cb_onbusy": "0" }, { "password": "Dv6\\.PVT-^", "display_order": "0", "extn_cidr": "", "call_limit": "1", "updated_at": "2025-08-19 09:32:23", "deleted_at": "", "enable_srtp": "0", "mac_address": "", "intercepted_group_name": "", "eavesdrop": "0", "enable_t38": "0", "enable_extn_time_recurrences": "0", "description": "", "dtmf_type": "0", "secretary_extn": "", "force_insert": "0", "enable_hotline": "0", "connect_phone": "", "hotline_address": "", "codec": "", "ha1b": "00700307ce3f700e7f368d9dbd5cb24c", "hotline_type": "", "hotline_number": "", "call_authority": "4", "sync_enabled": "0", "caller_display": "1", "ha1": "ea1c1267dd48dfc55dbc33efff24459d", "group_name": "", "type": "SIP", "vm_password": "", "call_transfer_type": "0", "created_at": "2025-08-19 09:32:23", "disabled": "0", "force_breakdown": "0", "user_id": "6", "extn": "444", "timeout": "", "auto_record": "0", "intercepted": "0", "context": "context-1", "intercept": "0", "forced_insert": "0", "eavesdropped": "0", "forced_breakdown": "0", "boss_extn": "f", "name": "444", "domain": "xswitch.cn", "id": "6", "weblogin_disabled": "0", "voicemail": "0", "priority": "99", "called_limit": "1", "cid_name": "", "enable_ringback": "0", "ringback": "", "cid_number": "", "enable_cb_onbusy": "0" }, { "password": "Wo8,W@4{Rxfk/0/(", "display_order": "0", "extn_cidr": "", "call_limit": "1", "updated_at": "2025-08-20 06:53:57", "deleted_at": "", "enable_srtp": "0", "mac_address": "", "intercepted_group_name": "", "eavesdrop": "0", "enable_t38": "0", "enable_extn_time_recurrences": "0", "description": "", "dtmf_type": "0", "secretary_extn": "", "force_insert": "0", "enable_hotline": "0", "connect_phone": "", "hotline_address": "", "codec": "", "ha1b": "af913f8be44f198beb2ffbad8e03be6c", "hotline_type": "", "hotline_number": "", "call_authority": "4", "sync_enabled": "0", "caller_display": "1", "ha1": "fdd3c377f2a6da5e385884a6b4882630", "group_name": "", "type": "SIP", "vm_password": "", "call_transfer_type": "0", "created_at": "2025-08-20 06:53:57", "disabled": "0", "force_breakdown": "0", "user_id": "7", "extn": "666", "timeout": "", "auto_record": "0", "intercepted": "0", "context": "context-1", "intercept": "0", "forced_insert": "0", "eavesdropped": "0", "forced_breakdown": "0", "boss_extn": "f", "name": "666", "domain": "xswitch.cn", "id": "7", "weblogin_disabled": "0", "voicemail": "0", "priority": "99", "called_limit": "1", "cid_name": "", "enable_ringback": "0", "ringback": "", "cid_number": "", "enable_cb_onbusy": "0" }, { "password": "Cx0-C0/h)RzZ$Vg%Lki", "display_order": "0", "extn_cidr": "", "call_limit": "1", "updated_at": "2025-08-20 06:56:31", "deleted_at": "", "enable_srtp": "0", "mac_address": "", "intercepted_group_name": "", "eavesdrop": "0", "enable_t38": "0", "enable_extn_time_recurrences": "0", "description": "", "dtmf_type": "0", "secretary_extn": "", "force_insert": "0", "enable_hotline": "0", "connect_phone": "", "hotline_address": "", "codec": "", "ha1b": "b25dfbda05ac0ba22e714954067feb51", "hotline_type": "", "hotline_number": "", "call_authority": "4", "sync_enabled": "0", "caller_display": "1", "ha1": "f3ae6fe0faed87dc2dc7182a76f19908", "group_name": "", "type": "SIP", "vm_password": "", "call_transfer_type": "0", "created_at": "2025-08-20 06:56:31", "disabled": "0", "force_breakdown": "0", "user_id": "8", "extn": "888", "timeout": "", "auto_record": "0", "intercepted": "0", "context": "context-1", "intercept": "0", "forced_insert": "0", "eavesdropped": "0", "forced_breakdown": "0", "boss_extn": "f", "name": "888", "domain": "xswitch.cn", "id": "8", "weblogin_disabled": "0", "voicemail": "0", "priority": "99", "called_limit": "1", "cid_name": "", "enable_ringback": "0", "ringback": "", "cid_number": "", "enable_cb_onbusy": "0" }, { "password": "ASWqwe345.", "display_order": "0", "extn_cidr": "", "call_limit": "1", "updated_at": "2025-08-20 07:17:21", "deleted_at": "", "enable_srtp": "0", "mac_address": "", "intercepted_group_name": "", "eavesdrop": "0", "enable_t38": "0", "enable_extn_time_recurrences": "0", "description": "", "dtmf_type": "0", "secretary_extn": "", "force_insert": "0", "enable_hotline": "0", "connect_phone": "", "hotline_address": "", "codec": "", "ha1b": "d556181f3c9535d997a2f706cb730e39", "hotline_type": "", "hotline_number": "", "call_authority": "4", "sync_enabled": "0", "caller_display": "1", "ha1": "9c9c3917fb5dd135bdba9e7f4a0775fd", "group_name": "", "type": "SIP", "vm_password": "", "call_transfer_type": "0", "created_at": "2025-08-20 07:17:21", "disabled": "0", "force_breakdown": "0", "user_id": "7", "extn": "85679", "timeout": "", "auto_record": "0", "intercepted": "0", "context": "context-1", "intercept": "0", "forced_insert": "0", "eavesdropped": "0", "forced_breakdown": "0", "boss_extn": "f", "name": "fjnghgj", "domain": "xswitch.cn", "id": "10", "weblogin_disabled": "0", "voicemail": "0", "priority": "99", "called_limit": "1", "cid_name": "", "enable_ringback": "0", "ringback": "", "cid_number": "", "enable_cb_onbusy": "0" } ] }
获取加入指定分组的用户成员
- 请求 URL:
/api/groups/:id/members
- 请求方式:
GET
- Body 信息:无
- 返回值
[ { "group_id": "0", "user_id": "31", "id": "32", "domain": "demo.xswitch.cn", "sort": "32", "name": "1029", "extn": "1029" } ]
获取加入指定分组的分机成员
- 请求 URL:
/api/groups/:id/users/extn
- 请求方式:
GET
- Body 信息:无
- 返回值
{ "pageCount": 1, "page": 1, "data": [ { "enable_srtp": "1", "id": "2", "eavesdrop": "1", "weblogin_disabled": "0", "voicemail": "0", "forced_breakdown": "1", "enable_t38": "0", "cid_number": "1000", "cid_name": "", "ha1b": "bea49893ddb6706b5d86075a7eabd0b9", "enable_extn_time_recurrences": "0", "priority": "99", "caller_display": "1", "ringback": "", "call_limit": "1", "ha1": "27ad917ae8d0d77bbede5d8f122e017c", "deleted_at": "", "extn": "1000", "call_transfer_type": "0", "secretary_extn": "", "enable_ringback": "0", "tmf_type": "0", "call_authority": "4", "created_at": "2024-03-18 02:06:40", "user_id": "2", "intercept": "2", "boss_extn": "f", "display_order": "0", "updated_at": "2024-06-27 01:18:18", "hotline_address": "", "password": "XSwitch.cn/6753997", "connect_phone": "", "force_breakdown": "1", "intercepted_group_name": "", "description": "", "hotline_type": "", "context": "context-1", "mac_address": "", "forced_insert": "1", "force_insert": "1", "timeout": "", "sync_enabled": "0", "hotline_number": "", "group_name": "", "vm_password": "", "dtmf_type": "2", "enable_cb_onbusy": "0", "codec": "", "called_limit": "1", "domain": "xswitch.cn", "auto_record": "0", "enable_hotline": "0", "disabled": "0", "extn_cidr": "", "type": "SIP", "name": "1000", "intercepted": "2", "eavesdropped": "1" } ], "rowCount": 1 }
获取指定分组的信息
- 请求 URL:
/api/groups/:id
- 请求方式:
GET
- Body 信息:无
- 返回值
{ "created_at": "2024-07-02 09:34:42", "name": "test", "realm": "xswitch.cn", "description": "本地分机", "sort": 1, "deleted_at": "", "id": 4, "updated_at": "2024-07-02 09:34:42", "level": 0, "group_type": 1 }
修改指定分组的信息
- 请求 URL:
/api/groups/:id
- 请求方式:
PUT
- Body 信息:
{ "description": "", "id": "3", "name": "test-1", "realm": "demo.xswitch.cn" }
- 返回值
{ "data": "4", "message": "success", "code": 200 }
获取所有的分机组
- 请求 URL:
/api/groups/extn_group
- 请求方式:
GET
- Body 信息:无
- 返回值
{ "page": 1, "rowCount": 1, "data": [ { "realm": "xswitch.cn", "group_type": "1", "deleted_at": "", "updated_at": "2025-08-19 08:52:11", "id": "1", "created_at": "2025-08-19 08:52:11", "level": "0", "sort": "", "name": "所有分机", "description": "", "group_id": "" } ], "pageCount": 1 }
获取所有用户组
- 请求 URL:
/api/groups/user_group
- 请求方式:
GET
- Body 信息:无
- 返回值
{ "rowCount": 1, "page": 1, "data": [ { "name": "所有用户", "sort": "", "realm": "xswitch.cn", "id": "0", "updated_at": "2025-08-19 08:52:11", "level": "0", "description": "", "deleted_at": "", "group_id": "", "created_at": "2025-08-19 08:52:11", "group_type": "0" } ], "pageCount": 1 }
获取用户组信息
- 请求 URL:
/api/groups/build_group_tree
- 请求方式:
GET
- Body 信息:无
- 返回值
[ { "realm": "xswitch.cn", "group_type": "0", "id": "0", "sort": "", "group_id": "", "description": "", "spaces": "", "updated_at": "2025-08-19 08:52:11", "level": "0", "created_at": "2025-08-19 08:52:11", "name": "所有用户", "deleted_at": "" } ]
获取分机组信息
- 请求 URL:
/api/groups/build_group_options_tree_extn
- 请求方式:
GET
- Body 信息:无
- 返回值
[ { "realm": "xswitch.cn", "name": "所有分机", "value": "1", "id": "1" } ]
获取所有用户组内的用户信息
- 请求 URL:
/api/groups/group_all/group_users
- 请求方式:
GET
- Body 信息:无
- 返回值
[ { "name": "所有用户", "children": [ { "domain": "xswitch.cn", "sha1": "", "idle_timeout": "60", "deleted_at": "", "is_super": "0", "tel": "", "tel_enabled": "0", "agent_info": "{}", "salt": "$1$yr7UkgXE", "email": "", "extn_id": "", "created_at": "2025-08-19 08:52:11", "context": "", "last_login_attempt_at": "", "is_admin": "f", "name": "SYSTEM", "first_login": "0", "cid_name": "", "last_login_at": "", "is_locked": "f", "login_attempts": "0", "vm_password": "", "extn": "", "updated_at": "2025-08-19 08:52:13", "password": "", "auto_record": "0", "login": "system", "cid_number": "", "type": "", "id": "0" } ... ], "id": "0" } ]
新增组
- 请求 URL:
/api/groups
- 请求方式:
POST
- Body 信息:
{ "name": "test1122", "description": "test1122", "group_type": 0 }
- 返回值
{ "code": 200, "message": "success", "data": "3" }
新增组内用户(组类型需要为用户)
- 请求 URL:
/api/groups/members
- 请求方式:
POST
- Body 信息:
[ { "group_id": 0, "user_id": "8" } ]
- 返回值
{ "message": "success", "data": [ { "user_id": "8", "sort": 10, "group_id": 0 } ], "code": 200 }
新增组内分机(组类型需要为分机)
- 请求 URL:
/api/groups/extns
- 请求方式:
POST
- Body 信息:
[ { "group_id": 4, "extn_id": "2513" } ]
- 返回值
{ "code": 200, "message": "success", "data": [ { "extn_id": "2513", "group_id": 4, "sort": 1 } ] }
删除分组
- 请求 URL:
/api/groups/:id
- 请求方式:
DELETE
- Body 信息:无
- 返回值:
{ "data": "3", "message": "success", "code": 200 }
删除分组的所有用户
- 请求 URL:
/api/groups/members/:group_id
- 请求方式:
DELETE
- Body 信息:无
- 返回值:
{ "code": 200, "message": "success", "data": "2" }
删除分组的指定用户
- 请求 URL:
/api/groups/members/:group_id/:member_id
- 请求方式:
DELETE
- Body 信息:无
- 返回值:
{ "data": "30", "message": "success", "code": 200 }
删除分组的指定分机
- 请求 URL:
/api/groups/extns/:group_id/:member_id
- 请求方式:
DELETE
- Body 信息:无
- 返回值:
{ "data": "2517", "message": "success", "code": 200 }
删除分组的所有分机
- 请求 URL:
/api/groups/extns/:group_id
- 请求方式:
DELETE
- Body 信息:无
- 返回值:
{ "message": "success", "code": 200, "data": "6" }
新建二级组
- 请求 URL:
/api/groups
- 请求方式:
POST
- Body 信息:
{ "name": "二级组", "description": "本地分机", "group_type": 0, "group_id": "2" }
- 返回值:
{ "message": "success", "code": 200, "data": 7 }
更新分组信息
字段 | 类型 | 备注 |
---|---|---|
id | string | 分组唯一标识 ID |
name | string | 分组名称 |
group_id | string | 父分组 ID(可选,若为 NULL表示顶级分组) |
level | number | 分组级别 |
sort | number | 同层级分组排序值(值越大越靠后) |
deleted_at | string | 软删除标记 |
- 请求 URL:
/api/groups/:id
- 请求方式:
PUT
- 消息头: Content-Type: application/json
- Body 信息:包含用户基础信息(必选/可选字段)及分机信息(可选字段,若需创建分机则必填)。
{ "name": "二级组", "id":2 }
- 返回值:
{ "data": "2", "message": "success", "code": 200 }
获取指定分组的成员信息
- 请求 URL:
/api/groups/:id/extns
- 请求方式:
GET
- Body 信息:无
- 返回值
[ { "extn_id": "1", "sort": "1", "domain": "xswitch.cn", "group_id": "1", "id": "1", "name": "Admin", "extn": "admin" }, { "extn_id": "2", "sort": "2", "domain": "xswitch.cn", "group_id": "1", "id": "2", "name": "1000", "extn": "1000" }, { "extn_id": "3", "sort": "3", "domain": "xswitch.cn", "group_id": "1", "id": "3", "name": "1001", "extn": "1001" }, { "extn_id": "4", "sort": "4", "domain": "", "group_id": "1", "id": "4", "name": "", "extn": "" }, { "extn_id": "5", "sort": "5", "domain": "", "group_id": "1", "id": "5", "name": "", "extn": "" }, { "extn_id": "6", "sort": "6", "domain": "xswitch.cn", "group_id": "1", "id": "6", "name": "444", "extn": "444" } ]
获取指定分组的权限信息
- 请求 URL:
/api/groups/:id/permissions
- 请求方式:
GET
- 返回值 权限验证失败时返回
{ "code": 403, "message": "no permission" }
权限验证通过且有权限数据时返回(示例)
[ { "method": "POST", "deleted_at": "", "param": "user", "created_at": "2025-08-20 02:23:30", "checked": "", "id": "5", "action": "edit", "updated_at": "2025-08-20 02:23:30", "permission_group_id": "1" } ]
权限验证通过但无关联权限数据时返回(空数组)
[]
向分组添加成员
- 请求 URL:
/api/groups/:id/member
- 请求方式:
POST
- Body 信息:需包含待添加成员的基础信息
{ "user_id": "7" }
- 返回值
{ "data": 25, "code": 200, "message": "success" }
更新分组成员信息
- 请求 URL:
/api/groups/:id/members
- 请求方式:
PUT
- 消息头: Content-Type: application/json
- Body 信息:
{ "id": "2", "name": "111", "sort": "4" }
- 返回值:
{ "data": "2", "message": "success", "code": 200 }
调整用户分组排序
字段 | 类型 | 备注 |
---|---|---|
start_id | string | 待拖动分组的 ID |
ebd_id | string | 目标参考分组的 ID |
group_id | string | 分组的父分组 ID(用于限定排序调整的范围,确保仅同一父分组内的分组参与排序) |
sort | number | 同层级分组排序值(值越大越靠后) |
- 请求 URL:
/api/groups/drag/:start_id/:end_id
- 请求方式:
PUT
- 消息头: Content-Type: application/json
- Body 信息:无
- 返回值:
{ "code": 200, "message": "success", "data": { "end_id": "3", "start_id": "2" } }
获取所有的可分组用户
- 请求 URL:
/api/groups/group_users
- 请求方式:
GET
- Body 信息:无
- 返回值
[ { "groupName": "All Users", "userID": "5", "userDomain": "demo.xswitch.cn", "userExten": "1003", "groupID": "0", "userName": "1003" }, { "groupName": "All Users", "userID": "6", "userDomain": "demo.xswitch.cn", "userExten": "1004", "groupID": "0", "userName": "1004" }, { "groupName": "All Users", "userID": "7", "userDomain": "demo.xswitch.cn", "userExten": "1005", "groupID": "0", "userName": "1005" } ]
获取指定分组的成员信息
- 请求 URL:
/api/groups/:id/extns
- 请求方式:
GET
- Body 信息:无
- 返回值
[ { "extn_id": "1", "sort": "1", "domain": "xswitch.cn", "group_id": "1", "id": "1", "name": "Admin", "extn": "admin" }, { "extn_id": "2", "sort": "2", "domain": "xswitch.cn", "group_id": "1", "id": "2", "name": "1000", "extn": "1000" }, { "extn_id": "3", "sort": "3", "domain": "xswitch.cn", "group_id": "1", "id": "3", "name": "1001", "extn": "1001" }, { "extn_id": "4", "sort": "4", "domain": "", "group_id": "1", "id": "4", "name": "", "extn": "" }, { "extn_id": "5", "sort": "5", "domain": "", "group_id": "1", "id": "5", "name": "", "extn": "" }, { "extn_id": "6", "sort": "6", "domain": "xswitch.cn", "group_id": "1", "id": "6", "name": "444", "extn": "444" } ]
获取指定分组的用户信息
- 请求 URL:
/api/groups/:id/users
- 请求方式:
GET
- Body 信息:无
- 返回值
[ { "last_login_attempt_at": "", "deleted_at": "", "tel_enabled": "0", "updated_at": "2025-08-19 08:52:13", "last_login_at": "", "salt": "$1$yr7UkgXE", "is_super": "0", "login_attempts": "0", "id": "0", "name": "SYSTEM", "context": "", "created_at": "2025-08-19 08:52:11", "cid_name": "", "agent_info": "{}", "tel": "", "domain": "xswitch.cn", "first_login": "0", "login": "system", "is_locked": "f", "is_admin": "f", "extn": "", "auto_record": "0", "sha1": "", "vm_password": "", "type": "", "extn_id": "", "email": "", "cid_number": "", "idle_timeout": "60" }, { "last_login_attempt_at": "", "deleted_at": "", "tel_enabled": "0", "updated_at": "2025-08-20 00:54:25", "last_login_at": "2025-08-20 00:54:25", "salt": "$1$LxKZqVGI", "is_super": "1", "login_attempts": "0", "id": "1", "name": "Admin", "context": "context-1", "created_at": "2025-08-19 08:52:11", "cid_name": "", "agent_info": "{}", "tel": "", "domain": "xswitch.cn", "first_login": "0", "login": "admin", "is_locked": "f", "is_admin": "f", "extn": "admin", "auto_record": "0", "sha1": "\\x386596678909a21f5c4c2671b85fc8c7ebbaf02f", "vm_password": "", "type": "", "extn_id": "", "email": "", "cid_number": "", "idle_timeout": "60" }, { "last_login_attempt_at": "", "deleted_at": "", "tel_enabled": "0", "updated_at": "2025-08-19 08:52:13", "last_login_at": "", "salt": "$1$gT0h/VjA", "is_super": "0", "login_attempts": "0", "id": "2", "name": "1000", "context": "context-1", "created_at": "2025-08-19 08:52:11", "cid_name": "", "agent_info": "{}", "tel": "", "domain": "xswitch.cn", "first_login": "0", "login": "1000", "is_locked": "f", "is_admin": "f", "extn": "1000", "auto_record": "0", "sha1": "\\x01807c7fcd6bd74d2bb88504f40228c7ce198cfa", "vm_password": "", "type": "NORMAL", "extn_id": "", "email": "", "cid_number": "", "idle_timeout": "60" }, { "last_login_attempt_at": "", "deleted_at": "", "tel_enabled": "0", "updated_at": "2025-08-19 08:52:13", "last_login_at": "", "salt": "$1$xIl7XAVn", "is_super": "0", "login_attempts": "0", "id": "3", "name": "1001", "context": "context-1", "created_at": "2025-08-19 08:52:11", "cid_name": "", "agent_info": "{}", "tel": "", "domain": "xswitch.cn", "first_login": "0", "login": "1001", "is_locked": "f", "is_admin": "f", "extn": "1001", "auto_record": "0", "sha1": "\\x0a9c501a40c4dd1c65f3c572eef4e092db7daaf9", "vm_password": "", "type": "NORMAL", "extn_id": "", "email": "", "cid_number": "", "idle_timeout": "60" }, { "last_login_attempt_at": "", "deleted_at": "", "tel_enabled": "0", "updated_at": "2025-08-19 09:32:23", "last_login_at": "", "salt": "$1$1I3lrofF", "is_super": "0", "login_attempts": "0", "id": "6", "name": "444", "context": "context-1", "created_at": "2025-08-19 09:32:23", "cid_name": "", "agent_info": "{}", "tel": "", "domain": "xswitch.cn", "first_login": "0", "login": "444", "is_locked": "f", "is_admin": "f", "extn": "444", "auto_record": "0", "sha1": "\\x32b1d6a74889d398c5fe2a7d6a8dea15d4376195", "vm_password": "", "type": "NORMAL", "extn_id": "6", "email": "", "cid_number": "", "idle_timeout": "60" } ]
获取分组关联用户的分机信息
- 请求 URL:
/api/groups/:id/group_users/extn
- 请求方式:
GET
- 返回值
{ "rowCount": "4", "data": [ { "boss_extn": "f", "connect_phone": "", "call_transfer_type": "0", "extn_cidr": "", "timeout": "", "force_insert": "0", "call_limit": "1", "eavesdrop": "0", "forced_breakdown": "0", "id": "1", "context": "context-1", "call_authority": "4", "user_id": "1", "user_login": "admin", "sync_enabled": "0", "updated_at": "2025-08-19 08:52:11", "user_name": "Admin", "name": "Admin", "caller_display": "1", "cid_number": "", "created_at": "2025-08-19 08:52:11", "secretary_extn": "", "deleted_at": "", "ha1b": "ac7f0950fa459b6779098a090bcc6af6", "hotline_address": "", "enable_t38": "0", "voicemail": "0", "enable_extn_time_recurrences": "0", "enable_hotline": "0", "type": "SIP", "description": "", "mac_address": "", "enable_srtp": "0", "dtmf_type": "0", "auto_record": "0", "domain": "xswitch.cn", "force_breakdown": "0", "cid_name": "", "hotline_number": "", "forced_insert": "0", "extn": "admin", "enable_cb_onbusy": "0", "vm_password": "", "priority": "99", "codec": "", "intercepted_group_name": "", "eavesdropped": "0", "called_limit": "1", "intercepted": "0", "weblogin_disabled": "0", "password": "XSwitch.cn/6753997", "ha1": "3737327c84bc4a3627053e431af87ba6", "display_order": "0", "group_name": "", "intercept": "0", "enable_ringback": "0", "disabled": "0", "ringback": "", "hotline_type": "" }, { "boss_extn": "f", "connect_phone": "", "call_transfer_type": "0", "extn_cidr": "", "timeout": "", "force_insert": "0", "call_limit": "1", "eavesdrop": "0", "forced_breakdown": "0", "id": "2", "context": "context-1", "call_authority": "4", "user_id": "2", "user_login": "1000", "sync_enabled": "0", "updated_at": "2025-08-19 08:52:11", "user_name": "1000", "name": "1000", "caller_display": "1", "cid_number": "", "created_at": "2025-08-19 08:52:11", "secretary_extn": "", "deleted_at": "", "ha1b": "bea49893ddb6706b5d86075a7eabd0b9", "hotline_address": "", "enable_t38": "0", "voicemail": "0", "enable_extn_time_recurrences": "0", "enable_hotline": "0", "type": "SIP", "description": "", "mac_address": "", "enable_srtp": "0", "dtmf_type": "0", "auto_record": "0", "domain": "xswitch.cn", "force_breakdown": "0", "cid_name": "", "hotline_number": "", "forced_insert": "0", "extn": "1000", "enable_cb_onbusy": "0", "vm_password": "", "priority": "99", "codec": "", "intercepted_group_name": "", "eavesdropped": "0", "called_limit": "1", "intercepted": "0", "weblogin_disabled": "0", "password": "XSwitch.cn/6753997", "ha1": "27ad917ae8d0d77bbede5d8f122e017c", "display_order": "0", "group_name": "", "intercept": "0", "enable_ringback": "0", "disabled": "0", "ringback": "", "hotline_type": "" }, { "boss_extn": "f", "connect_phone": "", "call_transfer_type": "0", "extn_cidr": "", "timeout": "", "force_insert": "0", "call_limit": "1", "eavesdrop": "0", "forced_breakdown": "0", "id": "3", "context": "context-1", "call_authority": "4", "user_id": "3", "user_login": "1001", "sync_enabled": "0", "updated_at": "2025-08-19 08:52:11", "user_name": "1001", "name": "1001", "caller_display": "1", "cid_number": "", "created_at": "2025-08-19 08:52:11", "secretary_extn": "", "deleted_at": "", "ha1b": "c7f1dcc9ea65b0162f55187e71aed9ae", "hotline_address": "", "enable_t38": "0", "voicemail": "0", "enable_extn_time_recurrences": "0", "enable_hotline": "0", "type": "SIP", "description": "", "mac_address": "", "enable_srtp": "0", "dtmf_type": "0", "auto_record": "0", "domain": "xswitch.cn", "force_breakdown": "0", "cid_name": "", "hotline_number": "", "forced_insert": "0", "extn": "1001", "enable_cb_onbusy": "0", "vm_password": "", "priority": "99", "codec": "", "intercepted_group_name": "", "eavesdropped": "0", "called_limit": "1", "intercepted": "0", "weblogin_disabled": "0", "password": "XSwitch.cn/6753997", "ha1": "cd37520c9b8e29b0cfa4fc46ff81da38", "display_order": "0", "group_name": "", "intercept": "0", "enable_ringback": "0", "disabled": "0", "ringback": "", "hotline_type": "" }, { "boss_extn": "f", "connect_phone": "", "call_transfer_type": "0", "extn_cidr": "", "timeout": "", "force_insert": "0", "call_limit": "1", "eavesdrop": "0", "forced_breakdown": "0", "id": "6", "context": "context-1", "call_authority": "4", "user_id": "6", "user_login": "444", "sync_enabled": "0", "updated_at": "2025-08-19 09:32:23", "user_name": "444", "name": "444", "caller_display": "1", "cid_number": "", "created_at": "2025-08-19 09:32:23", "secretary_extn": "", "deleted_at": "", "ha1b": "00700307ce3f700e7f368d9dbd5cb24c", "hotline_address": "", "enable_t38": "0", "voicemail": "0", "enable_extn_time_recurrences": "0", "enable_hotline": "0", "type": "SIP", "description": "", "mac_address": "", "enable_srtp": "0", "dtmf_type": "0", "auto_record": "0", "domain": "xswitch.cn", "force_breakdown": "0", "cid_name": "", "hotline_number": "", "forced_insert": "0", "extn": "444", "enable_cb_onbusy": "0", "vm_password": "", "priority": "99", "codec": "", "intercepted_group_name": "", "eavesdropped": "0", "called_limit": "1", "intercepted": "0", "weblogin_disabled": "0", "password": "Dv6\\.PVT-^", "ha1": "ea1c1267dd48dfc55dbc33efff24459d", "display_order": "0", "group_name": "", "intercept": "0", "enable_ringback": "0", "disabled": "0", "ringback": "", "hotline_type": "" } ], "pageCount": 1, "page": 1 }
角色权限
字段 | 类型 | 备注 |
---|---|---|
id | PRIMARY KEY | 角色权限ID,自动生成 |
name | string | 角色权限名 |
description | string | 描述 |
role_type | int | 角色类型 |
permission_type | int | 权限类型 |
created_at | TIMESTAMP(0) | DEFAULT now(), 创建时间 |
created_by | string | 创建人 |
updated_at | TIMESTAMP(0) | DEFAULT now(), 更新时间 |
获取所有系统角色
请求 URL:
/api/system_roles
请求方式:
GET
Body 信息:无
返回值
{ "page": 1, "data": [ { "updated_at": "2024-03-18 02:06:41", "created_by": "system", "role_type": 1, "created_at": "2024-03-18 02:06:41", "name": "超级管理员", "description": "", "id": 1 }, { "updated_at": "2024-03-18 02:06:41", "created_by": "system", "role_type": 1, "created_at": "2024-03-18 02:06:41", "name": "高级管理员", "description": "", "id": 2 }, { "updated_at": "2024-03-18 02:06:41", "created_by": "system", "role_type": 1, "created_at": "2024-03-18 02:06:41", "name": "只读管理员", "description": "", "id": 3 } ], "rowCount": 3, "pageCount": 1 }
获取角色详情
请求 URL:
/api/system_roles/:id
请求方式:
GET
Body 信息:无
返回值
{ "description": "", "id": 1, "updated_at": "2025-08-19 08:52:13", "created_at": "2025-08-19 08:52:13", "created_by": "system", "name": "超级管理员", "role_type": 1 }
获取指定角色下的用户列表
请求 URL:
/api/system_roles/:role_id/users?page=1&perPage=50
请求方式:
GET
Body 信息:无
返回值
{ "data": [ { "name": "ew", "id": "35" }, { "name": "666", "id": "61" } ], "pageCount": 1, "rowCount": 2, "page": 1 }
删除指定角色下的一个用户
请求 URL:
/api/system_roles/:role_id/users/user_id
请求方式:
DELETE
Body 信息:无
返回值
{ "message": "success", "code": 200, "data": "35" }
删除指定角色
- 请求 URL:
/api/system_roles/:id
- 请求方式:
DELETE
- Body 信息:无
- 返回值
{ "data": "4", "message": "success", "code": 200 }
创建系统角色
创建一个新的系统角色,并可选基于现有模板角色复制其权限(资源访问权限)。适用于快速初始化角色并继承已有权限配置。
- 请求 URL:
/api/system_roles
- 请求方式:
POST
- Body 信息:传入待创建角色的属性及可选的模板角色ID
{ "name": "财务管理员", "description": "负责财务系统权限管理", "template": "1001" }
- 返回值
{ "code": 200, "data": { "updated_at": "2025-08-20 09:23:04", "created_by": "system", "created_at": "2025-08-20 09:23:04", "id": 4, "description": "负责财务系统权限管理", "name": "财务管理员" }, "message": "success" }
给指定角色添加一个用户
- 请求 URL:
/api/system_roles/:role_id/users
- 请求方式:
POST
- Body 信息:
[ { "user_id": "46", "role_id": 1 } ]
- 返回值
{ "code": 200, "data": [ { "id": "38" } ], "message": "success" }
给指定角色添加多个用户
- 请求 URL:
/api/system_roles/:role_id/users
- 请求方式:
POST
- Body 信息:
[ { "user_id": "3", "role_id": "5" }, { "user_id": "4", "role_id": "5" }, { "user_id": "5", "role_id": "5" } ]
- 返回值
{ "code": 200, "data": [ { "id": "39" }, { "id": "40" }, { "id": "41" } ], "message": "success" }
给指定角色添加一个用户组
- 请求 URL:
/api/system_roles/:role_id/group_users
- 请求方式:
POST
- Body 信息:
[ { "group_id": "0" } ]
- 返回值
{ "data": [], "code": 200, "message": "success" }
给指定角色添加多个用户组
- 请求 URL:
/api/system_roles/:role_id/group_users
- 请求方式:
POST
- Body 信息:
[ { "group_id": "5" }, { "group_id": "0" } ]
- 返回值
{ "code": 200, "message": "success", "data": [] }
更新系统角色
- 请求 URL:
/api/system_roles/:id
- 请求方式:
PUT
- Body 信息:
{ "name": "test", "description": "测试" }
- 返回值
{ "code": 200, "data": "5", "message": "success" }
获取分组列表
请求 URL:
/api/role_privileges/build_role_groups/:id
请求方式:
GET
Body 信息:无
返回值
[ { "group_id": "", "created_at": "2022-09-20 14:40:38", "name": "All Users", "checked": true, "level": "0", "deleted_at": "", "realm": "xswitch.cn", "updated_at": "2022-09-20 14:40:38", "id": "0", "group_type": "0", "sort": "", "description": "" }, { "group_id": "", "created_at": "2022-09-20 14:40:38", "name": "test-1", "checked": true, "level": "0", "deleted_at": "", "realm": "demo.xswitch.cn", "updated_at": "2022-11-04 15:07:32", "id": "1", "group_type": "1", "sort": "", "description": "" }, { "group_id": "", "created_at": "2022-11-04 15:13:19", "name": "xxx", "checked": false, "level": "0", "deleted_at": "", "realm": "xswitch.cn", "updated_at": "2022-11-04 15:13:19", "id": "2", "group_type": "", "sort": "1", "description": "" } ]
为指定角色添加分组权限
- 请求 URL:
/api/role_privileges/groups
- 请求方式:
POST
- Body 信息:
{ "data": [ { "group_id": "2" } ], "role_id": "5" }
- 返回值
{ "code": 200, "text": "Success" }
为指定角色添加菜单控制
- 请求 URL:
/api/role_privileges
- 请求方式:
PUT
- Body 信息:
{ "data": [ { "resource_id": "15", "resource_type": 3, "check": 1 } ], "role_id": "2" }
- 返回值
{ "message": "ok" }
获取指定角色的菜单控制列表
请求 URL:
/api/role_privileges/build_role_privileges/:id
请求方式:
GET
Body 信息:无
返回值
[ { "level": "0", "leaf_flag": "1", "module_no": "3", "sort": "1", "icon": "UserOutlined", "checked": true, "menus": [ { "status_flag": "1", "sort": "1", "url": "/settings/users", "checked": true, "buttons": [ { "status_flag": "1", "checked": true, "k": "Edit User", "id": "4", "menu_id": "29", "button_no": "users_edit", "description": "" }, { "status_flag": "1", "checked": true, "k": "Delete User", "id": "6", "menu_id": "29", "button_no": "users_delete", "description": "" } ... ], "k": "Users", "module_id": "3", "description": "", "id": "29" } ... ], "k": "User", "module_id": "", "description": "", "id": "3", "v": "SMENUS_USERS" } ... ]
为角色分配分组权限
为指定角色(role_id)分配分组权限,操作前会清除该角色原有的所有组权限记录,确保权限分配的唯一性。
- 请求 URL:
/api/role_privileges/groups
- 请求方式:
POST
- Body 信息:传入角色 ID 及待分配的模块组数据。
{ "role_id": "2", "data": [ { "group_id": 0 }, { "group_id": 2 } ] }
- 返回值
{ "code": 200, "text": "Success" }
为角色分配资源权限
为指定角色(role_id)分配资源权限,操作前会清除该角色原有的所有资源权限记录,确保权限分配的唯一性。
- 请求 URL:
/api/role_privileges/
- 请求方式:
POST
- Body 信息:传入角色 ID 及待分配的资源数据。
{ "role_id": "3", "data": [ { "resource_id": 1, "resource_type": 2 }, { "resource_id": 2, "resource_type": 1 } ] }
- 返回值
{ "code": 200, "text": "Success" }
获取所有角色的菜单控制列表
请求 URL:
/api/role_privileges/build_role_privileges/
请求方式:
GET
Body 信息:无
返回值 下面只列举部分返回值
[ { "leaf_flag": "1", "k": "User", "description": "", "menus": [ { "url": "/settings/users", "k": "Users", "id": "29", "description": "", "status_flag": "1", "module_id": "1", "buttons": [ { "button_no": "users_new_extn", "description": "", "status_flag": "1", "k": "New Extn", "id": "8", "menu_id": "29" }, { "button_no": "users_delete", "description": "", "status_flag": "1", "k": "Delete User", "id": "7", "menu_id": "29" } ... ], "sort": "1" } ... ], "icon": "UserOutlined", "level": "0", "id": "1", "v": "SMENUS_USERS", "module_no": "1", "module_id": "", "sort": "1" } ]
删除角色权限
根据角色ID(role_id)删除该角色的所有权限记录(存储于 role_privileges表),用于移除角色对系统资源的访问权限。
- 请求 URL:
/api/role_privileges/:role_id
- 请求方式:
DELETE
- Body 信息:无
- 返回值
{ "text": "Success", "code": 200 }
获取未被分配角色的用户
查询未被分配到指定角色的剩余用户列表。
字段 | 必选 | 类型 | 备注 |
---|---|---|---|
page | 否 | number | 当前页码(默认 1) |
name | 否 | string | 姓名 |
perPage | 否 | number | 每页条数(默认 10) |
order | 否 | string | 排序字段 |
- 请求 URL:
/api/system_roles/remain_users
- 请求方式:
GET
- Body 信息:无
- 返回值
{ "rowCount": 7, "pageCount": 1, "data": [ { "id": "0", "name": "SYSTEM" }, { "id": "2", "name": "1000" } ... ], "page": 1 }
联系人
字段 | 类型 | 备注 |
---|---|---|
user_id | int | 用户ID |
name | string | 联系人姓名 |
phone | string | 联系人手机号 |
sex | string | 性别 |
string | 邮箱 | |
string | QQ号 | |
birth_day | string | 生日 |
company | string | 公司 |
descritption | string | 描述 |
address | string | 地址 |
authority_flag | string | 权限标识 |
created_at | TIMESTAMP(0) | DEFAULT now(), 创建时间 |
updated_at | TIMESTAMP(0) | DEFAULT now(), 更新时间 |
deleted_at | TIMESTAMP(0) | DEFAULT now(), 删除时间 |
新增联系人
- 请求 URL:
/api/contacts
- 请求方式:
POST
- Body 信息:
{ "name": "我在测试1", "phone": "12345678910", "sex": "female", "email": "hello@xx.com", "qq": "123456", "birth_day": "2022-01-01", "authority_flag": "0" }
- 返回值
{ "message": "success", "data": "4", "code": 200 }
获取所有联系人
请求 URL:
/api/contacts?page=1&perPage=500&
请求方式:
GET
Body 信息:无
返回值
{ "page": 1, "rowCount": 4, "data": [ { "address": "", "id": 1, "deleted_at": "", "phone": "1111111", "authority_flag": 0, "user_id": 1, "birth_day": "2022-10-25", "company": "", "description": "", "email": "test@gmail.com", "created_at": "2022-11-11 15:34:41", "updated_at": "2022-11-11 15:34:41", "qq": "111111", "name": "我在测试", "sex": "female" }, { "address": "", "id": 2, "deleted_at": "", "phone": "22222222", "authority_flag": 0, "user_id": 1, "birth_day": "2022-02-20", "company": "", "description": "", "email": "2536209658@qq.com", "created_at": "2022-11-11 15:36:20", "updated_at": "2022-11-11 15:36:20", "qq": "11111", "name": "admin", "sex": "female" }, { "address": "", "id": 3, "deleted_at": "", "phone": "33333", "authority_flag": 0, "user_id": 1, "birth_day": "2022-09-07", "company": "", "description": "", "email": "2536209658@qq.com", "created_at": "2022-11-11 15:36:42", "updated_at": "2022-11-11 15:36:42", "qq": "wwww", "name": "admin", "sex": "male" }, { "address": "", "id": 4, "deleted_at": "", "phone": "12345678910", "authority_flag": 0, "user_id": 1, "birth_day": "2022-01-01", "company": "", "description": "", "email": "hello@xx.com", "created_at": "2022-11-14 16:33:39", "updated_at": "2022-11-14 16:33:39", "qq": "123456", "name": "我在测试1", "sex": "female" } ], "pageCount": 1 }
删除联系人
请求 URL:
/api/contacts/:id
请求方式:
DELETE
Body 信息:无
返回值
{ "data": "3", "message": "success", "code": 200 }
根据电话查询
请求 URL:
/api/contacts?page=1&perPage=500&&searchField=phone&searchKey=123
请求方式:
GET
Body 信息:无
返回值
{ "page": 1, "data": [ { "name": "我在测试1", "user_id": "1", "sex": "female", "authority_flag": "0", "deleted_at": "", "qq": "123456", "phone": "12345678910", "id": "4", "description": "", "created_at": "2022-11-14 16:33:39", "address": "", "company": "", "birth_day": "2022-01-01", "email": "hello@xx.com", "updated_at": "2022-11-14 16:33:39" } ], "rowCount": 1, "pageCount": 1 }
根据姓名查询
请求 URL:
/api/contacts?page=1&perPage=500&&searchField=name&searchKey=%E6%B5%8B%E8%AF%95
请求方式:
GET
Body 信息:无
返回值
{ "rowCount": 2, "data": [ { "qq": "111111", "deleted_at": "", "name": "我在测试", "address": "", "company": "", "updated_at": "2022-11-11 15:34:41", "phone": "1111111", "created_at": "2022-11-11 15:34:41", "birth_day": "2022-10-25", "user_id": "1", "authority_flag": "0", "email": "test@gmail.com", "description": "", "id": "1", "sex": "female" }, { "qq": "123456", "deleted_at": "", "name": "我在测试1", "address": "", "company": "", "updated_at": "2022-11-14 16:33:39", "phone": "12345678910", "created_at": "2022-11-14 16:33:39", "birth_day": "2022-01-01", "user_id": "1", "authority_flag": "0", "email": "hello@xx.com", "description": "", "id": "4", "sex": "female" } ], "page": 1, "pageCount": 1 }
获取联系人列表
- 请求 URL:
/api/contacts/
- 请求方式:
GET
- Body 信息:无
- 返回值
{ "page": 1, "data": [ { "birth_day": "", "user_id": 1, "phone": "1", "description": "", "id": 2, "deleted_at": "", "updated_at": "2025-08-20 07:54:18", "created_at": "2025-08-20 07:54:18", "authority_flag": 1, "company": "", "address": "", "sex": "male", "email": "", "name": "111", "qq": "" } ], "rowCount": 1, "pageCount": 1 }
获取联系人详情
请求 URL:
/api/contacts/:id
请求方式:
GET
Body 信息:无
返回值
{ "phone": "1111111", "email": "test@gmail.com", "user_id": 1, "updated_at": "2022-11-11 15:34:41", "name": "我在测试", "company": "", "created_at": "2022-11-11 15:34:41", "authority_flag": 0, "id": 1, "deleted_at": "", "description": "", "birth_day": "2022-10-25", "sex": "female", "qq": "111111", "address": "" }
下载联系人信息
- 请求 URL:
/api/contacts/download
- 请求方式:
GET
- Body 信息:无
- 返回值
[ [ "Name", "Phone", "Sex", "Email", "QQ", "Company", "Address", "Birthday", "Authority", "Description" ], [ "111", "1", "Male", "", "", "", "", "", "Public", "" ] ]
修改联系人信息
- 请求 URL:
/api/contacts/:id
- 请求方式:
PUT
- Body 信息:
{ "name": "我在测试", "phone": "1111111", "sex": "female", "email": "test@gmail.com", "qq": "111111", "birth_day": "2022-10-25", "authority_flag": "1", "id": 1 }
- 返回值
{ "code": 200, "data": "1", "message": "success" }
导入联系人
- 请求 URL:
/api/contacts/import
- 请求方式:
POST
- Body 信息: 传入待导入的联系人数组
{ "contacts": [ { "名称": "张三", "电话": "13800138000", "性别": "女", "电子邮件": "zhangsan@example.com", "QQ": "123456", "公司": "小樱桃", "联系地址": "烟台市", "生日": "2000-01-01", "公开范围": "私有", "描述": "技术部负责人" }, { "名称": "李四", "电话": "13900139000", "性别": "男", "公开范围": "公开" } ] }
- 返回值
{ "data": [], "code": 200, "message": "success" }
删除联系人
- 请求 URL:
/api/contacts/delete
- 请求方式:
POST
- Body 信息:传入待删除的联系人 ID 列表(示例):
[11, 3]
- 返回值
{ "data": "(11,3)", "message": "success", "code": 200 }
删除联系人
根据请求体中提供的联系人名称(name)删除 contacts表中的对应记录。
- 请求 URL:
/api/contacts/delete
- 请求方式:
DELETE
- Body 信息:传入待删除联系人的名称
{ "name": "小樱桃客服" }
- 返回值
{ "data": "1", "message": "success", "code": 200 }
公告
获取公告列表
- 请求 URL:
/api/notices
- 请求方式:
GET
- Body 信息:无
- 返回值
{ "pageCount": 1, "data": [ { "publish_time": "", "title": "11", "created_at": "2025-08-21 02:39:22", "id": 5, "updated_at": "", "context": "context-1", "deleted_at": "", "recipient_group_id": "", "publisher": "6", "recipients": [], "status": 0, "notice_id": 5, "recipient_user_id": "6", "description": "55", "summary": "6", "name": "5" }, { "publish_time": "", "title": "Debian2", "created_at": "2025-08-21 02:40:16", "id": 6, "updated_at": "", "context": "1", "deleted_at": "", "recipient_group_id": "{\n2,\n}", "publisher": "Admin", "recipients": [ "Admin", "1000", "1001", "111" ], "status": 0, "recipient_user_id": "{\n1,\n2,\n3,\n}", "description": "", "summary": "1", "name": "" } ], "rowCount": 2, "page": 1 }
获取公告详情
- 请求 URL:
/api/notices/:id
- 请求方式:
GET
- Body 信息:无
- 返回值
{ "message": "success", "data": { "title": "11", "recipients": [ { "type": 0, "id": 6, "name": "444" } ], "notice_id": "5", "publish_time": "", "context": "context-1", "summary": "6", "publisher": "6" }, "code": 200 }
获取未关联通知的用户列表
- 请求 URL:
/api/notices/:id/remain_user_members
- 请求方式:
GET
- Body 信息:无
- 返回值
{ "page": 1, "rowCount": 7, "pageCount": 1, "data": [ { "user_name": "SYSTEM", "user_extn": "", "user_type": "", "user_login": "system", "id": "0", "user_domain": "xswitch.cn" }, { "user_name": "Admin", "user_extn": "admin", "user_type": "", "user_login": "admin", "id": "1", "user_domain": "xswitch.cn" }, { "user_name": "1000", "user_extn": "1000", "user_type": "NORMAL", "user_login": "1000", "id": "2", "user_domain": "xswitch.cn" }, { "user_name": "1001", "user_extn": "1001", "user_type": "NORMAL", "user_login": "1001", "id": "3", "user_domain": "xswitch.cn" }, { "user_name": "444", "user_extn": "444", "user_type": "NORMAL", "user_login": "444", "id": "6", "user_domain": "xswitch.cn" }, { "user_name": "666", "user_extn": "666", "user_type": "NORMAL", "user_login": "666", "id": "7", "user_domain": "xswitch.cn" }, { "user_name": "888", "user_extn": "888", "user_type": "NORMAL", "user_login": "888", "id": "8", "user_domain": "xswitch.cn" } ] }
获取未关联通知的用户组列表
- 请求 URL:
/api/notices/:id/remain_group_members
- 请求方式:
GET
- Body 信息:无
- 返回值
{ "data": [ { "group_realm": "xswitch.cn", "group_name": "所有用户", "group_type": "0", "id": "0" }, { "group_realm": "xswitch.cn", "group_name": "111", "group_type": "0", "id": "2" } ], "rowCount": 2, "page": 1, "pageCount": 1 }
获取所有公告里面的所有用户详情
- 请求 URL:
/api/notices/notice_all/notice_users
- 请求方式:
GET
- Body 信息:无
- 返回值
[ { "name": "5", "children": [ { "context": "context-1", "extn": "444", "login": "444", "deleted_at": "", "auto_record": "0", "email": "", "name": "444", "created_at": "2025-08-19 09:32:23", "idle_timeout": "60", "updated_at": "2025-08-19 09:32:23", "first_login": "0", "password": "Dv6\\.PVT-^", "domain": "xswitch.cn", "type": "NORMAL", "id": "6", "salt": "$1$1I3lrofF", "last_login_attempt_at": "", "is_super": "0", "agent_info": "{}", "tel": "", "vm_password": "", "cid_name": "", "extn_id": "6", "tel_enabled": "0", "login_attempts": "0", "last_login_at": "", "cid_number": "", "is_admin": "f", "sha1": "\\x32b1d6a74889d398c5fe2a7d6a8dea15d4376195", "is_locked": "f" } ], "id": "5" }, { "name": "", "children": [ { "context": "", "extn": "", "login": "system", "deleted_at": "", "auto_record": "0", "email": "", "name": "SYSTEM", "created_at": "2025-08-19 08:52:11", "idle_timeout": "60", "updated_at": "2025-08-19 08:52:13", "first_login": "0", "password": "", "domain": "xswitch.cn", "type": "", "id": "0", "salt": "$1$yr7UkgXE", "last_login_attempt_at": "", "is_super": "0", "agent_info": "{}", "tel": "", "vm_password": "", "cid_name": "", "extn_id": "", "tel_enabled": "0", "login_attempts": "0", "last_login_at": "", "cid_number": "", "is_admin": "f", "sha1": "", "is_locked": "f" }, { "context": "context-1", "extn": "admin", "login": "admin", "deleted_at": "", "auto_record": "0", "email": "", "name": "Admin", "created_at": "2025-08-19 08:52:11", "idle_timeout": "60", "updated_at": "2025-08-21 01:37:59", "first_login": "0", "password": "XSwitch.cn/6753997", "domain": "xswitch.cn", "type": "", "id": "1", "salt": "$1$LxKZqVGI", "last_login_attempt_at": "", "is_super": "1", "agent_info": "{}", "tel": "", "vm_password": "", "cid_name": "", "extn_id": "", "tel_enabled": "0", "login_attempts": "0", "last_login_at": "2025-08-21 01:37:59", "cid_number": "", "is_admin": "f", "sha1": "\\x386596678909a21f5c4c2671b85fc8c7ebbaf02f", "is_locked": "f" }, { "context": "context-1", "extn": "1000", "login": "1000", "deleted_at": "", "auto_record": "0", "email": "", "name": "1000", "created_at": "2025-08-19 08:52:11", "idle_timeout": "60", "updated_at": "2025-08-19 08:52:13", "first_login": "0", "password": "XSwitch.cn/6753997", "domain": "xswitch.cn", "type": "NORMAL", "id": "2", "salt": "$1$gT0h/VjA", "last_login_attempt_at": "", "is_super": "0", "agent_info": "{}", "tel": "", "vm_password": "", "cid_name": "", "extn_id": "", "tel_enabled": "0", "login_attempts": "0", "last_login_at": "", "cid_number": "", "is_admin": "f", "sha1": "\\x01807c7fcd6bd74d2bb88504f40228c7ce198cfa", "is_locked": "f" }, { "context": "context-1", "extn": "1001", "login": "1001", "deleted_at": "", "auto_record": "0", "email": "", "name": "1001", "created_at": "2025-08-19 08:52:11", "idle_timeout": "60", "updated_at": "2025-08-19 08:52:13", "first_login": "0", "password": "XSwitch.cn/6753997", "domain": "xswitch.cn", "type": "NORMAL", "id": "3", "salt": "$1$xIl7XAVn", "last_login_attempt_at": "", "is_super": "0", "agent_info": "{}", "tel": "", "vm_password": "", "cid_name": "", "extn_id": "", "tel_enabled": "0", "login_attempts": "0", "last_login_at": "", "cid_number": "", "is_admin": "f", "sha1": "\\x0a9c501a40c4dd1c65f3c572eef4e092db7daaf9", "is_locked": "f" }, { "context": "context-1", "extn": "444", "login": "444", "deleted_at": "", "auto_record": "0", "email": "", "name": "444", "created_at": "2025-08-19 09:32:23", "idle_timeout": "60", "updated_at": "2025-08-19 09:32:23", "first_login": "0", "password": "Dv6\\.PVT-^", "domain": "xswitch.cn", "type": "NORMAL", "id": "6", "salt": "$1$1I3lrofF", "last_login_attempt_at": "", "is_super": "0", "agent_info": "{}", "tel": "", "vm_password": "", "cid_name": "", "extn_id": "6", "tel_enabled": "0", "login_attempts": "0", "last_login_at": "", "cid_number": "", "is_admin": "f", "sha1": "\\x32b1d6a74889d398c5fe2a7d6a8dea15d4376195", "is_locked": "f" }, { "context": "context-1", "extn": "666", "login": "666", "deleted_at": "", "auto_record": "0", "email": "", "name": "666", "created_at": "2025-08-20 06:53:57", "idle_timeout": "60", "updated_at": "2025-08-20 07:13:50", "first_login": "0", "password": "Wo8,W@4{Rxfk/0/(", "domain": "xswitch.cn", "type": "NORMAL", "id": "7", "salt": "$1$6UG9XrsF", "last_login_attempt_at": "", "is_super": "0", "agent_info": "{}", "tel": "", "vm_password": "", "cid_name": "", "extn_id": "7", "tel_enabled": "0", "login_attempts": "0", "last_login_at": "", "cid_number": "", "is_admin": "f", "sha1": "\\x296cb71c04c303a668dd8aca77e6a51cedccb7bb", "is_locked": "f" } ], "id": "6" } ]
更新公告及关联收件人
- 请求 URL:
/api/notices/:id/
- 请求方式:
PUT
- 请求头:
Content-Type: application/json
- Body 信息: 传入待更新的通知信息及新的收件人列表(数组格式),示例如下:
{ "id": 5, "title": "系统升级通知", "summary": "系统将于今晚24点升级", "context": "升级期间服务将短暂中断", "recipients": [ { "type": 0, "user_id": 1 }, { "type": 1, "group_id": 2 } ] }
- 响应信息: 返回更新后的通知信息,示例如下:
{ "message": "success", "code": 200, "data": { "recipients": [ { "user_id": 1, "recipients_type": 0, "sort": 1, "notice_id": 5 }, { "user_id": 2, "recipients_type": 1, "sort": 2, "notice_id": 5 } ], "notice_id": 5 } }
创建一个公告
- 请求 URL:
/api/notices/create
- 请求方式:
POST
- 请求头:
Content-Type: application/json
- Body 信息: 传入待创建的通知信息及收件人列表(数组格式),示例如下:
{ "title": "暴雨通知", "summary": "全市今晚暴雨红色预警", "context":"关好门窗,减少出行", "recipients": [ { "type": 0, "user_id": 1 }, { "type": 1, "group_id": 2 } ] }
- 响应信息: 返回创建后的通知信息,示例如下:
{ "code": 200, "data": { "notice_id": 7, "recipients": [ { "recipients_type": 0, "sort": 1, "notice_id": 7, "user_id": 1 }, { "user_id": "7" }, { "user_id": "6" }, { "user_id": "3" }, { "user_id": "2" }, { "user_id": "1" }, { "user_id": "0" } ] }, "message": "success" }
发布状态更新
- 请求 URL:
/api/notices/send_status
- 请求方式:
POST
- 请求头:
Content-Type: application/json
- Body 信息: 传入需要更新状态的通知 ID 列表(纯数字数组),示例如下::
[5, 6, 7]
- 响应信息: 返回更新后的通知信息,示例如下:
{ "code": 200, "message": "update rows 3", "data": { "status": 1 } }
删除公告
- 请求 URL:
/api/notices/:id/
- 请求方式:
DELETE
- 请求头:
Content-Type: application/json
- Body 信息: 无
- 响应信息: 返回删除后的通知信息,示例如下:
{ "message": "success", "code": 200, "data": "5" }
删除指定公告的用户
- 请求 URL:
/api/notices/:id/remove_members/
- 请求方式:
DELETE
- 请求头:
Content-Type: application/json
- Body 信息:传入需删除的成员信息 ,示例如下:
删除用户
{ "user_id": 3 }
删除组
{ "group_id": 0 }
- 响应信息: 返回删除后的通知信息,示例如下:
{ "message": "success", "code": 200, "data": "{}" }
获取指定公告关联的用户和用户组
- 请求 URL:
/api/notices/:id/members
- 请求方式:
GET
- Body 信息:无
- 返回值
{ "message": "success", "data": { "users": [ { "name": "Admin", "id": 1 }, { "name": "1000", "id": 2 }, { "name": "1001", "id": 3 } ], "notice_id": "6", "groups": [ { "name": "111", "id": 2 } ] }, "code": 200 }
消息
获取消息列表
- 请求 URL:
/api/messages_center/
- 请求方式:
GET
- 请求头:
Content-Type: application/json
- Body 信息: 无
- 响应信息: 返回消息列表,示例如下:
{ "data": [ { "message_center_status": 0, "created_at": "2025-08-21 02:40:16", "context": "1", "notice_id": 6, "title": "Debian2" }, { "message_center_status": 0, "created_at": "2025-08-21 06:03:57", "context": "关好门窗,减少出行", "notice_id": 7, "title": "暴雨通知" } ], "pageCount": 1, "page": 1, "rowCount": 6 }
修改消息状态
- 请求 URL:
/api/messages_center/read_status/
- 请求方式:
POST
- 请求头:
Content-Type: application/json
- Body 信息: 传入待修改状态的消息 ID 列表(纯数字数组),示例如下:
[6]
- 响应信息: 返回更新后的通知信息,示例如下:
{ "message": "status updated successfully", "data": "{}", "code": 200 }
删除消息
- 请求 URL:
/api/messages_center/
- 请求方式:
DELETE
- 请求头:
Content-Type: application/json
- Body 信息: 传入待删除的消息 ID 列表(纯数字数组),示例如下:
[6]
- 响应信息: 返回删除后的通知信息,示例如下:
{ "code": 200, "message": "delete success", "data": "{}" }