Skip to main content

Communication Service — API Contracts

Status: populated Owner: TBD Last updated: 2026-04-17 Companion: Service Template · API Path Conventions

All routes are mounted behind Kong at /v1/communication/*. Legacy prefixes /v1/digital-communication/* and /v1/messaging/* are maintained for backward-compatibility during migration.

1. Auth & common headers

HeaderRequiredPurpose
Authorization: Bearer <jwt>All except join-token validationKeycloak RS256 JWT
Idempotency-Key: <uuid>All POST mutationsSee APPLICATION_LOGIC §6
X-Client-Mutation-Id: <uuid>OptionalOffline replay
X-Tenant-IdExtracted from JWT tid (not from client)Tenant scoping

2. Error envelope

{ "success": false, "error": { "code": "STRING_CODE", "message": "...", "details": {} } }

Common error codes: MODULE_NOT_LICENSED, FORBIDDEN, NOT_FOUND, CONFLICT, ATTACHMENT_REJECTED, INVALID_STATE_TRANSITION, VALIDATION_ERROR, DEPENDENCY_UNAVAILABLE, RATE_LIMITED.

3. Messaging endpoints

MethodPathScopeDescription
POST/v1/communication/threadsmessaging:writeCreate thread
GET/v1/communication/threadsmessaging:readList threads (?patientId=, ?unreadOnly=, ?urgent=, ?cursor=)
GET/v1/communication/threads/{threadId}messaging:readThread detail
PATCH/v1/communication/threads/{threadId}/archivemessaging:writeArchive
POST/v1/communication/threads/{threadId}/escalatemessaging:escalateEscalate
POST/v1/communication/threads/{threadId}/messagesmessaging:writeSend
GET/v1/communication/threads/{threadId}/messagesmessaging:readPaginate
POST/v1/communication/threads/{threadId}/readmessaging:readMark read (body {messageIds[]})
POST/v1/communication/threads/{threadId}/attachmentsmessaging:writeInitiate upload

3.1 POST /v1/communication/threads

Request:

{ "participantIds": ["usr_..."], "patientId": "pat_...?", "encounterId": "enc_...?", "subject": "..." }

Response 201:

{ "threadId": "thr_...", "createdAt": "ISO", "participantIds": [...] }

Errors: 400 validation, 403 MODULE_NOT_LICENSED, 403 FORBIDDEN (cross-tenant participants).

3.2 POST /v1/communication/threads/{threadId}/messages

Request:

{ "body": "string", "urgency": "routine|urgent|emergent", "attachmentIds": ["att_..."] }

Response 201:

{ "messageId": "msg_...", "threadId": "thr_...", "sentAt": "ISO" }

4. Notification endpoints

MethodPathScopeDescription
POST/v1/communication/notifications/intentsnotifications:writeSubmit intent (internal)
GET/v1/communication/notifications/intents/{id}notifications:readGet intent
GET/v1/communication/notifications/dispatch-status?correlationId=notifications:readPer-channel outcome (FR-COMMS-ENH-001)
POST/v1/communication/notifications/callbacks/smsProvider-secretGhasi-SMS-Gateway / Twilio DLR
POST/v1/communication/notifications/callbacks/emailProvider-secretBounce / complaint
POST/v1/communication/notifications/callbacks/pushProvider-secretFCM / APNs feedback
GET/v1/communication/notifications/healthnotifications:opsPer-adapter health

5. Virtual session endpoints

MethodPathScopeDescription
POST/v1/communication/virtual-sessionsvc:writeCreate session (typically auto from SCHEDULING event)
GET/v1/communication/virtual-sessionsvc:readList (identity-bound for PATIENT)
GET/v1/communication/virtual-sessions/{id}vc:readDetail
POST/v1/communication/virtual-sessions/{id}/endvc:writeEnd
POST/v1/communication/virtual-sessions/{id}/cancelvc:writeCancel
POST/v1/communication/virtual-sessions/{id}/fallback-messagevc:writeSpawn fallback thread
GET/v1/communication/virtual-sessions/{id}/join-tokenvc:joinIssue one-time token
GET/v1/communication/virtual-sessions/jointoken-in-queryValidate join token (anonymous)
POST/v1/communication/virtual-sessions/{id}/admit/{participantId}vc:admitAdmit from waiting room
POST/v1/communication/virtual-sessions/{id}/remove/{participantId}vc:writeRemove
GET/v1/communication/virtual-sessions/{id}/participantsvc:readParticipant list

6. Configuration

MethodPathDescription
GET/v1/communication/config/virtual-careGet tenant VC config
PUT/v1/communication/config/virtual-careUpdate (ADMIN)
GET/v1/communication/config/notifications/channelsPer-category channel policy
PUT/v1/communication/config/notifications/channelsUpdate (ADMIN)

7. FHIR projection (via interop-service)

InteractionResource
POST /fhir/R4/CommunicationNew message
GET /fhir/R4/Communication?patient=Patient/{id}Chart-filtered
POST /fhir/R4/CommunicationRequestEscalation / triage
GET /fhir/R4/Encounter?class=VR&patient=Virtual encounters

8. Pagination

Cursor-based: ?cursor=<opaque>&limit=25 (max 100). Responses include nextCursor?.

9. Rate limits

Route familyPer-tenantPer-user
/messages POST1000/min60/min
/notifications/intents POST10000/min
/virtual-sessions POST500/min10/min
DLR callbacks20000/min— (provider-secret)

10. Deprecations

OldNewSunset
/v1/digital-communication/*/v1/communication/*M4
/v1/messaging/*/v1/communication/*M3
ghasi.messaging.* eventsghasi.digital_communication.*M3
VIRTUAL_CARE.* subjectsghasi.digital_communication.virtual_session.*M3