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

# Upload Clock-In Records

> Call this API to upload card-swipe records from a third-party system to DingTalk and generate DingTalk clock-in records by employee and clock-in time.

Call this API to upload card-swipe or facial recognition records from a third-party attendance system to DingTalk Attendance as DingTalk clock-in records.

## Request

| **Basic Information** | |
| - | - |
| HTTP URL | [https://api.dingtalk.io/topapi/attendance/record/upload](https://api.dingtalk.io/topapi/attendance/record/upload) |
| HTTP Method | POST |
| Supported app types | appType-Internal app |
| Required permissions | permission-Pro.AttendanceRecord.Write-Write permission for attendance clock-in records |

### Query Parameters

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

### Request Body

| Name | Type | Required | Example | Description |
| - | - | - | - | - |
| userid | String | Yes | user123 | The user ID of the employee whose clock-in record you want to upload. |
| device\_name | String | Yes | East Gate Time Clock | The name of the Time Clock. This value is custom, such as 123456. |
| device\_id | String | Yes | abc123456 | The ID of the Time Clock. This value is custom, such as abcde. |
| photo\_url | String | No | [https://xxx.com/xxx.png](https://xxx.com/xxx.png) | The URL of the clock-in alias image. The URL must be publicly accessible. |
| user\_check\_time | Number | Yes | 1587020403000 | The time when the employee clocks in, in milliseconds.  **Note**   - This parameter must be in milliseconds. - Pass a date within the last 180 days. |

### Request Example

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.dingtalk.io/topapi/attendance/record/upload" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=0927xxxx3e28ea' \
-d 'device_id=abc123456' \
-d 'device_name=East%20Gate%20Time%20Clock' \
-d 'photo_url=https%3A%2F%2Fxxx.com%2Fxxx.png' \
-d 'user_check_time=1587020403000' \
-d 'userid=dd_dd'
```

Java

```java theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/attendance/record/upload");
OapiAttendanceRecordUploadRequest req = new OapiAttendanceRecordUploadRequest();
req.setUserid("dd_dd");
req.setDeviceName("East Gate Time Clock");
req.setDeviceId("abc123456");
req.setPhotoUrl("https://xxx.com/xxx.png");
req.setUserCheckTime(1587020403000L);
OapiAttendanceRecordUploadResponse 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.OapiAttendanceRecordUploadRequest("https://api.dingtalk.io/topapi/attendance/record/upload")

req.userid="dd_dd"
req.device_name="East Gate Time Clock"
req.device_id="abc123456"
req.photo_url="https://xxx.com/xxx.png"
req.user_check_time=1587020403000
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 OapiAttendanceRecordUploadRequest;
$req->setUserid("dd_dd");
$req->setDeviceName("East Gate Time Clock");
$req->setDeviceId("abc123456");
$req->setPhotoUrl("https://xxx.com/xxx.png");
$req->setUserCheckTime("1587020403000");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/attendance/record/upload");
```

C#

```csharp theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/attendance/record/upload");
OapiAttendanceRecordUploadRequest req = new OapiAttendanceRecordUploadRequest();
req.Userid = "dd_dd";
req.DeviceName = "East Gate Time Clock";
req.DeviceId = "abc123456";
req.PhotoUrl = "https://xxx.com/xxx.png";
req.UserCheckTime = 1587020403000L;
OapiAttendanceRecordUploadResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
```

## Response

### Response Body

| Name | Type | Example | Description |
| - | - | - | - |
| success | Boolean | true | Indicates whether the call succeeded. |
| errcode | Number | 0 | The return code. |
| errmsg | String | ok | The description of the return code. |
| request\_id | String | ktoftehkz2bt | The request ID. |

### Response Body Example

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

### Error Codes

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


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