Skip to main content

Documentation 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.

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 HTTP 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).
All endpoints require Authorization: Bearer <access_token>.

POST /api/chat/upload

Uploads an image file to Cloudinary and returns the hosted URL. Use the returned url 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

file
file
required
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

{
  "url": "https://res.cloudinary.com/debuta/image/upload/v1/debuta/chats/64f0.../photo.jpg"
}
url
string
Full Cloudinary URL of the uploaded image. Use this value as the message content when sending an image message.

Error responses

StatusDescription
400No file received in the request
401Missing or invalid Bearer token
500Cloudinary upload failure

Example

curl -X POST https://api.debuta.app/api/chat/upload \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -F "file=@/path/to/photo.jpg"

GET /api/chat/:userId

Returns the paginated message history between the authenticated user and userId. 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

userId
string
required
MongoDB _id of the other user in the conversation.

Query parameters

pagina
number
default:"1"
Page number (1-indexed).
limite
number
default:"50"
Maximum number of messages to return per page.

Response 200 OK

{
  "matchId": "64f1a2b3c4d5e6f7a8b9c0d2",
  "mensajes": [
    {
      "id": "64f9aa11b2c3d4e5f6a7b8c0",
      "matchId": "64f1a2b3c4d5e6f7a8b9c0d2",
      "sender_id": "64f0000000000000000000aa",
      "receiver_id": "64f1a2b3c4d5e6f7a8b9c0d1",
      "content": "¡Hola! ¿Cómo estás?",
      "is_read": true,
      "created_at": "2024-07-15T21:05:33.000Z"
    },
    {
      "id": "64f9aa22b2c3d4e5f6a7b8c1",
      "matchId": "64f1a2b3c4d5e6f7a8b9c0d2",
      "sender_id": "64f1a2b3c4d5e6f7a8b9c0d1",
      "receiver_id": "64f0000000000000000000aa",
      "content": "¡Muy bien, gracias! ¿Y tú?",
      "is_read": false,
      "created_at": "2024-07-15T21:06:10.000Z"
    }
  ]
}
matchId
string
The shared Match document ID for this conversation.
mensajes
Message[]
Array of message objects sorted oldest-first.
id
string
Message ID (mapped from MongoDB _id via the model’s toJSON transform).
matchId
string
Match document ID this message belongs to.
sender_id
string
User ID of the message author.
receiver_id
string
User ID of the message recipient.
content
string
Message text, or a Cloudinary URL for image messages (max 1,000 characters).
is_read
boolean
true if the recipient has read this message.
created_at
string
ISO 8601 creation timestamp (aliased from Mongoose createdAt by the model transform).

Error responses

StatusDescription
403No mutual match between the two users
401Missing or invalid Bearer token

Example

# Fetch the first 50 messages
curl -X GET "https://api.debuta.app/api/chat/64f1a2b3c4d5e6f7a8b9c0d1" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

# Fetch page 2 with a custom page size
curl -X GET "https://api.debuta.app/api/chat/64f1a2b3c4d5e6f7a8b9c0d1?pagina=2&limite=25" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

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 call GET /api/chat/:userId. For real-time delivery, use the mensaje:enviar socket event instead. Both users must have a confirmed mutual match.

Path parameters

userId
string
required
MongoDB _id of the message recipient.

Request body

content
string
required
Text content of the message. Cannot be empty or whitespace-only. Maximum 1,000 characters.

Response 201 Created

{
  "mensaje": {
    "id": "64f9bb33c3d4e5f6a7b8c9d0",
    "matchId": "64f1a2b3c4d5e6f7a8b9c0d2",
    "sender_id": "64f0000000000000000000aa",
    "receiver_id": "64f1a2b3c4d5e6f7a8b9c0d1",
    "content": "Aquí un mensaje de respaldo.",
    "is_read": false,
    "created_at": "2024-07-15T21:30:00.000Z"
  }
}

Error responses

StatusDescription
400Empty or whitespace-only content
403No mutual match between the two users
401Missing or invalid Bearer token

Example

curl -X POST https://api.debuta.app/api/chat/64f1a2b3c4d5e6f7a8b9c0d1 \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{ "content": "Hola, ¿cómo estás?" }'

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.

Build docs developers (and LLMs) love