Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
docs: clarify chat history limits (#356)
hsnyvsh71ca41686ac6
diff --git a/docs/README.md b/docs/README.mdindex 692856399..31d780411 100644--- a/docs/README.md+++ b/docs/README.md@@ -62,6 +62,7 @@| Example | Description || ------- | ----------- || [Session Phone-Number Pairing](./examples/session-phone-number-pairing.md) | Link an existing WhatsApp account by phone number instead of scanning QR |+| [Chat History Limits](./examples/chat-history-limits.md) | Understand local message history vs bounded live WhatsApp history || [Webhook Signature Verification](./examples/webhook-signature-verification.md) | Verify signed OpenWA webhook deliveries in Node.js and Python || [n8n Appointment Booking Workflow](./examples/n8n-appointment-booking.md) | Build an appointment-booking flow with OpenWA and n8n |@@ -235,4 +236,4 @@ MIT License._OpenWA Documentation · Last updated: 2026-06-18_-</div>+</div>\ No newline at end of filediff --git a/docs/examples/chat-history-limits.md b/docs/examples/chat-history-limits.mdnew file mode 100644index 000000000..dcc6d090f--- /dev/null+++ b/docs/examples/chat-history-limits.md@@ -0,0 +1,49 @@+# Chat History Limits++OpenWA has two different history paths, and they answer different questions.++## Local Message History++```http+GET /api/sessions/{sessionId}/messages+```++This endpoint reads from OpenWA's local database. It returns messages that OpenWA has observed and persisted while the session was connected.++Use this when you want stable pagination over messages already stored by OpenWA.++## Live WhatsApp Chat History++```http+GET /api/sessions/{sessionId}/messages/{chatId}/history?limit=50+```++This endpoint asks the active WhatsApp engine for recent messages in a chat. It bypasses OpenWA's local database and can be useful for retrieving messages that are visible to the linked WhatsApp Web session but were not yet stored locally.++The endpoint is intentionally bounded:++- `limit` defaults to `50`.+- `limit` is clamped to the range `1`–`100`.+- Values such as `limit=999` do not request unbounded history; they are reduced to the maximum allowed limit.+- `includeMedia=true` downloads media data and is slower than metadata-only history.++## What It Does Not Guarantee++The live history endpoint does not guarantee a complete import of all server-side WhatsApp history.++For the `whatsapp-web.js` engine, available history is limited by what WhatsApp Web exposes to the browser session. If WhatsApp Web itself requires manual loading of older messages from the phone, OpenWA cannot assume that the entire account history is already available through a single history request.++## Recommended Usage++For reliable long-term history, keep the OpenWA session connected and consume messages as they arrive through local storage, webhooks, or WebSocket events.++Use the live history endpoint as a bounded recent-history helper, not as a full historical import mechanism.++## Example++```bash+curl -H "X-API-Key: $API_KEY" \+ "http://localhost:2785/api/sessions/default/messages/[email protected]/history?limit=100"+```++Use `limit=100` when you want the maximum single-request live history window currently allowed by OpenWA.