Get Chats With Latest Messages
Endpoint
GET /api/whatsapp/get_chats_with_latest_messages
Authentication
This API requires authentication using the auth:api middleware. The request must include a Bearer Token for authorization.
<token>
Description
Retrieves a list of WhatsApp chats with the latest messages. The response is filtered based on user permissions (admin or non-admin).
Response
{
"isSuccessful": true,
"hasContent": true,
"code": 200,
"message": null,
"detailed_error": null,
"data": [
{
"id": 117,
"whatsapp_contact_id": 96,
"is_hash_ticketing_system_enabled": null,
"isGroup": 0,
"pinned": 0,
"unread": 1,
"isMuted": 0,
"is_admin": 0,
"active_odoo_ticket_id": null,
"is_hash_check_enabled": 0,
"is_hash_automation_system_enabled": 0,
"is_hash_check_auto_reply_enabled": 0,
"updated_at": "2025-02-08T11:10:56.000000Z",
"instance_name": "operations",
"employees": [
{
"id": 628,
"pivot": {
"whatsapp_chat_id": 117,
"user_id": 628
}
},
{
"id": 628,
"pivot": {
"whatsapp_chat_id": 117,
"user_id": 628
}
}
]
}
]
}
Error Responses
401 Unauthorized
{
"isSuccessful": false,
"code": 401,
"hasContent": false,
"message": "you are not authenticate please signup..",
"detailed_error": null,
"data": null
}
```
Notes
-
Admin users
(Auth::id() == Config::get('admin_user_id'))have access to all chats. -
Non-admin users can only retrieve chats associated with their user ID.
-
Messages are filtered based on visibility and delete status.