Skip to main content

Bulk create truckers from CSV

POST 

/company/truckers/bulk/

Creates multiple truckers in bulk via CSV file import.

Import flow:

  1. User uploads CSV file with trucker data
  2. System validates mandatory headers
  3. Processes each line validating data
  4. Verifies uniqueness of email, taxid and phone
  5. Generates automatic passwords if not provided
  6. Creates successful truckers
  7. 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 truckers
  • ko: 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

Import process completed