All chat endpoints require authentication with
auth:sanctum.Overview
The chat system allows customers to communicate with sellers about products. Each conversation is linked to a product and contains multiple messages.Get Conversations
Query Parameters
Page number
Response
Returns paginated list of conversations where the authenticated user is the sender, ordered by most recent first.Example
Get Messages
Path Parameters
Conversation ID
Query Parameters
Page number
Response
Returns paginated list of messages in the conversation, ordered by most recent first.Example
Create Conversation
Request
Product ID to inquire about
Conversation title/subject
Initial message content
Response
Success status
Success message
Created conversation ID
Seller’s shop name or “In House Product”
Seller’s shop logo URL
Conversation title
Example
When a conversation is created:
- An initial message is automatically added
- Email notification is sent to the seller
- Conversation is linked to the product
Send Message
Request
Conversation ID
Message content
Response
Returns the created message object in a collection format.Example
Get New Messages
Path Parameters
Conversation ID
Last message ID the client has
Response
Returns messages with ID greater thanlast_message_id, ordered by most recent first.
Example
Conversation Response Structure
Conversation ID
Customer user ID
Seller user ID
Conversation subject
Whether sender has viewed (0 or 1)
Whether receiver has viewed (0 or 1)
Creation timestamp
Message Response Structure
Message ID
Parent conversation ID
Sender user ID
Message content
Message timestamp
Chat Flow
1. Starting a Conversation
- Customer views a product
- Customer clicks “Contact Seller”
- App calls
/api/v2/chat/create-conversationwith product_id - Conversation is created and seller receives email notification
2. Sending Messages
- User views conversation messages
- User types and sends message
- App calls
/api/v2/chat/insert-message - Message is added to conversation
- View status is updated
3. Polling for New Messages
- App stores the latest message ID
- Periodically calls
/api/v2/chat/get-new-messages/{conversation_id}/{last_message_id} - Displays new messages to user
- Updates last message ID
Viewing Status
The conversation tracks viewing status:- sender_viewed: Set to “1” when sender sends a new message
- receiver_viewed: Set to “1” when receiver sends a new message
Email Notifications
When a new conversation is created, an email is sent to the seller containing:- Sender’s name
- Initial message content
- Link to view conversation (for admin or seller dashboard)
Best Practices
Limitations
- Messages are text-only (no attachments in current version)
- One conversation per product per customer-seller pair
- Conversations cannot be deleted by users
- No group conversations (only 1-to-1)