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

# Update Attendance Members

> Call this API to add or remove attendance members, attendance-exempt members, and attendance departments for a specified attendance group.

Call this API to update the members of an attendance group. Add or remove **attendance members** and **attendance-exempt members** for a specified attendance group.

## Request

| **Basic Information** | |
| - | - |
| HTTP URL | [https://api.dingtalk.io/topapi/attendance/group/member/update](https://api.dingtalk.io/topapi/attendance/group/member/update) |
| HTTP Method | POST |
| Supported app types | appType-Internal app　appType-Third-party enterprise app |
| Required permissions | 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 obtaining the access\_token of a third-party organization to obtain it. |

### Request Body

| Name | Type | Required | Example | Description |
| - | - | - | - | - |
| op\_user\_id | String | Yes | user123 | The userId of the operator. |
| group\_id | Number | Yes | 98562 | 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. |
| schedule\_flag | Number | Yes | 0 | The day from which scheduling starts.   - **0**: Start scheduling today - **1**: Start scheduling tomorrow |
| update\_param | TopGroupMemberUpdateParam | Yes | | The attendance group update information. |
| remove\_extra\_users | String\[] | No | \["user123","user456"] | The attendance-exempt members to remove. Leave empty if not applicable. Pass up to 20 userIds per call. |
| remove\_depts | String\[] | No | \["123","456"] | The attendance departments to remove. Leave empty if not applicable. Pass up to 20 department IDs per call. |
| remove\_users | String\[] | No | \["user123","user456"] | The attendance members to remove. Leave empty if not applicable. Pass up to 20 userIds per call. |
| add\_depts | String\[] | No | \["123","456"] | The attendance departments to add. Leave empty if not applicable. Pass up to 20 department IDs per call. |
| add\_users | String\[] | No | \["user123","user456"] | The attendance members to add. Leave empty if not applicable. Pass up to 20 userIds per call. |
| add\_extra\_users | String\[] | No | \["user123","user456"] | The attendance-exempt members to add. Leave empty if not applicable. Pass up to 20 userIds per call. |

### Request Example

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.dingtalk.io/topapi/attendance/group/member/update" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=0142dxxxxa6204' \
-d 'group_id=122' \
-d 'op_user_id=dd_dd' \
-d 'schedule_flag=0' \
-d 'update_param=null'
```

Java

```java theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/attendance/group/member/update");
OapiAttendanceGroupMemberUpdateRequest req = new OapiAttendanceGroupMemberUpdateRequest();
req.setOpUserId("user123");
req.setGroupId(98562L);
req.setScheduleFlag(0L);
TopGroupMemberUpdateParam updateParam = new TopGroupMemberUpdateParam();
updateParam.setAddDepts(Arrays.asList("123"));
updateParam.setRemoveDepts(Arrays.asList("456"));
updateParam.setAddUsers(Arrays.asList("user123"));
updateParam.setAddExtraUsers(Arrays.asList("user456"));
updateParam.setRemoveExtraUsers(Arrays.asList("user789"));
updateParam.setRemoveUsers(Arrays.asList("user121"));
req.setUpdateParam(updateParam);
OapiAttendanceGroupMemberUpdateResponse 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.OapiAttendanceGroupMemberUpdateRequest("https://api.dingtalk.io/topapi/attendance/group/member/update")

req.op_user_id="dd_dd"
req.group_id=122
req.schedule_flag=0
req.update_param=""
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 OapiAttendanceGroupMemberUpdateRequest;
$req->setOpUserId("dd_dd");
$req->setGroupId("122");
$req->setScheduleFlag("0");
$update_param = new TopGroupMemberUpdateParam;
$update_param->remove_extra_users="dd_test";
$update_param->remove_depts="1234";
$update_param->remove_users="dd_dd";
$update_param->add_depts="123";
$update_param->add_users="dd_mana";
$update_param->add_extra_users="dd_d";
$req->setUpdateParam($update_param);
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/attendance/group/member/update");
```

C#

```csharp theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/attendance/group/member/update");
OapiAttendanceGroupMemberUpdateRequest req = new OapiAttendanceGroupMemberUpdateRequest();
req.OpUserId = "dd_dd";
req.GroupId = 122L;
req.ScheduleFlag = 0L;
OapiAttendanceGroupMemberUpdateRequest.TopGroupMemberUpdateParamDomain obj1 = new OapiAttendanceGroupMemberUpdateRequest.TopGroupMemberUpdateParamDomain();
obj1.RemoveExtraUsers = "dd_test";
obj1.RemoveDepts = "1234";
obj1.RemoveUsers = "dd_dd";
obj1.AddDepts = "123";
obj1.AddUsers = "dd_mana";
obj1.AddExtraUsers = "dd_d";
req.UpdateParam_ = obj1;
OapiAttendanceGroupMemberUpdateResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
```

## Response

### Response Body

| Name | Type | Example | Description |
| - | - | - | - |
| request\_id | String | 3pgsafymemlr | The request ID. |
| errcode | Number | 0 | The return code. |
| success | Boolean | true | Indicates whether the call succeeded.   - **true**: Success - **false**: Failed |

### Response Body Example

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "errcode": 0,
  "success": true,
  "request_id": "5sj3lgigiqm9"
}
```

### Error Codes

If the 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.