intermediate
vehicles
import
csv

Bulk Vehicle Import (CSV)

Import multiple vehicles at once using CSV files for efficient fleet setup

Levy Fleets TeamJanuary 15, 202510 min read

Bulk Vehicle Import (CSV)

The bulk import feature allows you to add multiple vehicles to your fleet at once using a CSV file. This is ideal for initial fleet setup, fleet expansions, or migrating from another system.

Accessing the Import Feature

  1. Navigate to Dashboard > Vehicles
  2. Click Import CSV button in the top-right corner
  3. The import dialog will open

CSV File Requirements

File Format

  • Format: CSV (Comma-Separated Values)
  • Encoding: UTF-8 (recommended)
  • Delimiter: Comma (,)
  • Header Row: First row must contain column names

Required Columns

Only one column is required:

ColumnDescriptionExample
vehicle_numberUnique identifier for the vehicle"VH-001", "SCOOTER-123"

Important

Each vehicle must have a unique vehicle_number. Duplicates will update existing records rather than create new ones.

Optional Columns (Actively Imported)

These columns are fully supported by the import function:

ColumnDescriptionExample
vehicle_model_idModel ID (numeric) or model name (text)"1" or "Levy Max"
vehicle_modelModel name (alternative to vehicle_model_id)"Levy Max Pro"
iot_imeiIMEI of linked IoT device"123456789012345"
vinVehicle Identification Number"1HGBH41JXMN109186"

Default Values on Import

When vehicles are imported, the following defaults are set:

FieldDefault Value
status"offline"
battery_level0
iot_battery_pct0
vehicle_odometer"0"

Note

To set additional values like battery levels, GPS coordinates, or custom statuses, update vehicles individually after import or use the API.


Sample CSV Templates

Minimal Template

vehicle_number
VH-001
VH-002
VH-003
VH-004
VH-005

Basic Template with IoT

vehicle_number,iot_imei,vehicle_model
VH-001,123456789012345,Levy Max
VH-002,123456789012346,Levy Max
VH-003,123456789012347,Levy Max Pro
VH-004,123456789012348,Levy Max Pro
VH-005,123456789012349,Segway E22

Full Template

vehicle_number,vehicle_model,iot_imei,vin
VH-001,Levy Max,123456789012345,1HGBH41JXMN109186
VH-002,Levy Max,123456789012346,1HGBH41JXMN109187
VH-003,Levy Max Pro,123456789012347,1HGBH41JXMN109188
VH-004,Levy Max Pro,123456789012348,1HGBH41JXMN109189
VH-005,Segway E22,123456789012349,1HGBH41JXMN109190

Status Note

All imported vehicles start with status "offline". Update individual vehicle statuses after import via the dashboard or API.


Import Process

Step 1: Prepare Your CSV File

  1. Create a CSV file following the format above
  2. Ensure vehicle_number column is present and all values are unique
  3. Verify data accuracy before import

Step 2: Upload the File

  1. Click Import CSV on the Vehicles page
  2. Select your CSV file
  3. The system will parse and validate the file

Step 3: Review Preview

Before importing, you'll see:

  • Number of vehicles to import
  • Any validation errors
  • Warnings about potential issues

Step 4: Confirm Import

  1. Click Import to proceed
  2. Wait for the import to complete
  3. Review the results summary

Step 5: Verify Results

After import, you'll see:

  • Imported count: Successfully added/updated vehicles
  • Failed count: Vehicles that couldn't be imported
  • Failure details: Specific errors for failed rows

How Import Handles Existing Vehicles

The import uses "upsert" logic (update or insert):

New Vehicles

  • If vehicle_number doesn't exist, a new vehicle is created
  • Vehicle is assigned to the selected subaccount
  • Initial status is set to "offline"

Existing Vehicles

  • If vehicle_number already exists, the record is updated
  • Only provided fields are updated
  • Existing data for unprovided fields is preserved
  • updated_at timestamp is refreshed

Example: If you import a CSV with just vehicle_number and iot_imei for an existing vehicle, only the iot_imei is updated - all other fields remain unchanged.


Linking IoT Devices During Import

Automatic Linking

When you provide an iot_imei in your CSV:

  1. The system looks for an existing IoT device with that IMEI
  2. If found and unlinked, it associates with the vehicle
  3. If found and already linked to another vehicle, the import may fail for that row

Best Practice

  1. Create IoT devices first via the IoT Devices page
  2. Note the IMEI for each device
  3. Include IMEIs in your vehicle import CSV
  4. Devices will be automatically linked

Specifying Vehicle Models

You can specify the vehicle model in two ways:

By Model ID

If you know the model ID (from the Vehicle Models page):

vehicle_number,vehicle_model_id
VH-001,123
VH-002,123
VH-003,456

By Model Name

You can use the model name instead:

vehicle_number,vehicle_model_id
VH-001,Levy Max
VH-002,Levy Max
VH-003,Levy Max Pro

Or use the vehicle_model column:

vehicle_number,vehicle_model
VH-001,Levy Max
VH-002,Levy Max
VH-003,Levy Max Pro

The import function will attempt to match by name if a numeric ID isn't provided.


Error Handling

Common Validation Errors

ErrorCauseSolution
"Vehicle number is required"Empty or missing vehicle_numberEnsure all rows have vehicle_number
"Invalid IMEI format"IMEI not 15 digitsCheck IMEI format
"Model not found"Model ID/name doesn't existCreate the model first or fix the name
"Duplicate vehicle number"Same vehicle_number in CSV twiceRemove duplicate rows

Partial Import Behavior

  • Import is not atomic - successful rows are imported even if some fail
  • Failed rows are reported with specific error messages
  • You can fix failed rows and re-import (updates are safe)

API Reference

Endpoint

POST /api/vehicles/import

Request Body

{
  "csv_data": [
    {
      "vehicle_number": "VH-001",
      "iot_imei": "123456789012345",
      "vehicle_model": "Levy Max"
    },
    {
      "vehicle_number": "VH-002",
      "iot_imei": "123456789012346",
      "vehicle_model": "Levy Max"
    }
  ],
  "subaccount_id": "uuid-of-target-subaccount"
}

Response

{
  "success": true,
  "message": "Successfully imported 2 vehicle(s)",
  "imported_count": 2,
  "failed_count": 0,
  "failures": [],
  "results": [
    {
      "success": true,
      "vehicle_uuid": "uuid-1",
      "vehicle_number": "VH-001",
      "error_message": null
    },
    {
      "success": true,
      "vehicle_uuid": "uuid-2",
      "vehicle_number": "VH-002",
      "error_message": null
    }
  ]
}

Best Practices

Before Import

  1. Back up existing data if updating existing vehicles
  2. Validate your CSV with a spreadsheet program first
  3. Create vehicle models before importing vehicles that reference them
  4. Create IoT devices if you want to link them during import

During Import

  1. Start small: Test with 5-10 vehicles first
  2. Check the preview before confirming
  3. Note any warnings - they may indicate issues

After Import

  1. Review the results carefully
  2. Check failed rows and fix issues
  3. Verify a few vehicles in the dashboard
  4. Confirm IoT links are correct
  5. Update statuses from "offline" to appropriate values

Naming Conventions

Use consistent, meaningful vehicle numbers:

  • Good: NYC-001, LEVY-001, ZONE-A-001
  • Avoid: 1, new scooter, test123

Permissions

The following roles can import vehicles:

  • Super Admin
  • Global Admin
  • Admin
  • Fleet Manager

Other roles cannot access the import feature.


Troubleshooting

"CSV data is required and must be an array"

  • The file couldn't be parsed as CSV
  • Check file format and encoding
  • Ensure proper comma separation

"Subaccount ID is required"

  • Select a subaccount before importing
  • Or provide subaccount_id in API request

Import seems to hang

  • Large imports may take time
  • 1000+ vehicles may take 30+ seconds
  • Don't refresh the page during import

Vehicles imported but not showing

  • Check the correct subaccount is selected
  • Clear any active filters on the Vehicles page
  • Refresh the page

IoT devices not linking

  • Verify IMEI exists in IoT Devices
  • Check IMEI is not already linked to another vehicle
  • Ensure IMEI format is correct (15 digits)