Introduction

This guide is aimed at helping you mass delete TimeEntries. It can help you reset clear TimeEntries after an incorrect import or any problem encountered when updating TimeEntries.

Prerequisites

You will need:

Guide

1. Identify TimeEntries

Submitted TimeEntries cannot be deleted. Once a timesheet has been submitted, and whether or not it is approved, the TimeEntries it contains can no longer be modified or deleted. You may want to first reject the timesheet, and there’s a guide for this.

Retrieving TimeEntries is achieved through the /api/v3/timeentries endpoint. Its API reference can be found here.

In order to isolate the TimeEntries that need to be deleted, the most common filters are:

  • ?ownerId=1,2,...: filter on the user(s).
  • ?startsAt=between,2022-01-01,2022-O2-01: filter on the TimeEntry date.
  • ?unit=0,1,2: filter on the TimeEntry unit.

Please page your request. Requests aimed at retrieving a large set of resources should be paged. You can read more about paging here.

The request should look like this:

GET /api/v3/timeentries?ownerId=416&startsAt=between,2022-01-01,2022-O2-01&paging=0,1000&fields=id,ownerId,startsAt,timesheetId,collection.count HTTP/1.1
Host: {yourDomain}
Authorization: lucca application={apiKey}
Accept: application/json

Response:
{
  "data": {
    "count": 1, 
    "items": [
      {
        "id": 12354,
        "ownerId": 416,
        "startsAt": "2021-01-01 08:45:00",
        "timesheetId": null
      }
    ]
  }
}

If timesheetId is not null. If the timesheetId of the returned TimeEntries is not null, then it belongs to a submitted timesheet and cannot be deleted as long as said timesheet is not rejected.

2. Delete TimeEntries

Deleting TimeEntries can be done through a DELETE request on the /api/v3/timeentries endpoint. The array of TimeEntries to delete must be passed in the request body.

Please refer to the API reference.

DELETE /api/v3/timeentries HTTP/1.1
Host: {yourDomain}
Authorization: lucca application={apiKey}
Content-Type: application/json

[
  {
    "id": 12354
  }
]