Recommended: Use conversation threads for automatic context management. Include a
threadId in your request to let the server handle conversation history automatically.Endpoint
Request Body
The user’s question or message to send to the AI
Recommended: 5-digit conversation thread ID from POST /threads.When provided:
- Server automatically loads last 20 messages as context
- No need to send
conversationHistorymanually - Thread expiration timer resets
- Returns updated
messageCountin response
UUID of the patient for context retrieval. Only needed if not using a thread or if thread wasn’t created with patient info.
Patient’s phone number for lookup if patientId is not available. Accepts ANY format:
+15551234567(E.164 format)15551234567(11-digit)5551234567(10-digit)(555) 123-4567(formatted)- The system automatically normalizes all formats for lookup
Patient information to override or supplement stored data
Array of previous conversation messages for context
Response
Indicates if the request was successful
The AI-generated response to the user’s message
The thread ID (only present when using threads)
Total number of messages in the thread (only present when using threads)
Error message if the request failed (only present when success is false)
Examples
With Thread (Recommended)
Use athreadId for automatic context management across multiple messages.
Basic Request (Without Thread)
Request with Patient Context
Request with Patient Data Override
Phone Number Lookup
Response Examples
Success Response
Error Response
Best Practices
Use Patient IDs
Use Patient IDs
Always provide a
patientId when available for:- More accurate, personalized responses
- Complete audit trails for compliance
- Automatic context from stored patient data
Conversation History
Conversation History
Include the last 5-10 conversation turns for context:
- Maintains conversation continuity
- Provides better contextual understanding
- Avoids repetitive responses
Phone Format Flexibility
Phone Format Flexibility
Phone numbers can be provided in ANY format - the system will automatically normalize them:
+15551234567,15551234567,5551234567(555) 123-4567,555-123-4567,555.123.4567- All formats work equally well for patient lookup
Patient Data Override
Patient Data Override
Use
patientData to:- Provide temporary context without updating records
- Override specific fields for the current conversation
- Include recent changes not yet stored in the system
Error Codes
| Status Code | Error Message | Description |
|---|---|---|
| 400 | ”message is required” | The message field is missing or empty |
| 401 | ”Unauthorized - Invalid API key” | The provided API key is invalid or missing |
| 500 | ”Failed to process chat request” | An unexpected error occurred |
Phone Lookup: If a phone number is provided but no patient is found, the request will still proceed without patient context rather than returning an error.

