> ## Documentation Index
> Fetch the complete documentation index at: https://developers.luccasoftware.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Mass Delete TimeEntries

## 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](https://developers.luccasoftware.com/api-reference/legacy/timmi-timesheet/guides/update-time-entries.md).

> [!CAUTION]
>
> **Deletion is permanent**.
> Please bear in mind that once TimeEntries have been deleted,
> they cannot be restored back.

## Prerequisites

You will need:

* (required) Your domain name `{yourDomain}`, eg: "[https://myawesomecompany.ilucca.net](https://myawesomecompany.ilucca.net)".
* (required) An [API key](https://support.lucca.fr/hc/en-us/articles/115000084851) `{apiKey}` that has TimeEntries editing rights to the given owners.

## Guide

### 1. Identify TimeEntries

> [!WARNING]
>
> **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](https://developers.luccasoftware.com/api-reference/legacy/timmi-timesheet/guides/mass-rejection-timesheets.md).

Retrieving TimeEntries is achieved through the `/api/v3/timeentries` endpoint. Its [API reference can be found here.](../../timmi-timesheet)

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.

> [!WARNING]
>
> **Please page your request.**
> Requests aimed at retrieving a large set of resources should be paged.
> [You can read more about paging here](https://developers.luccasoftware.com/api-reference/legacy/introduction.md).

The request should look like this:

```http theme={null}
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
      }
    ]
  }
}
```

> [!NOTE]
>
> **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.](../..//timmi-timesheet)

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

[
  {
    "id": 12354
  }
]
```


## Related topics

- [How to Update TimeEntries](https://developers.luccasoftware.com/api-reference/legacy/timmi-timesheet/guides/update-time-entries.md)
- [How To Retrieve TimeEntries](https://developers.luccasoftware.com/api-reference/legacy/timmi-timesheet/guides/retrieve-time-entries.md)
- [Delete a time-entry by id](https://developers.luccasoftware.com/api-reference/legacy/timmi-timesheet/time-entries/delete-a-time-entry-by-id.md)
- [Delete multiple time-entries](https://developers.luccasoftware.com/api-reference/legacy/timmi-timesheet/time-entries/delete-multiple-timeentries.md)
- [TimeEntries update service](https://developers.luccasoftware.com/api-reference/legacy/timmi-timesheet/time-entries/import-time-entries.md)
