Skip to main content

WebSocket Endpoint

Connect to the MedAssist WebSocket for real-time medical consultations:
Replace <session-id> with the session ID obtained from the Create Session API.

Authentication

After establishing the WebSocket connection, authenticate using the session token:

Message Types

Text Messages

Send text-based medical queries:

Audio Messages

Send base64-encoded audio for voice consultations:

File Upload

File uploads require a two-step process:

Step 1: Request presigned URL

Step 2: Send file URL after upload

Message Fields

ev
string
required
Event type. Use “auth” for authentication, “chat” for messages
ct
string
Content type. Options: “text”, “audio”, “file”
ts
number
Timestamp in milliseconds
_id
string
required
Unique message identifier
data
object
required
Message payload containing the actual content

Example Implementation

Error Handling

The WebSocket may return error messages for various scenarios:
  • Authentication failure: Invalid or expired token
  • Invalid message format: Malformed JSON or missing required fields
  • Rate limiting: Too many messages sent in a short period
  • Session expired: Session has exceeded its lifetime
Always implement proper error handling and reconnection logic in your WebSocket client.