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

# Convert groupKey to groupId

> Call this API with the operator's userId and the attendance group's group_key to convert the legacy attendance group identifier to the new groupId.

Call this API to convert the groupKey of an attendance group to a groupId.

## Request

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

### Query Parameters

| Name | Type | Required | Example | Description |
| - | - | - | - | - |
| access\_token | String | Yes | bE74xxxx | The App credential used to call this API.   - 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. - 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 |
| - | - | - | - | - |
| op\_user\_id | String | Yes | user01 | The userId of the operator. |
| group\_key | String | Yes | 02B1Exxxx | The attendance group ID, which is the legacy attendance group identifier. Call the [Batch Get Attendance Group Details](https://help.dingtalk.io/open/development/batch-obtain-attendance-group-details.md) API to obtain the group\_id parameter value. |

### Request Example

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.dingtalk.io/topapi/attendance/groups/keytoid" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=40bafxxxx9d3b06' \
-d 'group_key=0151E0xxxxA917E876' \
-d 'op_user_id=123'
```

Java

```java theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/attendance/groups/keytoid");
OapiAttendanceGroupsKeytoidRequest req = new OapiAttendanceGroupsKeytoidRequest();
req.setOpUserId("user01");
req.setGroupKey("02B1Exxxx");
OapiAttendanceGroupsKeytoidResponse 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.OapiAttendanceGroupsKeytoidRequest("https://api.dingtalk.io/topapi/attendance/groups/keytoid")

req.op_user_id="123"
req.group_key="0151E022xxxx917E876"
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 OapiAttendanceGroupsKeytoidRequest;
$req->setOpUserId("123");
$req->setGroupKey("0151E02xxxx17E876");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/attendance/groups/keytoid");
```

C#

```csharp theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/attendance/groups/keytoid");
OapiAttendanceGroupsKeytoidRequest req = new OapiAttendanceGroupsKeytoidRequest();
req.OpUserId = "123";
req.GroupKey = "0151E0xxxx7E876";
OapiAttendanceGroupsKeytoidResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
```

## Response

### Response Body

| Name | Type | Example | Description |
| - | - | - | - |
| result | Number | 685935028 | The attendance group ID. |
| 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 | 3yt2gu3zz0qi | The request ID. |

### Response Body Example

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

### Error Codes

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