Creates a new user account with email and password. Upon successful registration, a verification email is sent to the provided email address. A FREE subscription plan is automatically created for new users.
Request Body
User’s email address. Must be a valid email format and unique in the system.
User’s password. Must be at least 8 characters long and cannot be empty or contain only whitespace.
User’s first name (optional). Trimmed of leading/trailing whitespace.
User’s last name (optional). Trimmed of leading/trailing whitespace.
User’s phone number (optional). Trimmed of leading/trailing whitespace.
Response
Success message indicating the user was registered and should verify their email.
The created user object.User’s unique identifier.
User’s email address (lowercase and trimmed).
Email verification status (always false for new registrations).
Error Responses
400 Bad Request
Returned when validation fails:
- Email is invalid or missing
- Password is missing, less than 8 characters, or empty/whitespace only
- Invalid field types
409 Conflict
Returned when the email is already registered in the system.
500 Internal Server Error
Returned when:
- Database connection fails
- Password hashing fails
- User creation fails
- Subscription creation fails
If the subscription creation fails, the user account is automatically deleted to maintain data consistency.
Example Request
curl -X POST https://api.tresacontafy.com/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"password": "securePassword123",
"nombre": "Juan",
"apellido": "Pérez",
"telefono": "+52 55 1234 5678"
}'
Example Response
{
"message": "Usuario registrado correctamente. Por favor verifica tu email.",
"user": {
"id": 123,
"email": "[email protected]",
"nombre": "Juan",
"apellido": "Pérez",
"telefono": "+52 55 1234 5678",
"email_verified": false
}
}
Implementation Details
- Emails are automatically converted to lowercase and trimmed
- Passwords are hashed using bcrypt with a salt rounds of 10
- A verification token is generated and expires in 24 hours
- A FREE subscription with status ACTIVE is automatically created
- Verification emails may fail silently - users can request a new verification email later