Bulk create truckers from CSV
POST/company/truckers/bulk/
Create multiple carriers in bulk through CSV file import.
Import flow:
- User uploads a CSV file with carrier data
- System validates mandatory headers
- Processes each line by validating data
- Verifies uniqueness of email, taxid, and phone
- Generates automatic passwords if not provided
- Creates successful carriers
- Returns a report with successes and errors
Validations per line:
- Email: Unique in the system and valid format
- Taxid: Unique and valid format according to country
- Phone: Valid format according to regex
- Default_vehicle: Exists in the company (by license plate)
- Role: Valid value (automatically normalized)
Mandatory CSV headers:
- name, lastname, email, phone, taxid
- Optional: default_vehicle (vehicle license plate)
Credential generation:
- If no password is provided: Generated automatically
- Welcome email with credentials is sent
- 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 carriersko: 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 database
Limits:
- Verification of active subscription plan
- Carrier 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
Request
Responses
- 200
- 400
- 401
- 404
Import process completed
Invalid headers or empty data
Company not found
CSV file not found