Skip to main content
POST
/
secured
/
upload_user
Create User
curl --request POST \
  --url https://api.example.com/secured/upload_user \
  --header 'Content-Type: application/json' \
  --data '
{
  "nombre": "<string>",
  "apellidoPaterno": "<string>",
  "email": "<string>",
  "password": "<string>",
  "nivelCuenta": "<string>"
}
'
{
  "msg": "<string>",
  "400 Bad Request": {},
  "401 Unauthorized": {},
  "500 Internal Server Error": {}
}

Authentication

This endpoint requires authentication. Include a valid JWT token in the Authorization header.

Request Body

nombre
string
required
User’s first name
apellidoPaterno
string
required
User’s last name (paternal surname)
email
string
required
User’s email address (must be unique)
password
string
required
User’s password (will be hashed with bcrypt using 10 salt rounds)
nivelCuenta
string
required
User account type/level (e.g., “admin”, “user”)

Password Security

Passwords are automatically hashed using bcrypt with 10 salt rounds before being stored in the database. The plain text password is never stored.

Email Validation

The endpoint validates email uniqueness using a stored procedure (valida_correo_repetido) before creating the user. If the email already exists, the request will be rejected.
curl --location 'http://localhost:8080/secured/upload_user' \
--header 'Content-Type: application/json' \
--header 'Authorization: YOUR_JWT_TOKEN' \
--data-raw '{
  "nombre": "Carlos",
  "apellidoPaterno": "Ramírez",
  "email": "[email protected]",
  "password": "securePassword123",
  "nivelCuenta": "user"
}'

Response

msg
string
Success or error message

Success Response (200)

{
  "msg": "Usuario creado"
}

Error Responses

400 Bad Request
object
Returned when the email already exists in the database
{
  "message": "El usuario ya existe"
}
401 Unauthorized
object
Returned when the JWT token is invalid or missing
{
  "msg": "Token_invalido"
}
500 Internal Server Error
object
Returned when a database or server error occurs
{
  "msg": "ocurrió un error"
}

Implementation Details

The user creation process follows these steps:
  1. Email Validation: Checks if email exists using stored procedure valida_correo_repetido(?)
  2. Password Hashing: Uses bcrypt with 10 rounds: bcrypt.hash(password, 10)
  3. Database Insert: Inserts user with fields: tipoUsuario, correo, password, nombre, apellido

Build docs developers (and LLMs) love