Create multiple vehicles from CSV file
POST/company/vehicles/bulk/
Enables bulk creation of multiple vehicles from a CSV file upload.
Objective
Allow companies to efficiently import their entire fleet or large batches of vehicles from external systems or spreadsheets.
Use Cases
- Migrate existing fleet from another system
- Import vehicles from fleet management spreadsheets
- Bulk onboarding of new vehicles
- Update multiple vehicles simultaneously
Validation Flow
flowchart TD
A[Receive CSV File] --> B{Payment Limit OK?}
B -->|No| C[402 Payment Required]
B -->|Yes| D{File Present?}
D -->|No| E[404 FILE_NOT_FOUND]
D -->|Yes| F{Parse CSV}
F --> G{Headers Valid?}
G -->|No| H[Return ko: MIN_HEADERS]
G -->|Yes| I{Data Present?}
I -->|No| J[400 INVALID_DATA]
I -->|Yes| K[Process Each Line]
K --> L{Line Valid?}
L -->|Yes| M[Create Vehicle - Add to ok]
L -->|No| N[Add to ko with reason]
M --> O{More Lines?}
N --> O
O -->|Yes| K
O -->|No| P[Update Company]
P --> Q[Return ok and ko arrays]
Payment Limits
This endpoint is subject to payment plan limits via the isPaymentUpdate middleware. If the company has reached its vehicle limit, the request will fail with error 402 before processing the CSV.
CSV Structure
Required headers (minimum):
- cargo_type
- vehicle_type
- plate
- shipping_type
Optional headers:
- fresh_cargo_temp
Example CSV:
cargo_type,fresh_cargo_temp,vehicle_type,plate,shipping_type
up, lateral,-20,f2c,8796HSN,fresh
up,,rt,7628BCB,dry
back,,r3c,4052SMR,dry
Field Formats
- cargo_type: Comma-separated string (e.g., up, lateral, back)
- vehicle_type: Single type code (e.g., tir, van, f2c)
- plate: License plate string
Request
Responses
- 200
- 400
- 401
- 402
- 404
Bulk creation completed (may include partial failures).
Check 'ok' and 'ko' arrays for results.
Response Headers
Invalid request
- INVALID_DATA: CSV data is empty or malformed
- CIA_SAVE_VEHICLES: Error updating company's vehicle list
User does not have an associated company
Vehicle limit exceeded for current payment plan
File or user not found