temetro

Conversations

Staff messaging — conversations, messages, and real-time events.

Conversations are participant-scoped: you only ever see conversations you are part of, regardless of role. All endpoints require a signed-in member with an active clinic.

MethodPathPurpose
GET/api/conversationsYour conversations, with last message and unread count
GET/api/conversations/membersClinic members you can start a conversation with
POST/api/conversationsCreate a conversation (or reuse an existing DM)
GET/api/conversations/{id}/messagesMessage history
POST/api/conversations/{id}/messagesSend a message
POST/api/conversations/{id}/readMark the conversation read

Endpoints

Create a conversation

FieldTypeNotes
participantIdsstring[]Required. User ids to include (at least one)
namestring | nullOptional group name (max 120 chars); DMs are unnamed
curl -b cookies.txt -X POST http://localhost:4000/api/conversations \
  -H "Content-Type: application/json" \
  -d '{ "participantIds": ["usr_def456"] }'

Creating a DM with someone you already have a DM with returns the existing conversation instead of a duplicate.

Send a message

FieldTypeNotes
bodystringRequired. 1–5000 characters
curl -b cookies.txt -X POST http://localhost:4000/api/conversations/CONV_ID/messages \
  -H "Content-Type: application/json" \
  -d '{ "body": "Labs for 1042 are back — HbA1c improving." }'

Real-time delivery

Messages are also pushed live over Socket.io (same origin, authenticated by the session cookie). Connected clients receive new-message events for their conversations and notification:new events for record changes — the REST endpoints above are the fallback and history source. The web app keeps both in sync automatically.

On this page