服务端 API/考勤打卡/考勤班次/按名称查询班次
# 按名称查询班次

通过班次的名称查询班次信息。

## 请求

基本 | &nbsp;
---|---
HTTP URL | https://open.larksuite.com/open-apis/attendance/v1/shifts/query
HTTP Method | POST
支持的应用类型 | Custom App
权限要求<br>**调用该 API 所需的权限。开启其中任意一项权限即可调用** | 导出打卡数据(attendance:task:readonly)

### 请求头

名称 | 类型 | 必填 | 描述
---|---|---|---
Authorization | string | 是 | `tenant_access_token`<br>**值格式**："Bearer `access_token`"<br>**示例值**："Bearer t-7f1bcd13fc57d46bac21793a18e560"<br>[了解更多：获取与使用access_token](https://open.larksuite.com/document/ukTMukTMukTM/uMTNz4yM1MjLzUzM)

### 查询参数

名称 | 类型 | 必填 | 描述
---|---|---|---
shift_name | string | 是 | 班次名称<br>**示例值**："早班"

## 响应

### 响应体

名称 | 类型 | 描述
---|---|---
code | int | 错误码，非 0 表示失败
msg | string | 错误描述
data | shift | \-
&emsp;∟&nbsp;shift_id | string | 班次 ID
&emsp;∟&nbsp;shift_name | string | 班次名称
&emsp;∟&nbsp;punch_times | int | 打卡次数
&emsp;∟&nbsp;is_flexible | boolean | 是否弹性打卡
&emsp;∟&nbsp;flexible_minutes | int | 弹性打卡的时间
&emsp;∟&nbsp;no_need_off | boolean | 不需要打下班卡
&emsp;∟&nbsp;punch_time_rule | punch_time_rule\[\] | 打卡规则
&emsp;&emsp;∟&nbsp;on_time | string | 上班时间
&emsp;&emsp;∟&nbsp;off_time | string | 下班时间
&emsp;&emsp;∟&nbsp;late_minutes_as_late | int | 晚到多久记为迟到
&emsp;&emsp;∟&nbsp;late_minutes_as_lack | int | 晚到多久记为缺卡
&emsp;&emsp;∟&nbsp;on_advance_minutes | int | 最早多久可打上班卡
&emsp;&emsp;∟&nbsp;early_minutes_as_early | int | 早退多久记为早退
&emsp;&emsp;∟&nbsp;early_minutes_as_lack | int | 早退多久记为缺卡
&emsp;&emsp;∟&nbsp;off_delay_minutes | int | 最晚多久可打下班卡
&emsp;∟&nbsp;late_off_late_on_rule | late_off_late_on_rule\[\] | 晚走晚到规则
&emsp;&emsp;∟&nbsp;late_off_minutes | int | 晚走多久
&emsp;&emsp;∟&nbsp;late_on_minutes | int | 晚到多久
&emsp;∟&nbsp;rest_time_rule | rest_rule\[\] | 休息规则
&emsp;&emsp;∟&nbsp;rest_begin_time | string | 休息开始
&emsp;&emsp;∟&nbsp;rest_end_time | string | 休息结束

### 响应体示例

```json
{
    "code": 0,
    "msg": "success",
    "data": {
        "shift_id": "6919358778597097404",
        "shift_name": "早班",
        "punch_times": 1,
        "is_flexible": false,
        "flexible_minutes": 60,
        "no_need_off": true,
        "punch_time_rule": [
            {
                "on_time": "9:00",
                "off_time": "18:00， 第二天凌晨2点， 26:00",
                "late_minutes_as_late": 30,
                "late_minutes_as_lack": 60,
                "on_advance_minutes": 60,
                "early_minutes_as_early": 30,
                "early_minutes_as_lack": 60,
                "off_delay_minutes": 60
            }
        ],
        "late_off_late_on_rule": [
            {
                "late_off_minutes": 60,
                "late_on_minutes": 30
            }
        ],
        "rest_time_rule": [
            {
                "rest_begin_time": "13:00",
                "rest_end_time": "14:00"
            }
        ]
    }
}
```

### 错误码

HTTP状态码 | 错误码 | 描述 | 排查建议
---|---|---|---
400 | 1220001 | 参数错误 | 请检查参数是否符合要求
400 | 1220002 | 租户不存在 | 请检查 tenant_access_token 是否正确
500 | 1225000 | 系统错误 | 详见错误信息
500 | 1226000 | 班次服务系统错误 | 详见错误信息
400 | 1226003 | 班次不存在 | 请检查 shift_id 是否正确

