{"id":3455,"date":"2018-03-04T17:37:50","date_gmt":"2018-03-04T15:37:50","guid":{"rendered":"http:\/\/modulus.help\/kb\/docs\/documentation\/introduction\/api-import-attendance-logs\/"},"modified":"2021-02-17T13:10:41","modified_gmt":"2021-02-17T11:10:41","slug":"api-import-attendance-logs","status":"publish","type":"docs","link":"https:\/\/modulus.help\/kb\/docs\/documentation\/personnel-apis-v1\/api-import-attendance-logs\/","title":{"rendered":"API: Import Attendance Logs"},"content":{"rendered":"<p>The purpose of this API is to upload attendance logs to modulus&reg;.<\/p>\n<h4>Request<\/h4>\n<table style=\"width: auto\">\n<tbody>\n<tr>\n<th style=\"text-align:left;\">API Name<\/th>\n<td>\nPublicAttendanceLogImport\n<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align:left;\">URL<\/th>\n<td>https:\/\/your_account.modulus.biz\/api\/hr\/PublicAttendanceLogImport&#038;token=YOUR_TOKEN<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align:left;\">Method<\/th>\n<td>POST<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align:left;\">Source<\/th>\n<td>Third Party Server<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align:left;\">Recipient<\/th>\n<td>modulus&reg; Server<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align:left;\">Content Type<\/th>\n<td>multipart\/form-data<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Query String Parameters<\/h4>\n<table style=\"width: auto\">\n<thead>\n<tr>\n<th>Parameter<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th style=\"text-align:left;\">token<\/th>\n<td>Security token retrieved from <a href=\"\/kb\/docs\/documentation\/getting-started\/step-2-authentication-token\/\">Authentication API<\/a>.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Request Body Parameters<\/h4>\n<table style=\"width: auto\">\n<thead>\n<tr>\n<th>Parameter<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th style=\"text-align:left;\">device_id<\/th>\n<td>The device ID retrieved from the API <a href=\"https:\/\/modulus.help\/kb\/docs\/documentation\/introduction\/api-list-attendance-devices\/\">PublicAttendanceDeviceList<\/a>.<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align:left;\">log_file<\/th>\n<td>File in CSV format that holds attendance logs to be uploaded. File should be UTF-8 encoded without BOM.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The uploaded file must be structured as follows:<\/p>\n<table style=\"width:auto\">\n<thead>\n<tr>\n<th>Employee ID<\/th>\n<th>Date Time<\/th>\n<th>Direction Flag<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>2018-01-01 10:00:00<\/td>\n<td>I<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>2018-01-01 16:30:00<\/td>\n<td>O<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>File is in CSV format with PIPE &#8220;|&#8221; separator, the above table should map to the following file content:<\/p>\n<pre><code class=\"csv\">1 | 2018-01-01 10:00:00 | I\r\n1 | 2018-01-01 16:30:00 | O<\/code><\/pre>\n<h5>Notes<\/h5>\n<ul>\n<li>Possible direction flag values: &#8216;I&#8217; for check-in, &#8216;O&#8217; for check-out.<\/li>\n<li>Note that, header row must not be included in the uploaded file.<\/li>\n<li>The direction flag is necessary if the device setup on modulus&reg; is marked to accept this flag (i.e. device direction set to &#8220;IN\/OUT&#8221; value)<\/li>\n<li>If the device direction is set to &#8220;IN&#8221;, modulus&reg; accepts all logs as &#8220;check-in&#8221;, regardless of the direction flag.<\/li>\n<li>If the device direction is set to &#8220;OUT&#8221;, modulus&reg; accepts all logs as &#8220;check-out&#8221;, regardless of the direction flag.<\/li>\n<li>If the device direction is set to &#8220;NONE&#8221;, modulus&reg; decides direction of logs depending on the shifts on relevant date.<\/li>\n<li>Log file size should not exceed 100KB. Larger log amounts should be split into smaller files of sizes less than 100KB.<\/li>\n<\/ul>\n<h4>Responses<\/h4>\n<table style=\"width: auto;\">\n<thead>\n<tr>\n<th>HTTP Status<\/th>\n<th>result<\/th>\n<th>title<\/th>\n<th>message<\/th>\n<th>object<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th colspan=\"5\">Success Responses<\/th>\n<\/tr>\n<tr>\n<td>200 OK<\/td>\n<td>true<\/td>\n<td>Success<\/td>\n<td>Attendance logs imported successfully.<\/td>\n<td>null<\/td>\n<\/tr>\n<tr>\n<th colspan=\"5\">Failure Responses<\/th>\n<\/tr>\n<tr>\n<td>400 Bad Request<\/td>\n<td>false<\/td>\n<td>Bad Request<\/td>\n<td>Device ID is missing.<br \/>\nLogs file is missing.<br \/>\nUpload error #error_number<br \/>\nUploaded file is larger than 100 KB.<br \/>\nInvalid file mime type.<br \/>\nInvalid file content.<br \/>\nInvalid Device ID.<br \/>\nDevice is disabled.\n<\/td>\n<td>null<\/td>\n<\/tr>\n<tr>\n<td>500 Internal Server Error<\/td>\n<td>false<\/td>\n<td>Error<\/td>\n<td>Importing file failed.<\/td>\n<td>null<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Example<\/h4>\n<table style=\"width: auto;\">\n<tbody>\n<tr>\n<th style=\"text-align:left\">Request<\/th>\n<td>\n<pre><code class=\"json\">curl --request POST 'https:\/\/your_account.modulus.biz\/api\/cmn\/PublicAttendanceLogImport?token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \\\r\n--form 'device_id=13' \\\r\n--form 'log_file=@\/D:\/files\/logs.csv'\r\n<\/code><\/pre>\n<\/td>\n<\/tr>\n<tr>\n<th colspan=\"2\">Success Responses<\/th>\n<\/tr>\n<tr>\n<th style=\"text-align:left\">200 OK<\/th>\n<td>\n<pre><code class=\"json\">{\r\n    \"result\": true,\r\n    \"title\": \"Success\",\r\n    \"message\": \"Attendance logs imported successfully.\",\r\n    \"object\": null\r\n}<\/code><\/pre>\n<\/td>\n<\/tr>\n<tr>\n<th colspan=\"2\">Failure Responses<\/th>\n<\/tr>\n<tr>\n<th style=\"text-align:left\">400 Bad Request<\/th>\n<td>\n<pre><code class=\"json\">{\r\n    \"result\": false,\r\n    \"title\": \"Bad Request\",\r\n    \"message\": \"Device is disabled.\",\r\n    \"object\": null\r\n}<\/code><\/pre>\n<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align:left\">500 Internal Server Error<\/th>\n<td>\n<pre><code class=\"json\">{\r\n    \"result\": false,\r\n    \"title\": \"Error\",\r\n    \"message\": \"Importing file failed.\",\r\n    \"object\": null\r\n}<\/code><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"featured_media":0,"parent":3773,"menu_order":2,"comment_status":"closed","ping_status":"closed","template":"","doc_tag":[],"comment_count":0,"_links":{"self":[{"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/docs\/3455"}],"collection":[{"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/comments?post=3455"}],"version-history":[{"count":22,"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/docs\/3455\/revisions"}],"predecessor-version":[{"id":4580,"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/docs\/3455\/revisions\/4580"}],"up":[{"embeddable":true,"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/docs\/3773"}],"prev":[{"title":"API: List Attendance Devices","link":"https:\/\/modulus.help\/kb\/docs\/documentation\/personnel-apis-v1\/api-list-attendance-devices\/","href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/docs\/3453"}],"wp:attachment":[{"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/media?parent=3455"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/modulus.help\/kb\/wp-json\/wp\/v2\/doc_tag?post=3455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}