Bulk Delete Workforce Trainings 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_workforce_trainings/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_workforce_trainings/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_workforce_trainings/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 Trainings by Filters
Delete every training record matching a set of filters, guarded by the hash of the list you saw
POST
/
v1
/
own_workforce_trainings
/
bulk-delete-by-filters
Bulk Delete Workforce Trainings 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_workforce_trainings/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_workforce_trainings/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_workforce_trainings/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 training matching a filter set, without collecting ids. Filters go in the query string — the same ones List Workforce Trainings 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.
That is what stops a client from listing one subsidiary and then, after widening the perimeter, deleting the whole group. 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.
At least one real filter is required. consolidate_group and organization_id[] do not count: they change the perimeter rather than select rows, so on their own they answer 422. That blocks a filterless call, not a broad one: a single wide created_at_from satisfies the rule and can still match every row, 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
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 on or before this instant, inclusive
string
Free-text search, up to 255 characters
boolean
default:"false"
Widen the perimeter to the accepted family. Part of the hash; does not satisfy the “at least one filter” rule.
array[string]
Narrow a group-view delete to these organizations. Part of the hash; does not satisfy the “at least one filter” rule.
Body
string
required
The
filter_hash from the paginated list response that showed you these rowsResponse
Same shape as Bulk Delete Workforce Trainings:success_count, success_ids, failed_count, failed_ids and message.
Example
curl -X POST "https://api.dcycle.io/v1/own_workforce_trainings/bulk-delete-by-filters?file_id[]=aa11bb22-cc33-4d44-8e55-ff6677889900" \
-H "x-api-key: ${DCYCLE_API_KEY}" \
-H "x-organization-id: ${DCYCLE_ORG_ID}" \
-H "Content-Type: application/json" \
-d '{"filter_hash": "4e8a1c07d3b95f26"}'
import os
import requests
headers = {
"x-api-key": os.getenv("DCYCLE_API_KEY"),
"x-organization-id": os.getenv("DCYCLE_ORG_ID"),
}
filters = {"file_id[]": "aa11bb22-cc33-4d44-8e55-ff6677889900"}
listed = requests.get(
"https://api.dcycle.io/v1/own_workforce_trainings/paginated",
headers=headers,
params=filters,
).json()
print(f"about to delete {listed['total']} trainings")
response = requests.post(
"https://api.dcycle.io/v1/own_workforce_trainings/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[]': 'aa11bb22-cc33-4d44-8e55-ff6677889900' };
axios.get('https://api.dcycle.io/v1/own_workforce_trainings/paginated', { headers, params })
.then(listed => axios.post(
'https://api.dcycle.io/v1/own_workforce_trainings/bulk-delete-by-filters',
{ filter_hash: listed.data.filter_hash },
{ headers, params }
))
.then(({ data }) => console.log(data.message))
.catch(error => console.error(error));
Successful Response
{
"success_count": 320,
"success_ids": [
"… 320 ids in total, abridged here …",
"3d9b0a11-2c4e-4f6a-8b1d-5e7f9a0c2d4e"],
"failed_count": 0,
"failed_ids": [],
"message": "Deleted 320 training 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.
{
"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 trainings paginated
Where
filter_hash comes fromBulk delete by ids
When you already hold the ids
Was this page helpful?