Delete Vehicle
const options = {
method: 'DELETE',
headers: {'x-api-key': '<x-api-key>', 'x-organization-id': '<x-organization-id>'}
};
fetch('https://api.dcycle.io/v1/vehicles/{vehicle_id}', 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}"
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/vehicles/{vehicle_id} \
--header 'x-api-key: <x-api-key>' \
--header 'x-organization-id: <x-organization-id>'Delete Vehicle
Remove a vehicle from your organization’s fleet
DELETE
/
v1
/
vehicles
/
{vehicle_id}
Delete Vehicle
const options = {
method: 'DELETE',
headers: {'x-api-key': '<x-api-key>', 'x-organization-id': '<x-organization-id>'}
};
fetch('https://api.dcycle.io/v1/vehicles/{vehicle_id}', 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}"
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/vehicles/{vehicle_id} \
--header 'x-api-key: <x-api-key>' \
--header 'x-organization-id: <x-organization-id>'Delete Vehicle
Permanently remove a vehicle from your organization’s fleet. This action cannot be undone.Irreversible Action: Deleting a vehicle will remove all associated data. Ensure you have backed up any necessary information before deleting.
Request
Path Parameters
uuid
required
The UUID of the vehicle 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-d839e68d51faResponse
Returns HTTP 204 No Content on successful deletion. No response body.Example
curl -X DELETE "https://api.dcycle.io/v1/vehicles/550e8400-e29b-41d4-a716-446655440000" \
-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")
vehicle_id = "550e8400-e29b-41d4-a716-446655440000"
headers = {
"x-api-key": api_key,
"x-organization-id": org_id
}
response = requests.delete(
f"https://api.dcycle.io/v1/vehicles/{vehicle_id}",
headers=headers
)
if response.status_code == 204:
print("Vehicle 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 vehicleId = "550e8400-e29b-41d4-a716-446655440000";
const headers = {
'x-api-key': apiKey,
'x-organization-id': orgId
};
axios.delete(
`https://api.dcycle.io/v1/vehicles/${vehicleId}`,
{ headers }
)
.then(response => {
if (response.status === 204) {
console.log('Vehicle deleted successfully');
}
})
.catch(error => console.error(error));
Successful Response
HTTP/1.1 204 No Content
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"
}
500 Internal Server Error
Cause: Server error during deletion{
"detail": "Internal server error",
"code": "INTERNAL_ERROR"
}
Use Cases
Remove a Decommissioned Vehicle
Delete a vehicle that is no longer in the fleet:def decommission_vehicle(vehicle_id, license_plate):
"""Remove a decommissioned vehicle from fleet"""
response = requests.delete(
f"https://api.dcycle.io/v1/vehicles/{vehicle_id}",
headers=headers
)
if response.status_code == 204:
print(f"Vehicle {license_plate} successfully decommissioned")
return True
else:
print(f"Failed to delete vehicle: {response.status_code}")
return False
# Remove vehicle
success = decommission_vehicle(
"550e8400-e29b-41d4-a716-446655440000",
"ABC-1234"
)
Clean Up Fleet Duplicates
Remove duplicate entries from your fleet:def remove_duplicate_vehicles(duplicate_ids):
"""Remove duplicate vehicle entries"""
deleted = []
failed = []
for vehicle_id in duplicate_ids:
response = requests.delete(
f"https://api.dcycle.io/v1/vehicles/{vehicle_id}",
headers=headers
)
if response.status_code == 204:
deleted.append(vehicle_id)
else:
failed.append(vehicle_id)
return {
"deleted_count": len(deleted),
"failed_count": len(failed),
"failed_ids": failed
}
# Remove duplicates
result = remove_duplicate_vehicles([
"550e8400-e29b-41d4-a716-446655440000",
"550e8400-e29b-41d4-a716-446655440001"
])
print(f"Deleted: {result['deleted_count']}, Failed: {result['failed_count']}")
Batch Delete Vehicles
Remove multiple vehicles in bulk:def bulk_delete_vehicles(vehicle_ids):
"""Delete multiple vehicles"""
results = {
"success": 0,
"failed": 0,
"errors": []
}
for vehicle_id in vehicle_ids:
try:
response = requests.delete(
f"https://api.dcycle.io/v1/vehicles/{vehicle_id}",
headers=headers
)
if response.status_code == 204:
results["success"] += 1
else:
results["failed"] += 1
results["errors"].append({
"vehicle_id": vehicle_id,
"status": response.status_code
})
except Exception as e:
results["failed"] += 1
results["errors"].append({
"vehicle_id": vehicle_id,
"error": str(e)
})
return results
# Bulk delete example
ids_to_delete = [
"550e8400-e29b-41d4-a716-446655440000",
"550e8400-e29b-41d4-a716-446655440001",
"550e8400-e29b-41d4-a716-446655440002"
]
results = bulk_delete_vehicles(ids_to_delete)
print(f"Deleted: {results['success']}, Failed: {results['failed']}")
if results['errors']:
print(f"Errors: {results['errors']}")
Best Practices
Before Deletion
- Verify the Vehicle ID: Ensure you have the correct vehicle ID
- Check Dependencies: Confirm the vehicle has no active consumptions or related data
- Backup Information: Consider exporting vehicle data if needed
- Notify Team: Alert relevant stakeholders before deleting from shared fleets
Alternative to Deletion
If you want to keep the vehicle data for historical records, consider archiving instead:def archive_vehicle(vehicle_id):
"""Archive a vehicle instead of deleting (if status field supports it)"""
# Use PATCH to set status to archived
response = requests.patch(
f"https://api.dcycle.io/v1/vehicles/{vehicle_id}",
headers=headers,
json={"status": "archived"}
)
return response.json()
Related Endpoints
List Vehicles
Retrieve all vehicles with filtering and pagination
Create Vehicle
Add a new vehicle to your fleet
Update Vehicle
Modify vehicle details
Vehicle Overview
Learn about the Vehicles API
Was this page helpful?