> ## 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/topapi/attendance/group/schedule/async](https://api.dingtalk.io/topapi/attendance/group/schedule/async) |
| HTTP メソッド | POST |
| 対応アプリタイプ | appType-社内アプリ　appType-サードパーティ社内アプリ |
| 必要な権限 | permission-qyapi\_attendance\_group\_manage-勤怠グループ管理権限 |

### クエリパラメータ

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

### リクエストボディ

| 名前 | タイプ | 必須 | 例 | 説明 |
| - | - | - | - | - |
| op\_user\_id | String | はい | user456 | 操作者のユーザー ID です。 |
| group\_id | Number | はい | 2987 | 勤怠グループ ID です。  **注意**  旧形式の勤怠グループ識別子 group\_key を使用している場合は、[groupKey から groupId への変換](https://help.dingtalk.io/ja/open/development/convert-groupkey-to-groupid.md) API を呼び出して group\_key を group\_id に変換してください。 |
| schedules | TopScheduleParam\[] | はい | | シフト設定の詳細です。例：   `&#123;   "is_rest": false,   "work_date": 1605150671000,   "shift_id": 1,   "userid": "user123" &#125;`   **注意**  リストの最大長は 200 です。 |
| shift\_id | Number | はい | 1 | シフト ID です。休息シフトの場合は 1 を指定します。id の値は、[シフト概要を取得](https://help.dingtalk.io/ja/open/development/enterprise-shift-query-in-batches.md) API を呼び出して取得します。  **注意**   - is\_rest が true の場合は、shift\_id に 1 を指定してください。 - シフトをクリアする場合は、shift\_id に -2 を指定してください。 |
| work\_date | Number | はい | 1564985177000 | シフト設定の日付です。  **注意**  日付は、180 日前から 180 日後までの範囲で指定してください。 |
| is\_rest | Boolean | いいえ | false | 休日かどうかを指定します。   - **true**：休日  **注意**  このパラメータが true の場合は、shift\_id に 1 を指定してください。 - **false**：休日ではない |
| userid | String | はい | user123 | 対象ユーザーのユーザー ID です。 |

### リクエスト例

```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);
```

## レスポンス

### レスポンスボディ

| 名前 | タイプ | 例 | 説明 |
| - | - | - | - |
| success | Boolean | true | リクエストが成功したかどうかを示します。   - **true**：成功 - **false**：失敗 |
| errcode | Number | 0 | 戻りコードです。 |
| errmsg | String | ok | 戻りコードの説明です。 |
| request\_id | String | zpd0i7dlr7bi | リクエスト ID です。 |

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

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

### エラーコード

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.