# 启用或停用岗位

对岗位进行启用或停用操作

## 请求

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

### 请求体

名称 | 类型 | 必填 | 描述
---|---|---|---
position_id | string | 是 | 岗位ID，详细信息可通过[查询岗位信息](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/corehr-v2/position/query)接口获得<br>**示例值**："6862995757234914823"
active | boolean | 是 | 可选值：true（启用）、false（停用）<br>**示例值**：true
effective_time | string | 是 | 生效时间<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
{
    "position_id": "6862995757234914823",
    "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 | 1160267 | Activation date cannot be earlier than the effective date of the last deactivated version | 启用生效日期不可早于最后一个版本生效日期，请检查最后一个版本的生效日期，并确保当前设置的启用生效日期不早于该日期后重试
400 | 1160104 | Record doesn't exist | 记录不存在，请检查传入的记录ID是否正确或确认记录是否存在
400 | 1160281 | Failed to disable as 1 or more members of it are in a job status change process after the current deactivation date | 停用失败。在停用生效日期后，此岗位仍有在途的异动，请检查该岗位在停用生效日期后的在途异动列表，处理完毕后重试
400 | 1160269 | Effective date can't be later than the year 9999 | 生效日期不能晚于9999年，请修改生效日期为9999年12月31日或之前
400 | 1160353 | Effective Date cannot earlier than 1900 | 生效日期不能早于1900年，请修改生效日期为1900年1月1日或之后
400 | 1160501 | Failed to disable as it still has sub position(s) after the deactivation effective time. | 停用失败。在停用生效日期后，此岗位仍有生效的下级岗位，请检查该岗位在停用生效日期后的下级岗位列表，移除或调整相关岗位后重试
400 | 1160508 | Failed to disable. As the position still has pre-hires after the deactivation effective time. | 停用失败。在停用生效日期后，此岗位仍有人员将入职，请检查该岗位在停用生效日期后的预入职人员列表，处理完毕后重试
400 | 1160268 | Effective date for disabling the position can't be earlier than the effective date of the last version | 停用生效日期不可早于最后一个版本生效日期，请检查最后一个版本的生效日期并调整停用生效日期
400 | 1161200 | There are still enabled subordinates on the current deactivation date | 停用失败。在停用生效日期后，此岗位仍有在职员工，请检查该岗位在停用生效日期后的在职员工列表，移除或调整相关员工后重试
400 | 1160266 | Effective date must be later than the first effective date | 生效日期必须晚于第一个版本的生效日期，请检查第一个版本的生效日期，并调整当前生效日期至其之后重试
429 | 1161604 | QPS over limit | QPS 超出限制，请降低请求频率重试，必要时请联系 [技术支持](https://applink.feishu.cn/TLJpeNdW)

