curl --request POST \
--url https://api.example.com/api/clients \
--header 'Content-Type: application/json' \
--data '
{
"email": "<string>",
"name": "<string>",
"surname": "<string>",
"phone": "<string>",
"address": "<string>",
"city": "<string>",
"country": "<string>",
"postal_code": "<string>",
"gender": "<string>",
"birth_date": "<string>",
"document_type": "<string>",
"document_number": "<string>",
"status": "<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": "<string>",
"status": "<string>",
"avatar": "<string>",
"document_type": "<string>",
"document_number": "<string>",
"created_at": "<string>",
"updated_at": "<string>"
}Create a new client in the system
curl --request POST \
--url https://api.example.com/api/clients \
--header 'Content-Type: application/json' \
--data '
{
"email": "<string>",
"name": "<string>",
"surname": "<string>",
"phone": "<string>",
"address": "<string>",
"city": "<string>",
"country": "<string>",
"postal_code": "<string>",
"gender": "<string>",
"birth_date": "<string>",
"document_type": "<string>",
"document_number": "<string>",
"status": "<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": "<string>",
"status": "<string>",
"avatar": "<string>",
"document_type": "<string>",
"document_number": "<string>",
"created_at": "<string>",
"updated_at": "<string>"
}USER role) in the system. The endpoint validates all input fields, checks for duplicate emails, and automatically sets a default secure password.
DNI.Allowed values: DNI, PASSPORT, NIEON.Allowed values: ON, OFFUSER for clientsON or OFF)curl --request POST \
--url 'https://your-domain.com/api/clients' \
--header 'Content-Type: application/json' \
--header 'Cookie: your-session-token' \
--data '{
"email": "[email protected]",
"name": "Lucia",
"surname": "Martin",
"phone": "+34623456789",
"address": "Avenida Libertad 45",
"city": "Barcelona",
"country": "Spain",
"postal_code": "08001",
"gender": "female",
"birth_date": "1988-03-22",
"document_type": "DNI",
"document_number": "87654321B",
"status": "ON"
}'
{
"user_id": "660e8400-e29b-41d4-a716-446655440001",
"email": "[email protected]",
"name": "Lucia",
"surname": "Martin",
"phone": "+34623456789",
"address": "Avenida Libertad 45",
"city": "Barcelona",
"country": "Spain",
"postal_code": "08001",
"gender": "female",
"birth_date": "1988-03-22",
"role": "USER",
"status": "ON",
"avatar": "",
"document_type": "DNI",
"document_number": "87654321B",
"created_at": "2024-03-05T09:15:00.000Z",
"updated_at": "2024-03-05T09:15:00.000Z"
}
{
"statusCode": 409,
"statusMessage": "El correo electrónico ya está registrado"
}
{
"statusCode": 400,
"statusMessage": "Email inválido"
}
Email inválido - Invalid email formatEl nombre es obligatorio - Name must be at least 2 charactersEl apellido es obligatorio - Surname must be at least 2 charactersEl teléfono es obligatorio - Phone must be at least 6 charactersrole: 'USER' for all created clientsbeils12345 is set (hashed with bcrypt, salt rounds: 10)avatar field is initialized as an empty stringpassword field is always excluded from responsesbirth_date is stored as a Date object in the databaseserver/api/clients/index.post.ts