Bulk create truckers from CSV
POST/company/truckers/bulk/
Creates multiple truckers in bulk via CSV file import.
Import flow:
- User uploads CSV file with trucker data
- System validates mandatory headers
- Processes each line validating data
- Verifies uniqueness of email, taxid and phone
- Generates automatic passwords if not provided
- Creates successful truckers
- Returns report with successes and errors
Validations per line:
- Email: Unique in system and valid format
- Taxid: Unique and valid format according to country
- Phone: Valid format according to regex
- Default_vehicle: Exists in company (by plate)
- Role: Valid value (automatically normalized)
Mandatory CSV headers:
- name, lastname, email, phone, taxid
- Optional: default_vehicle (vehicle plate)
Credential generation:
- If password not provided: Automatically generated
- Welcome email sent with credentials
- Personalized email with company name
CSV format:
- Separator: comma (,)
- Encoding: UTF-8
- First line: headers
- Example: name,lastname,email,phone,taxid,default_vehicle
Detailed response:
ok: Array of successfully created truckersko: Array of errors with line, reason and data
Error structure:
{
"line": 5,
"reason": "EMAIL_ALREADY_IN_USE",
"data": {...},
"details": "john@example.com"
}
Common error codes:
- MIN_HEADERS: Missing mandatory headers
- EMAIL_ALREADY_IN_USE: Duplicate email
- TAXID_ALREADY_IN_USE: Duplicate taxid
- EMAIL_NOT_VALID: Invalid email format
- TAXID_NOT_VALID: Invalid taxid format
- PHONE_NOT_VALID: Invalid phone format
- CANNOT_SAVE_TRUCKER: Error saving to DB
Limits:
- Active subscription plan verification
- Trucker limit according to plan
HTTP Responses:
- 200 OK: Process completed (check ok/ko in body)
- 400 Bad Request: Invalid headers or empty data
- 401 Unauthorized: Company not found
- 404 Not Found: CSV file not found
Request
Responses
- 200
- 400
- 401
- 404
Import process completed
Invalid headers or empty data
Company not found
CSV file not found