Add a driver to a carrier
POST/company/my_carriers/driver/:carrierId
Register a new driver associated with a specific carrier. Requires JWT authentication.
Use cases:
- Register drivers for existing carriers
- Maintain a directory of available drivers
- Associate drivers with logistics operations
Notes:
- The carrier must already exist
- Basic driver data is required
- Driver reuse: If a driver with the same
taxidalready exists, the endpoint will reuse the existing driver instead of creating a duplicate - Automatic password: If no password is provided, one is automatically generated as 123456 and hashed with bcrypt before saving
Request
Responses
- 201
- 400
- 401
- 404
Driver added successfully.
IMPORTANT NOTE: The endpoint returns the complete Carrier object with the updated drivers array,
NOT just the created driver. The new driver will be in the last element of the drivers array.
ID structure in drivers:
_id: ID of the subdocument within the carrier'sdriversarrayassociated: ID of thetrucker_userin thetruckers_userscollection (reference to the real user)
Response Headers
Invalid input data. Possible causes:
- Empty or too short name
- Incorrect DNI/NIE format
- Invalid email
- Malformed phone number
Response Headers
Unauthorized. Invalid or missing JWT token.
Response Headers
Carrier not found. The provided ID does not exist or is not associated with the company.