Create Thread
curl --request POST \
--url https://api.mycura.org/api/cura/threads \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <x-api-key>' \
--data '
{
"patientId": {},
"phone": "<string>",
"metadata": {}
}
'import requests
url = "https://api.mycura.org/api/cura/threads"
payload = {
"patientId": {},
"phone": "<string>",
"metadata": {}
}
headers = {
"X-API-Key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({patientId: {}, phone: '<string>', metadata: {}})
};
fetch('https://api.mycura.org/api/cura/threads', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mycura.org/api/cura/threads",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'patientId' => [
],
'phone' => '<string>',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mycura.org/api/cura/threads"
payload := strings.NewReader("{\n \"patientId\": {},\n \"phone\": \"<string>\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<x-api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mycura.org/api/cura/threads")
.header("X-API-Key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"patientId\": {},\n \"phone\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mycura.org/api/cura/threads")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"patientId\": {},\n \"phone\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"error": "Unauthorized - Invalid API key"
}
{
"error": "Failed to create thread"
}
Conversation Threads
Create Thread
Create a new conversation thread for stateful chat sessions
POST
/
api
/
cura
/
threads
Create Thread
curl --request POST \
--url https://api.mycura.org/api/cura/threads \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <x-api-key>' \
--data '
{
"patientId": {},
"phone": "<string>",
"metadata": {}
}
'import requests
url = "https://api.mycura.org/api/cura/threads"
payload = {
"patientId": {},
"phone": "<string>",
"metadata": {}
}
headers = {
"X-API-Key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({patientId: {}, phone: '<string>', metadata: {}})
};
fetch('https://api.mycura.org/api/cura/threads', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mycura.org/api/cura/threads",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'patientId' => [
],
'phone' => '<string>',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mycura.org/api/cura/threads"
payload := strings.NewReader("{\n \"patientId\": {},\n \"phone\": \"<string>\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<x-api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mycura.org/api/cura/threads")
.header("X-API-Key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"patientId\": {},\n \"phone\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mycura.org/api/cura/threads")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"patientId\": {},\n \"phone\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"error": "Unauthorized - Invalid API key"
}
{
"error": "Failed to create thread"
}
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
string
required
Your Cura API key
Body Parameters
All parameters are optional. You can send an empty body
{} for general conversations without patient context.string (UUID)
Optional patient UUID to link this thread to a patient profile. The AI will have access to patient data.
string
Optional patient phone number (any format:
5551234567, +15551234567, (555) 123-4567).The system will automatically find the patient and link the thread.object
Optional metadata to store with the thread (e.g., session info, source, tags).
{
"source": "mobile_app",
"sessionId": "abc123",
"name": "Medication Questions"
}
Examples:
{}- General conversation (no patient lookup) Recommended{"phone": "5551234567"}- With patient lookup{"patientId": "uuid-123"}- With patient ID
Request Example
# General conversation (recommended)
curl -X POST "https://api.mycura.org/api/cura/threads" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'
# With patient lookup
curl -X POST "https://api.mycura.org/api/cura/threads" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"phone": "5551234567",
"metadata": {
"source": "mobile_app"
}
}'
const axios = require('axios');
const response = await axios.post(
'https://api.mycura.org/api/cura/threads',
{
phone: '5551234567',
metadata: {
source: 'mobile_app'
}
},
{
headers: {
'X-API-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
}
}
);
console.log(response.data.threadId);
import requests
response = requests.post(
'https://api.mycura.org/api/cura/threads',
json={
'phone': '5551234567',
'metadata': {
'source': 'mobile_app'
}
},
headers={
'X-API-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
}
)
thread_id = response.json()['threadId']
print(f"Created thread: {thread_id}")
<?php
$ch = curl_init('https://api.mycura.org/api/cura/threads');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'phone' => '5551234567',
'metadata' => ['source' => 'mobile_app']
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-API-Key: YOUR_API_KEY',
'Content-Type: application/json'
]);
$response = curl_exec($ch);
$data = json_decode($response, true);
echo "Thread ID: " . $data['threadId'];
?>
Response
boolean
Whether the thread was created successfully
string
Unique 5-digit thread identifier (e.g.,
"82451")string (optional)
An initial question from the AI to start the conversation (e.g., demographic questions like gender). Display this message to the user immediately after thread creation to begin the conversation flow.
string (ISO 8601)
ISO 8601 timestamp when the thread will auto-delete (30 minutes from creation)
number
Initial message count (typically 0 for new threads, or 2 if initialMessage is present)
string
Success message with usage instructions
Success Response (201)
{
"success": true,
"threadId": "82451",
"initialMessage": "Are you male or female?",
"expiresAt": "2025-11-10T15:30:00Z",
"messageCount": 2,
"message": "Thread created successfully. Use this threadId in your chat requests."
}
The
initialMessage field may or may not be present depending on whether the AI has an initial question. Always check for its presence and display it to the user if available.Error Responses
{
"error": "Unauthorized - Invalid API key"
}
{
"error": "Failed to create thread"
}
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
threadId2
Save Thread ID
Store the
threadId on your client (localStorage, state, session, etc.)3
Send Messages
Use the
threadId in your chat requests4
Continue Conversation
Keep using the same
threadId - context is automatic!Best Practices
Create threads at session start
Create threads at session start
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;
});
}
}, []);
Link to patients when available
Link to patients when available
If you have patient information, include it for better AI context:
// With patient
await createThread({ phone: user.phone });
// Without patient (anonymous)
await createThread({});
Use metadata for tracking
Use metadata for tracking
Store useful information in metadata for analytics:
await createThread({
phone: user.phone,
metadata: {
platform: 'iOS',
version: '2.1.0',
sessionId: generateSessionId()
}
});
Handle expiration gracefully
Handle expiration gracefully
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;
}
Related Endpoints
Chat
Send messages to the thread
Get Thread
Retrieve thread information
Delete Thread
Manually end a conversation
Next Steps
Learn About Conversation Threads
Comprehensive guide to using threads effectively
Was this page helpful?

