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

> Delete many own workforce employees at once by passing their ids

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

Delete up to 100,000 employees in one call by listing their ids. The response reports what succeeded and what did not, so a partial failure is visible rather than silent.

<Warning>
  Irreversible, and it cascades: each deleted employee takes their contracts, remunerations, trainings and absence records with them. There is no create endpoint to put them back — only a re-import.
</Warning>

## 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="own_workforce_ids" type="array[string]" required>
  Employee UUIDs to delete. 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` authorizes it across the whole accepted family.

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

## Response

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

<ResponseField name="success_ids" type="array[string]">
  Ids of the deleted employees
</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. Always read `failed_count` rather than relying on the status code.

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X POST "https://api.dcycle.io/v1/own_workforces/bulk-delete" \
    -H "x-api-key: ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}" \
    -H "Content-Type: application/json" \
    -d '{
      "own_workforce_ids": [
        "550e8400-e29b-41d4-a716-446655440000",
        "661f9511-f3ac-52e5-b827-557766551111"
      ]
    }'
  ```

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

  payload = {
      "own_workforce_ids": [
          "550e8400-e29b-41d4-a716-446655440000",
          "661f9511-f3ac-52e5-b827-557766551111",
      ]
  }

  response = requests.post(
      "https://api.dcycle.io/v1/own_workforces/bulk-delete",
      headers=headers,
      json=payload,
  )

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

  ```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_workforces/bulk-delete', {
    own_workforce_ids: [
      '550e8400-e29b-41d4-a716-446655440000',
      '661f9511-f3ac-52e5-b827-557766551111'
    ]
  }, { headers })
  .then(response => {
    const { success_count, failed_count, failed_ids } = response.data;
    console.log(`deleted ${success_count}, failed ${failed_count}`);
    if (failed_ids.length) console.log('not deleted:', failed_ids);
  })
  .catch(error => console.error(error));
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "success_count": 1,
  "success_ids": ["550e8400-e29b-41d4-a716-446655440000"],
  "failed_count": 1,
  "failed_ids": ["661f9511-f3ac-52e5-b827-557766551111"],
  "message": "Deleted 1 of 2 own workforce 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"
}
```

### 422 Unprocessable Entity

**Cause:** empty `own_workforce_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", "own_workforce_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-by-filters">
    Delete what a filtered list returned, without collecting ids
  </Card>

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