Bulk Delete Workforce Employees 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/v1/own_workforces/bulk-delete-by-filters', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.dcycle.io/v1/own_workforces/bulk-delete-by-filters"
payload = { "filter_hash": "<string>" }
headers = {
"x-api-key": "<x-api-key>",
"x-organization-id": "<x-organization-id>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)curl --request POST \
--url https://api.dcycle.io/v1/own_workforces/bulk-delete-by-filters \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--header 'x-organization-id: <x-organization-id>' \
--data '
{
"filter_hash": "<string>"
}
'Bulk Delete Workforce Employees by Filters
Delete every own workforce employee matching a set of filters, guarded by the hash of the list you saw
POST
/
v1
/
own_workforces
/
bulk-delete-by-filters
Bulk Delete Workforce Employees 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/v1/own_workforces/bulk-delete-by-filters', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.dcycle.io/v1/own_workforces/bulk-delete-by-filters"
payload = { "filter_hash": "<string>" }
headers = {
"x-api-key": "<x-api-key>",
"x-organization-id": "<x-organization-id>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)curl --request POST \
--url https://api.dcycle.io/v1/own_workforces/bulk-delete-by-filters \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--header 'x-organization-id: <x-organization-id>' \
--data '
{
"filter_hash": "<string>"
}
'← Own Workforce API
Delete every employee matching a filter set, without collecting their ids first. The filters go in the query string — the same ones List Workforce Employees accepts — and the body carries the
filter_hash that list returned.
Irreversible, and it cascades to contracts, remunerations, trainings and absence records. Always run the equivalent list call first and read
total before deleting.The filter_hash guard
filter_hash fingerprints the filters that produced a page — including consolidate_group, organization_id[] and the project scope. Send it back and the server recomputes the fingerprint from the filters on this request:
- they match → the delete proceeds over exactly the set you listed;
- they differ →
409 Conflict, and nothing is deleted.
consolidate_group and organization_id[] do not count: they change the perimeter rather than select rows, so on their own they answer 422. Note what this does and does not buy you — it blocks a filterless call, not a broad one. A single wide created_at_from satisfies the rule and can still match every row in the organization, so read total from the list before you delete.
Request
Headers
string
required
Your API key for authenticationExample:
sk_live_1234567890abcdefstring
required
Your organization UUIDExample:
a8315ef3-dd50-43f8-b7ce-d839e68d51faQuery Parameters
The same filters as the list endpoint. At least one of the first four is required.string
Search by the employee identifier your HR system uses
array[string]
Filter by source upload file. The nil UUID matches rows with no file.
datetime
Only rows created at or after this instant
datetime
Only rows created at or before this instant
boolean
default:"false"
Widen the perimeter to the accepted business family. Part of the hash; does not satisfy the “at least one filter” rule on its own.
array[string]
Narrow a group-view delete to these organizations. Part of the hash; does not satisfy the “at least one filter” rule on its own.
Body
string
required
The
filter_hash from the list response that showed you these rowsResponse
Same shape as Bulk Delete Workforce Employees:success_count, success_ids, failed_count, failed_ids and message.
Example
curl -X POST "https://api.dcycle.io/v1/own_workforces/bulk-delete-by-filters?file_id[]=9f1c7f2a-64a1-4b2c-9d3e-70a5b8c1d2e3" \
-H "x-api-key: ${DCYCLE_API_KEY}" \
-H "x-organization-id: ${DCYCLE_ORG_ID}" \
-H "Content-Type: application/json" \
-d '{"filter_hash": "b6d1f0c47a9e2d38"}'
import os
import requests
headers = {
"x-api-key": os.getenv("DCYCLE_API_KEY"),
"x-organization-id": os.getenv("DCYCLE_ORG_ID"),
}
filters = {"file_id[]": "9f1c7f2a-64a1-4b2c-9d3e-70a5b8c1d2e3"}
# 1. List first: you need the hash, and you should see the count before deleting.
listed = requests.get(
"https://api.dcycle.io/v1/own_workforces",
headers=headers,
params=filters,
).json()
print(f"about to delete {listed['total']} employees")
# 2. Delete exactly that set.
response = requests.post(
"https://api.dcycle.io/v1/own_workforces/bulk-delete-by-filters",
headers=headers,
params=filters,
json={"filter_hash": listed["filter_hash"]},
)
print(response.json()["message"])
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[]': '9f1c7f2a-64a1-4b2c-9d3e-70a5b8c1d2e3' };
axios.get('https://api.dcycle.io/v1/own_workforces', { headers, params })
.then(listed => {
console.log(`about to delete ${listed.data.total} employees`);
return axios.post(
'https://api.dcycle.io/v1/own_workforces/bulk-delete-by-filters',
{ filter_hash: listed.data.filter_hash },
{ headers, params }
);
})
.then(response => console.log(response.data.message))
.catch(error => console.error(error));
Successful Response
{
"success_count": 145,
"success_ids": [
"… 145 ids in total, abridged here …",
"550e8400-e29b-41d4-a716-446655440000"],
"failed_count": 0,
"failed_ids": [],
"message": "Deleted 145 own workforce records"
}
Common Errors
401 Unauthorized
Cause: the key is invalid, or it does not belong to the organization inx-organization-id — the two are looked up as a pair. A request carrying no credentials at all answers AUTH_REQUIRED instead.
{
"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.{
"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. Re-list with the filters you intend, then retry with the fresh hash.
{
"detail": "Filter hash mismatch. The filters have changed since the list was loaded. Please refresh and try again."
}
422 Unprocessable Entity
Cause: no real filter was supplied — onlyconsolidate_group and/or organization_id[], or nothing at all.
{
"detail": "At least one filter parameter is required for bulk delete by filters."
}
Related Endpoints
List employees
Where
filter_hash comes fromBulk delete by ids
When you already hold the ids
Was this page helpful?