POST /api/user/register
Registers a new user in the system with their personal information and credentials. All user data is validated before creating the account, and passwords are securely hashed before storage.Headers
Must be
application/jsonRequest Body
User’s identification document number. Must be unique in the system.
User’s email address. Must be unique in the system and will be used for login.
User’s password. Will be hashed using bcrypt before storage.
User’s first name.
User’s last name.
User’s mobile phone number.
Type of user account (e.g., “admin”, “client”, “contractor”).
Request Example
Response
201 - User Created Successfully
201 - User Created Successfully
Success message confirming user registration.
The newly created user object.
User’s identification document number.
User’s email address.
Hashed password (bcrypt).
User’s first name.
User’s last name.
User’s mobile phone number.
Type of user account.
MongoDB generated user ID.
Example Response
400 - Bad Request
400 - Bad Request
Returned when validation fails or required fields are missing.
Error message describing the validation failure.
Missing Required Fields
Email Already Registered
Document Already Registered
500 - Internal Server Error
500 - Internal Server Error
Validation Rules
- email and password are mandatory fields
- document must be unique across all users
- email must be unique across all users
- All fields defined in the request body are required
- Password is hashed using bcrypt with a salt round of 10
Implementation Reference
The registration endpoint is implemented in:- Route:
/home/daytona/workspace/source/src/routes/userRoutes.js:7 - Controller:
/home/daytona/workspace/source/src/controllers/userController.js:4