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

# 打刻記録のアップロード

> サードパーティの勤怠システムで取得した打刻記録を、社員と打刻時刻ごとに DingTalk 勤怠へ連携するアップロード API です。

この API を呼び出すと、サードパーティの勤怠システムで取得したカード打刻記録や顔認証記録を DingTalk 勤怠にアップロードし、DingTalk の打刻記録として登録します。

## リクエスト

| **ベーシック情報** | |
| - | - |
| HTTP URL | [https://api.dingtalk.io/topapi/attendance/record/upload](https://api.dingtalk.io/topapi/attendance/record/upload) |
| HTTP メソッド | POST |
| 対応アプリタイプ | appType-社内アプリ |
| 必要な権限 | permission-Pro.AttendanceRecord.Write-勤怠打刻記録の書き込み権限 |

### クエリパラメータ

| 名前 | タイプ | 必須 | 例 | 説明 |
| - | - | - | - | - |
| access\_token | 文字列 | はい | af21axxx | この API の呼び出しに使用するアプリ認証情報です。[社内アプリの access\_token を取得する](https://help.dingtalk.io/ja/open/development/obtain-orgapp-token)を呼び出して取得してください。 |

### リクエストボディ

| 名前 | タイプ | 必須 | 例 | 説明 |
| - | - | - | - | - |
| userid | 文字列 | はい | user123 | 打刻記録をアップロードする社員のユーザー ID です。 |
| device\_name | 文字列 | はい | 東門打刻機 | 打刻機の名前です。123456 などのカスタム値を指定します。 |
| device\_id | 文字列 | はい | abc123456 | 打刻機の ID です。abcde などのカスタム値を指定します。 |
| photo\_url | 文字列 | いいえ | [https://xxx.com/xxx.png](https://xxx.com/xxx.png) | 打刻時の表示名画像の URL です。公開アクセス可能な URL を指定してください。 |
| user\_check\_time | 数値 | はい | 1587020403000 | 社員の打刻時刻（ミリ秒）です。  **注意**   - ミリ秒単位で指定してください。 - 直近 180 日以内の日付を指定してください。 |

### リクエスト例

```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=%E6%9D%B1%E9%96%80%E6%89%93%E5%88%BB%E6%A9%9F' \
-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("東門打刻機");
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="東門打刻機"
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("東門打刻機");
$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 = "東門打刻機";
req.DeviceId = "abc123456";
req.PhotoUrl = "https://xxx.com/xxx.png";
req.UserCheckTime = 1587020403000L;
OapiAttendanceRecordUploadResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
```

## レスポンス

### レスポンスボディ

| 名前 | タイプ | 例 | 説明 |
| - | - | - | - |
| success | 真偽値 | true | 呼び出しに成功したかどうかを示します。 |
| errcode | 数値 | 0 | リターンコードです。 |
| errmsg | 文字列 | ok | リターンコードの説明です。 |
| request\_id | 文字列 | ktoftehkz2bt | リクエスト ID です。 |

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

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

### エラーコード

この 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.