> ## Documentation Index
> Fetch the complete documentation index at: https://help.dingtalk.io/llms.txt
> Use this file to discover all available pages before exploring further.

# 過去のシフトの照会

> シフト ID とバージョンを指定し、過去のシフトをを照会する API です。シフト名、シフト設定、打刻時間、休憩時間を取得できます。

この API を呼び出すと、シフト ID とバージョンを指定して過去のシフトを照会できます。レスポンスには、シフト名、シフト設定、打刻時間、休憩時間が含まれます。

## リクエスト

| **基本情報** | |
| - | - |
| HTTP URL | [https://api.dingtalk.io/topapi/attendance/shift/history/query](https://api.dingtalk.io/topapi/attendance/shift/history/query) |
| HTTP メソッド | POST |
| サポートされるアプリタイプ | appType-社内アプリ |
| 権限 | permission-qyapi\_attendance\_group\_read-勤怠グループの照会権限 |

### クエリパラメータ

| 名前 | タイプ | 必須 | 例 | 説明 |
| - | - | - | - | - |
| access\_token | String | はい | 73e9xxx | この API の呼び出しに使用するアプリ認証情報です。[社内アプリの access\_token の取得](https://help.dingtalk.io/ja/open/development/obtain-orgapp-token) API を呼び出して取得します。 |

### リクエストボディ

| 名前 | タイプ | 必須 | 例 | 説明 |
| - | - | - | - | - |
| op\_user\_id | String | はい | user123 | 操作者の userId です。 |
| shift\_id | Number | はい | 628380875 | シフト ID です。[シフト概要の取得](https://help.dingtalk.io/ja/open/development/enterprise-shift-query-in-batches.md) API を呼び出し、id の値を取得します。 |
| version | Number | はい | 624190327 | シフトのバージョンです。[ユーザーのシフト設定情報の一括照会](https://help.dingtalk.io/ja/open/development/query-batch-scheduling-information.md) API を呼び出し、shift\_version の値を取得します。 |

### リクエスト例

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.dingtalk.io/topapi/attendance/shift/history/query" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=e56f7xxxxeb7ef1' \
-d 'op_user_id=dd_dd' \
-d 'shift_id=2445' \
-d 'version=222'
```

Java

```java theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/attendance/shift/history/query");
OapiAttendanceShiftHistoryQueryRequest req = new OapiAttendanceShiftHistoryQueryRequest();
req.setOpUserId("user456");
req.setShiftId(715390132L);
req.setVersion(624190327L);
OapiAttendanceShiftHistoryQueryResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
```

Python

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import dingtalk.api

req=dingtalk.api.OapiAttendanceShiftHistoryQueryRequest("https://api.dingtalk.io/topapi/attendance/shift/history/query")

req.op_user_id="dd_dd"
req.shift_id=2445
req.version=222
try:
  resp= req.getResponse(access_token)
  print(resp)
except Exception,e:
  print(e)
```

PHP

```php theme={"theme":{"light":"github-light","dark":"github-dark"}}
include "TopSdk.php";
date_default_timezone_set('Asia/Shanghai');

$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_POST , DingTalkConstant::$FORMAT_JSON);
$req = new OapiAttendanceShiftHistoryQueryRequest;
$req->setOpUserId("dd_dd");
$req->setShiftId("2445");
$req->setVersion("222");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/attendance/shift/history/query");
```

C#

```csharp theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/attendance/shift/history/query");
OapiAttendanceShiftHistoryQueryRequest req = new OapiAttendanceShiftHistoryQueryRequest();
req.OpUserId = "dd_dd";
req.ShiftId = 2445L;
req.Version = 222L;
OapiAttendanceShiftHistoryQueryResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
```

## レスポンス

### レスポンスボディ

| 名前 | タイプ | 例 | 説明 |
| - | - | - | - |
| result | TopShiftVo | | 照会結果です。 |
| shift\_group\_name | String | 通常日勤 | シフトグループ名です。 |
| corp\_id | String | dinge87fxxx | 組織 ID（corpId）です。 |
| shift\_setting | TopShiftSettingVo | | シフト設定です。 |
| shift\_id | Number | 628380875 | シフト ID です。 |
| gmt\_modified | Date | 2021-01-14 14:21:03 | シフトの最終更新日時です。 |
| corp\_id | String | dinge87fxxx | 組織 ID（corpId）です。 |
| is\_deleted | String | N | 削除フラグです。 |
| work\_time\_minutes | Number | 480 | 勤務時間（分）です。-1 の場合、この機能は無効です。 |
| id | Number | 350530359 | シフト設定 ID です。現在は使用されていません。 |
| attend\_days | String | 21 | このシフトの出勤日数です。 |
| gmt\_create | Date | 2021-01-14 14:18:08 | 作成時間です。 |
| name | String | 通常日勤 | シフト名です。 |
| id | Number | 241120079 | シフト ID です。 |
| sections | TopSectionVo\[] | | 打刻セクションです。 |
| punches | TopPunchVo\[] | | 打刻ポイントです。 |
| check\_type | String | OnDuty | 打刻タイプ：  - **OnDuty**：出勤打刻 - **OffDuty**：退勤打刻 |
| end\_min | Number | 1 | 打刻を許可する最大の遅延時間（分）です。 |
| across | Number | 0 | シフトが翌日にまたがるかどうか：  - **0**：翌日にまたがらない - **1**：翌日にまたがる |
| check\_time | Date | 1970-01-01 09:00:00 | 打刻時間です。 |
| permit\_minutes | Number | 60 | 遅刻または早退の許容時間です。 |
| free\_check | Boolean | false | 打刻が免除されるかどうか：  - **true**：打刻不要 - **false**：打刻必須 |
| id | Number | 376955859 | 打刻ポイント ID です。現在は使用されていません。 |
| begin\_min | Number | demo | 打刻を許可する最大の前倒し時間（分）です。 |
| work\_time\_minutes | Number | 480 | 勤務時間（分）です。 |
| rests | TopRestVo\[] | | 休憩セクションです。 |
| check\_type | String | OnDuty | 休憩タイプ：  - **OnDuty**：休憩開始 - **OffDuty**：休憩終了 |
| across | Number | 0 | 休憩が翌日にまたがるかどうか（休憩時間が翌日にあたるかどうか）：  - **0**：翌日にまたがらない - **1**：翌日にまたがる |
| check\_time | Date | 1970-01-01 12:00:00 | 休憩時間です。 |
| id | Number | 376955861 | 休憩ポイント ID です。 |
| id | Number | 22979360 | 打刻セクション ID です。出勤打刻と退勤打刻の 1 組で 1 セクションとなります。1 つのシフトに複数のセクションを設定できます。 |
| shift\_group\_id | Number | 22979 | シフトグループ ID です。 |
| success | Boolean | true | 呼び出しに成功したかどうか：  - **true**：成功 - **false**：失敗 |
| errcode | Number | 0 | リターンコードです。 |
| errmsg | String | ok | リターンコードの説明です。 |
| request\_id | String | q3ef3y3sogkd | リクエスト ID です。 |

### レスポンスボディの例

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "errcode": 0,
  "errmsg":"ok",
  "result": {
    "corp_id": "dinge87fxxx",
    "id": 628380875,
    "name": "通常日勤",
    "sections": [
      {
        "id": 350530359,
        "punches": [
          {
            "across": 0,
            "begin_min": 1,
            "check_time": "1970-01-01 09:00:00",
            "check_type": "OnDuty",
            "end_min": 1,
            "free_check": false,
            "id": 376955859,
            "permit_minutes": 60
          },
          {
            "across": 0,
            "begin_min": 1,
            "check_time": "1970-01-01 18:00:00",
            "check_type": "OffDuty",
            "end_min": 1,
            "free_check": false,
            "id": 376955860,
            "permit_minutes": 15
          }
        ],
        "rests": [
          {
            "across": 0,
            "check_time": "1970-01-01 12:00:00",
            "check_type": "OnDuty",
            "id": 376955861
          },
          {
            "across": 0,
            "check_time": "1970-01-01 13:00:00",
            "check_type": "OffDuty",
            "id": 376955862
          }
        ]
      }
    ],
    "shift_setting": {
      "corp_id": "dinge87fxxx",
      "gmt_create": "2021-01-14 14:18:08",
      "gmt_modified": "2021-01-14 14:21:03",
      "id": 624190327,
      "is_deleted": "N",
      "shift_id": 628380875,
      "work_time_minutes": 480
    }
  },
  "success": true,
  "request_id": "q3ef3y3sogkd"
}
```

### エラーコード

この API がエラーを返した場合は、エラーメッセージをもとに[グローバルエラーコード](https://help.dingtalk.io/ja/open/development/server-api-error-codes-1.md)ドキュメントで解決方法を確認してください。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.