Creating a patient
UsePOST /patients to add a new patient to a clinic. The name and phone fields are required; all other fields are optional but strongly recommended for a complete clinical record.
201 Created:
Searching for patients
Before creating a patient, search for an existing record to avoid duplicates.GET /patients?search= matches against name, phone, and CPF simultaneously.
?search=123.456.789-00 or ?search=+5511999999999 for precise lookups.
Updating a patient
UsePATCH /patients/{id} to apply a partial update. Send only the fields you want to change — all other fields remain untouched.
200 OK returns the full updated patient object.
Deduplication strategy
When syncing from an external system, determine whether a patient already exists in ByDoctor before deciding to create or update:- Search by CPF — CPF is a national unique identifier; if a match is found, it is the same person.
- Search by phone — Use as a secondary fallback if CPF is unavailable.
- If no match is found — Call
POST /patientsto create the record. - If a match is found — Compare fields and call
PATCH /patients/{id}only if data has changed.
Bulk import from CSV
1
Parse the CSV file
Read the file row by row and normalise the data — strip formatting from CPF (remove
. and -), convert phone numbers to E.164, and standardise date formats to YYYY-MM-DD.2
Check each patient by CPF or phone
Query ByDoctor for each patient before writing to avoid duplicates.
3
Create if missing, update if changed
Upsert each patient based on the lookup result.
Webhook-based sync
Subscribe topatient.created and patient.updated events to push changes from ByDoctor into your external system in real time — for example, to update a CRM or populate a data warehouse.