Skip to main content
DELETE
https://api.dcycle.io
/
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));

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

vehicle_id
uuid
required
The UUID of the vehicle to deleteExample: 550e8400-e29b-41d4-a716-446655440000

Headers

x-api-key
string
required
Your API key for authenticationExample: sk_live_1234567890abcdef
x-organization-id
string
required
Your organization UUIDExample: a8315ef3-dd50-43f8-b7ce-d839e68d51fa

Response

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

Successful Response

HTTP/1.1 204 No Content
No response body is returned for successful deletions.

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.

404 Not Found

Cause: Vehicle not found in organization
{
  "code": "VEHICLE_NOT_FOUND",
  "detail": "Vehicle with id=UUID('...') not found"
}
Solution: Verify that the vehicle ID is correct and belongs to your organization. Use the List Vehicles endpoint to get valid IDs.

500 Internal Server Error

Cause: Server error during deletion
{
  "detail": "Internal server error",
  "code": "INTERNAL_ERROR"
}
Solution: Contact support if the error persists. Provide the vehicle ID and timestamp of the failed deletion.

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

  1. Verify the Vehicle ID: Ensure you have the correct vehicle ID
  2. Check Dependencies: Confirm the vehicle has no active consumptions or related data
  3. Backup Information: Consider exporting vehicle data if needed
  4. 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()