Documentation Index
Fetch the complete documentation index at: https://mintlify.com/No-Country-simulation/S02-26-Equipo-33-Web-App/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Conversations represent chat threads between two users. Each conversation can optionally be linked to a horse listing (e.g., when a buyer contacts a seller about a specific horse).Authentication
All conversation endpoints require authentication via JWT token in theAuthorization header.
Create or Get Conversation
POST /api/chat/conversations
Creates a new conversation or returns an existing one between the authenticated user and the recipient. If a conversation already exists between these two users (optionally for the same horse), the existing conversation is returned.
MongoDB ObjectId of the user to start a conversation with. Must be a valid ObjectId and cannot be the current user’s ID.
MongoDB ObjectId of the horse listing this conversation is about. Optional. If provided, the conversation will be linked to this specific horse.
Response Fields
Indicates if the request was successful
The conversation object
Unique conversation identifier
Array of exactly 2 user ObjectIds representing the participants in the conversation
MongoDB ObjectId of the related horse listing (if applicable)
ISO 8601 timestamp when the conversation was created
ISO 8601 timestamp when the conversation was last updated
Error message (only present when success is false)
Error Responses
- 400 Bad Request: Invalid recipient ID or attempting to message yourself
- 500 Internal Server Error: Server error occurred
List Conversations
GET /api/chat/conversations
Returns all conversations for the authenticated user, sorted by most recently updated first. Results include populated participant details and horse information.
Response Fields
Indicates if the request was successful
Array of conversation objects sorted by
updated_at (most recent first)Unique conversation identifier
Most recent message in the conversation (see Create or Get Conversation for fields)
ISO 8601 timestamp when the conversation was created
ISO 8601 timestamp when the conversation was last updated
Error Responses
- 500 Internal Server Error: Server error occurred
Socket.io Events
Join Conversation Room
Join a specific conversation room to receive real-time messages.The ID of the conversation to join
New Message Event
Receive new messages in conversations you’ve joined.Message Notification Event
Receive notifications when someone sends you a message (delivered to your personal user room).The preview field contains the first 60 characters of the message text.
Data Model
Conversation Schema
Validation Rules
- Conversations must have exactly 2 participants
- Participants must be valid user ObjectIds
- Users cannot create conversations with themselves
- The
last_messagefield is automatically updated when new messages are sent
Indexes
participants: Used for efficiently finding all conversations for a user

