Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

docs(changelog): consolidate the Unreleased section into a concise entry per change

Yudhi Armyndharisa173f2e57d64
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ca7febb6e..03147e25a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,668 +9,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
-- **Autoreply automation rules.** Per-session single-message rules under
- `POST|GET|PUT|DELETE /api/sessions/:sessionId/automation-rules`: when an inbound message matches a
- rule's conditions — the same filter format (and evaluator) webhook filters use — the gateway
- replies into the chat with the rule's text. Rules evaluate in creation order, first match wins,
- and the reply flows through the ordinary send path, so send pacing and plugin vetoes apply to it
- like any other outbound message. Three guards bound reply loops: rules never answer the
- account's own messages, messages older than five minutes get no automated answer (a reconnect
- never burst-replies the offline backlog), and a per-chat `cooldownSeconds` (default 60)
- rate-bounds a rule after it fires. Evaluation is fire-and-forget off the receive path and
- deduplicated per message. Two read-only
- agent tools (`AutomationRuleFindAll`, `AutomationRuleFindOne`) expose the rules to MCP callers;
- as operator-level configuration the module is not part of the SDK surface.
-
-### Added
-
-- **WebSocket events now fan out across replicas when Redis is enabled.** The realtime gateway
- broadcasts to Socket.IO rooms, but the default in-memory adapter only reached sockets on the same
- process — so a client connected to one replica never saw an event raised on another. A Socket.IO
- Redis adapter (`@socket.io/redis-adapter`, pub/sub over the existing `REDIS_*` connection) is now
- attached when `REDIS_ENABLED=true` — the same flag the throttler and cache already use — so a
- broadcast reaches clients on every replica. The scope is fan-out only: mid-connection API-key
- eviction, per-key WS rate-limit state, and the engine registry remain process-local (see
- docs/13). Without `REDIS_ENABLED` the adapter is inert and delivery is single-node exactly as
- before; a Redis outage falls back to local delivery rather than failing the boot.
-
-- **Session requests are now routed to the owning node (opt-in via `NODE_URL`).** In a multi-node
- deployment a load balancer knows nothing about session placement; a request landing on a
- non-owner previously could not be served. When every node announces its own reachable URL
- (`NODE_URL`), a session-scoped request is now forwarded to the live owner after API-key
- authentication and the owner's response is relayed back, marked `x-openwa-served-by`. The
- forward carries the caller's credentials (nodes share the auth database), is bounded by
- `SESSION_PROXY_TIMEOUT_MS` (default 60s), and is strictly one hop — a forwarded request is never
- forwarded again, so stale ownership data degrades to a wrong-node answer instead of a loop. A
- lapsed owner is deliberately not forwarded to: the local node serves the request, which is how a
- takeover begins. An unreachable live owner answers a clear `503` naming the node. Without
- `NODE_URL` the path is entirely inert, so single-node deployments pay nothing.
-
-- **Sessions abandoned by a dead node are now adopted automatically.** The ownership lease made a
- crashed node's sessions *claimable*, but nothing ever claimed them: boot auto-start runs exactly
- once, so a peer that was already up — or a recreated container whose boot landed before its own
- previous identity's lease expired — left the sessions sitting disconnected until someone called
- `POST /start` (both cases observed live). A periodic takeover sweep (default every 30s,
- `SESSION_TAKEOVER_SWEEP_MS`, gated by the same `AUTO_START_SESSIONS` flag as boot auto-start) now
- finds lapsed-lease sessions and starts them through the ordinary race-safe claim path. Only
- sessions worth resuming are adopted: authenticated ones in a running-or-should-be state — never
- mid-pairing (`qr_ready`), never operator-flagged `failed`, and never deliberately released ones
- (stop and graceful shutdown clear the holder, so they are not "lapsed"). Adopting a session also
- fails its stuck in-flight bulk batches (same no-auto-resume policy as the boot reaper — the dead
- node's already-sent messages are unknowable, so resuming would risk double-sends).
-
-### Fixed
-
-- **whatsapp-web.js sessions could come up "ready" with a dead inbound pipeline after a warm
- restart, silently losing every incoming message.** whatsapp-web.js runs its whole post-auth
- pipeline — including attaching the page-to-Node message listeners — inside a callback fired only
- by the page's `change:hasSynced` *transition*. On a warm profile the page can restore to
- already-synced before that listener exists (the callback then never runs), and the listener
- attachment itself can fail partway with the rejection swallowed; in both cases `ready` never
- fires while sends keep working, and this gateway's readiness reconciliation then promoted the
- session, masking the loss. Confirmed live: messages visible in the WhatsApp store, never
- persisted, never dispatched to webhooks.
-
- A new postinstall patcher (`scripts/patch-wwebjs-ready-sync.js`, run fatally in the image build
- like its siblings) closes the missed-transition race by also firing the handler when the synced
- state has already been reached, and records completion of the listener attachment on the client.
- The adapter now refuses to promote a session whose message bridge never attached — on BOTH paths:
- the genuine `ready` event (whatsapp-web.js bare-re-emits it while the first run's listener
- attachment is still in flight, so a premature emit is ignored and the attach's own completion
- re-emit promotes instead) and the readiness reconciliation. When the bridge stays dead the
- reconciliation reloads the page once to reinject it (whatsapp-web.js reinjects on navigation),
- and — if it still never attaches — marks the session failed **without** deleting the saved
- credentials: the link itself is healthy, so a restart must be enough to recover, never a re-pair.
-
-- **Status posting on the whatsapp-web.js engine, which current WhatsApp Web had broken outright.**
- whatsapp-web.js 1.34.7 builds every status message with
- `window.require('WAWebStatusGatingUtils').canCheckStatusRankingPosterGating()`. That helper no
- longer exists in current WhatsApp Web builds, so the call threw before the message was sent and
- took down text, image, video and voice status alike — a `500` on every attempt.
-
- Confirmed on a live account against the published image with none of this project's newer code
- present, so it is upstream rather than a regression here. The postinstall patcher now guards the
- call: it is used when the build still provides it, and falls back to `false` — what
- `cannotBeRanked` meant before WhatsApp introduced the gating check — when it does not. Text status
- posts again, verified live.
-
- Media status was failing for a second and unrelated upstream reason: `sendStatusMediaMsgAction`
- no longer accepts the positional `(msg, mediaUpdate)` call whatsapp-web.js 1.34.7 makes, so
- WhatsApp Web's own bundle threw `Cannot read properties of undefined (reading 'id')`. The same
- patcher (`scripts/patch-wwebjs-status.js`, formerly `patch-wwebjs-status-gating.js`) now also
- rewrites that call to the current single-options-object signature, adopting the open upstream
- fix (wwebjs/whatsapp-web.js#201816). Image, video and voice status post again, verified live.
- The patcher also now runs in the production image build, which previously shipped without the
- gating guard.
-
-### Security
-
-- **Five advisories in the production dependency tree resolved**, all through transitive bumps —
- `brace-expansion` 5.0.9, `fast-uri` 3.1.5, `hono` 4.13.0, `ip-address` 10.4.0, `socket.io-parser`
- 4.2.7. No direct dependency changed and nothing was added or removed.
-
- The one that mattered most for release was `brace-expansion`. A second advisory
- (CVE-2026-69152) bypasses the mitigation the first one's fix introduced, and it reached the
- **application's own tree** in the shipped image — which the image-scan allow-list explicitly does
- not cover. The next release scan would have failed on it. The root override floor now sits at
- ^5.0.9 so the application tree cannot resolve below the fix, which is also what keeps the
- id-level allow-list entries for npm's own bundled copy from silently hiding an app-tree
- regression.
-
- `ip-address` carries SSRF and trust-boundary advisories, but this project's SSRF guard does not
- use it — the guard resolves and pins addresses through Node's built-in `net` and `dns`. The
- vulnerable copy reached the tree through the rate limiter and the SOCKS proxy agent.
-
-### Fixed
-
-- **Voice notes sent through the Baileys engine now carry a waveform.** Baileys draws the amplitude
- bars from `audio-decode`, which it declares as an optional peer dependency and imports at send
- time. It was never installed, so that import threw on every voice note, was swallowed by a
- debug-level catch, and each one went out with a flat bar — a silent failure with no signal
- anywhere above `debug`, on a send that otherwise succeeded.
-
- Installing it is the upstream-supported path, at the major version Baileys itself asks for. That
- detail matters: the newest release is a major ahead, installs cleanly and resolves fine, and would
- quietly leave the declared peer range unmet. A spec now checks the dependency is declared,
- resolvable, and on that major, since the failure it prevents is invisible at runtime.
-
- whatsapp-web.js was never affected — it generates the waveform in the browser page.
-
-
-- **Labels are reachable from an agent.** They had five REST endpoints and no tools at all, so an
- agent could read and write contacts, groups, messages and webhooks but could not see a label, let
- alone tag a chat with one. Eight tools close that.
-
- Each description states which engine supports it, because labels split almost exactly down the
- middle: every read needs whatsapp-web.js, since Baileys exposes no label query; editing a label
- needs Baileys, since whatsapp-web.js cannot change one; only tagging and untagging a chat works on
- both. Left unsaid, an agent reads the `501` as a transient failure and retries a call that cannot
- succeed on that engine.
-
-
-- **Sessions record which process owns them.** A session's WhatsApp engine runs in exactly one
- process, but nothing recorded which, so a booting process reset every active-looking session on
- the assumption they were all its own leftovers. With one process that is correct. With two it is
- not: a booting replica reported a live peer's sessions as disconnected, and both replicas raced to
- auto-start the same sessions — two browsers writing one LocalAuth directory, which is how a
- session gets corrupted into a forced logout.
-
- `sessions` gains `nodeId`, `claimedAt` and `leaseExpiresAt`. A process claims a session before
- starting its engine and refuses with `409` when another node holds a live claim; a boot resets
- only what it may claim. The claim is a lease rather than a lock, so a process that dies without
- releasing does not strand its sessions — the claim stops being honoured once unrenewed, and a
- running owner keeps extending it. `NODE_ID` names the process and defaults to the hostname;
- `SESSION_LEASE_TTL_MS` and `SESSION_LEASE_HEARTBEAT_MS` tune the rest.
-
- Existing rows read as unclaimed, so a single-process deployment behaves exactly as before.
-
- A node that loses a claim stops running the session. A lease can lapse while the process itself is
- healthy — a slow query is enough — and a peer is then free to claim the session, so an engine left
- running here would be the second one on that WhatsApp account. Renewal is the regular contact with
- the row, so it is also where the loss is noticed and the local engine is torn down. A failed
- renewal is explicitly not a loss: the TTL exists to absorb a database blip, and treating a failed
- query as lost ownership would stop every healthy engine on the node the first time one occurred.
-
- Bulk-send batches follow the same ownership. The boot reaper marked every `PROCESSING` batch
- `FAILED`, which on a second replica meant declaring a peer's in-flight batches failed while they
- were still sending — the caller told the send failed, the messages going out regardless. A batch
- is only ever driven by the process holding its session's engine, so the reaper now acts only on
- batches whose session this node may claim. A data import reports the sessions it could not
- reconcile because another node is running them, rather than returning cleanly over engines it
- never touched.
-
- Request routing, fencing on the remaining lifecycle paths and WebSocket fan-out are still not
- done, so **one API instance per session-data volume remains the supported topology** —
- `docs/13-horizontal-scaling.md` states precisely what is and is not in place.
-
-
-- **Voice status.** `POST /api/sessions/:sessionId/status/send-voice` posts an audio status as a
- voice note on both engines. It carries no caption, because WhatsApp has nowhere to render one on a
- status voice note.
-
- On whatsapp-web.js the send sets `sendAudioAsVoice`, which becomes `isPtt` in the page and is the
- only thing separating a voice-note bubble from an audio file; on Baileys the content is
- `{ audio, ptt: true }`, and because Baileys keys its coloured-status handling off exactly that
- combination, `backgroundColor` applies here as it does for a text status.
-
- Neither engine transcodes, and WhatsApp plays a status voice note only as Ogg/Opus, so the
- mimetype defaults to it and the media conversion endpoint is what produces the bytes.
-
- `Status.type` gains a `voice` member. Before this, the read-back mapped only images and videos and
- collapsed everything else to `text`, so an incoming voice status was reported as a text status —
- one with audio attached and a type saying otherwise. Existing values are unchanged; clients that
- switch on `type` should treat an unrecognised value as they already treat any other.
-
-
-- **Server-side media conversion, and `ffmpeg` in the image.** WhatsApp renders a playable
- voice-note bubble only for Ogg/Opus. Nothing in the pipeline transcoded, so posting MP3 bytes to
- `send-audio` with `ptt: true` sent them as they were — labelled `audio/ogg; codecs=opus`, because
- that is the default applied when no mimetype is given — and the recipient got a mic bubble that
- would not play.
-
- `POST /api/sessions/:sessionId/media/convert/voice` and `.../video` transcode caller-supplied
- media and return it in the same base64 shape the send endpoints accept, so converting is one extra
- call rather than a change to how sending works. `GET .../media/convert` reports whether the
- feature is usable here. Opt-in via `MEDIA_CONVERSION_ENABLED`; sends are untouched otherwise.
-
- ffmpeg is run as a binary rather than through a wrapper package, and comes from Debian rather than
- a bundled static build, so codec fixes arrive through the same security stream as everything else
- in the image. Measured cost: about 210 MB, with no new fixable CRITICAL/HIGH findings under the
- release image scan. ffmpeg is only ever handed a file this server wrote and is confined to the
- file protocol — left unrestricted it resolves its input as a URL and will make the request.
-
- This also repairs an existing gap: whatsapp-web.js requires `fluent-ffmpeg` and uses it to build
- animated stickers from video, so `send-sticker` with a video mimetype has been failing in the
- published image for want of the binary.
+- **Autoreply rules** — per-session single-message autoreplies under `/api/sessions/:id/automation-rules`; conditions use the webhook filter format, the reply goes through the normal send path, and `fromMe`/freshness/per-chat-cooldown guards bound reply loops.
+- **Message & chat management** — pin/unpin and star/unstar messages, archive/unarchive chats, clear a chat without deleting it, and vote on polls (whatsapp-web.js).
+- **Contacts, groups & channels** — save/edit/remove addressbook contacts; read/set/remove a group picture; `memberAddMode` group setting; preview a group from its invite code before joining; create/delete/mute channels.
+- **Labels** — create, rename, recolour and delete labels; two read-only label agent tools for MCP.
+- **Presence & calls** — subscribe to presence (`presence.update`, online/typing) and receive call-outcome events (`call.accepted`, `call.rejected`, `call.missed`).
+- **Send options** — `linkPreview` toggle on `send-text`, plus a caller-supplied `customLinkPreview` on Baileys.
+- **Media & status** — server-side media conversion (audio→Ogg/Opus, video→MP4) via `ffmpeg` (`MEDIA_CONVERSION_ENABLED`); post an audio status as a voice note; archive chat media to the file store and fetch it back after delivery (`CHAT_MEDIA_ARCHIVE_ENABLED`).
+- **Opt-in send pacing** (`SEND_PACING_ENABLED`) — warm-up ramp, daily caps, a failure breaker, and a cold-reachout budget that also bounds group participant adds; enforcement is recorded in the audit log.
+- **Account restrictions surfaced** — WhatsApp-imposed restrictions appear on the session (API + `session.restriction` webhook + dashboard badge) instead of a generic error.
+- **Horizontal-scaling groundwork (opt-in)** — sessions record their owning process via a renewed lease so two replicas cannot both start one; a dead node's sessions are adopted automatically once the lease lapses (`SESSION_TAKEOVER_SWEEP_MS`); session-scoped requests are forwarded to the owning node when each node sets `NODE_URL`; and WebSocket events fan out across replicas when `REDIS_ENABLED=true`.
### Changed
-- **The full TypeScript strict family is now enabled.** `strictFunctionTypes`,
- `strictPropertyInitialization` and `useUnknownInCatchVariables` were off, so the compiler accepted
- unsound code the project had no other guard against. Six explicit flags collapse to `strict: true`,
- which is also the compiler's own default, so the configuration no longer has to track the strict
- family as it evolves.
-
- Nearly all of the fallout was mechanical: entity, DTO and framework-injected properties have no
- constructor assignment because TypeORM, class-transformer and Nest populate them, and now carry a
- definite-assignment assertion — syntax that is erased at compile time, so runtime behaviour is
- unchanged. Three registries that stored differently-shaped descriptors in one list relied on
- parameter bivariance and now use an explicitly erased type, with the single bridging cast placed
- where the real type is known rather than spread across every definition.
-
- The catch-variable flag also found four places interpolating a caught value straight into a
- message. Two reach operators through API responses, where a non-`Error` throw rendered as
- `[object Object]` instead of a cause.
-
-- **Each agent tool's handler is now tied to its own input schema.** Declaring the tool lists as an
- array pinned the input type to `unknown` for every entry, so a tool's schema and its handler were
- only ever checked against `unknown` and never against each other — a handler reading a field its
- schema did not declare compiled fine. Inferring the type per tool closes that, and makes the forty
- hand-written parameter annotations redundant: the shape is now stated once, in the schema that
- validates it and is advertised to callers.
-
-- **Coverage floors now cover every substantial module.** Eight directories had floors; everything
- else was graded only by the global average, where a well-tested module masks a neglected one. Each
- remaining module of meaningful size gains a floor, and the eight that had drifted are re-tightened
- — the session floor sat thirty points below its actual branch coverage. The policy table in
- `docs/09-testing-strategy.md` restated these by hand; a spec now holds the document and the
- configuration in agreement, so it cannot advertise a floor the build does not enforce.
+- Built under the full TypeScript `strict` family, with per-module test-coverage floors across the codebase.
### Fixed
-- **`docs/05-database-design.md` documented column names that do not exist.** Every table but
- `message_batches` was written in snake_case while the real columns are camelCase, so SQL copied out
- of the document referenced columns no database has — and PostgreSQL, which folds unquoted
- identifiers to lowercase, would fail on them at runtime rather than at review. The DDL blocks, the
- ER diagram, the index tables and the surrounding prose now carry the literal names, and the
- TypeORM-derived index names replace the readable slugs that were never real.
-
- `message_batches` genuinely is snake_case, which is what made the rest so easy to get wrong: no
- single rule covers the schema. That exception is now stated once, up front, where the tables begin.
-
- A spec builds the schema from the entities and checks every documented column against it, so the
- document cannot drift from the code again.
+- **Status posting on the whatsapp-web.js engine** — current WhatsApp Web had broken text and media status outright; the postinstall patcher restores both. Text, image, video and voice status post again.
+- **whatsapp-web.js sessions could report "ready" with a dead inbound pipeline** after a warm restart, silently dropping incoming messages. The adapter now refuses to promote a session whose event bridge never attached, reloading the page once and failing loudly (keeping credentials) if it stays dead.
+- **Baileys delete-chat, mark-unread and delete-for-me silently did nothing on individual (1:1) chats** — the neutral id was not folded to the engine form used as the app-state key.
+- **Voice notes on the Baileys engine now carry a waveform.**
+- The webhook producer enqueues idempotently, and the bundled Redis is pinned `--maxmemory-policy noeviction` so queued jobs are not silently dropped.
+- A media-storage root the app cannot write to is caught at boot with a clear error, instead of failing on the first write (#1066).
+- Corrected column names in `docs/05-database-design.md`.
-### Added
-
-- **Link previews on Baileys, generated safely — and `customLinkPreview` for supplying your own.**
-
- Baileys produced no previews at all before this. Its own generator delegates to `link-preview-js`,
- an optional peer this project does not install, so every message containing a URL quietly attempted
- to load it, threw, and was swallowed with a warning.
-
- Installing that package was the obvious fix and is the wrong one: it carries an **unfixed** SSRF
- advisory ([GHSA-4gp8-rjrq-ch6q](https://github.com/advisories/GHSA-4gp8-rjrq-ch6q), CWE-918 — "IPv6
- and internal loopback attacks", no patched release), and the URL being fetched comes from message
- text, so an attacker chooses the destination. Guarding in front of it would still leave a
- DNS-rebinding window, because the package re-resolves when it fetches.
-
- So the gateway generates previews itself, through the SSRF guard it already uses elsewhere — which
- validates the destination **and pins the connection to the vetted address**. No new dependency, no
- code under advisory, and `WEBHOOK_SSRF_PROTECT` / `SSRF_ALLOWED_HOSTS` govern it like every other
- outbound fetch. Non-http schemes never reach the fetch layer, non-document responses are not read,
- the body is size-capped, and any failure yields no preview rather than a failed send.
-
- `customLinkPreview` (`{ url, title, description? }`) attaches a preview you supply, fetching
- nothing — so it works for URLs this server cannot reach. Baileys only: whatsapp-web.js takes a
- boolean and has nowhere to put a title, so it answers `501` rather than silently sending a message
- that looks nothing like what was asked for. Combining it with `linkPreview: false` is a `400`.
-
-- **`linkPreview` on `send-text`**, in all five SDKs and the MCP tool. Sending `false` suppresses the
- URL preview on both engines.
-
- It is documented as guaranteed **only in that direction**, because that is all the engines
- actually agree on. Left unset it means "the engine default", and the defaults differ:
- whatsapp-web.js asks WhatsApp Web to build a preview in-page, while Baileys builds none — its
- preview generator is an optional package this project does not install. So `true` does not force a
- preview onto Baileys; it only declines to suppress one, and saying otherwise would be a promise
- nothing keeps.
-
- A side effect worth knowing: Baileys wires that generator by default, so **every message
- containing a URL currently attempts to load the missing package, fails, and logs a warning** before
- sending without a preview. Passing `false` skips that path entirely.
-
- Existing sends are byte-identical. A send with no preview choice keeps its exact previous call
- shape rather than gaining a trailing `undefined`.
-
-- **Preview a group before joining it:** `GET /api/sessions/:sessionId/groups/join-info?code=…`, in
- all five SDKs. Supported on both engines. Read-only, so it is safe to call on a code from an
- untrusted source — which is the point, since it is the step you want *before* `POST /groups/join`.
-
- The response is its own shape rather than the usual group info: a non-member has no participant
- list, only a count, and only when WhatsApp discloses one. Reusing the member-facing shape would
- have forced an empty participant array that reads as "this group has no members".
-
- Only `id` and `name` are guaranteed. Everything else is omitted when the engine did not report it,
- never defaulted — `whatsapp-web.js` returns an untyped object with no contract, and a
- `createdAt: 0` would claim the group was created at the epoch. A response carrying no group id at
- all is a refused invite, so it surfaces as `404` rather than a half-populated success.
-
-- **Call outcomes: `call.accepted`, `call.rejected`, `call.missed`** — webhook and socket events for
- what happened to a ringing call, correlated to the preceding `call.received` by `callId`. Modelled
- in the JavaScript, Python, Go and Java SDKs.
-
- **Baileys only.** whatsapp-web.js hooks the insert into WhatsApp Web's call collection and receives
- no status at all, so it can announce a ring but never its outcome — there is nothing to wire.
-
- Three events rather than one carrying an outcome field, so a consumer that only cares about missed
- calls can subscribe to exactly that.
-
- Two things are reported honestly rather than guessed. The engines say *what* happened but not *who*
- did it — an accept can come from any of the account's linked devices — so nothing is attributed.
- And WhatsApp's `terminate` is deliberately left unmapped: it covers both a caller hanging up before
- the call was answered and either side ending an answered one, with nothing in the event to separate
- them, so publishing it as an outcome would be wrong about half the time.
-
- An outcome is only published for a call this session actually saw ring, and offline-replayed
- signalling — WhatsApp resends the traffic for calls that ended while a session was disconnected —
- is dropped, so a reconnect cannot announce last week's declined call as if it had just happened.
- The cached call handle is released at the same time, so a `reject` arriving after the call ended
- now reports not-found instead of acting on a dead call.
-
-- **Channel administration: create, delete, mute.** `POST /api/sessions/:sessionId/channels`,
- `POST .../channels/:channelId/delete` and `POST .../channels/:channelId/mute`, in all five SDKs.
-
- Supported on **both** engines — whatsapp-web.js has `createChannel`/`deleteChannel` and mute on the
- Channel model, and Baileys has the matching newsletter calls. (The enhancement notes this was
- planned against expected `501`s on whatsapp-web.js; checking the library showed otherwise, so both
- engines are wired.)
-
- Deletion is `POST .../delete`, not `DELETE .../channels/:channelId` — that route already exists and
- means *unsubscribe*. Leaving a channel and destroying it for every subscriber are very different
- acts, and one mistyped verb should not be able to turn the first into the second.
-
- Two whatsapp-web.js failure modes are translated rather than passed on: `createChannel` signals
- failure by **returning an error string** instead of throwing, which would otherwise have been
- mapped into a channel object full of undefineds and reported as success; and `deleteChannel` and
- the mute calls return `false` rather than raising. All three now surface as a refusal.
-
-- **Labels can now be created, renamed, recoloured and deleted** — `PUT` and
- `DELETE /api/sessions/:sessionId/labels/:labelId` — and **listed by chat**:
- `GET /api/sessions/:sessionId/labels/:labelId/chats`. All five SDKs gain the matching methods.
-
- The two engines split down the middle and neither covers both halves, so this is honest about
- which is which rather than pretending at parity. whatsapp-web.js can read labels and assign them
- but cannot edit one — `index.d.ts` has no create/rename/delete of any kind — so the edits answer
- `501` there. Baileys is the mirror image: it has the writes and no label query whatsoever, so
- listing a label's chats answers `501` on it. Assigning a label to a chat is the only part that
- works everywhere.
-
- **Creating a label means choosing its id**, which is why the route is `PUT /labels/:labelId` and not
- `POST /labels`. WhatsApp carries one write keyed on the label id, so create and update are the same
- operation and there is no server-assigned id to return — reusing an existing id rewrites that
- label rather than failing, because the protocol has no create-only form. Saying so is better than
- a `POST` that implies a guarantee nothing can keep.
-
- `color` is WhatsApp's colour **index** (0–19), not the `hexColor` the read routes return. The two
- deliberately do not round-trip: neither engine exposes the mapping, so translating between them
- would be guesswork that silently sets the wrong colour.
-
-- **Presence: see who is online or typing.** `POST /api/sessions/:id/presence/subscribe` starts
- WhatsApp reporting a chat's presence; `GET /api/sessions/:id/presence/:chatId` serves the latest
- report; changes arrive as the new `presence.update` webhook **and** socket event. Exposed in all
- five SDKs and as two MCP tools.
-
- Baileys only. whatsapp-web.js exposes `sendPresenceAvailable`/`sendPresenceUnavailable`, which
- publish the account's *own* presence, and emits no presence event at all — so it answers `501`
- rather than pretending. That refusal is declared inline on the adapter so the engine parity gate
- can actually verify it, unlike the delegated refusals it cannot see.
-
- Two properties are documented rather than papered over. The subscription belongs to the
- **connection**: it does not survive a restart or an automatic reconnect and must be re-issued,
- because silently replaying subscriptions would report presence the account never asked for. And
- presence is **push-only** — it cannot be queried from either library — which is why `GET` serves a
- remembered report and answers `null`, not `404`, when nothing has been reported yet.
-
- Only genuine state *changes* are dispatched. WhatsApp repeats itself freely, and one watched chat
- with an active typist would otherwise bury every other event a consumer subscribes to; `lastSeen`
- and the group online count drifting on their own do not count as changes. The last report is held
- in memory and cleared when the session restarts, since presence from before a restart is worse than
- no answer at all.
-
-- **Group participant adds are paced too.** `POST .../groups/:groupId/participants` and
- `POST .../groups` reached WhatsApp with no gate of any kind — no moderation hook, no pacing, no
- persisted record — while being the most ban-associated action the product performs: they put the
- account in front of people who did not ask for it, in bulk, in one call.
-
- Each participant the account has no history with now costs one cold reachout from the same budget
- a first message draws on, so a day spent on direct outreach leaves nothing for group invites and
- vice versa. A repeated id costs one; participants already known cost nothing. The whole request is
- refused rather than partially applied — these endpoints already report per-participant failures,
- and a pacing refusal must not be mistaken for one. No message is sent, so neither call consumes the
- overall daily send allowance.
-
-- **Send pacing now bounds cold reachouts separately** (`SEND_PACING_COLD_DAILY_CAP`). A send counts
- as a cold reachout when the account has no history with that chat **in either direction**; a reply
- to someone who wrote first is never counted and never refused by this rule, and status posts, which
- address no chat, are exempt.
-
- This is the rule that matches what WhatsApp actually punishes — its own reachout timelock exists
- precisely for accounts that start conversations with strangers — so it ramps far more tightly than
- the overall daily allowance and is checked after it. Refusals carry the same `429` +
- `SEND_PACING_LIMITED`, distinguished in the metric and audit trail by `rule: cold_daily_cap`.
-
-- **The dashboard shows account restrictions on the session card**, in all 12 locales. The row is
- deliberately not gated on status, unlike the error row beside it: a reachout timelock applies to a
- session that is perfectly `ready`, and hiding it behind a failure status would make it invisible in
- exactly the case an operator needs it. The visible label is the translated kind; the engine's raw
- cause token and the expiry ride in the tooltip, since the token is searchable but not readable.
-
-- **Enforcement and account standing are now in the audit log**, not only in the process log. Four new
- `AuditAction` members: `session_restricted` / `session_restriction_lifted` when WhatsApp restricts
- an account or releases it, and `send_pacing_blocked` / `send_breaker_tripped` when pacing refuses a
- send or the failure breaker opens.
-
- These are the durable record. Both features keep their live state in memory — correctly, since both
- re-establish themselves within one connection — which means without these rows there was no way to
- answer "when was this account restricted, and for how long" after a restart.
-
- `send_pacing_blocked` is sampled to at most one row per session per minute, carrying the count it
- stood in for, on the same reasoning as the websocket limiter's `rate_limit_exceeded`: a session that
- hits its daily cap goes on being refused for the rest of the day, and a row per refused request
- would make enforcing the limit a flood of its own. A breaker trip is rare and never sampled.
- Repeat reports of an unchanged restriction are not re-audited either.
-
-- **Opt-in send pacing, to keep a young or struggling account from sending its way into a ban:**
- `SEND_PACING_ENABLED=false` by default, so nothing changes until you turn it on. When enabled, two
- rules can refuse an outbound send:
-
- - a **warm-up daily cap** whose allowance grows with the session's age
- (`SEND_PACING_WARMUP_SCHEDULE`), because a brand-new account that immediately sends at volume is
- the pattern that gets numbers banned;
- - a **failure breaker** that pauses sending after `SEND_PACING_BREAKER_THRESHOLD` consecutive send
- failures — usually the sign that WhatsApp has already started refusing the account — and releases
- after a cooldown or on the first success.
-
- Refusals are `429` carrying `code: "SEND_PACING_LIMITED"` and `retryAfterSeconds`. That code is what
- separates them from the global rate limiter's own `429`, which carries none: the throttler's clears
- in seconds, a daily cap does not. Refusals are counted per rule in the new
- `openwa_send_pacing_refusals_total` Prometheus counter.
-
- It covers every path that reaches WhatsApp with a message: all the `send-*` routes and `edit`, bulk
- batches, status posts, and `send-product` — the last of which never went through the message
- service and so had no moderation gate either. Inside a batch a refusal fails just that item, not
- the batch, since the allowance may free up and a killed batch cannot be resumed. Reactions, poll
- votes, pins and deletes are deliberately not paced: they act on conversations that already exist,
- which is not the traffic that gets accounts banned.
-
- **Plugin-visible behaviour change:** the pacing check runs *before* the `message:sending` hook, so a
- paced-out send does not fire it. Plugins are not asked to moderate, and cannot rewrite, traffic that
- policy already forbids — but a plugin treating that hook as a complete record of send *attempts*
- will no longer see refused ones. It remains complete for sends actually attempted against WhatsApp.
- A plugin veto is still `400`.
-
- Daily counts are read from the messages table rather than a counter of their own, so they survive
- restarts, cannot drift from what was really sent, and needed no new table or migration.
-
-- **WhatsApp-imposed account restrictions are now surfaced, instead of being lost inside a generic
- disconnect:** a new `restriction` field on every session response, a `session.restriction` webhook,
- and an `openwa_sessions_restricted` Prometheus gauge. Modelled in the JavaScript, Python, Go and
- Java SDKs. Nothing is opt-in and nothing changes an existing payload's meaning; the field is
- additive and `null` when there is no restriction.
-
- The two engines can observe genuinely different things, so the signal says which:
-
- - `reachout_timelock` (Baileys) — the account stays connected and existing chats keep working;
- WhatsApp blocks only the start of **new** conversations. Read from the library's typed
- `reachoutTimeLock` state, which reports both the onset and the lift, and carries an `expiresAt`
- when WhatsApp states one.
- - `tos_block` / `proxy_block` (whatsapp-web.js) — a connection-level refusal, derived from the
- `WAState` the library reports when it drops the link.
-
- Only three of whatsapp-web.js's twelve states are treated as restrictions. An unlink, a takeover
- by another device, a stale client version and a timeout all say nothing about the account's
- standing, and reporting them would make the signal useless to act on.
-
- Because WhatsApp only *pushes* a timelock when it changes, a gateway that starts while an account
- is already restricted would never be told, so the Baileys engine asks outright once per
- connection. Repeats are deduped: an unchanged restriction is not re-announced, and a lift is only
- sent when one was actually in force.
-
- Detection is observational. It never changes a session's status or its reconnect behaviour, so a
- misread cannot take a working session out of service — and a `reachout_timelock` in particular
- applies to a session that is still fully `ready`. The state is held in memory rather than
- persisted, because both engines re-establish it within one connection.
-
-- **Polls can be voted on, on the whatsapp-web.js engine:**
- `POST /api/sessions/:sessionId/messages/vote-poll` with `{ chatId, pollMessageId, options }`.
- Exposed in all five SDKs as `messages.votePoll`. Baileys returns `501` — it has no vote-send
- helper at all, only `decryptPollVote` for *receiving*.
-
- `options` are the option **texts**, not ids: whatsapp-web.js matches options by name, and no
- engine surfaces a stable per-option id through this API, so there is nothing else to name an
- option by. A poll with two identically-worded options will select both. The list replaces the
- current selection, and `[]` clears the vote.
-
- Two limits are documented rather than papered over: the poll must be inside the engine's
- 100-message window for the chat (an older one is `404`), and a non-poll target is `400` — the
- library throws a bare string there, which would otherwise have surfaced as an opaque `500`.
-
-- **Group pictures can be read, set and removed:**
- `GET|PUT|DELETE /api/sessions/:sessionId/groups/:groupId/picture`. Supported on both engines and
- exposed in all five SDKs as `groups.getPicture` / `setPicture` / `deletePicture`. The `PUT` body
- matches the profile-picture one (`url` or `base64` + `mimetype`). Setting or removing requires
- admin rights on the group; a refusal comes back as `403` rather than a silent success.
-
- The read needed no new engine method — the existing profile-picture lookup already accepts a group
- JID on both engines — so only the two writes were added.
-
-- **Addressbook contacts can be saved, edited and removed:**
- `PUT /api/sessions/:sessionId/contacts/:contactId` with `{ firstName, lastName? }`, and
- `DELETE` on the same path. Supported on both engines and exposed in all five SDKs as
- `contacts.upsert` / `contacts.delete`. This writes the WhatsApp contact record only — it does not
- block the contact or touch the chat.
-
- The two engines address the entry differently — whatsapp-web.js by bare phone number, Baileys by
- JID — so the adapters convert from the neutral contact id. A privacy id (`…@lid`) is refused with
- a `400`: the addressbook is keyed by phone number and a lid's digits are not one, so an unguarded
- lid would be stored as if it were a real phone. Neither syncs through to the device
- addressbook: both are called with their sync-to-device flag off, so the behaviour does not depend
- on which engine is running.
-
-- **`memberAddMode` on group settings — who may add participants.** `PUT /groups/:groupId/settings`
- accepts `memberAddMode: "all" | "admins"`, `GET .../settings` reports it, and `GroupInfo` carries
- it. Supported on both engines. Exposed on the `GroupSettings` shape in all five SDKs.
-
- The two engines encode this incompatibly, and the API deliberately hides that: Baileys uses a
- boolean where **true means everyone may add**, while whatsapp-web.js stores WhatsApp's own
- `all_member_add`/`admin_add` strings — and types the field as a boolean with the **opposite**
- meaning to Baileys'. Reading it as a plain boolean would silently invert the setting on one engine
- or the other, so both encodings are decoded explicitly and anything unrecognised is reported as
- unknown rather than guessed.
-
- Within a settings patch, `memberAddMode` is applied *after* `ephemeralSeconds`. That ordering is
- load-bearing: `ephemeralSeconds` is the only field with a deterministic per-engine refusal
- (whatsapp-web.js always `501`s it), so it must fail before anything else has been applied.
-
-- **A chat's messages can be cleared without deleting the chat:**
- `DELETE /api/sessions/:id/chats/:chatId/messages`. Available in all five SDKs as
- `chats.clearMessages`. Like `chats/archive`, `success: false` is a defined outcome — an unknown
- chat on whatsapp-web.js, or on Baileys a chat with no known history to key the change to.
-
-- **Chats can be archived and unarchived:** `POST /api/sessions/:id/chats/archive` with
- `{ chatId, archive }`, alongside the existing read/unread/delete chat operations. Available in all
- five SDKs as `chats.archive`.
-
- `success: false` is a real outcome rather than an error: on the Baileys engine the archive is an
- app-state modification keyed to the chat's **last message**, so a chat with no known history
- cannot be archived — the same limitation `chats/delete` and `chats/unread` already carry there.
- whatsapp-web.js uses `Client.archiveChat`/`unarchiveChat`, which report the new state, rather than
- `Chat.archive()`, which resolves nothing.
-
- No webhook fires for your own archive: Baileys emits no event for a change the account itself made,
- and whatsapp-web.js's `chat_archived` event is not wired. A `chat.archived` event covering
- remote-device archives is left as follow-up work — it needs event wiring on both engines and is a
- separate change from this endpoint.
-
-- **Messages can be starred and unstarred:** `POST /api/sessions/:sessionId/messages/star` with
- `{ chatId, messageId, star }`. Starring is private to the account, has no group-admin
- restriction, and never expires. Available in all five SDKs as `messages.star`.
-
- Best-effort on whatsapp-web.js: its `star()`/`unstar()` resolve with no value and silently do
- nothing when WhatsApp declines the message, so a `200` means the instruction was delivered rather
- than that the star is definitely set — there is no signal at the engine boundary to tell the two
- apart. Baileys applies it through an app-state modification and is exact.
-
-- **Messages can be pinned and unpinned, on both engines:** `POST /api/sessions/:sessionId/messages/pin`
- and `.../messages/unpin`. `durationSeconds` is `86400` (24h, the default), `604800` (7d) or
- `2592000` (30d) — WhatsApp recognises no others, so anything else is a `400` here rather than a
- silent no-op at the engine. In a group only admins may pin; that refusal surfaces as `403`, and a
- message the engine cannot locate as `404`. Available in all five SDKs as `messages.pin` /
- `messages.unpin`.
-
- Nothing is stored locally: a pin is chat state owned by WhatsApp and expires on its clock, so a
- mirrored copy in the message row would go stale silently. As with react/delete/edit, the target
- must be within whatsapp-web.js's 100-message fetch window for the chat, or in the Baileys
- adapter's message store.
-
-- **Chat media can now be archived to the file store and fetched back after delivery, via
- `GET /api/sessions/:sessionId/messages/:chatId/:messageId/media`.** Media has always been
- persisted as base64 inline on the message row, which makes it part of every row read and ties its
- lifetime to the row; there was no way to keep the file itself, put it on S3, or age it out on its
- own schedule. With `CHAT_MEDIA_ARCHIVE_ENABLED=true` each inbound message's media is additionally
- written through `StorageService` — local disk or S3, whichever is configured — and the row records
- where it went (`mediaPath`, `mediaMimetype`; a data-connection migration adds both).
-
- Opt-in and off by default, because the inline copy is deliberately **kept**: the dashboard renders
- from it and removing it would change the message response shape. Archiving therefore roughly
- doubles storage for media under `CHAT_MEDIA_ARCHIVE_MAX_BYTES` (25 MiB default), which is the
- trade for being able to retrieve, relocate, and expire the file independently.
- `CHAT_MEDIA_ARCHIVE_TTL_DAYS` (0 = forever) expires the archived **file** and clears the row's
- pointers; the message row itself is never deleted by retention. An hourly reconciliation sweep
- reaps archive files no row references, scoped to the `chat-media/` prefix so it can never touch
- status media sharing the same bucket. Writing is fire-and-forget off the receive path — a storage
- outage delays nothing and drops no messages. The download is served as an attachment with a
- conservative inert `Content-Type`, so an archived document (or an `image/svg+xml`) cannot render
- as active content on the API origin. Available in all five SDKs as `messages.media(...)`.
-
- With the flag off, behaviour is unchanged except that message responses carry two additional
- always-null fields, and no sweeps are scheduled.
-
-### Fixed
+### Security
-- **The webhook producer now enqueues idempotently.** It passed a job name but no job id, so BullMQ
- treated every `add()` as a brand-new job. The job id is now the delivery id, matching the ingress
- producer and putting BullMQ's dedupe boundary and the receiver's on one identifier. The id is
- minted per webhook per dispatch, so an event fanning out to several subscriptions still produces
- one job each.
-
- Scoped honestly: this is hardening, not a fix for an observed duplicate. No path in the gateway
- currently re-enqueues an existing delivery id — it is minted per dispatch and never persisted, and
- BullMQ retries a failed job rather than re-adding it — so the deduplication cannot fire today. It
- exists so that any future replay path (a redrive, a persisted outbox) cannot double-deliver by
- construction. **Receivers must still honour `X-OpenWA-Delivery-Id`:** the one real at-least-once
- window is unchanged, because when `add()` fails the producer falls back to delivering over HTTP
- directly, and if that `add()` had in fact reached Redis both copies are sent — a job id cannot
- dedupe a delivery that never went through the queue.
-- **The bundled Redis no longer risks silently dropping queued jobs.** BullMQ requires the
- `noeviction` maxmemory policy; both Redis launch paths — `docker-compose.yml` and the
- dashboard-orchestrated container — started `redis-server` with `--appendonly yes` alone, leaving
- the policy at whatever the image defaults to. Under any evicting policy Redis may discard queue
- keys once `maxmemory` is reached, losing jobs with no error raised anywhere. Both paths (and the
- scaling guide's compose sample) now pass `--maxmemory-policy noeviction`.
-
-- **A media storage root the app cannot write to is now caught at boot, with an error that says what
- to change.** The check ran on the wrong question: `StorageService` created the root only when it did
- not already exist, so a root that existed but belonged to another user sailed through startup and
- failed much later, on the first media write — surfacing as a bare `EACCES` from `mkdir` deep inside
- status ingestion, naming neither the setting at fault nor the file that set it.
- Startup now probes writability, and refuses to start with the value of
- `STORAGE_LOCAL_PATH`, the absolute path it resolved to, and the uid the process is running as. (#1065)
-
- One value self-heals instead of stopping the boot. `./uploads` was never an operator's choice:
- `GET /infra/status` read a config key that never existed and returned it as the storage path on every
- request in v0.2.0–v0.7.3, so any save on the dashboard's Infrastructure page in that window wrote
- `STORAGE_LOCAL_PATH=./uploads` into `data/.env.generated` — which lives on the data volume and
- outlives every upgrade. #472 fixed the endpoint; nothing migrated the stored value. An **unwritable**
- `./uploads` is therefore treated as damage this project caused and is moved to `./data/media` with a
- warning. A **writable** one is left exactly as it is, so a bare-metal install already serving media
- from that directory is never relocated out from under it.
-
- Installs carrying this value have been losing media quietly, not loudly: until v0.13.0 the image
- chowned all of `/app`, so writes to `/app/uploads` succeeded — into the container's ephemeral layer,
- outside the mounted volume, discarded on every container recreate. v0.13.0 narrowed that chown to
- `./data`, which is what finally turned a silent loss into a visible error.
+- Resolved five advisories in the production dependency tree via transitive bumps (`brace-expansion`, `fast-uri`, `hono`, `ip-address`, `socket.io-parser`); no direct dependency changed.
## [0.13.0] - 2026-08-03