Get the sub-department ID list
API call description
- This API is not restricted by the authorization scope.
- This API only supports getting the ID list of the next level of departments.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Call this API to get the list of all direct sub-department IDs under a department, not subject to the authorization scope restriction.
| Basic information | |
|---|---|
| HTTP URL | https://api.dingtalk.io/topapi/v2/department/listsubid |
| HTTP Method | POST |
| Supported app types | appType-Internal app, appType-Third-party enterprise app |
| Permissions | permission-qyapi_get_department_list-Read permission for Contacts department information |
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| access_token | String | Yes | bE74xxxx | The app credential used to call this API. - For an internal app, get it through the API for getting the access_token of an internal app. - For a third-party enterprise app, get it through the API for getting the access_token of a third-party enterprise. |
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| dept_id | Number | Yes | 1 | The parent department ID. Pass 1 for the root department. To get the dept_id value, call the Get the department list API. |
curl -X POST "https://api.dingtalk.io/topapi/v2/department/listsubid" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=0dcxxxx108dcd028' \
-d 'dept_id=100'
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/v2/department/listsubid");
OapiV2DepartmentListsubidRequest req = new OapiV2DepartmentListsubidRequest();
req.setDeptId(100L);
OapiV2DepartmentListsubidResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
import dingtalk.api
req=dingtalk.api.OapiV2DepartmentListsubidRequest("https://api.dingtalk.io/topapi/v2/department/listsubid")
req.dept_id=100
try:
resp= req.getResponse(access_token)
print(resp)
except Exception,e:
print(e)
include "TopSdk.php";
date_default_timezone_set('Asia/Shanghai');
$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_POST , DingTalkConstant::$FORMAT_JSON);
$req = new OapiV2DepartmentListsubidRequest;
$req->setDeptId("100");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/v2/department/listsubid");
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/v2/department/listsubid");
OapiV2DepartmentListsubidRequest req = new OapiV2DepartmentListsubidRequest();
req.DeptId = 100L;
OapiV2DepartmentListsubidResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
| Name | Type | Example | Description |
|---|---|---|---|
| request_id | String | 48vhxdnwhve6 | The request ID. |
| errcode | Number | 0 | The return code. |
| errmsg | String | Invalid department ID | The error message returned when the call fails. |
| result | DeptListSubIdResponse | The returned result. | |
| dept_id_list | Number[] | [2,3,4,5] | The sub-department list. |
{
"errcode": 0,
"errmsg":"ok",
"result": {
"dept_id_list": [
379xxxx95,
411xxxx76,
399xxxx96,
400xxxx83,
404xxxx47
]
},
"request_id": "169dfniaazqb4"
}
| Error code (errcode) | Error message (errmsg) | Solution |
|---|---|---|
| 60003 | The corresponding department is not found | Verify that dept_id is correct. |
| 400002 | Invalid parameter | Verify that the parameters are entered as required. |
| -1 | System busy | Try again later. |
Was this page helpful?