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/v1/invoices/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/invoices/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/invoices/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>"
}
'{
"success_count": 123,
"success_ids": [
"<string>"
],
"failed_count": 123,
"failed_ids": [
"<string>"
],
"message": "<string>"
}Bulk Delete by Filters
Delete all invoices matching filter criteria with concurrency guard
POST
/
v1
/
invoices
/
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/v1/invoices/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/invoices/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/invoices/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>"
}
'{
"success_count": 123,
"success_ids": [
"<string>"
],
"failed_count": 123,
"failed_ids": [
"<string>"
],
"message": "<string>"
}← Invoices API
Delete all invoices that match the given filter criteria. Uses the same filters as the list endpoint plus a
filter_hash for optimistic concurrency — ensuring you delete exactly what the user saw.
Request
Headers
string
required
Your API key for authenticationExample:
sk_live_1234567890abcdefstring
required
Your organization UUIDExample:
a8315ef3-dd50-43f8-b7ce-d839e68d51faQuery Parameters
facility_id and type are required; every other filter is optional. Without one the delete covers every invoice of that type in the facility (narrowed to the project when project_id is set), the same set the unfiltered list shows.
string
required
UUID of the facility
string
required
Invoice type:
electricity, heat, water, rechargestring
Filter invoices on or after this date
string
Filter invoices on or before this date
string[]
Filter by status
string
Filter by CO2e calculation status
string[]
Filter by CUPS identifier
string[]
Filter by supplier UUID
Body Parameters
string
required
Hash from the list endpoint response. Must match the current filter set.
Example
# Step 1: Get filter_hash from list
RESPONSE=$(curl -s "https://api.dcycle.io/v1/invoices?facility_id=${FACILITY_ID}&type=electricity&status[]=error" \
-H "x-api-key: ${DCYCLE_API_KEY}" \
-H "x-organization-id: ${DCYCLE_ORG_ID}")
FILTER_HASH=$(echo $RESPONSE | jq -r '.filter_hash')
# Step 2: Bulk delete with the same filters
curl -X POST "https://api.dcycle.io/v1/invoices/bulk-delete-by-filters?facility_id=${FACILITY_ID}&type=electricity&status[]=error" \
-H "x-api-key: ${DCYCLE_API_KEY}" \
-H "x-organization-id: ${DCYCLE_ORG_ID}" \
-H "Content-Type: application/json" \
-d "{\"filter_hash\": \"${FILTER_HASH}\"}"
import requests
import os
headers = {
"x-api-key": os.getenv("DCYCLE_API_KEY"),
"x-organization-id": os.getenv("DCYCLE_ORG_ID"),
}
filters = {
"facility_id": os.getenv("FACILITY_ID"),
"type": "electricity",
"status[]": "error",
}
# Step 1: Get filter_hash
list_resp = requests.get("https://api.dcycle.io/v1/invoices", headers=headers, params=filters)
filter_hash = list_resp.json()["filter_hash"]
# Step 2: Bulk delete
delete_resp = requests.post(
"https://api.dcycle.io/v1/invoices/bulk-delete-by-filters",
headers={**headers, "Content-Type": "application/json"},
params=filters,
json={"filter_hash": filter_hash},
)
result = delete_resp.json()
print(f"Deleted: {result['success_count']} | Failed: {result['failed_count']}")
const axios = require('axios');
const headers = {
'x-api-key': process.env.DCYCLE_API_KEY,
'x-organization-id': process.env.DCYCLE_ORG_ID,
};
const filters = {
facility_id: process.env.FACILITY_ID,
type: 'electricity',
'status[]': 'error',
};
// Step 1: Get filter_hash
const listResp = await axios.get('https://api.dcycle.io/v1/invoices', { headers, params: filters });
const filterHash = listResp.data.filter_hash;
// Step 2: Bulk delete
const deleteResp = await axios.post(
'https://api.dcycle.io/v1/invoices/bulk-delete-by-filters',
{ filter_hash: filterHash },
{ headers: { ...headers, 'Content-Type': 'application/json' }, params: filters },
);
const { success_count, failed_count } = deleteResp.data;
console.log(`Deleted: ${success_count} | Failed: ${failed_count}`);
Successful Response
{
"success_count": 2,
"success_ids": [
"a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"b2c3d4e5-f6a7-8901-bcde-f12345678901"
],
"failed_count": 0,
"failed_ids": [],
"message": "Successfully deleted 2 invoices"
}
Response
integer
Number of invoices successfully deleted
string[]
UUIDs of successfully deleted invoices
integer
Number of invoices that failed to delete
string[]
UUIDs of invoices that failed to delete
string
Human-readable summary message
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:filter_hash doesn’t match — filters changed since the list was loaded
{
"detail": "Filter hash mismatch. The filters have changed since the list was loaded. Please refresh and try again."
}
Related Endpoints
Bulk Delete
Delete specific invoices by ID
Was this page helpful?