Kantuta POS Backend includes a built-in WhatsApp gateway powered by @whiskeysockets/baileys — an open-source, reverse-engineered WhatsApp Web API. This means no paid WhatsApp Business API subscription is required. Instead, you link a real WhatsApp number to the server by scanning a QR code once, and the backend then gains the ability to send text messages, images, and documents programmatically to any WhatsApp contact or group. The linked session is persisted on disk, so subsequent server restarts reconnect automatically without re-scanning.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Eleazarguitar18/kantuta_pos_back/llms.txt
Use this file to discover all available pages before exploring further.
Setup & QR Code Linking
Start the NestJS Server
The WhatsApp Baileys session initializes automatically when the application boots. No additional configuration is needed beyond having the module registered in Watch the server logs — Baileys will emit a QR code string within a few seconds of startup if no saved session is found.
AppModule.Retrieve the QR Code
Navigate to the QR view endpoint in your browser (or call it programmatically):Browser-friendly HTML page:Open Returns JSON with a If already linked:
http://localhost:3000/api/whatsapp/connect/view in a browser. The server renders an HTML page with a scannable QR image.JSON API endpoint (for frontend integration):qrBase64 field (a data:image/png;base64,... string) that you can render in an <img> tag, or a success message if already connected:Scan with WhatsApp on Your Phone
- Open WhatsApp on your phone.
- Go to Settings → Linked Devices → Link a Device.
- Point your camera at the QR code displayed by the server.
- Wait for the pairing confirmation — typically 2–5 seconds.
Sending Messages
All
/whatsapp/send* routes are decorated with @Public() — they do not require a JWT Bearer token. Protect access to these endpoints at the network or API-gateway level in production environments.Send a Text Message
| Field | Type | Required | Description |
|---|---|---|---|
code | string | ✅ | Country code, digits only, 2–3 characters (e.g., 591 for Bolivia) |
phone | string | ✅ | Local phone number, digits only, 8–15 characters (e.g., 71234567) |
message | string | ✅ | Text content of the message |
The backend concatenates
code + phone internally to form the full WhatsApp JID: [email protected]. Never include the + prefix or spaces in either field.200 OK):
Send an Image
multipart/form-data. Maximum file size: 5 MB.
Form fields:
| Field | Type | Required | Description |
|---|---|---|---|
code | string | ✅ | Country code (digits only, 2–3 chars) |
phone | string | ✅ | Local phone number (digits only, 8–15 chars) |
caption | string | Optional | Caption text displayed below the image |
file | binary | ✅ | Image file (.jpg, .png, etc.) — max 5 MB |
Send a Document
multipart/form-data. Maximum file size: 15 MB.
Form fields:
| Field | Type | Required | Description |
|---|---|---|---|
code | string | ✅ | Country code (digits only, 2–3 chars) |
phone | string | ✅ | Local phone number (digits only, 8–15 chars) |
fileName | string | Optional | Display name for the file (e.g., Factura_Mayo.pdf). Defaults to the original filename |
file | binary | ✅ | Document file — max 15 MB |
Group Messaging
Send a Message to a Group
| Field | Type | Required | Description |
|---|---|---|---|
groupId | string | ✅ | Full WhatsApp group JID ending in @g.us |
message | string | ✅ | Message text to broadcast |
200 OK):
List All Groups
Phone Number Format
Kantuta POS uses a two-field format for phone numbers —code (country code) and phone (local number) — and concatenates them server-side:
| Country | code | phone example |
|---|---|---|
| Bolivia | 591 | 71234567 |
| Perú | 51 | 987654321 |
| Argentina | 54 | 1123456789 |
| México | 52 | 5512345678 |
- Both
codeandphonemust contain digits only — no+, spaces, or dashes. codemust be 2–3 digits.phonemust be 8–15 digits.
Endpoint Reference
| Method | Endpoint | Auth | Description |
|---|---|---|---|
GET | /whatsapp/connect/view | Public | HTML page with QR code |
GET | /whatsapp/connect | JWT | JSON QR code or connection status |
POST | /whatsapp/send | Public | Send a text message |
POST | /whatsapp/send-image | Public | Send an image (max 5 MB) |
POST | /whatsapp/send-document | Public | Send a document (max 15 MB) |
POST | /whatsapp/send-to-group | Public | Broadcast text to a group |
GET | /whatsapp/list-groups | Public | List all groups the bot is in |
GET | /whatsapp/view | Public | Browser-based send form (debug UI) |