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

# Query Leave Status

> Call this API to query users' daily leave status and duration within a time range by user ID list. Supports pagination and up to 180 days.

Call this API to query the daily leave status and leave duration of specified users in a specified organization within a specified time range.

## Request

| **Basic Information** | |
| - | - |
| HTTP URL | [https://api.dingtalk.io/topapi/attendance/getleavestatus](https://api.dingtalk.io/topapi/attendance/getleavestatus) |
| HTTP Method | POST |
| Supported App Types | appType-Internal app　appType-Third-party enterprise app |
| Required Permissions | permission-qyapi\_get\_attendance\_data-Attendance data read permission |

### Query Parameters

| Name | Type | Required | Example | Description |
| - | - | - | - | - |
| access\_token | String | Yes | 6d1bxxxx | The app credential used to call this API. Obtain it by calling [Get the access\_token of an Internal App](https://help.dingtalk.io/open/development/obtain-orgapp-token). |

### Request Body

| Name | Type | Required | Example | Description |
| - | - | - | - | - |
| userid\_list | String | Yes | user456,user123 | The list of user IDs to query. Up to 100 IDs per request. |
| start\_time | Number | Yes | 1538323200000 | The start time, as a Unix timestamp. The query range can be up to 180 days. |
| end\_time | Number | Yes | 1546358399000 | The end time, as a Unix timestamp. The query range can be up to 180 days. |
| offset | Number | Yes | 0 | The pagination offset, starting from 0. Takes effect only when set together with the size parameter. |
| size | Number | Yes | 10 | The page size. Maximum value: 20. Takes effect only when set together with the offset parameter. |

### Request Example

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.dingtalk.io/topapi/attendance/getleavestatus" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=11b9xxxxc35a' \
-d 'end_time=1546358399000' \
-d 'offset=0' \
-d 'size=10' \
-d 'start_time=1538323200000' \
-d 'userid_list=123%2C121'
```

Java

```java theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/attendance/getleavestatus");
OapiAttendanceGetleavestatusRequest req = new OapiAttendanceGetleavestatusRequest();
req.setUseridList("user123,user456");
req.setStartTime(1538323200000L);
req.setEndTime(1546358399000L);
req.setOffset(0L);
req.setSize(10L);
OapiAttendanceGetleavestatusResponse 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.OapiAttendanceGetleavestatusRequest("https://api.dingtalk.io/topapi/attendance/getleavestatus")

req.userid_list="123,121"
req.start_time=1538323200000
req.end_time=1546358399000
req.offset=0
req.size=10
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 OapiAttendanceGetleavestatusRequest;
$req->setUseridList("123,121");
$req->setStartTime("1538323200000");
$req->setEndTime("1546358399000");
$req->setOffset("0");
$req->setSize("10");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/attendance/getleavestatus");
```

C#

```csharp theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/attendance/getleavestatus");
OapiAttendanceGetleavestatusRequest req = new OapiAttendanceGetleavestatusRequest();
req.UseridList = "123,121";
req.StartTime = 1538323200000L;
req.EndTime = 1546358399000L;
req.Offset = 0L;
req.Size = 10L;
OapiAttendanceGetleavestatusResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
```

## Response

### Response Body

| Name | Type | Example | Description |
| - | - | - | - |
| errcode | Number | 0 | The return code. |
| result | LeaveStatusListVO | | The query result. |
| has\_more | Boolean | true | Indicates whether more data exists.   - **true**: Yes - **false**: No |
| leave\_status | LeaveStatusVO\[] | | The list of leave statuses. |
| duration\_unit | String | percent\_day | The leave unit:   - **percent\_day**: Day - **percent\_hour**: Hour |
| duration\_percent | Number | 100 | The leave duration multiplied by 100. For example, if a user's leave duration is 1 day, this value is 100. |
| end\_time | Number | 1599465600000 | The leave end time, as a Unix timestamp. |
| start\_time | Number | 1599372000000 | The leave start time, as a Unix timestamp. |
| userid | String | user456 | The user ID. |
| success | Boolean | true | Indicates whether the request succeeded.   - **true**: Success - **false**: Failed |
| request\_id | String | 5lbpbi9p1awk | The request ID. |

### Response Body Example

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "errcode": 0,
  "result": {
    "has_more": false,
    "leave_status": [
      {
        "duration_percent": 650,
        "duration_unit": "percent_hour",
        "end_time": 1599465600000,
        "start_time": 1599372000000,
        "leave_code":"16f856xxxx09aa16"
        "userid": "user123"
      }
    ]
  },
  "success": true,
  "request_id": "5lbpbi9p1awk"
}
```

### Error Codes

If a call to this API returns an error, find solutions based on the error message in the [Global Error Codes](https://help.dingtalk.io/open/development/server-api-error-codes-1.md) document.


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