Skip to main content
POST
/
patients
Create patient
curl --request POST \
  --url https://api.example.com/patients \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "surname": "<string>",
  "dni": "<string>",
  "birthdate": "<string>",
  "gender": "<string>",
  "address": "<string>",
  "phone": "<string>",
  "email": "<string>",
  "socialWorkId": 123
}
'
{
  "patient": {
    "id": 123,
    "name": "<string>",
    "surname": "<string>",
    "dni": 123,
    "birthdate": "<string>",
    "gender": "<string>",
    "address": "<string>",
    "phone": "<string>",
    "email": "<string>",
    "socialWorkId": 123,
    "state": "<string>"
  }
}

Authentication

This endpoint requires a valid JWT token and administrator privileges.
Authorization
string
required
Bearer token for authentication. Include as Bearer <token>.
This endpoint requires administrator role. Users without admin privileges will receive a 403 Forbidden error.

Request Body

name
string
required
Patient’s first name. Cannot be empty.
surname
string
required
Patient’s last name. Cannot be empty.
dni
string
required
Patient’s national identification number (DNI).
  • Minimum 7 characters
  • Must be unique in the system
birthdate
string
required
Patient’s date of birth. Should be in ISO 8601 format (YYYY-MM-DD).
gender
string
required
Patient’s gender.
address
string
required
Patient’s residential address. Cannot be empty.
phone
string
required
Patient’s phone number.
  • Must be between 10 and 20 characters
  • Can only contain numbers, spaces, hyphens, or plus signs
  • Pattern: /^[0-9\s\-\+]*$/
email
string
required
Patient’s email address. Must be a valid email format.
socialWorkId
number
required
ID of the patient’s social work. Must reference a valid social work that exists in the system.

Response

patient
object
The newly created patient object.

Example Request

curl -X POST https://api.clinica-vitalis.com/patients \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "María",
    "surname": "González",
    "dni": "12345678",
    "birthdate": "1985-03-15",
    "gender": "Femenino",
    "address": "Av. Corrientes 1234, CABA",
    "phone": "11-4567-8901",
    "email": "[email protected]",
    "socialWorkId": 1
  }'

Example Response

{
  "patient": {
    "id": 1,
    "name": "María",
    "surname": "González",
    "dni": 12345678,
    "birthdate": "1985-03-15T00:00:00.000Z",
    "gender": "Femenino",
    "address": "Av. Corrientes 1234, CABA",
    "phone": "11-4567-8901",
    "email": "[email protected]",
    "socialWorkId": 1,
    "state": "Activo/a"
  }
}

Error Responses

400 Bad Request

Returned when validation fails for any field.
{
  "errors": [
    {
      "msg": "El nombre es obligatorio",
      "param": "name"
    }
  ]
}
Common validation errors:
  • El nombre es obligatorio - Name is required
  • El apellido es obligatorio - Surname is required
  • El DNI es obligatorio - DNI is required
  • DNI no válido - DNI must be at least 7 characters
  • El DNI ya está registrado - DNI already exists in the system
  • La fecha de nacimiento es obligatoria - Birthdate is required
  • El genero es obligatorio - Gender is required
  • La dirección es obligatoria - Address is required
  • El teléfono es obligatorio - Phone is required
  • El teléfono debe tener entre 10 y 20 caracteres - Phone must be 10-20 characters
  • El teléfono solo puede contener números, guiones o espacios - Invalid phone format
  • El email es obligatorio - Email is required
  • El email no es válido - Invalid email format
  • La obra social es obligatoria - Social work ID is required
  • La obra social no existe - Social work ID does not exist

401 Unauthorized

Returned when the JWT token is missing or invalid.
{
  "msg": "Token inválido"
}

403 Forbidden

Returned when the user does not have administrator privileges.
{
  "msg": "No tienes permisos de administrador"
}

500 Internal Server Error

Returned when a server error occurs.
{
  "msg": "Error del servidor"
}

Build docs developers (and LLMs) love