curl --request POST \
--url https://api.example.com/api/users \
--header 'Content-Type: application/json' \
--data '
{
"email": "<string>",
"name": "<string>",
"surname": "<string>",
"password": "<string>",
"role": {},
"status": {},
"phone": "<string>",
"address": "<string>",
"city": "<string>",
"country": "<string>",
"postal_code": "<string>",
"gender": "<string>",
"birth_date": "<string>",
"document_type": {},
"document_number": "<string>",
"avatar": "<string>"
}
'{
"user_id": "<string>",
"email": "<string>",
"name": "<string>",
"surname": "<string>",
"phone": "<string>",
"address": "<string>",
"city": "<string>",
"country": "<string>",
"postal_code": "<string>",
"gender": "<string>",
"birth_date": "<string>",
"role": {},
"status": {},
"avatar": "<string>",
"document_type": {},
"document_number": "<string>",
"refresh_token": {},
"created_at": "<string>",
"updated_at": "<string>"
}Create a new user in the system
curl --request POST \
--url https://api.example.com/api/users \
--header 'Content-Type: application/json' \
--data '
{
"email": "<string>",
"name": "<string>",
"surname": "<string>",
"password": "<string>",
"role": {},
"status": {},
"phone": "<string>",
"address": "<string>",
"city": "<string>",
"country": "<string>",
"postal_code": "<string>",
"gender": "<string>",
"birth_date": "<string>",
"document_type": {},
"document_number": "<string>",
"avatar": "<string>"
}
'{
"user_id": "<string>",
"email": "<string>",
"name": "<string>",
"surname": "<string>",
"phone": "<string>",
"address": "<string>",
"city": "<string>",
"country": "<string>",
"postal_code": "<string>",
"gender": "<string>",
"birth_date": "<string>",
"role": {},
"status": {},
"avatar": "<string>",
"document_type": {},
"document_number": "<string>",
"refresh_token": {},
"created_at": "<string>",
"updated_at": "<string>"
}Authorization: Bearer <token>auth_token=<token>ADMIN role to create users, though this depends on your implementation of role-based access control.
"123456" if not provided.ADMIN: Administrator with full accessUSER: Regular user with limited accessON: Active accountOFF: Inactive/disabled account"1990-01-01" if not provided.DNI: National Identity Document (Spain)PASSPORT: PassportNIE: Foreign Identity Number (Spain)curl -X POST https://your-domain.com/api/users \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
-H "Content-Type: application/json" \
-d '{
"name": "Laura",
"surname": "Martínez",
"email": "[email protected]",
"password": "SecurePass123!",
"role": "USER",
"phone": "+34655443322",
"address": "Calle de la Rosa 78",
"city": "Valencia",
"country": "España",
"postal_code": "46001",
"gender": "Femenino",
"birth_date": "1995-08-22",
"document_type": "DNI",
"document_number": "23456789C"
}'
ADMIN or USER)ON or OFF){
"user_id": "c3d4e5f6-a7b8-9012-cdef-123456789012",
"email": "[email protected]",
"name": "Laura",
"surname": "Martínez",
"phone": "+34655443322",
"address": "Calle de la Rosa 78",
"city": "Valencia",
"country": "España",
"postal_code": "46001",
"gender": "Femenino",
"birth_date": "1995-08-22T00:00:00.000Z",
"role": "USER",
"status": "ON",
"avatar": "https://ui-avatars.com/api/?name=Laura&background=random",
"document_type": "DNI",
"document_number": "23456789C",
"refresh_token": null,
"created_at": "2024-03-05T10:30:00.000Z",
"updated_at": "2024-03-05T10:30:00.000Z"
}
{
"statusCode": 400,
"statusMessage": "Faltan campos obligatorios"
}
{
"statusCode": 400,
"statusMessage": "El email ya está en uso"
}
{
"statusCode": 401,
"statusMessage": "Unauthorized: Token is missing or invalid"
}
{
"statusCode": 500,
"statusMessage": "Error al crear usuario"
}
const hashedPassword = await bcrypt.hash(password || '123456', 10)
avatar: body.avatar || `https://ui-avatars.com/api/?name=${encodeURIComponent(name)}&background=random`
@default(uuid()).