# Batch query department (not recommended)

Query department information in batches, including department basic information, custom field information, etc
**Notice**：This API is no longer recommended (does not support more complex field authentication function), please use [Batch Query Department V2](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/corehr-v2/department/batch_get) API (supports cost center, department manager, custom field authentication).
**Notice**：The delay of the database leader/follower is within 2s, that is, calling this API within 2s after directly creating the department may not query the data.

## Request

Facts | &nbsp;
---|---
HTTP URL | https://open.feishu.cn/open-apis/corehr/v1/departments
HTTP Method | GET
Rate Limit | [1000 per minute、50 per second](https://open.feishu.cn/document/ukTMukTMukTM/uUzN04SN3QjL1cDN)
Supported app types | Custom App、Store App
Required scopes<br>**To use this API, you must have at least 1 of the listed scopes.**<br>Enable any scope from the list | Obtain core HR information(corehr:corehr:readonly)<br>Update core HR information(corehr:corehr)
Required field scopes | **Notice**：The response body of the API contains the following sensitive fields, and they will be returned only after corresponding scopes are added. If you do not need the fields, it is not recommended that you request the scopes.<br>Obtain user ID(contact:user.employee_id:readonly)

### Request header

Parameter | Type | Required | Description
---|---|---|---
Authorization | string | Yes | `tenant_access_token`<br>**Value format**: "Bearer `access_token`"<br>**Example value**: "Bearer t-7f1bcd13fc57d46bac21793a18e560"<br>[How to choose and get access token](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-choose-which-type-of-token-to-use)

### Query parameters

Parameter | Type | Required | Description
---|---|---|---
page_token | string | No | Page identifier. It is not filled in the first request, indicating traversal from the beginning; when there will be more groups, the new page_token will be returned at the same time, and the next traversal can use the page_token to get more groups<br>**Example value**: "6966234786251671053"
page_size | string | Yes | paging size<br>**Example value**: 100
department_id_list | string\[\] | No | Department ID List<br>**Example value**: 7094136522860922111
name_list | string\[\] | No | List of department names, exact match required<br>**Example value**: Back-end R & D Department
user_id_type | string | No | User ID categories<br>**Example value**: people_corehr_id<br>**Optional values are**:<br>- open_id：Identifies a user to an app. The same user has different Open IDs in different apps. [How to get Open ID](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-obtain-openid)<br>- union_id：Identifies a user to a tenant that acts as a developer. A user has the same Union ID in apps developed by the same developer, and has different Union IDs in apps developed by different developers. A developer can use Union ID to link the same user's identities in multiple apps.[How to get Union ID](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-obtain-union-id)<br>- user_id：Identifies a user to a tenant. The same user has different User IDs in different tenants. In one single tenant, a user has the same User ID in all apps （including store apps）. User ID is usually used to communicate user data between different apps. [How to get User ID](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-obtain-user-id)<br>- people_corehr_id：Identify users with Feishu personnel IDs<br>**Default value**: `people_corehr_id`<br>**When the value is `user_id`, the following field scopes are required**:<br>Obtain user ID(contact:user.employee_id:readonly)
department_id_type | string | No | The department ID type used in this call<br>**Example value**: people_corehr_department_id<br>**Optional values are**:<br>- open_department_id：Identify departments by open_department_id<br>- department_id：Identify departments by department_id<br>- people_corehr_department_id：Identify departments by people_corehr_department_id<br>**Default value**: `people_corehr_department_id`

## Response

### Response body

Parameter | Type | Description
---|---|---
code | int | Error codes, fail if not zero
msg | string | Error descriptions
data | \- | \-
items | department\[\] | Inquiring department information
id | string | Department ID
sub_type | enum | The department subtype, the enumeration value can be obtained by the document [[Feishu personnel enumeration constant]] (/ssl: ttdoc/uAjLw4CM/ukTMukTMukTM/reference/corehr-v1/feishu-people-enum-constant) department subtype (department_sub_type) enumeration definition section
enum_name | string | enumeration value
display | i18n\[\] | enumerated multilingual display
lang | string | Language of name information
value | string | Content of name information
manager | string | The ID of the person in charge of the department, the enumeration value and detailed information can be obtained through the [Batch Query Employment Information] interface query
is_confidential | boolean | Is it confidential?
hiberarchy_common | hiberarchy_common | Hierarchical relationship, see entity for inner fields
parent_id | string | parent organization ID
name | i18n\[\] | name
lang | string | Language of name information
value | string | Content of name information
type | enum | Organization type, enumeration values can be obtained from the document [[Feishu personnel enumeration constant]] (/ssl: ttdoc/uAjLw4CM/ukTMukTMukTM/reference/corehr-v1/feishu-people-enum-constant) Organization type (organization_type) enumeration definition section
enum_name | string | enumeration value
display | i18n\[\] | enumerated multilingual display
lang | string | Language of name information
value | string | Content of name information
active | boolean | Whether to enable
effective_time | string | effective time
expiration_time | string | expiration time
code | string | code
description | i18n\[\] | description
lang | string | Language of name information
value | string | Content of name information
tree_order | string | tree order
list_order | string | list order
custom_fields | object_field_data\[\] | custom fields
field_name | string | field name
value | string | value
effective_time | string | effective time
expiration_time | string | expiration time
custom_fields | object_field_data\[\] | custom fields
field_name | string | field name
value | string | value
cost_center_id | string | cost center id
staffing_model | enum | Whether to use the position
enum_name | string | enumeration value
display | i18n\[\] | enumeration multilingual presentation
lang | string | language
value | string | content
has_more | boolean | Whether the response body has more parameters
page_token | string | Page identifier, when has_more is true, a new page_token will also be returned. Otherwise, page_token will not be returned

### Response body example
```json
{
    "code": 0,
    "msg": "Success",
    "data": {
        "items": [
            {
                "id": "6969828847121885087",
                "sub_type": {
                    "enum_name": "type_1",
                    "display": [
                        {
                            "lang": "zh-CN",
                            "value": "Zhang San"
                        }
                    ]
                },
                "manager": "6893013238632416776",
                "is_confidential": true,
                "hiberarchy_common": {
                    "parent_id": "4719168654814483759",
                    "name": [
                        {
                            "lang": "zh-CN",
                            "value": "Zhang San"
                        }
                    ],
                    "type": {
                        "enum_name": "type_1",
                        "display": [
                            {
                                "lang": "zh-CN",
                                "value": "Zhang San"
                            }
                        ]
                    },
                    "active": true,
                    "effective_time": "2020-05-01 00:00:00",
                    "expiration_time": "2020-05-02 00:00:00",
                    "code": "123456",
                    "description": [
                        {
                            "lang": "zh-CN",
                            "value": "Zhang San"
                        }
                    ],
                    "tree_order": "001000",
                    "list_order": "001000-001000",
                    "custom_fields": [
                        {
                            "field_name": "name",
                            "value": "\"Sandy\""
                        }
                    ]
                },
                "effective_time": "2020-05-01 00:00:00",
                "expiration_time": "2020-05-02 00:00:00",
                "custom_fields": [
                    {
                        "field_name": "name",
                        "value": "\"Sandy\""
                    }
                ],
                "cost_center_id": "7142384817131652652",
                "staffing_model": {
                    "enum_name": "phone_type",
                    "display": [
                        {
                            "lang": "zh-CN",
                            "value": "刘梓新"
                        }
                    ]
                }
            }
        ],
        "has_more": true,
        "page_token": "eVQrYzJBNDNONlk4VFZBZVlSdzlKdFJ4bVVHVExENDNKVHoxaVdiVnViQT0="
    }
}
```

