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?
About the creationSource / timeSource
When sending TimeEntries to Lucca Timesheet, you will need to set atimeSource
or a creationSource
depending on the endpoints used :
timeSource=manual
orcreationSource=2
for standard TimeEntries that users should be able to edit normally. [the default for any TimeEntry]timeSource=import
orcreationSource=3
for read-only TimeEntries that only users with “Edit times” right should be able to edit through the user interface. (only for attendance-schedule-clock-in/clock-out or activity-schedule timesheet modes)timeSource=timer
orcreationSource=4
for clocked-in / clocked-out TimeEntries that users should be able to adjust if necessary. After editing the TimeEntry,timeSource
/creationSource
will be set tomanual
/2
.
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.