Skip to main content

Bulk create truckers from CSV

POST 

/company/truckers/bulk/

Create multiple carriers in bulk through CSV file import.

Import flow:

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

Import process completed