添加部门
更新时间:2026.07.21 10:41
功能说明
在当前租户中新增部门。根部门的 parentId 传 0 或不传。
调用说明
地址:
https://www.shudacloud.com/api/open-api/platform/contacts/departments/create
方式:POST
接口编码:contacts:departments:create
鉴权方式:在请求 Header 中传入 X-API-Key。无需传入 tenant-id,服务端会根据 API Key 自动识别所属租户。
本页参数和返回值来自测试环境真实调试;请求示例中的域名已按生产环境填写。当前示例 API Key 仅在测试环境有效。
请求参数
| 名称 | 位置 | 类型 | 是否必选 | 示例值 | 描述 |
|---|---|---|---|---|---|
| X-API-Key | Header | String | 是 | qop_f9f5d23ff4c84e2aa513e37d08780022 | 开放平台 API Key |
| name | Body | String | 是 | 开放接口文档测试部门 | 部门名称 |
| parentId | Body | String | 否 | 0 | 父部门编号 |
| leaderUserIds | Body | Array | 否 | [] | 负责人租户成员编号列表 |
返回数据
| 名称 | 类型 | 示例值 | 描述 |
|---|---|---|---|
| code | Integer | 0 | 业务状态码,0 表示成功 |
| msg | String | 空字符串 | 业务提示信息 |
| data | String | ea415fa680d92b39e8b7317597d9ce55 | 新增成功的部门编号 |
示例
请求示例
curl --request POST \
--url "https://www.shudacloud.com/api/open-api/platform/contacts/departments/create" \
--header "X-API-Key: qop_f9f5d23ff4c84e2aa513e37d08780022" \
--header "Content-Type: application/json" \
--data '{
"name": "开放接口文档测试部门",
"parentId": "0",
"leaderUserIds": []
}'
正常返回示例
{
"code": 0,
"msg": "",
"data": "ea415fa680d92b39e8b7317597d9ce55"
}
常见异常
| 业务状态码 | 说明 |
|---|---|
| 400 | 请求参数格式或必填参数校验失败 |
| 1002030001 | 未传入 X-API-Key |
| 1002030002 | API Key 无效 |
| 1002030003 | API Key 已停用 |
| 1002030004 | 当前调用 IP 不在 API Key 白名单内 |
| 1002030006 | 当前 API Key 无权调用该接口 |
开放接口的业务异常通常仍返回 HTTP 200,请以响应体中的
code判断调用是否成功。