Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
docs: document RESOLVE_LID_TO_PHONE at the surfaces it changes
Yudhi Armyndharis9adeff1af3cd
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 65abc7c23..cde249461 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- Turkish (`tr`) dashboard translation. Thanks @codedByCan.+### Documentation++- `RESOLVE_LID_TO_PHONE` was documented nowhere outside `.env.example`, so an operator receiving `@lid` senders had no path to the flag that resolves them; the event catalog now carries the `senderPhone` opt-in callout, the contact-phone endpoint points back to it, and the troubleshooting FAQ covers the symptom.+## [0.16.0] - 2026-08-11### Addeddiff --git a/docs/06-api-specification.md b/docs/06-api-specification.mdindex 1f626a156..754296954 100644--- a/docs/06-api-specification.md+++ b/docs/06-api-specification.md@@ -2266,6 +2266,8 @@ Resolve a contact id (e.g. an `@lid`) to a phone number (MSISDN digits), best-ef`phone` is `null` when the engine cannot map the id (e.g. an `@lid` the account has never seen).+For inbound messages the gateway can attach this automatically instead: `RESOLVE_LID_TO_PHONE=true` adds `senderPhone` to every `message.received` payload (§6.6). It is off by default; this endpoint works either way.+**Errors:** `400` session is not started · `401` missing/invalid API key#### PUT /api/sessions/:sessionId/contacts/:contactId@@ -6505,6 +6507,8 @@ These are the events OpenWA actually emits. A webhook is registered with an `eve> **`STORE_EPHEMERAL_MESSAGES=false` affects `message.received`.** When `STORE_EPHEMERAL_MESSAGES` is set to `false`, incoming disappearing messages (those with `ephemeralDuration > 0`) are **not** persisted nor dispatched — no DB insert, no webhook delivery, and no websocket event. Downstream consumers and the dashboard both stop seeing them. Default is `true` (backward compatible — store and dispatch everything).+> **`senderPhone` on `message.received` is opt-in (`RESOLVE_LID_TO_PHONE`).** When a sender is identified by a WhatsApp privacy id (`…@lid`) rather than a phone number, setting `RESOLVE_LID_TO_PHONE=true` attaches a best-effort `senderPhone` — MSISDN digits, or `null` when the engine cannot map the id — before dispatch, so the webhook and the websocket event both carry it in the same pass. Default is **off**, and while it is off the field is absent from every payload: resolving costs a per-sender lookup (cached). Only inbound privacy-id senders are resolved — a sender that already is a phone number needs no lookup, and own-sends are skipped. The on-demand `GET /api/sessions/:sessionId/contacts/:contactId/phone` works regardless of this flag.+> **Large media is not inlined into webhook payloads.** A `media` blob whose decoded size exceeds `WEBHOOK_MEDIA_INLINE_MAX_BYTES` (default **1 MiB**; `0` = never inline) is replaced — before the payload is fanned out to your webhook — with the marker form `media: { mimetype, filename?, omitted: true, sizeBytes }`, the same shape the engine emits for capped inbound media. Media at or under the cap stays inline unchanged. Additionally, if the serialized body still exceeds `WEBHOOK_MAX_PAYLOAD_BYTES` (default **1 MiB**) after `webhook:before` hooks ran, any remaining inline media is shed the same way so the event is still delivered; only a payload that is over budget _without_ inline media is dropped (recorded in `GET /api/webhooks/delivery-failures`). Because shedding happens before enqueue, queued and failed BullMQ jobs in Redis never carry the blob either — failed-job retention is bounded by the queue's `removeOnComplete`/`removeOnFail` windows (1h/1000 completed, 24h/5000 failed). Fetch the media itself afterwards via `GET /api/sessions/:sessionId/messages/:chatId/history?includeMedia=true` when you need it.> There is **no** `contact.update` event. `presence.update` is emitted only for chats you have subscribed to (see the presence-subscription endpoint); call outcomes are reported as `call.accepted`, `call.rejected` and `call.missed` alongside `call.received`.diff --git a/docs/12-troubleshooting-faq.md b/docs/12-troubleshooting-faq.mdindex 79da8c86c..891944c63 100644--- a/docs/12-troubleshooting-faq.md+++ b/docs/12-troubleshooting-faq.md@@ -772,6 +772,35 @@ WEBHOOK_TIMEOUT=10000 # per-attempt HTTP timeout in ms (default 10000)WEBHOOK_RETRY_DELAY=5000 # base retry backoff in ms (default 5000)```+### Issue: An inbound sender arrives as an `@lid` id instead of a phone number++**Symptoms:**++- `message.received` carries `from` (or `author`, in a group) as `162878178984075@lid` rather than `[email protected]`+- The number cannot be matched against your own contact records, and replies have to be addressed by the `@lid` id+- `contact.number` on the payload repeats the lid digits, so it is not the phone number either++**Cause:** WhatsApp identifies some accounts by a privacy id (`@lid`) instead of their phone number,+and the message itself carries no phone number to read. Mapping one back costs a lookup against the+engine, so the gateway does not do it on every message unless you ask for it.++**Solution:**++```bash+# Resolve a single id on demand — works whether or not the flag below is set+curl -H "X-API-Key: $API_KEY" \+ http://localhost:2785/api/sessions/{sessionId}/contacts/{contactId}/phone++# Or have every inbound message carry it: adds `senderPhone` to the message.received webhook+# and the websocket event. Set it in the `.env` next to docker-compose.yml (both compose files+# already forward the variable), then restart the process — an env change is not picked up by a+# session reload.+RESOLVE_LID_TO_PHONE=true+```++`senderPhone` is `null` when the engine cannot map the id — an `@lid` the account has never seen has+no mapping to return. Both engines support the lookup.+## 12.5 Performance Issues### Issue: High Memory Usage