curl --request PUT \
--url https://api.example.com/api/clients/{id} \
--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>"
}Update an existing client’s information
curl --request PUT \
--url https://api.example.com/api/clients/{id} \
--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>"
}DNI, PASSPORT, NIEON, OFFUSER for clientsON or OFF)curl --request PUT \
--url 'https://your-domain.com/api/clients/550e8400-e29b-41d4-a716-446655440000' \
--header 'Content-Type: application/json' \
--header 'Cookie: your-session-token' \
--data '{
"phone": "+34634567890",
"address": "Calle Nueva 456"
}'
curl --request PUT \
--url 'https://your-domain.com/api/clients/550e8400-e29b-41d4-a716-446655440000' \
--header 'Content-Type: application/json' \
--header 'Cookie: your-session-token' \
--data '{
"status": "OFF"
}'
curl --request PUT \
--url 'https://your-domain.com/api/clients/550e8400-e29b-41d4-a716-446655440000' \
--header 'Content-Type: application/json' \
--header 'Cookie: your-session-token' \
--data '{
"email": "[email protected]",
"phone": "+34645678901",
"city": "Valencia",
"postal_code": "46001"
}'
{
"user_id": "550e8400-e29b-41d4-a716-446655440000",
"email": "[email protected]",
"name": "Maria",
"surname": "Garcia",
"phone": "+34634567890",
"address": "Calle Nueva 456",
"city": "Madrid",
"country": "Spain",
"postal_code": "28013",
"gender": "female",
"birth_date": "1990-05-15",
"role": "USER",
"status": "ON",
"avatar": "",
"document_type": "DNI",
"document_number": "12345678A",
"created_at": "2024-01-15T10:30:00.000Z",
"updated_at": "2024-03-05T15:45:00.000Z"
}
{
"statusCode": 400,
"statusMessage": "ID requerido"
}
{
"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 charactersUSER). This is indicated by Prisma error code P2025.
{
"statusCode": 404,
"statusMessage": "Cliente no encontrado"
}
{
"statusCode": 409,
"statusMessage": "El correo electrónico ya está en uso por otro cliente"
}
role: 'USER' to ensure only clients can be updated via this endpointpassword field is always excluded from responsesbirth_date is provided, it’s converted to a Date object before storageupdated_at timestamp is automatically updated by Prismaupdate method with a where clause that includes both user_id and role{
"status": "OFF"
}
{
"phone": "+34612345678",
"address": "New Street 123",
"city": "Barcelona",
"postal_code": "08001"
}
status field can be used to activate or deactivate client accounts:
ON: Active client accountOFF: Inactive client account (soft delete alternative)OFF is recommended over deletion for maintaining historical records.
server/api/clients/[id].put.ts