[Feature]: Group isolation — per-chat scoping for webhooks and the read surface
Author: bhavyachopra99Created Sep 17, 2026Updated Sep 17, 2026
Pre-flight
- I searched existing issues and this isn't already requested
Problem / motivation
OpenWA links a full WhatsApp account. Any API key or dashboard session that can reach a session can read every chat on it — DMs included. For a personal number there is no way to let a downstream agent/tool see only a specific set of groups.
Two concrete gaps today:
- Webhook filters have no chat-id field. In
src/modules/webhook/filters/filter-types.ts,FILTER_FIELDS.messageexposessender,recipient,body,type,isGroup,kind,fromMe,hasMedia,mentions. In a group,senderresolves to the participant (author), sokind: "group"selects all groups and cannot be narrowed to chosen JIDs. There is nochatId. - Filters only gate webhook dispatch. The read surface is not scoped either:
GET /sessions/{id}/chats,/contacts, and/messages?chatId=return everything, andchatIdonGET /sessions/{id}/messagesis optional, so a bare call lists messages across all chats.
Use case: link a personal number, let an agent read only a curated set of groups, and keep personal DMs and all other groups off the wire. Today the only option is an external filtering proxy in front of the API.
Proposed solution
- Add a
chatIdfield to the message filter registry (kindid, operatorsis/isNot), resolvingdata.chatId ?? data.from. This looks like the documented extension point — one entry inFILTER_FIELDS.message, plus the dashboardMESSAGE_FIELDSlist and one i18n key. Happy to open a focused PR for this part. - Longer term: a group-level scope alongside the existing session-scoped API keys (
allowedSessions), enforced on the read surface (REST + MCP + dashboard). The repo already has route/query fence coverage machinery (global-route-fence-coverage.spec.ts,query-session-scope-coverage.spec.ts) that this could extend. Note thechatId-optional path onGET /messageswould need handling (requirechatIdor filter the result set), and list endpoints (/contacts,/groups) can't 403 — they would need filtering rather than rejection.
Alternatives considered
- External relay: receive the webhook and re-serve only allowlisted groups. Works, but every consumer must be prevented from reaching the OpenWA API directly, and it duplicates a scoping concept the server already implements for sessions.
- Forking to add a per-endpoint guard. High upstream-maintenance cost, and easy to miss a surface (list endpoints, MCP).
Scope
- I understand some features are limited by the underlying WhatsApp engine.
Environment: main, self-hosted. WhatsApp engine: Baileys.
Source: rmyndharis/OpenWA