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

# Get a User's Attendance Group

> Call this API to get the attendance group of an employee by user ID, including the attendance group name, ID, and attendance type.

Call this API to get the attendance group information of an employee, including the attendance group name and attendance type. An employee can belong to only one attendance group within an organization.

## Request

| **Basic Information** | |
| - | - |
| HTTP URL | [https://api.dingtalk.io/topapi/attendance/getusergroup](https://api.dingtalk.io/topapi/attendance/getusergroup) |
| HTTP Method | POST |
| Supported App Types | appType-Internal app　appType-Third-party enterprise app |
| Permission Requirements | permission-qyapi\_base-Basic permission required to call organization APIs |

### Query Parameters

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

### Request Body

| Name | Type | Required | Example | Description |
| - | - | - | - | - |
| userid | String | Yes | user123 | The user ID of the employee in your organization. |

### Request Example

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.dingtalk.io/topapi/attendance/getusergroup" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=04cd6xxxx91f77' \
-d 'userid=zhangsan'
```

Java

```java theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/attendance/getusergroup");
OapiAttendanceGetusergroupRequest req = new OapiAttendanceGetusergroupRequest();
req.setUserid("user123");
OapiAttendanceGetusergroupResponse 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.OapiAttendanceGetusergroupRequest("https://api.dingtalk.io/topapi/attendance/getusergroup")

req.userid="zhangsan"
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 OapiAttendanceGetusergroupRequest;
$req->setUserid("zhangsan");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/attendance/getusergroup");
```

C#

```csharp theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/attendance/getusergroup");
OapiAttendanceGetusergroupRequest req = new OapiAttendanceGetusergroupRequest();
req.Userid = "zhangsan";
OapiAttendanceGetusergroupResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
```

## Response

### Response Body

| Name | Type | Example | Description |
| - | - | - | - |
| result | AtGroupFullForTopVo | | The query result. |
| name | String | Attendance | The name of the attendance group. |
| group\_id | Number | 685935028 | The ID of the attendance group.  **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**. |
| type | String | TURN | The attendance type:   - **FIXED**: Fixed scheduling - **TURN**: Rotating scheduling - **NONE**: No shift |
| classes | AtClassVo\[] | | The list of shifts in the attendance group. |
| class\_id | Number | 678215070 | The shift ID. |
| name | String | Shift A | The shift name. |
| sections | AtSectionVo\[] | | The list of on-duty and off-duty sections in the shift. |
| times | AtTimeVo\[] | | The list of on-duty and off-duty details in the shift. |
| check\_time | Date | 1970-01-01 19:00:00 | The clock-in time. |
| check\_type | String | OnDuty | The clock-in type:   - **OnDuty**: On duty - **OffDuty**: Off duty |
| across | Number | 0 | The number of days the clock-in time spans. |
| begin\_min | Number | 30 | The earliest allowed clock-in time before the scheduled time, in minutes. |
| end\_min | Number | 0 | The latest allowed clock-in time after the scheduled time, in minutes. |
| setting | ClassSettingVo | | The shift configuration. |
| rest\_begin\_time | AtTimeVo | | The break start settings. |
| across | Number | 0 | The time span.   - **0**: Does not span days - **1**: Spans days |
| begin\_min | Number | 0 | The start time. |
| end\_min | Number | 0 | The end time. |
| check\_time | Date | 1970-01-01 19:00:00 | The break start time. |
| check\_type | String | OnDuty | The settings type:   - **OnDuty**: Break start - **OffDuty**: Break end |
| rest\_end\_time | AtTimeVo | | The break end time settings. |
| across | Number | 0 | The time span. |
| begin\_min | Number | 0 | The start time. |
| end\_min | Number | 0 | The end time. |
| check\_time | Date | 1970-01-01 20:00:00 | The break end time. |
| check\_type | String | OffDuty | The clock-in type:   - **OnDuty**: Break start - **OffDuty**: Break end |
| errcode | Number | 0 | The return code. |
| errmsg | String | ok | The description of the return code. |
| request\_id | String | f8zybbfze3e8 | The request ID. |

### Response Body Example

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "errcode": 0,
  "result": {
    "classes": [
      {
        "class_id": 677995086,
        "name": "A",
        "sections": [
          {
            "times": [
              {
                "across": 0,
                "check_time": "1970-01-01 09:30:00",
                "check_type": "OnDuty"
              },
              {
                "across": 0,
                "check_time": "1970-01-01 18:30:00",
                "check_type": "OffDuty"
              }
            ]
          }
        ],
        "setting": {}
      },
      {
        "class_id": 678215070,
        "name": "B",
        "sections": [
          {
            "times": [
              {
                "across": 0,
                "check_time": "1970-01-01 19:00:00",
                "check_type": "OnDuty"
              },
              {
                "across": 1,
                "check_time": "1970-01-01 05:00:00",
                "check_type": "OffDuty"
              }
            ]
          }
        ],
        "setting": {}
      }
    ],
    "group_id": 685935028,
    "name": "Attendance",
    "type": "FIXED"
  },
  "request_id": "f8zybbfze3e8"
}
```

### Error Codes

If a call to this API 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.