Bulk Delete Vehicle Consumptions 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/vehicles/{vehicle_id}/consumptions/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/vehicles/{vehicle_id}/consumptions/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/vehicles/{vehicle_id}/consumptions/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": {},
"failed_count": 123,
"failed_ids": {},
"message": "<string>"
}Bulk Delete Vehicle Consumptions by Filters
Delete all consumption records for a vehicle matching the given filter criteria
POST
/
v1
/
vehicles
/
{vehicle_id}
/
consumptions
/
bulk-delete-by-filters
Bulk Delete Vehicle Consumptions 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/vehicles/{vehicle_id}/consumptions/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/vehicles/{vehicle_id}/consumptions/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/vehicles/{vehicle_id}/consumptions/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": {},
"failed_count": 123,
"failed_ids": {},
"message": "<string>"
}Bulk Delete Vehicle Consumptions by Filters
Delete all consumption records for a specific vehicle that match a set of filter criteria. This endpoint uses a two-step workflow: first fetch the consumption list with filters applied (which returns afilter_hash), then call this endpoint with that hash to confirm you are deleting exactly what you saw.
Permanent Action: Deleting consumption records is permanent and cannot be undone. All associated emissions data will be removed from your organization’s totals.
How It Works
- Call
GET /v1/vehicles/{vehicle_id}/consumptionswith your desired filters — the response includes afilter_hashfield. - Call this endpoint with the same query filters and pass the
filter_hashin the request body. - The API verifies the hash matches the current filter results to prevent stale-data race conditions.
Request
Path Parameters
uuid
required
The UUID of the vehicle whose consumptions you want to deleteExample:
550e8400-e29b-41d4-a716-446655440000Headers
string
required
Your API key for authenticationExample:
sk_live_1234567890abcdefstring
required
Your organization UUIDExample:
a8315ef3-dd50-43f8-b7ce-d839e68d51faBody Parameters
string
required
The hash returned in the
filter_hash field of the consumption list response. Confirms you are deleting exactly the records you saw.Example: "b4c2d3e5f6a7b8c9"Query Parameters
At least one filter parameter is required.array[string]
Filter by consumption statusAvailable values:
active, success, loading, errorExample: status[]=error&status[]=loadingarray[string]
Filter by unit UUIDs
string
Filter by custom identifier
string
Filter consumptions with a start date on or after this date (YYYY-MM-DD)Example:
2024-01-01string
Filter consumptions with an end date on or before this date (YYYY-MM-DD)Example:
2024-12-31array[string]
Filter by source file UUIDs (e.g. to delete all consumptions imported from a specific file)
string
Filter consumptions created on or after this datetime (ISO 8601)Example:
2024-01-01T00:00:00Zstring
Filter consumptions created on or before this datetime (ISO 8601)Example:
2024-12-31T23:59:59Zstring
Filter by CO2e calculation statusAvailable values:
calculated, not_calculatedExample: co2e_status=not_calculatedResponse
Returns200 OK with a JSON summary of the operation.
integer
Number of consumption records successfully deleted
array[string]
UUIDs of successfully deleted consumption records
integer
Number of records that failed to delete
array[string]
UUIDs of records that failed to delete
string
Human-readable summary of the operation
Example
# Step 1: get list with filters to obtain filter_hash
curl -X GET "https://api.dcycle.io/v1/vehicles/550e8400-e29b-41d4-a716-446655440000/consumptions?status[]=error" \
-H "x-api-key: ${DCYCLE_API_KEY}" \
-H "x-organization-id: ${DCYCLE_ORG_ID}"
# Step 2: bulk delete using the filter_hash from the list response
curl -X POST "https://api.dcycle.io/v1/vehicles/550e8400-e29b-41d4-a716-446655440000/consumptions/bulk-delete-by-filters?status[]=error" \
-H "x-api-key: ${DCYCLE_API_KEY}" \
-H "x-organization-id: ${DCYCLE_ORG_ID}" \
-H "Content-Type: application/json" \
-d '{"filter_hash": "b4c2d3e5f6a7b8c9"}'
import requests
import os
api_key = os.getenv("DCYCLE_API_KEY")
org_id = os.getenv("DCYCLE_ORG_ID")
vehicle_id = "550e8400-e29b-41d4-a716-446655440000"
headers = {
"x-api-key": api_key,
"x-organization-id": org_id,
"Content-Type": "application/json"
}
filters = {"status[]": ["error"]}
# Step 1: fetch list to get filter_hash
list_response = requests.get(
f"https://api.dcycle.io/v1/vehicles/{vehicle_id}/consumptions",
headers=headers,
params=filters
)
filter_hash = list_response.json()["filter_hash"]
# Step 2: bulk delete with hash confirmation
response = requests.post(
f"https://api.dcycle.io/v1/vehicles/{vehicle_id}/consumptions/bulk-delete-by-filters",
headers=headers,
params=filters,
json={"filter_hash": filter_hash}
)
result = response.json()
print(f"Deleted: {result['success_count']}, Failed: {result['failed_count']}")
print(result["message"])
const axios = require('axios');
const apiKey = process.env.DCYCLE_API_KEY;
const orgId = process.env.DCYCLE_ORG_ID;
const vehicleId = '550e8400-e29b-41d4-a716-446655440000';
const headers = {
'x-api-key': apiKey,
'x-organization-id': orgId,
'Content-Type': 'application/json'
};
const filters = { 'status[]': ['error'] };
// Step 1: fetch list to get filter_hash
axios.get(
`https://api.dcycle.io/v1/vehicles/${vehicleId}/consumptions`,
{ headers, params: filters }
)
.then(listResponse => {
const filterHash = listResponse.data.filter_hash;
// Step 2: bulk delete with hash confirmation
return axios.post(
`https://api.dcycle.io/v1/vehicles/${vehicleId}/consumptions/bulk-delete-by-filters`,
{ filter_hash: filterHash },
{ headers, params: filters }
);
})
.then(response => {
const result = response.data;
console.log(`Deleted: ${result.success_count}, Failed: ${result.failed_count}`);
console.log(result.message);
})
.catch(error => console.error(error));
Successful Response
{
"success_count": 8,
"success_ids": [
"660e8400-e29b-41d4-a716-446655440000",
"770e8400-e29b-41d4-a716-446655440001"
],
"failed_count": 0,
"failed_ids": [],
"message": "Successfully deleted 8 vehicle consumptions"
}
Common Errors
401 Unauthorized
Cause: Missing or invalid API key{
"detail": "Invalid API key",
"code": "INVALID_API_KEY"
}
404 Not Found
Cause: Vehicle not found in organization{
"code": "VEHICLE_NOT_FOUND",
"detail": "Vehicle with id=UUID('...') not found"
}
409 Conflict — Filter Hash Mismatch
Cause: Thefilter_hash does not match the current filter results. The underlying data changed between the list call and the delete call.
{
"detail": "Filter hash mismatch. The filters have changed since the list was loaded. Please refresh and try again."
}
filter_hash, then retry.
422 Unprocessable Entity — No Filters Provided
Cause: No filter query parameters were supplied. At least one filter is required to prevent accidental mass deletion.{
"detail": "At least one filter parameter is required for bulk delete by filters."
}
422 Validation Error
Cause: Invalid query parameter value (e.g. unknown status enum){
"detail": [
{
"loc": ["query", "status[]"],
"msg": "value is not a valid enumeration member; permitted: 'active', 'success', 'loading', 'error'",
"type": "type_error.enum"
}
]
}
Related Endpoints
Vehicle Consumptions
List consumptions and obtain the filter_hash
Bulk Delete Consumptions
Delete specific consumption records by ID
Bulk Delete Vehicles by Filters
Delete vehicles matching filter criteria
Delete Vehicle
Delete a single vehicle
Bulk Delete by Filters (Organization)
Delete consumptions matching filters across every vehicle in the organization
Was this page helpful?