Skip to main content
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));

Documentation Index

Fetch the complete documentation index at: https://code.dcycle.io/llms.txt

Use this file to discover all available pages before exploring further.

Delete Vehicle Consumptions by File

Delete all vehicle consumption records that were created from a specific CSV bulk upload, identified by its 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

file_id
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-d839e68d51fa

Headers

x-api-key
string
required
Your API key for authenticationExample: sk_live_1234567890abcdef
x-organization-id
string
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-d839e68d51fa

Response

Returns 204 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}"

Successful Response

HTTP/1.1 204 No Content
No response body is returned. If no records matched the 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"
}
Solution: Verify your API key is valid and active. Get a new one from Settings → API.

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

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