> ## 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.

# 社員の休暇残数変更記録の一括照会

> 指定社員の休暇残数変更記録を休暇タイプごとに一括取得する API です。残数の初期化・消費・更新履歴をページングで照会できます。

この API を呼び出して、社員の休暇残数変更記録をすべて取得します。記録には、休暇残数の初期化、社員が消費したクォータ、休暇残数の更新が含まれます。

## リクエスト

### 基本情報

| フィールド | 値 |
| - | - |
| HTTP URL | [https://api.dingtalk.io/v1.0/attendance/vacations/records/query](https://api.dingtalk.io/v1.0/attendance/vacations/records/query) |
| HTTP メソッド | POST |
| 対応アプリタイプ | appType-社内アプリ　appType-サードパーティ社内アプリ |
| 権限 | permission-qyapi\_holiday\_readonly-DingTalk 休暇照会権限 |

### リクエストヘッダー

| 名前 | タイプ | 必須 | 説明 |
| - | - | - | - |
| x-acs-dingtalk-access-token | 文字列 | はい | この API を呼び出すためのアクセス認証情報です。次の方法で取得します。   - 社内アプリ：[社内アプリのアクセストークンを取得](https://help.dingtalk.io/ja/open/development/obtain-the-access-token-of-an-internal-app.md) API を呼び出します。 - サードパーティ社内アプリ：サードパーティアプリを承認した組織のアクセストークンを取得する API を呼び出します。 |

### リクエストボディ

| 名前 | タイプ | 必須 | 説明 |
| - | - | - | - |
| opUserId | 文字列 | はい | OA承認のアプリ権限を持つ社内の管理者の userId です。スーパー管理者の userId を指定してください。[管理者リストを取得](https://help.dingtalk.io/ja/open/development/query-the-administrator-list.md) API を呼び出し、レスポンス内のスーパー管理者の `userId` フィールドを使用します。 |
| leaveCode | 文字列 | はい | 休暇タイプの一意の識別子です。[休暇ルールリストを照会](https://help.dingtalk.io/ja/open/development/holiday-type-query.md) API を呼び出して `leave_code` の値を取得します。 |
| userIds | 文字列の配列 | はい | 照会対象の社員の userId リストです。1 回の呼び出しで最大 50 件の userId を指定できます。 |
| pageNumber | long | はい | ページングカーソルです。   - 初回の照会時は 0 を指定します。 - 2 回目以降は、前回の照会までの累積オフセットを指定します。 |
| pageSize | 整数 | はい | ページングのオフセットです。最大値：200。 |

### リクエスト例

HTTP

```http theme={"theme":{"light":"github-light","dark":"github-dark"}}
POST /v1.0/attendance/vacations/records/query HTTP/1.1
Host:api.dingtalk.io
x-acs-dingtalk-access-token:xxxxx
Content-Type:application/json

{
  "opUserId" : "user01",
  "leaveCode" : "f84a2dxxxx",
  "userIds" : [ "user1" ],
  "pageNumber" : 1,
  "pageSize" : 100
}
```

Java

```java theme={"theme":{"light":"github-light","dark":"github-dark"}}
// このファイルは自動生成されています。編集しないでください。
package com.aliyun.sample;

import com.aliyun.tea.*;

public class Sample {

    /**
     * Token を使用してアカウントの Client を初期化します
     * @return Client
     * @throws Exception
     */
    public static com.aliyun.dingtalkattendance_1_0.Client createClient() throws Exception {
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
        config.protocol = "https";
        config.regionId = "central";
        return new com.aliyun.dingtalkattendance_1_0.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        com.aliyun.dingtalkattendance_1_0.Client client = Sample.createClient();
        com.aliyun.dingtalkattendance_1_0.models.GetLeaveRecordsHeaders getLeaveRecordsHeaders = new com.aliyun.dingtalkattendance_1_0.models.GetLeaveRecordsHeaders();
        getLeaveRecordsHeaders.xAcsDingtalkAccessToken = "<your access token>";
        com.aliyun.dingtalkattendance_1_0.models.GetLeaveRecordsRequest getLeaveRecordsRequest = new com.aliyun.dingtalkattendance_1_0.models.GetLeaveRecordsRequest()
                .setOpUserId("user01")
                .setLeaveCode("f84a2dxxxx")
                .setUserIds(java.util.Arrays.asList(
                    "user1"
                ))
                .setPageNumber(1L)
                .setPageSize(100);
        try {
            client.getLeaveRecordsWithOptions(getLeaveRecordsRequest, getLeaveRecordsHeaders, new com.aliyun.teautil.models.RuntimeOptions());
        } catch (TeaException err) {
            if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                // err には code と message 属性が含まれ、開発者が問題を特定するのに役立ちます
            }

        } catch (Exception _err) {
            TeaException err = new TeaException(_err.getMessage(), _err);
            if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                // err には code と message 属性が含まれ、開発者が問題を特定するのに役立ちます
            }

        }        
    }
}
```

Python

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
# -*- coding: utf-8 -*-
# このファイルは自動生成されています。編集しないでください。
import sys

from typing import List

from alibabacloud_dingtalk.attendance_1_0.client import Client as dingtalkattendance_1_0Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_dingtalk.attendance_1_0 import models as dingtalkattendance__1__0_models
from alibabacloud_tea_util import models as util_models
from alibabacloud_tea_util.client import Client as UtilClient

class Sample:
    def __init__(self):
        pass

    @staticmethod
    def create_client() -> dingtalkattendance_1_0Client:
        """
        Token を使用してアカウントの Client を初期化します
        @return: Client
        @throws Exception
        """
        config = open_api_models.Config()
        config.protocol = 'https'
        config.region_id = 'central'
        return dingtalkattendance_1_0Client(config)

    @staticmethod
    def main(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        get_leave_records_headers = dingtalkattendance__1__0_models.GetLeaveRecordsHeaders()
        get_leave_records_headers.x_acs_dingtalk_access_token = '<your access token>'
        get_leave_records_request = dingtalkattendance__1__0_models.GetLeaveRecordsRequest(
            op_user_id='user01',
            leave_code='f84a2dxxxx',
            user_ids=[
                'user1'
            ],
            page_number=1,
            page_size=100
        )
        try:
            client.get_leave_records_with_options(get_leave_records_request, get_leave_records_headers, util_models.RuntimeOptions())
        except Exception as err:
            if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
                # err には code と message 属性が含まれ、開発者が問題を特定するのに役立ちます
                pass

    @staticmethod
    async def main_async(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        get_leave_records_headers = dingtalkattendance__1__0_models.GetLeaveRecordsHeaders()
        get_leave_records_headers.x_acs_dingtalk_access_token = '<your access token>'
        get_leave_records_request = dingtalkattendance__1__0_models.GetLeaveRecordsRequest(
            op_user_id='user01',
            leave_code='f84a2dxxxx',
            user_ids=[
                'user1'
            ],
            page_number=1,
            page_size=100
        )
        try:
            await client.get_leave_records_with_options_async(get_leave_records_request, get_leave_records_headers, util_models.RuntimeOptions())
        except Exception as err:
            if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
                # err には code と message 属性が含まれ、開発者が問題を特定するのに役立ちます
                pass

if __name__ == '__main__':
    Sample.main(sys.argv[1:])
```

PHP

```php theme={"theme":{"light":"github-light","dark":"github-dark"}}
<?php

// このファイルは自動生成されています。編集しないでください。
namespace AlibabaCloud\SDK\Sample;

use AlibabaCloud\SDK\Dingtalk\Vattendance_1_0\Dingtalk;
use \Exception;
use AlibabaCloud\Tea\Exception\TeaError;
use AlibabaCloud\Tea\Utils\Utils;

use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\Dingtalk\Vattendance_1_0\Models\GetLeaveRecordsHeaders;
use AlibabaCloud\SDK\Dingtalk\Vattendance_1_0\Models\GetLeaveRecordsRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;

class Sample {

    /**
     * Token を使用してアカウントの Client を初期化します
     * @return Dingtalk Client
     */
    public static function createClient(){
        $config = new Config([]);
        $config->protocol = "https";
        $config->regionId = "central";
        return new Dingtalk($config);
    }

    /**
     * @param string[] $args
     * @return void
     */
    public static function main($args){
        $client = self::createClient();
        $getLeaveRecordsHeaders = new GetLeaveRecordsHeaders([]);
        $getLeaveRecordsHeaders->xAcsDingtalkAccessToken = "<your access token>";
        $getLeaveRecordsRequest = new GetLeaveRecordsRequest([
            "opUserId" => "user01",
            "leaveCode" => "f84a2dxxxx",
            "userIds" => [
                "user1"
            ],
            "pageNumber" => 1,
            "pageSize" => 100
        ]);
        try {
            $client->getLeaveRecordsWithOptions($getLeaveRecordsRequest, $getLeaveRecordsHeaders, new RuntimeOptions([]));
        }
        catch (Exception $err) {
            if (!($err instanceof TeaError)) {
                $err = new TeaError([], $err->getMessage(), $err->getCode(), $err);
            }
            if (!Utils::empty_($err->code) && !Utils::empty_($err->message)) {
                // err には code と message 属性が含まれ、開発者が問題を特定するのに役立ちます
            }
        }
    }
}
$path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
if (file_exists($path)) {
    require_once $path;
}
Sample::main(array_slice($argv, 1));
```

Go

```go theme={"theme":{"light":"github-light","dark":"github-dark"}}
// このファイルは自動生成されています。編集しないでください。
package main

import (
  "os"
  util  "github.com/alibabacloud-go/tea-utils/v2/service"
  dingtalkattendance_1_0  "github.com/alibabacloud-go/dingtalk/attendance_1_0"
  openapi  "github.com/alibabacloud-go/darabonba-openapi/v2/client"
  "github.com/alibabacloud-go/tea/tea"
)

/**
 * Token を使用してアカウントの Client を初期化します
 * @return Client
 * @throws Exception
 */
func CreateClient () (_result *dingtalkattendance_1_0.Client, _err error) {
  config := &openapi.Config{}
  config.Protocol = tea.String("https")
  config.RegionId = tea.String("central")
  _result = &dingtalkattendance_1_0.Client{}
  _result, _err = dingtalkattendance_1_0.NewClient(config)
  return _result, _err
}

func _main (args []*string) (_err error) {
  client, _err := CreateClient()
  if _err != nil {
    return _err
  }

  getLeaveRecordsHeaders := &dingtalkattendance_1_0.GetLeaveRecordsHeaders{}
  getLeaveRecordsHeaders.XAcsDingtalkAccessToken = tea.String("<your access token>")
  getLeaveRecordsRequest := &dingtalkattendance_1_0.GetLeaveRecordsRequest{
    OpUserId: tea.String("user01"),
    LeaveCode: tea.String("f84a2dxxxx"),
    UserIds: []*string{tea.String("user1")},
    PageNumber: tea.Int64(1),
    PageSize: tea.Int32(100),
  }
  tryErr := func()(_e error) {
    defer func() {
      if r := tea.Recover(recover()); r != nil {
        _e = r
      }
    }()
    _, _err = client.GetLeaveRecordsWithOptions(getLeaveRecordsRequest, getLeaveRecordsHeaders, &util.RuntimeOptions{})
    if _err != nil {
      return _err
    }

    return nil
  }()

  if tryErr != nil {
    var err = &tea.SDKError{}
    if _t, ok := tryErr.(*tea.SDKError); ok {
      err = _t
    } else {
      err.Message = tea.String(tryErr.Error())
    }
    if !tea.BoolValue(util.Empty(err.Code)) && !tea.BoolValue(util.Empty(err.Message)) {
      // err には code と message 属性が含まれ、開発者が問題を特定するのに役立ちます
    }

  }
  return _err
}

func main() {
  err := _main(tea.StringSlice(os.Args[1:]))
  if err != nil {
    panic(err)
  }
}
```

Node.js

```typescript theme={"theme":{"light":"github-light","dark":"github-dark"}}
// このファイルは自動生成されています。編集しないでください。
import Util, * as $Util from '@alicloud/tea-util';
import dingtalkattendance_1_0, * as $dingtalkattendance_1_0 from '@alicloud/dingtalk/attendance_1_0';
import OpenApi, * as $OpenApi from '@alicloud/openapi-client';
import * as $tea from '@alicloud/tea-typescript';

export default class Client {

  /**
   * Token を使用してアカウントの Client を初期化します
   * @return Client
   * @throws Exception
   */
  static createClient(): dingtalkattendance_1_0 {
    let config = new $OpenApi.Config({ });
    config.protocol = "https";
    config.regionId = "central";
    return new dingtalkattendance_1_0(config);
  }

  static async main(args: string[]): Promise<void> {
    let client = Client.createClient();
    let getLeaveRecordsHeaders = new $dingtalkattendance_1_0.GetLeaveRecordsHeaders({ });
    getLeaveRecordsHeaders.xAcsDingtalkAccessToken = "<your access token>";
    let getLeaveRecordsRequest = new $dingtalkattendance_1_0.GetLeaveRecordsRequest({
      opUserId: "user01",
      leaveCode: "f84a2dxxxx",
      userIds: [
        "user1"
      ],
      pageNumber: 1,
      pageSize: 100,
    });
    try {
      await client.getLeaveRecordsWithOptions(getLeaveRecordsRequest, getLeaveRecordsHeaders, new $Util.RuntimeOptions({ }));
    } catch (err) {
      if (!Util.empty(err.code) && !Util.empty(err.message)) {
        // err には code と message 属性が含まれ、開発者が問題を特定するのに役立ちます
      }

    }    
  }

}

Client.main(process.argv.slice(2));
```

C#

```csharp theme={"theme":{"light":"github-light","dark":"github-dark"}}
// このファイルは自動生成されています。編集しないでください。

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;

using Tea;
using Tea.Utils;

namespace AlibabaCloud.SDK.Sample
{
    public class Sample 
    {

        /**
         * Token を使用してアカウントの Client を初期化します
         * @return Client
         * @throws Exception
         */
        public static AlibabaCloud.SDK.Dingtalkattendance_1_0.Client CreateClient()
        {
            AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config();
            config.Protocol = "https";
            config.RegionId = "central";
            return new AlibabaCloud.SDK.Dingtalkattendance_1_0.Client(config);
        }

        public static void Main(string[] args)
        {
            AlibabaCloud.SDK.Dingtalkattendance_1_0.Client client = CreateClient();
            AlibabaCloud.SDK.Dingtalkattendance_1_0.Models.GetLeaveRecordsHeaders getLeaveRecordsHeaders = new AlibabaCloud.SDK.Dingtalkattendance_1_0.Models.GetLeaveRecordsHeaders();
            getLeaveRecordsHeaders.XAcsDingtalkAccessToken = "<your access token>";
            AlibabaCloud.SDK.Dingtalkattendance_1_0.Models.GetLeaveRecordsRequest getLeaveRecordsRequest = new AlibabaCloud.SDK.Dingtalkattendance_1_0.Models.GetLeaveRecordsRequest
            {
                OpUserId = "user01",
                LeaveCode = "f84a2dxxxx",
                UserIds = new List<string>
                {
                    "user1"
                },
                PageNumber = 1,
                PageSize = 100,
            };
            try
            {
                client.GetLeaveRecordsWithOptions(getLeaveRecordsRequest, getLeaveRecordsHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions());
            }
            catch (TeaException err)
            {
                if (!AlibabaCloud.TeaUtil.Common.Empty(err.Code) && !AlibabaCloud.TeaUtil.Common.Empty(err.Message))
                {
                    // err には code と message 属性が含まれ、開発者が問題を特定するのに役立ちます
                }
            }
            catch (Exception _err)
            {
                TeaException err = new TeaException(new Dictionary<string, object>
                {
                    { "message", _err.Message }
                });
                if (!AlibabaCloud.TeaUtil.Common.Empty(err.Code) && !AlibabaCloud.TeaUtil.Common.Empty(err.Message))
                {
                    // err には code と message 属性が含まれ、開発者が問題を特定するのに役立ちます
                }
            }
        }

    }
}
```

## レスポンス

### レスポンスボディ

| 名前 | タイプ | 説明 |
| - | - | - |
| result | オブジェクト | 返却結果です。 |
| hasMore | 真偽値 | 後続の結果があるかどうかを示します。   - **true**：後続の結果があります。 - **false**：後続の結果はありません。 |
| leaveRecords | 配列 | 休暇消費記録のリストです。 |
| userId | 文字列 | 社員の userId です。 |
| leaveCode | 文字列 | 休暇タイプの一意の識別子です。 |
| recordId | 文字列 | 休暇消費記録の一意の識別子です。 |
| quotaId | 文字列 | 休暇クォータの一意の識別子です。 |
| calType | 文字列 | 計算タイプです。   - **insert**：新規レコード - **add**：追加 - **delete**：削除 - **update**：更新 - **null**（またはフィールドが返されない場合）：休暇申請による消費 |
| startTime | long | クォータ有効期間または休暇申請の開始時刻です（ミリ秒単位のタイムスタンプ）。 |
| endTime | long | クォータ有効期間または休暇申請の終了時刻です（ミリ秒単位のタイムスタンプ）。 |
| leaveViewUnit | 文字列 | 表示単位です。   - **day**：日 - **hour**：時間 |
| leaveReason | 文字列 | 理由です。 |
| leaveRecordType | 文字列 | 休暇記録のタイプです。   - **leave**：休暇申請 - **update**：クォータ更新 - **modify\_quota**：残数の初期化または残数の更新 |
| leaveStatus | 文字列 | 休暇申請のステータスです。   - **init**：休暇申請は承認待ちです。 - **success**：休暇申請は承認されました。 - **refuse**：休暇申請は却下されました。 - **abort**：休暇申請は取り下げられました。 - **revoke**：休暇申請は承認された後、取消申請が承認されました。 |
| recordNumPerDay | long | 日単位で計算した消費クォータです。   - **注意**  休暇タイプが日単位で計算される場合、この値は空ではなく、1/100 日単位で表されます。例：1000 = 10 日。 |
| recordNumPerHour | long | 時間単位で計算した消費クォータです。   - **注意**  休暇タイプが時間単位で計算される場合、この値は空ではなく、1/100 時間単位で表されます。例：1000 = 10 時間。 |
| gmtCreate | long | 記録の作成時間です（ミリ秒単位のタイムスタンプ）。 |
| gmtModified | long | 記録の編集時間です（ミリ秒単位のタイムスタンプ）。 |
| opUserId | 文字列 | 記録の操作者の ID です。 |
| success | 真偽値 | リクエストが成功したかどうかを示します。   - **true**：成功 - **false**：失敗 |

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

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
HTTP/1.1 200 OK
Content-Type:application/json

{
  "result" : {
    "hasMore" : true,
    "leaveRecords" : [ {
      "userId" : "user1",
      "leaveCode" : "f84a2dxxxx",
      "recordId" : "db1d74xxxxbaa",
      "quotaId" : "db1d74xxxxbaa",
      "calType" : "add",
      "startTime" : 1653851001000,
      "endTime" : 1753851001000,
      "leaveViewUnit" : "day",
      "leaveReason" : "管理者によるインポート",
      "leaveRecordType" : "update",
      "leaveStatus" : "init",
      "recordNumPerDay" : 100,
      "recordNumPerHour" : 100,
      "gmtCreate" : 1653851001000,
      "gmtModified" : 1753851001000,
      "opUserId" : "manage2323"
    } ]
  },
  "success" : true
}
```

### エラーコード

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

| HttpCode | エラーコード | エラーメッセージ | 説明 |
| - | - | - | - |
| 400 | userNotExist | ユーザーが存在しません | ユーザーが存在しません。 |
| 400 | leaveOpuserIdIsNotAdmin | 管理者以外は自分の情報のみ照会できます | 管理者以外は自分の情報のみ照会できます。 |
| 400 | leaveTypeNotFound | 休暇タイプが見つかりません | 休暇タイプが見つかりませんでした。 |
| 400 | paramterInvalid | パラメータエラー | opUserId と userId パラメータは空にできません。 |
| 400 | leaveUserIdListMax | 一度に照会できるのは最大 50 件です | 一度に照会できる社員の userId は最大 50 件です。 |
| 400 | pageIndexIllegal | ページングパラメータエラー | ページングパラメータは 0 から始まる 0 以上の整数で指定してください。 |
| 400 | pageSizeIllegal | ページサイズが上限を超えています | ページサイズの最大値は 200 です。 |
| 400 | noPermission | アクセス権限がありません | アクセス権限がありません。 |
| 400 | leaveOrgIsUsed | 組織のみアクセスできます | この API にアクセスできるのは組織のみです。 |


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