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

# Schedule Members of a Shift-Based Attendance Group

> Call this API to schedule members of a shift-based attendance group by assigning a shift or rest day to a specific date. Batch-set scheduling details by user.

Call this API to schedule members of a shift-based attendance group. Make sure the attendance group type is **shift-based attendance**.

## Request

| **Basic Information** | |
| - | - |
| HTTP URL | [https://api.dingtalk.io/topapi/attendance/group/schedule/async](https://api.dingtalk.io/topapi/attendance/group/schedule/async) |
| HTTP Method | POST |
| Supported app types | appType-Internal app　appType-Third-party enterprise app |
| Required permissions | permission-qyapi\_attendance\_group\_manage-Attendance group management permission |

### Query Parameters

| Name | Type | Required | Example | Description |
| - | - | - | - | - |
| access\_token | String | Yes | bE74xxxx | The App credential used to call this API.   - For an Internal app, call the [Get the access\_token of an Internal App](https://help.dingtalk.io/open/development/obtain-orgapp-token) API to obtain it. - For a Third-party enterprise app, call the API for getting the access\_token of a third-party organization to obtain it. |

### Request Body

| Name | Type | Required | Example | Description |
| - | - | - | - | - |
| op\_user\_id | String | Yes | user456 | The user ID of the operator. |
| group\_id | Number | Yes | 2987 | The attendance group ID.  **Note**  If you use the legacy attendance group identifier group\_key, call the [Convert groupKey to groupId](https://help.dingtalk.io/open/development/convert-groupkey-to-groupid.md) API to convert group\_key to group\_id. |
| schedules | TopScheduleParam\[] | Yes | | The scheduling details. Example:   `&#123;   "is_rest": false,   "work_date": 1605150671000,   "shift_id": 1,   "userid": "user123" &#125;`   **Note**  The maximum list length is 200. |
| shift\_id | Number | Yes | 1 | The shift ID. Pass 1 for a rest shift. Call the [Get Shift Summaries](https://help.dingtalk.io/open/development/enterprise-shift-query-in-batches.md) API to obtain the id value.  **Note**   - When is\_rest is true, pass 1 for shift\_id. - To clear the schedule, pass -2 for shift\_id. |
| work\_date | Number | Yes | 1564985177000 | The scheduling date.  **Note**  The date must be no earlier than 180 days ago and no later than 180 days from now. |
| is\_rest | Boolean | No | false | Specifies whether the day is a rest day:   - **true**: Rest day  **Note**  When this parameter is true, pass 1 for shift\_id. - **false**: Not a rest day |
| userid | String | Yes | user123 | The user ID of the user. |

### Request Example

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.dingtalk.io/topapi/attendance/group/schedule/async" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=d64b3xxxx57b23' \
-d 'group_id=2987' \
-d 'op_user_id=dd_test' \
-d 'schedules=null'
```

Java

```java theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/attendance/group/schedule/async");
OapiAttendanceGroupScheduleAsyncRequest req = new OapiAttendanceGroupScheduleAsyncRequest();
req.setOpUserId("user456");
req.setGroupId(2987L);
List<TopScheduleParam> list2 = new ArrayList<TopScheduleParam>();
TopScheduleParam obj3 = new TopScheduleParam();
obj3.setShiftId(1L);
obj3.setWorkDate(1564985177000L);
obj3.setIsRest(false);
obj3.setUserid("user123");
list2.add(obj3);
req.setSchedules(list2);
OapiAttendanceGroupScheduleAsyncResponse 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.OapiAttendanceGroupScheduleAsyncRequest("https://api.dingtalk.io/topapi/attendance/group/schedule/async")

req.op_user_id="dd_test"
req.group_id=2987
req.schedules=""
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 OapiAttendanceGroupScheduleAsyncRequest;
$req->setOpUserId("dd_test");
$req->setGroupId("2987");
$schedules = new TopScheduleParam;
$schedules->shift_id="1";
$schedules->work_date="1564985177000";
$schedules->is_rest="false";
$schedules->userid="dd_test";
$req->setSchedules(array($schedules));
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/attendance/group/schedule/async");
```

C#

```csharp theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/attendance/group/schedule/async");
OapiAttendanceGroupScheduleAsyncRequest req = new OapiAttendanceGroupScheduleAsyncRequest();
req.OpUserId = "dd_test";
req.GroupId = 2987L;
List<OapiAttendanceGroupScheduleAsyncRequest.TopScheduleParamDomain> list2 = new List<OapiAttendanceGroupScheduleAsyncRequest.TopScheduleParamDomain>();
OapiAttendanceGroupScheduleAsyncRequest.TopScheduleParamDomain obj3 = new OapiAttendanceGroupScheduleAsyncRequest.TopScheduleParamDomain();
list2.Add(obj3);
obj3.ShiftId = 1L;
obj3.WorkDate = 1564985177000L;
obj3.IsRest = false;
obj3.Userid = "dd_test";
req.Schedules_ = list2;
OapiAttendanceGroupScheduleAsyncResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
```

## Response

### Response Body

| Name | Type | Example | Description |
| - | - | - | - |
| success | Boolean | true | Indicates whether the request succeeded.   - **true**: Success - **false**: Failed |
| errcode | Number | 0 | The return code. |
| errmsg | String | ok | The description of the return code. |
| request\_id | String | zpd0i7dlr7bi | The request ID. |

### Response Body Example

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "errcode":0,
  "errmsg":"ok",
  "success":true,
  "request_id":"zpd0i7dlr7bi"
}
```

### Error Codes

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


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