curl --request GET \
--url https://api.example.com/api/chat/history{
"success": true,
"message": "<string>",
"data.conversations": [
{
"_id": "<string>",
"title": "<string>",
"createdAt": "<string>",
"totalTokens": 123,
"claudeModel": "<string>",
"templateId": {
"_id": "<string>",
"name": "<string>",
"category": "<string>"
}
}
],
"data.pagination": {
"page": 123,
"limit": 123,
"total": 123,
"pages": 123,
"hasNext": true,
"hasPrev": true
},
"data.conversation": {
"_id": "<string>",
"userId": {},
"templateId": {},
"title": "<string>",
"claudeModel": "<string>",
"messages": [
{
"role": "<string>",
"content": "<string>",
"timestamp": "<string>",
"tokenCount": 123
}
],
"status": "<string>",
"totalTokens": 123,
"metadata": {
"userPrompt": "<string>",
"combinedPrompt": "<string>",
"responseTime": 123,
"temperature": 123,
"maxTokens": 123
},
"createdAt": "<string>",
"updatedAt": "<string>"
}
}Retrieve and manage conversation history for users
curl --request GET \
--url https://api.example.com/api/chat/history{
"success": true,
"message": "<string>",
"data.conversations": [
{
"_id": "<string>",
"title": "<string>",
"createdAt": "<string>",
"totalTokens": 123,
"claudeModel": "<string>",
"templateId": {
"_id": "<string>",
"name": "<string>",
"category": "<string>"
}
}
],
"data.pagination": {
"page": 123,
"limit": 123,
"total": 123,
"pages": 123,
"hasNext": true,
"hasPrev": true
},
"data.conversation": {
"_id": "<string>",
"userId": {},
"templateId": {},
"title": "<string>",
"claudeModel": "<string>",
"messages": [
{
"role": "<string>",
"content": "<string>",
"timestamp": "<string>",
"tokenCount": 123
}
],
"status": "<string>",
"totalTokens": 123,
"metadata": {
"userPrompt": "<string>",
"combinedPrompt": "<string>",
"responseTime": 123,
"temperature": 123,
"maxTokens": 123
},
"createdAt": "<string>",
"updatedAt": "<string>"
}
}Authorization: Bearer YOUR_JWT_TOKEN
GET /api/chat/history
Show conversation properties
curl -X GET "https://api.cuido.com/api/chat/history?page=1&limit=20" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
{
"success": true,
"message": "Historial obtenido exitosamente",
"data": {
"conversations": [
{
"_id": "65a1b2c3d4e5f6a7b8c9d0e8",
"title": "Analiza el nivel de satisfacción del personal en el último mes y sugiere acciones para mejorarlo...",
"createdAt": "2024-01-15T10:30:00.000Z",
"totalTokens": 432,
"claudeModel": "claude-3-sonnet-20240229",
"templateId": {
"_id": "65a1b2c3d4e5f6a7b8c9d0e1",
"name": "Análisis de RRHH en Salud",
"category": "Recursos Humanos y Salud"
}
},
{
"_id": "65a1b2c3d4e5f6a7b8c9d0e7",
"title": "Cómo reducir los tiempos de espera en urgencias...",
"createdAt": "2024-01-14T15:20:00.000Z",
"totalTokens": 567,
"claudeModel": "claude-3-sonnet-20240229",
"templateId": {
"_id": "65a1b2c3d4e5f6a7b8c9d0e2",
"name": "Mejora de Calidad Asistencial",
"category": "Calidad Asistencial y Salud"
}
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 45,
"pages": 3,
"hasNext": true,
"hasPrev": false
}
}
}
GET /api/chat/conversations/:id
Show conversation properties
active, completed, errorcurl -X GET https://api.cuido.com/api/chat/conversations/65a1b2c3d4e5f6a7b8c9d0e8 \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
{
"success": true,
"message": "Conversación obtenida exitosamente",
"data": {
"conversation": {
"_id": "65a1b2c3d4e5f6a7b8c9d0e8",
"userId": {
"_id": "65a1b2c3d4e5f6a7b8c9d0e0",
"name": "Admin User",
"email": "[email protected]"
},
"templateId": {
"_id": "65a1b2c3d4e5f6a7b8c9d0e1",
"name": "Análisis de RRHH en Salud",
"description": "Plantilla para analizar métricas de recursos humanos y generar recomendaciones",
"category": "Recursos Humanos y Salud"
},
"title": "Analiza el nivel de satisfacción del personal en el último mes y sugiere acciones para mejorarlo...",
"claudeModel": "claude-3-sonnet-20240229",
"messages": [
{
"role": "user",
"content": "Analiza el nivel de satisfacción del personal en el último mes y sugiere acciones para mejorarlo",
"timestamp": "2024-01-15T10:30:00.000Z",
"tokenCount": 245
},
{
"role": "assistant",
"content": "Basado en las métricas de satisfacción del personal, se observa un promedio de 7.2/10...",
"timestamp": "2024-01-15T10:30:02.000Z",
"tokenCount": 187
}
],
"status": "completed",
"totalTokens": 432,
"metadata": {
"userPrompt": "Analiza el nivel de satisfacción del personal en el último mes y sugiere acciones para mejorarlo",
"combinedPrompt": "[Full combined prompt with system instructions...]",
"responseTime": 2350,
"temperature": 0.7,
"maxTokens": 500
},
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-01-15T10:30:02.000Z"
}
}
}
src/controllers/chatController.js:165):
src/controllers/chatController.js:128):
const [conversations, total] = await Promise.all([
Conversation.find({ userId }).select(...).limit(...).skip(...),
Conversation.countDocuments({ userId })
]);
{
"success": false,
"message": "No autorizado. Token inválido o expirado."
}
{
"success": false,
"message": "Conversación no encontrada"
}
src/routes/chatRoutes.js:58-67src/controllers/chatController.js:121src/controllers/chatController.js:160src/models/Conversation.js