# 启用/停用自定义组织

对自定义组织进行启用或停用操作
**注意事项**：- 停用自定义组织时请确认有无在职员工、异动单据、待入职单据关联此自定义组织，如有会导致停用失败。
- 若启/停用的生效时间当天不存在版本则会自动生成一个版本。
- 若启/停用的生效时间当天存在版本则会修改该版本。 
- 如果该自定义组织设置了自动匹配规则，该规则也会同时被停用。

## 请求

基本 | &nbsp;
---|---
HTTP URL | https://open.feishu.cn/open-apis/corehr/v2/custom_orgs/active
HTTP Method | POST
接口频率限制 | [5 次/秒](https://open.feishu.cn/document/ukTMukTMukTM/uUzN04SN3QjL1cDN)
支持的应用类型 | Custom App、Store App
权限要求<br>**调用该 API 所需的权限。开启其中任意一项权限即可调用** | 读写自定义组织信息(corehr:custom_org:write)

### 请求头

名称 | 类型 | 必填 | 描述
---|---|---|---
Authorization | string | 是 | `tenant_access_token`<br>**值格式**："Bearer `access_token`"<br>**示例值**："Bearer t-7f1bcd13fc57d46bac21793a18e560"<br>[了解更多：如何选择与获取 access token](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-choose-which-type-of-token-to-use)
Content-Type | string | 是 | **固定值**："application/json; charset=utf-8"

### 请求体

名称 | 类型 | 必填 | 描述
---|---|---|---
org_id | string | 是 | 自定义组织 ID<br>- 可从 [批量查询自定义组织](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/corehr-v2/custom_org/query)的 org_id 字段中获取。<br>**示例值**："6862995757234914823"
object_api_name | string | 是 | 组织类型编码，可在「飞书人事-设置-组织配置」中相应的自定义组织目录下查看<br>**示例值**："custom_org_01"
active | boolean | 是 | 启用/停用状态。<br>- active 传 true 代表启用<br>- active 传 false 代表停用<br>**示例值**：true
effective_time | string | 是 | 自定义组织生效时间<br>- 填写格式： YYYY-MM-DD<br>- 系统默认为填写日期当天的 00:00:00 生效 <br>- 该接口只支持到最小单位为日<br>- 日期范围要求:1900-01-01 ～ 9999-12-31<br>**示例值**："2020-01-01"<br>**数据校验规则**：<br>- 长度范围：`10` ～ `10` 字符<br>- 正则校验：`^((([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29))$`

### 请求体示例
```json
{
    "org_id": "6862995757234914823",
    "object_api_name": "custom_org_01",
    "active": true,
    "effective_time": "2020-01-01"
}
```

## 响应

### 响应体

名称 | 类型 | 描述
---|---|---
code | int | 错误码，非 0 表示失败
msg | string | 错误描述
data | \- | \-

### 响应体示例
```json
{
    "code": 0,
    "msg": "success",
    "data": {}
}
```

### 错误码

HTTP状态码 | 错误码 | 描述 | 排查建议
---|---|---|---
400 | 1160285 | Failed to disable as it still has active employees after the deactivation effective time. | 检查是否还有人员关联该组织
400 | 1160281 | 1 or more members are in a job status change process after the current deactivation date | 检查是否有异动人员关联该组织
400 | 1160508 | Still has an individual to be onboarded after the current deactivation date | 仍有待入职人员
400 | 1160268 | Effective date for disabling the custom organization can't be earlier than the effective date of the last version | 停用日期不能早于最新的启用日期
400 | 1161200 | There are still enabled subordinates on the current deactivation date | 停用日期下仍有启用的下级
503 | 1161204 | Requset timeout | 联系飞书人事 [Oncall](https://applink.feishu.cn/TLJpeNdW)
429 | 1161604 | QPS over limit | 联系飞书人事 [Oncall](https://applink.feishu.cn/TLJpeNdW)

