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

# Bulk Delete Workforce Absences by Filters

> Delete every absence and accident record matching a set of filters, guarded by the hash of the list you saw

[← Own Workforce API](/api-reference/own-workforce/overview)

Delete every absence and accident record matching a filter set, without collecting ids. Filters go in the **query string** — the same ones [List Workforce Absences Paginated](/api-reference/own-workforce/list-absences-paginated) accepts — and the body carries the `filter_hash` that list returned.

## The filter\_hash guard

`filter_hash` fingerprints the filters that produced a page, including `consolidate_group` and `organization_id[]`. Send it back; the server recomputes the fingerprint from the filters on *this* request. Match, and the delete proceeds over exactly the set you listed. Differ, and it answers `409 Conflict` without deleting anything.

It guards against that drift, not against a caller who deliberately sends different filters — the tenant boundary is the organization scoping, not the hash. Take the hash verbatim from the list response.

No filter is required. With none, the delete covers every row of the perimeter the list showed: the header organization, or under `consolidate_group` the accepted family narrowed by `organization_id[]` (and the project scope, when it is on). That is the same set the unfiltered list counts in `total`, so read it before you delete.

## Request

### Headers

<ParamField header="x-api-key" type="string" required>
  Your API key for authentication

  **Example:** `sk_live_1234567890abcdef`
</ParamField>

<ParamField header="x-organization-id" type="string" required>
  Your organization UUID

  **Example:** `a8315ef3-dd50-43f8-b7ce-d839e68d51fa`
</ParamField>

### Query Parameters

<ParamField query="file_id[]" type="array[string]">
  Filter by source upload file. The nil UUID matches rows with no file.
</ParamField>

<ParamField query="created_at_from" type="datetime">
  Only rows created at or after this instant
</ParamField>

<ParamField query="created_at_to" type="datetime">
  Only rows created on or before this instant, inclusive
</ParamField>

<ParamField query="search" type="string">
  Free-text search, up to 255 characters
</ParamField>

<ParamField query="consolidate_group" type="boolean" default="false">
  Widen the perimeter to the accepted family. Part of the hash.
</ParamField>

<ParamField query="organization_id[]" type="array[string]">
  Narrow a group-view delete to these organizations. Part of the hash.
</ParamField>

### Body

<ParamField body="filter_hash" type="string" required>
  The `filter_hash` from the paginated list response that showed you these rows
</ParamField>

## Response

Same shape as [Bulk Delete Workforce Absences](/api-reference/own-workforce/bulk-delete-absences): `success_count`, `success_ids`, `failed_count`, `failed_ids` and `message`.

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X POST "https://api.dcycle.io/v1/own_workforce_absenteeisms_accidents/bulk-delete-by-filters?file_id[]=dd44ee55-ff66-4077-8188-99aabbccddee" \
    -H "x-api-key: ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}" \
    -H "Content-Type: application/json" \
    -d '{"filter_hash": "9c1b7e34a0f5d862"}'
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import os

  import requests

  headers = {
      "x-api-key": os.getenv("DCYCLE_API_KEY"),
      "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
  }

  filters = {"file_id[]": "dd44ee55-ff66-4077-8188-99aabbccddee"}

  listed = requests.get(
      "https://api.dcycle.io/v1/own_workforce_absenteeisms_accidents/paginated",
      headers=headers,
      params=filters,
  ).json()
  print(f"about to delete {listed['total']} records")

  response = requests.post(
      "https://api.dcycle.io/v1/own_workforce_absenteeisms_accidents/bulk-delete-by-filters",
      headers=headers,
      params=filters,
      json={"filter_hash": listed["filter_hash"]},
  )

  print(response.json()["message"])
  ```

  ```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const axios = require('axios');

  const headers = {
    'x-api-key': process.env.DCYCLE_API_KEY,
    'x-organization-id': process.env.DCYCLE_ORG_ID
  };

  const params = { 'file_id[]': 'dd44ee55-ff66-4077-8188-99aabbccddee' };
  const base = 'https://api.dcycle.io/v1/own_workforce_absenteeisms_accidents';

  axios.get(`${base}/paginated`, { headers, params })
    .then(listed => axios.post(
      `${base}/bulk-delete-by-filters`,
      { filter_hash: listed.data.filter_hash },
      { headers, params }
    ))
    .then(({ data }) => console.log(data.message))
    .catch(error => console.error(error));
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "success_count": 96,
  "success_ids": [
    "… 96 ids in total, abridged here …",
    "6f2c8d13-4a5b-4c6d-9e0f-1a2b3c4d5e6f"],
  "failed_count": 0,
  "failed_ids": [],
  "message": "Deleted 96 absenteeism/accident records"
}
```

## Common Errors

### 401 Unauthorized

**Cause:** the key is invalid, or it does not belong to the organization in `x-organization-id` — the two are looked up as a pair. A request carrying no credentials at all answers `AUTH_REQUIRED` instead.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": "Invalid API key for organization",
  "code": "INVALID_API_KEY"
}
```

### 403 Forbidden

**Cause:** the key's owner is not an enabled member of the organization, or their role cannot write.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": "Logged User is not Member of Organization",
  "code": "LOGGED_USER_NOT_MEMBER"
}
```

### 409 Conflict

**Cause:** `filter_hash` does not match the filters on this request. Nothing was deleted.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": "Filter hash mismatch. The filters have changed since the list was loaded. Please refresh and try again."
}
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="List absences paginated" icon="list-ol" href="/api-reference/own-workforce/list-absences-paginated">
    Where `filter_hash` comes from
  </Card>

  <Card title="Bulk delete by ids" icon="trash" href="/api-reference/own-workforce/bulk-delete-absences">
    When you already hold the ids
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.