> ## 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

> Delete many absence and accident records at once by passing their ids

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

Delete up to 100,000 absence and accident records in one call. The response reports what succeeded and what did not, so a partial failure is visible rather than silent.

Irreversible: there is no endpoint that recreates these records, only a re-import. Remember that a row covering an accident and its sick leave removes both events.

## 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>

### Body

<ParamField body="absenteeism_accident_ids" type="array[string]" required>
  Record UUIDs to delete — the `id` of each row, not `accident_id` or `absenteeism_id`. Between 1 and 100,000 entries.
</ParamField>

<ParamField body="consolidate_group" type="boolean" default="false">
  Group view. `false` authorizes deletion inside the header organization only; `true` across the whole accepted family.

  Ids outside the resolved perimeter are never deleted — they come back in `failed_ids`.
</ParamField>

## Response

<ResponseField name="success_count" type="integer">
  How many records were deleted
</ResponseField>

<ResponseField name="success_ids" type="array[string]">
  Ids of the deleted records
</ResponseField>

<ResponseField name="failed_count" type="integer">
  How many ids were not deleted — unknown, already gone, or outside your perimeter
</ResponseField>

<ResponseField name="failed_ids" type="array[string]">
  Ids that were not deleted
</ResponseField>

<ResponseField name="message" type="string">
  Human-readable summary
</ResponseField>

The call returns `200 OK` even when some ids fail. Read `failed_count`, not the status code.

## 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" \
    -H "x-api-key: ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}" \
    -H "Content-Type: application/json" \
    -d '{"absenteeism_accident_ids": ["6f2c8d13-4a5b-4c6d-9e0f-1a2b3c4d5e6f"]}'
  ```

  ```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"),
  }

  response = requests.post(
      "https://api.dcycle.io/v1/own_workforce_absenteeisms_accidents/bulk-delete",
      headers=headers,
      json={"absenteeism_accident_ids": ["6f2c8d13-4a5b-4c6d-9e0f-1a2b3c4d5e6f"]},
  )

  result = response.json()
  print(f"deleted {result['success_count']}, failed {result['failed_count']}")
  ```

  ```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
  };

  axios.post('https://api.dcycle.io/v1/own_workforce_absenteeisms_accidents/bulk-delete', {
    absenteeism_accident_ids: ['6f2c8d13-4a5b-4c6d-9e0f-1a2b3c4d5e6f']
  }, { headers })
  .then(({ data }) => console.log(`deleted ${data.success_count}, failed ${data.failed_count}`))
  .catch(error => console.error(error));
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "success_count": 1,
  "success_ids": ["6f2c8d13-4a5b-4c6d-9e0f-1a2b3c4d5e6f"],
  "failed_count": 0,
  "failed_ids": [],
  "message": "Deleted 1 absenteeism/accident record"
}
```

## 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"
}
```

### 422 Unprocessable Entity

**Cause:** empty `absenteeism_accident_ids`, more than 100,000 entries, or a value that is not a UUID.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": [
    {
      "type": "too_short",
      "loc": ["body", "absenteeism_accident_ids"],
      "msg": "List should have at least 1 item after validation, not 0"
    }
  ]
}
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Bulk delete by filters" icon="filter-circle-xmark" href="/api-reference/own-workforce/bulk-delete-absences-by-filters">
    Delete a filtered set without collecting ids
  </Card>

  <Card title="Delete one record" icon="trash" href="/api-reference/own-workforce/delete-absence">
    Single-record deletion
  </Card>
</CardGroup>
