Create Time Punch Data
This section focuses on:
- Structure of POST requests to the /time_punches endpoint
- Send clock-in data to 7shifts (employee clocking in)
Creating time punch data in 7shifts is handled through a POST request to the 7shifts /time_punches endpoint. Here’s an example:
Request URL
POST https://api.7shifts.com/v1/time_punches
Request body
{
"time_punch": {
"user_id": 246800,
"role_id": 135790,
"department_id": 98765,
"location_id": 12345,
"date": "2020-07-31",
"clocked_in": "16:00:00"
}
}
Response
{
"status": "success",
"data": {
"time_punch": {
"id": 1357924680
}
},
"message": "Punch has been added"
}
Here’s an explanation of each of the fields required in the request body:
Parameter | Type | Description |
---|---|---|
user_id | Numeric | The 7shifts ID of the user clocking in (ID field from the users response object). |
role_id | Numeric | The ID of the role that the user is clocking in to work for. |
department_id | Numeric | The ID of the department that the user is clocking in at. |
location_id | Numeric | The ID of the location that the user is clocking in at. |
date | Text/Date | The local date that the user clocked in on (format: YYYY-MM-DD). |
clocked_in | Text/Date | The local time that the user clocked in at (format: HH:MM:SS). |
Send employee clock-ins to 7shifts
As soon as an employee clocks in on your system, you will need to create a new time punch object in 7shifts using the above request.
This newly created punch will need to be updated for all subsequent break/clock out actions, so please be sure to store and map the ID from the response of the time punch that just got created. This ID will be the identifier that you will use in the next section for PUT requests to update this time punch.
NOTE
Please ensure that you are using the correct department_id & location_id that the role is actually associated to. This endpoint doesn’t validate whether the role_id belongs to the specified department_id & location_id or not. Failure to specify the appropriate department & location IDs will result in inaccurate reporting in 7shifts.
In the above example, the employee with user ID 246800 is clocking in for role ID 135790, which belongs to department ID 98765, which in turn belongs to location ID 12345.
Updated 1 day ago