curl --request GET \
--url https://api.example.com/api/conversations{
"success": true,
"conversations": [
{
"id": 123,
"phone_number": "<string>",
"contact_name": "<string>",
"status": "<string>",
"ai_enabled": 123,
"last_message_at": "<string>",
"created_at": "<string>",
"last_message": "<string>",
"last_sender_type": "<string>",
"last_message_created_at": "<string>"
}
],
"error": "<string>"
}Retrieve all conversations with optional filtering by status
curl --request GET \
--url https://api.example.com/api/conversations{
"success": true,
"conversations": [
{
"id": 123,
"phone_number": "<string>",
"contact_name": "<string>",
"status": "<string>",
"ai_enabled": 123,
"last_message_at": "<string>",
"created_at": "<string>",
"last_message": "<string>",
"last_sender_type": "<string>",
"last_message_created_at": "<string>"
}
],
"error": "<string>"
}GET /api/conversations
active - Active conversationspending_human - Conversations waiting for human interventionclosed - Closed conversationsactive, pending_human, or closedcustomer, ai, or humansuccess is false)curl -X GET 'https://your-domain.com/api/conversations'
{
"success": true,
"conversations": [
{
"id": 1,
"phone_number": "1234567890",
"contact_name": "John Doe",
"status": "active",
"ai_enabled": 1,
"last_message_at": "2024-01-15 14:30:25",
"created_at": "2024-01-10 09:00:00",
"last_message": "Thank you for your help!",
"last_sender_type": "customer",
"last_message_created_at": "2024-01-15 14:30:25"
},
{
"id": 2,
"phone_number": "0987654321",
"contact_name": "Jane Smith",
"status": "pending_human",
"ai_enabled": 0,
"last_message_at": "2024-01-15 13:15:00",
"created_at": "2024-01-12 11:30:00",
"last_message": "I need to speak with a human agent",
"last_sender_type": "customer",
"last_message_created_at": "2024-01-15 13:15:00"
}
]
}
{
"success": false,
"error": "Error al obtener conversaciones"
}
api/get-conversations.php and uses the ConversationService::getAllConversations() method. The query joins the conversations table with the messages table to fetch the most recent message for each conversation.
Route pattern (from index.php:161):
if ($requestMethod === 'GET' && ($path === '/api/conversations' ||
$path === '/api/get-conversations' ||
$path === '/api/get-conversations.php'))
ConversationService.php:77)last_message_at in descending order (most recent first)