Skip to main content
POST
/
v2
/
employees
/
bulk-delete-by-filters
Bulk Delete by Filters
const options = {
  method: 'POST',
  headers: {
    'x-api-key': '<x-api-key>',
    'x-organization-id': '<x-organization-id>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({filter_hash: '<string>'})
};

fetch('https://api.dcycle.io/v2/employees/bulk-delete-by-filters', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "total": 123,
  "success": 123,
  "failed": 123,
  "errors": {}
}

Bulk Delete by Filters

Delete all employees that match the given filter criteria. Uses the same filters as the list endpoint. Requires a filter_hash for optimistic concurrency — the hash must match what the server computes for the same filters, ensuring the user deletes exactly what they saw.

Request

Headers

x-api-key
string
required
Your API key for authenticationExample: sk_live_1234567890abcdef
x-organization-id
string
required
Your organization UUIDExample: a8315ef3-dd50-43f8-b7ce-d839e68d51fa

Body Parameters

filter_hash
string
required
Hash from the list endpoint response (filter_hash field). Prevents stale deletes.

Query Parameters (Filters)

Free-text search across employee fields
transport_type[]
string[]
Filter by transport type (car, bus, metro, train, bicycle, etc.)
situation[]
string[]
Filter by employee situation
status[]
string[]
Filter by calculation status: pending, active, error
response_medium[]
string[]
Filter by survey response medium
file_id[]
string[]
Filter by bulk-upload file UUIDs
created_at_from
string
Filter records created on or after this datetime (ISO 8601)
created_at_to
string
Filter records created on or before this datetime (ISO 8601)
co2e_status
string
Filter by CO2e calculation status

Response

total
integer
Total number of employees processed
success
integer
Number of employees successfully deleted
failed
integer
Number of employees that failed to delete
errors
array[object]
Details of failed deletions

Example

curl -X POST "https://api.dcycle.io/v2/employees/bulk-delete-by-filters?file_id[]=file-uuid-1" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}" \
  -H "Content-Type: application/json" \
  -d '{"filter_hash": "abc123def456"}'

Successful Response

{
  "total": 85,
  "success": 85,
  "failed": 0,
  "errors": []
}

Common Errors

401 Unauthorized

Cause: Missing or invalid API key
{"detail": "Invalid API key for organization", "code": "INVALID_API_KEY"}

403 Forbidden

Cause: The authenticated user is not a member of the organization
{"detail": "Logged User is not Member of Organization", "code": "LOGGED_USER_NOT_MEMBER"}

409 Conflict

Cause: The filter_hash doesn’t match the current filter state — data changed since the list was loaded
{
  "detail": "Filter hash mismatch. The filters have changed since the list was loaded. Please refresh and try again."
}

422 Unprocessable Entity

Cause: No filter parameters provided (safety check to prevent accidental mass deletion)
{
  "detail": "At least one filter parameter is required for bulk delete by filters."
}

Bulk Delete

Delete employees by specific IDs

List Employees

Retrieve all employees with filtering and pagination