Skip to main content
Recommended: Use conversation threads for automatic context management. Include a threadId in your request to let the server handle conversation history automatically.

Endpoint

POST https://app.mycura.org/api/cura/chat

Request Body

message
string
required
The user’s question or message to send to the AI
threadId
string
Recommended: 5-digit conversation thread ID from POST /threads.When provided:
  • Server automatically loads last 20 messages as context
  • No need to send conversationHistory manually
  • Thread expiration timer resets
  • Returns updated messageCount in response
See the Conversation Threads guide for details.
patientId
string
UUID of the patient for context retrieval. Only needed if not using a thread or if thread wasn’t created with patient info.
phone
string
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
patientData
object
Patient information to override or supplement stored data
conversationHistory
array
Array of previous conversation messages for context

Response

success
boolean
Indicates if the request was successful
response
string
The AI-generated response to the user’s message
threadId
string
The thread ID (only present when using threads)
messageCount
number
Total number of messages in the thread (only present when using threads)
error
string
Error message if the request failed (only present when success is false)

Examples

Use a threadId for automatic context management across multiple messages.
# First, create a thread (do this once)
curl -X POST "https://app.mycura.org/api/cura/threads" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"phone": "5551234567"}'

# Returns: {"threadId": "82451", ...}

# Then use the threadId in chat requests
curl -X POST "https://app.mycura.org/api/cura/chat" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "threadId": "82451",
    "message": "I have been experiencing headaches"
  }'

# AI remembers automatically on next message!
curl -X POST "https://app.mycura.org/api/cura/chat" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "threadId": "82451",
    "message": "What could be causing them?"
  }'
Response:
{
  "success": true,
  "response": "Headaches can be caused by various factors including...",
  "threadId": "82451",
  "messageCount": 4
}

Basic Request (Without Thread)

curl -X POST "https://app.mycura.org/api/cura/chat" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "message": "What side effects should I expect from Lisinopril?"
  }'

Request with Patient Context

curl -X POST "https://app.mycura.org/api/cura/chat" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "message": "What side effects should I watch for?",
    "patientId": "patient-uuid-123",
    "conversationHistory": [
      {"role": "user", "content": "I was prescribed Lisinopril"},
      {"role": "assistant", "content": "Lisinopril is an ACE inhibitor used to treat high blood pressure..."}
    ]
  }'

Request with Patient Data Override

curl -X POST "https://app.mycura.org/api/cura/chat" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "message": "Are there any drug interactions I should know about?",
    "patientId": "patient-uuid-123",
    "patientData": {
      "medications": [
        {
          "name": "Lisinopril",
          "dosage": "10mg",
          "condition": "Hypertension"
        },
        {
          "name": "Metformin",
          "dosage": "500mg",
          "condition": "Type 2 Diabetes"
        }
      ],
      "allergies": ["Penicillin"]
    }
  }'

Phone Number Lookup

curl -X POST "https://app.mycura.org/api/cura/chat" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "message": "What should I know about my prescription?",
    "phone": "+15551234567"
  }'

Response Examples

Success Response

{
  "success": true,
  "response": "Common side effects of Lisinopril include a dry cough (in about 10-15% of patients), dizziness, headache, and fatigue. More serious but rare side effects can include swelling of the face, lips, or throat (angioedema), which requires immediate medical attention. Given your medical history, monitor for any persistent cough or dizziness, especially when standing up quickly."
}

Error Response

{
  "success": false,
  "error": "Patient not found with the provided ID"
}

Best Practices

Always provide a patientId when available for:
  • More accurate, personalized responses
  • Complete audit trails for compliance
  • Automatic context from stored patient data
Include the last 5-10 conversation turns for context:
  • Maintains conversation continuity
  • Provides better contextual understanding
  • Avoids repetitive responses
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
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 CodeError MessageDescription
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.