Delete Vehicle Consumptions by File
const options = {
method: 'DELETE',
headers: {'x-api-key': '<x-api-key>', 'x-organization-id': '<x-organization-id>'}
};
fetch('https://api.dcycle.io/v1/vehicle_consumptions/by-file/{file_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.dcycle.io/v1/vehicle_consumptions/by-file/{file_id}"
headers = {
"x-api-key": "<x-api-key>",
"x-organization-id": "<x-organization-id>"
}
response = requests.delete(url, headers=headers)
print(response.text)curl --request DELETE \
--url https://api.dcycle.io/v1/vehicle_consumptions/by-file/{file_id} \
--header 'x-api-key: <x-api-key>' \
--header 'x-organization-id: <x-organization-id>'Delete Vehicle Consumptions by File
Delete all vehicle consumption records associated with a CSV upload file ID, across the entire holding
DELETE
/
v1
/
vehicle_consumptions
/
by-file
/
{file_id}
Delete Vehicle Consumptions by File
const options = {
method: 'DELETE',
headers: {'x-api-key': '<x-api-key>', 'x-organization-id': '<x-organization-id>'}
};
fetch('https://api.dcycle.io/v1/vehicle_consumptions/by-file/{file_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.dcycle.io/v1/vehicle_consumptions/by-file/{file_id}"
headers = {
"x-api-key": "<x-api-key>",
"x-organization-id": "<x-organization-id>"
}
response = requests.delete(url, headers=headers)
print(response.text)curl --request DELETE \
--url https://api.dcycle.io/v1/vehicle_consumptions/by-file/{file_id} \
--header 'x-api-key: <x-api-key>' \
--header 'x-organization-id: <x-organization-id>'← Vehicles API
Delete all vehicle consumption records that were created from a specific CSV bulk upload, identified by its
No response body is returned. If no records matched the
Solution: Verify your API key is valid and active. Get a new one from Settings → API.
file_id. This endpoint traverses the full holding hierarchy, removing matching records from the parent organization and all child organizations.
Irreversible Action: This permanently deletes all consumption records linked to the given file. All associated CO₂e impact data will be removed across every organization in the holding.
Holding-aware: When a CSV is uploaded to a parent organization, consumption records may be created across multiple child organizations. This endpoint finds and deletes all of them in a single call.
Request
Path Parameters
uuid
required
The UUID of the file whose associated consumption records should be deleted. This is the
file_id returned when the bulk CSV upload was processed.Example: a8315ef3-dd50-43f8-b7ce-d839e68d51faHeaders
string
required
Your API key for authenticationExample:
sk_live_1234567890abcdefstring
required
Your organization UUID. The deletion will include consumption records from this organization and all child organizations in the holding.Example:
a8315ef3-dd50-43f8-b7ce-d839e68d51faResponse
Returns204 No Content on success, even if no records matched the given file_id. No response body.
Example
curl -X DELETE "https://api.dcycle.io/v1/vehicle_consumptions/by-file/a8315ef3-dd50-43f8-b7ce-d839e68d51fa" \
-H "x-api-key: ${DCYCLE_API_KEY}" \
-H "x-organization-id: ${DCYCLE_ORG_ID}"
import requests
import os
api_key = os.getenv("DCYCLE_API_KEY")
org_id = os.getenv("DCYCLE_ORG_ID")
file_id = "a8315ef3-dd50-43f8-b7ce-d839e68d51fa"
headers = {
"x-api-key": api_key,
"x-organization-id": org_id
}
response = requests.delete(
f"https://api.dcycle.io/v1/vehicle_consumptions/by-file/{file_id}",
headers=headers
)
if response.status_code == 204:
print("Vehicle consumptions deleted successfully")
else:
print(f"Error: {response.status_code}")
const axios = require('axios');
const apiKey = process.env.DCYCLE_API_KEY;
const orgId = process.env.DCYCLE_ORG_ID;
const fileId = 'a8315ef3-dd50-43f8-b7ce-d839e68d51fa';
const headers = {
'x-api-key': apiKey,
'x-organization-id': orgId
};
axios.delete(
`https://api.dcycle.io/v1/vehicle_consumptions/by-file/${fileId}`,
{ headers }
)
.then(response => {
if (response.status === 204) {
console.log('Vehicle consumptions deleted successfully');
}
})
.catch(error => console.error(error));
Successful Response
HTTP/1.1 204 No Content
file_id, the response is still 204.
Common Errors
401 Unauthorized
Cause: Missing or invalid API key{
"detail": "Invalid API key",
"code": "INVALID_API_KEY"
}
422 Validation Error
Cause: Malformed UUID in path parameter{
"detail": [
{
"loc": ["path", "file_id"],
"msg": "value is not a valid uuid",
"type": "type_error.uuid"
}
]
}
Use Cases
Undo a Bulk CSV Upload
When a user uploads a CSV file and realizes it contained errors, use this endpoint to remove all the records it created before re-uploading the corrected file:def undo_csv_upload(file_id):
"""Remove all consumptions created by a bulk CSV upload"""
response = requests.delete(
f"https://api.dcycle.io/v1/vehicle_consumptions/by-file/{file_id}",
headers=headers
)
if response.status_code == 204:
print(f"All consumptions from file {file_id} removed")
return True
else:
print(f"Failed: {response.status_code}")
return False
Related Endpoints
Vehicle Consumptions
List all consumption records for a vehicle
Delete Vehicle Consumption
Delete a single consumption record by ID
Bulk Delete Consumptions
Delete multiple consumption records by their IDs
Bulk Delete by Filters
Delete consumptions matching filter criteria
Was this page helpful?