Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
docs(webhook): state the effective inline media ceiling
Yudhi Armyndharis44a23cef9d26
diff --git a/.env.example b/.env.exampleindex c0b59c3c6..a9dfdc02d 100644--- a/.env.example+++ b/.env.example@@ -393,7 +393,14 @@ WEBHOOK_RETRY_DELAY=5000 # Delay between retries in ms# larger media is delivered as { omitted: true, sizeBytes }# instead (0 = never inline media)# WEBHOOK_MAX_PAYLOAD_BYTES=1048576 # max serialized webhook body; over-budget payloads shed inline- # media first, then are recorded undelivered if still too large+ # media first, then are recorded undelivered if still too large.+ # Checked on the JSON body after the inline cap, where base64+ # adds a third: at the defaults, media over ~768 KiB arrives as+ # the omitted marker. Raise both, this one to >= 4/3 of the+ # inline cap plus room for the envelope. WebSocket events apply+ # only the inline cap. Downloaded media stays retrievable from+ # GET /api/sessions/:sessionId/messages/:chatId/:messageId/media+ # (404 when nothing was stored).# Days to keep webhook delivery-failure records before pruning them (default 90; set <= 0 to disable).# WEBHOOK_FAILURE_RETENTION_DAYS=90# Block outbound WEBHOOK deliveries to internal/reserved addresses (SSRFdiff --git a/CHANGELOG.md b/CHANGELOG.mdindex e9a5fa09e..7d7d1689a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- The dashboard session card keeps the phone number, session id and last-active time while a linked session reconnects, instead of the pairing placeholder ([#1546](https://github.com/rmyndharis/OpenWA/issues/1546)). Thanks @OdaiAhmed99 for the report.- The Sessions page reports a dead live-event feed and re-reads the list once the feed recovers.- A Baileys media download aborted at `MEDIA_DOWNLOAD_MAX_BYTES` reports the bytes received as `sizeBytes`, and a timed-out one its declared size, instead of the cap.+- The webhook docs state that at the default limits media above about 768 KiB reaches webhooks as the omitted marker, and how to raise both limits ([#1569](https://github.com/rmyndharis/OpenWA/issues/1569)). Thanks @Magnarks for the report.- The takeover sweep marks sessions left `ready` or `initializing` by a node that never returned disconnected, regardless of `AUTO_START_SESSIONS`.- Branch Docker images (`:main`, sha tags) rebuild the production apt layer, so they cannot serve stale OS packages from the build cache.- The Message Tester's bulk-recipients file picker refuses files over 2 MB before reading them.diff --git a/docs/04-security-design.md b/docs/04-security-design.mdindex 206cff7ed..18161e5f6 100644--- a/docs/04-security-design.md+++ b/docs/04-security-design.md@@ -384,6 +384,13 @@ Each webhook still receives its own copy of the event data — a `webhook:before`payload.data` in place and must not bleed into sibling deliveries — but the copy is taken aftermedia shedding, so it is small. The HMAC signature is computed over the exact shed bytes sent.+The two media bounds compound. `WEBHOOK_MAX_PAYLOAD_BYTES` is measured on the serialized JSON body+and applies after `WEBHOOK_MEDIA_INLINE_MAX_BYTES`; base64 inflates media by a third, so at the+defaults media above roughly 768 KiB reaches webhooks as the omitted marker. Raise both together,+with the payload limit at least 4/3 of the inline limit plus room for the envelope. The WebSocket+gateway applies only the inline limit. Media the engine downloaded stays retrievable from+`GET /api/sessions/:sessionId/messages/:chatId/:messageId/media` (`404` when nothing was stored).+## 4.9 Security Headers### Helmet Configurationdiff --git a/docs/06-api-specification.md b/docs/06-api-specification.mdindex 9ae45bf3d..dd9d2603f 100644--- a/docs/06-api-specification.md+++ b/docs/06-api-specification.md@@ -6845,7 +6845,7 @@ These are the events OpenWA actually emits. A webhook is registered with an `eve> **`contact` on `message.received` is minimal unless you opt in (`WEBHOOK_CONTACT_DETAILS`).** By default the payload carries only `contact { name?, pushName? }`. Setting `WEBHOOK_CONTACT_DETAILS=true` adds `id`, `number`, `shortName`, `type`, `isMyContact`, `isWAContact`, `isBusiness`, `isEnterprise`, `verifiedName`, `verifiedLevel`, `isBlocked` and `labels`, each present only when the engine has a value for it. Every field is copied from the contact record the engine has already loaded for the message, so opting in costs no extra WhatsApp lookup and cannot add rate-limiting pressure. The same enrichment reaches the websocket event, since both are dispatched from one payload. `contact` itself is omitted entirely when the engine has no value for any of its fields, so treat the whole object as optional rather than just its members. **whatsapp-web.js only** — the Baileys path emits `contact { pushName }` when a push name is available, and never reads 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. The **WebSocket** `message.received` / `message.sent` events apply the same cap and the same marker: an over-cap blob is never broadcast to subscribed sockets (or, with the Redis adapter enabled, replicated across every replica's pub/sub link), and the media stays fetchable via that same history route.+> **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). The two limits compound: `WEBHOOK_MAX_PAYLOAD_BYTES` is measured on the serialized JSON body after `WEBHOOK_MEDIA_INLINE_MAX_BYTES` has been applied, and base64 inflates media by a third, so at the defaults media above roughly **768 KiB** reaches your webhook as the omitted marker. To inline larger media, raise both together and keep the payload limit at least 4/3 of the inline limit plus room for the rest of the event (for example `5242880` inline with `7340032` payload). The **WebSocket** `message.received` / `message.sent` events apply only the inline cap, with the same marker: an over-cap blob is never broadcast to subscribed sockets (or, with the Redis adapter enabled, replicated across every replica's pub/sub link). On either sink, media the engine downloaded stays retrievable from [`GET /api/sessions/:sessionId/messages/:chatId/:messageId/media`](#get-apisessionssessionidmessageschatidmessageidmedia), which returns `404` when nothing was stored.> 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`.