Introduction
This guide is aimed at helping you edit TimeEntries through API requests. For example, if you have another ‘source’ system that handle working times (e.g. a planner, a clock-in clock-out physical device, another time-tracking software, …), you might want to send its data to Lucca Timesheet to automatically fill in timesheets either partially or entirely. On following timesheet modes, you will be able to tag TimeEntries as ‘imported’ to prevent edition from unauthorized users (requires ‘Edit times’ right) :- Attendance schedule with clock-in clock-out system ;
- Activity schedule. If you need to set TimeEntries as read-only on other modes, please contact your account manager or your consultant to discuss options.
Two Different Approaches
Depending on your needs, TimeEntries can be modified two different ways:- Manual CRUD requests
/api/v3/timeentries: if you have precise requirements regarding TimeEntries lifecycle (when a TimeEntry should be deleted, edit a very specific TimeEntry and not another ‘look-a-like’) to match an existing business logic. [recommended] - Smart update service
/timmi-timesheet/services/time-entries: if you only want to send “what Alexander given timesheet should look like”, without caring what might it already be
- What do you want to do if a user edit simultaneously the TimeEntries on Lucca Timesheet and on the other system? Where is the truth?
- What do you want to do if a user deletes a TimeEntry in the source system, and recreates another quite like it with a slightly different duration? Do you want Lucca Timesheet to delete the original TimeEntry and recreate another? Or do you want to to edit the original to match the new duration?
Editing rights : matching the source and the user rights
Thesource property of the time-entry affects its access-rights. As a result, when creating new time-entries, make sure to pick the one that matches your integration purpose:
- Manual source (
timeSource=manualorcreationSource=2) is for regular time-entries that employees should be able to edit themselves down the line. The idea here would be to “automatically suggest time-entries” to employees. The access operation “Add/Edit Times” is required to create or edit such time-entries. - Import source (
timeSource=importorcreationSource=3) is used for time-entries that regular employees should NOT be able to edit. It is most commonly used to import clocked-in times that can’t be tampered, except by administrators. Only users with “Edit imported or clocked-in times” right will be able to edit such time-entries through the user interface.
import source and do not give them the “Edit imported or clock-in times” operation.
See the TimeEntry API reference.
Prerequisites
You will need:- (required) Your domain name
{yourDomain}, eg: “https://myawesomecompany.ilucca.net”. - (required) An API key
{apiKey}that has editing rights on the TimeEntries of the users concerned by your integration project.
Guide
Approach 1 - Manual CRUD Requests
You will need to track any change made to the source system for TimeEntries, and translate those changes into Lucca Timesheet TimeEntries requests.- A new TimeEntry has been created -> POST a new TimeEntry
- A TimeEntry has been modified (duration, project, comment, …) -> PUT on the corresponding TimeEntry id
- A TimeEntry has been deleted -> DELETE the corresponding TimeEntry id
/api/v3/timeentries POST, PUT, and DELETE endpoints.
Examples
Create new TimeEntriesApproach 2 - Smart update service
You will need to track any change made to the source system TimeEntries, and send back to Lucca Timesheet ALL TimeEntries for the whole period, including those that weren’t modified. The service will automatically match and update Lucca Timesheet TimeEntries to meet what you sent. The service should be seen as an ‘erase and replace’ request. See the API reference for/timmi-timesheet/services/time-entries endpoint.