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

curl --request --url POST 'https://api.7shifts.com/v2/company/1234/time_punches'

Request body

{
	  "time_punch": {
		    "user_id": 1111,
		    "role_id": 7410,
		    "department_id": 3698,
		    "location_id": 7890,
		    "clocked_in": "2022-01-31T16:00:00Z"
	  }
}

Response

{
    "data": {
        "id": 1,
        "company_id": 1234,
        "shift_id": 0,
        "user_id": 1111,
        "editable_punch": true,
        "role_id": 7410,
        "location_id": 7890,
        "department_id": 3698,
        "hourly_wage": 1500,
        "approved": false,
        "clocked_in": "2022-01-31T16:00:00Z",
        "clocked_out": null,
        "notes": "",
        "auto_clocked_out": false,
        "clocked_in_offline": false,
        "clocked_out_offline": false,
        "tips": 0,
        "created": "2022-01-31T16:00:00Z",
        "modified": "2022-01-31T16:00:00Z",
        "deleted": false,
        "pos_type": "web",
        "breaks": []
    },
    "object": "time_punch"
}

Here’s an explanation of each of the fields required in the request body. NOTE all ID fields are 7shifts IDs unless specified otherwise. Reference our Mapping guide for more information.

ParameterTypeDescription
user_idintegerUser ID clocking in.
role_idintegerThe ID of the role that the user is clocking in to work for.
department_idintegerThe ID of the department that the user is clocking in at.
location_idintegerThe ID of the location that the user is clocking in at.
clocked_indatetimeThe clocked in datet time. UTC in ISO8601 format (format: YYYY-MM-DDTHH: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 & 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 associated with. 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 1111 is clocking in for role_id 7410, which belongs to department_id 3698, which in turn belongs to location_id 7890.