Skip to main content
POST
https://app.mycura.org
/
api
/
cura
/
threads
Create Thread
curl --request POST \
  --url https://app.mycura.org/api/cura/threads \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <x-api-key>' \
  --data '
{
  "patientId": {},
  "phone": "<string>",
  "metadata": {}
}
'
{
  "error": "Unauthorized - Invalid API key"
}
Recommended: This is the preferred way to start a conversation with the Cura AI. Threads handle context automatically.

Overview

Creates a new conversation thread with a unique 5-digit ID. Once created, you can send multiple messages to this thread and the AI will automatically remember the conversation history (last 20 messages).

Authentication

X-API-Key
string
required
Your Cura API key

Body Parameters

patientId
string (UUID)
Optional patient UUID to link this thread to a patient profile. The AI will have access to patient data.
phone
string
Optional patient phone number (any format: 5551234567, +15551234567, (555) 123-4567).The system will automatically find the patient and link the thread.
metadata
object
Optional metadata to store with the thread (e.g., session info, source, tags).
{
  "source": "mobile_app",
  "sessionId": "abc123",
  "name": "Medication Questions"
}

Request Example

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",
    "metadata": {
      "source": "mobile_app"
    }
  }'

Response

success
boolean
Whether the thread was created successfully
threadId
string
Unique 5-digit thread identifier (e.g., "82451")
expiresAt
string (ISO 8601)
ISO 8601 timestamp when the thread will auto-delete (30 minutes from creation)
message
string
Success message with usage instructions

Success Response (201)

{
  "success": true,
  "threadId": "82451",
  "expiresAt": "2025-10-22T19:30:00.000Z",
  "message": "Thread created successfully. Use this threadId in your chat requests."
}

Error Responses

{
  "error": "Unauthorized - Invalid API key"
}

Thread Features

Unique 5-Digit ID

Each thread gets a unique identifier that’s easy to reference and share

Auto-Expires in 30 Min

Threads automatically delete after 30 minutes of inactivity for privacy

Automatic Context

Last 20 messages auto-loaded on every request - no manual history management

Patient Linking

Optional patient linking gives AI access to medical information

Usage Flow

1

Create Thread

Make this request to get a threadId
2

Save Thread ID

Store the threadId on your client (localStorage, state, session, etc.)
3

Send Messages

Use the threadId in your chat requests
4

Continue Conversation

Keep using the same threadId - context is automatic!

Best Practices

When a user opens your app or starts a new conversation, create a thread immediately:
// On app load
useEffect(() => {
  if (!sessionStorage.threadId) {
    createThread().then(thread => {
      sessionStorage.threadId = thread.threadId;
    });
  }
}, []);
Store useful information in metadata for analytics:
await createThread({
  phone: user.phone,
  metadata: {
    platform: 'iOS',
    version: '2.1.0',
    sessionId: generateSessionId()
  }
});
Monitor expiresAt and create new threads when needed:
if (new Date(thread.expiresAt) < new Date()) {
  // Thread expired, create new one
  const newThread = await createThread({ phone: user.phone });
  sessionStorage.threadId = newThread.threadId;
}

Next Steps

Learn About Conversation Threads

Comprehensive guide to using threads effectively