The Chat REST API handles two concerns: retrieving persisted message history for a conversation and uploading images before sending them as chat messages. All real-time message delivery — including typing indicators and read receipts — runs over Socket.io. The HTTPDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/desarrolladorandres2026-gif/Native-tailwind/llms.txt
Use this file to discover all available pages before exploring further.
POST /api/chat/:userId endpoint exists as a fallback only; prefer the mensaje:enviar socket event in normal operation.
Both users must have a confirmed mutual match (esMatch: true) before any chat endpoint will respond with data. Attempts to read or write messages without a match return 403 Forbidden.
Endpoints
POST /api/chat/upload
Upload a chat image to Cloudinary.
GET /api/chat/:userId
Fetch paginated message history.
POST /api/chat/:userId
Send a text message (REST fallback).
Authorization: Bearer <access_token>.
POST /api/chat/upload
Uploads an image file to Cloudinary and returns the hosted URL. Use the returnedurl as the content value in a subsequent mensaje:enviar socket event or POST /api/chat/:userId call.
The request must be multipart/form-data with a single field named file.
Request
Image file to upload. Must be a valid image format accepted by Cloudinary (JPEG, PNG, WebP, etc.).
Sent as
multipart/form-data.Response 200 OK
Full Cloudinary URL of the uploaded image. Use this value as the message content when sending an image message.
Error responses
| Status | Description |
|---|---|
400 | No file received in the request |
401 | Missing or invalid Bearer token |
500 | Cloudinary upload failure |
Example
GET /api/chat/:userId
Returns the paginated message history between the authenticated user anduserId. Messages are sorted oldest first. Calling this endpoint also marks all unread messages from userId as read (is_read: true).
Both users must be in a confirmed mutual match, otherwise 403 is returned.
Path parameters
MongoDB
_id of the other user in the conversation.Query parameters
Page number (1-indexed).
Maximum number of messages to return per page.
Response 200 OK
The shared Match document ID for this conversation.
Array of message objects sorted oldest-first.
Message ID (mapped from MongoDB
_id via the model’s toJSON transform).Match document ID this message belongs to.
User ID of the message author.
User ID of the message recipient.
Message text, or a Cloudinary URL for image messages (max 1,000 characters).
true if the recipient has read this message.ISO 8601 creation timestamp (aliased from Mongoose
createdAt by the model transform).Error responses
| Status | Description |
|---|---|
403 | No mutual match between the two users |
401 | Missing or invalid Bearer token |
Example
POST /api/chat/:userId
HTTP fallback for sending a text message. This endpoint saves the message to the database but does not emit a Socket.io event — the recipient will only see it when they next callGET /api/chat/:userId. For real-time delivery, use the mensaje:enviar socket event instead.
Both users must have a confirmed mutual match.
Path parameters
MongoDB
_id of the message recipient.Request body
Text content of the message. Cannot be empty or whitespace-only. Maximum 1,000 characters.
Response 201 Created
Error responses
| Status | Description |
|---|---|
400 | Empty or whitespace-only content |
403 | No mutual match between the two users |
401 | Missing or invalid Bearer token |
Example
For real-time messaging, always prefer the Socket.io
mensaje:enviar event over this
REST endpoint. The socket path persists the message and emits mensaje:nuevo to
both users instantly. This REST endpoint is a graceful fallback for clients that lose
their socket connection mid-conversation; the useChat hook in the mobile app
automatically switches to it when socket.connected is false.