Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
docs(engine): record where the engines answer the same call differently
Yudhi Armyndharis4f211a4d2466
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 9b1470ca3..b1e782d2a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -32,6 +32,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- A session launch that fails on a locked database is retried. The classifier looked for `SQLITE_BUSY` in the error message while the driver carries it on `code`, so the session stayed down until a restart.- Meta-hosted ids (`@hosted`, `@hosted.lid`) normalize to the dialect they name. They parsed as unknown before, so a chat surfaced with kind `unknown` and the same id was then refused with a `400` on any write.+### Documentation++- The API reference and capability matrix record where the two engines differ on calls both support: read receipts, edit, pin and unpin, the profile writes, mute, and the channel lookup.+## [0.21.0] - 2026-08-18### Fixeddiff --git a/docs/06-api-specification.md b/docs/06-api-specification.mdindex 05bcb152c..2c1e6e158 100644--- a/docs/06-api-specification.md+++ b/docs/06-api-specification.md@@ -852,6 +852,11 @@ Mark a chat as read/seen.Returns HTTP `200`, matching the OpenAPI contract.+> **`success: false` is a real outcome on the Baileys engine.** The read receipt is sent against the+> chat's last known message, so a chat the session has seen no message in is reported as declined+> rather than marked read. The whatsapp-web.js engine reads the chat from the page and needs no local+> history, so it never produces this outcome.+**Errors:** `400` validation, or session not started · `401` · `403` · `404` session not found · `409` the session is not connected (engine exists but is not `ready`) · `503` WhatsApp did not answer within the request budget, or the engine’s browser page died — the change may or may not have been applied#### POST /api/sessions/:sessionId/chats/unread@@ -1000,7 +1005,7 @@ Mute a chat's notifications until a given moment, or unmute it.> last message on either engine, so a chat with no known history mutes like any other. The response is> always `{ "success": true }` or an error.-**Errors:** `400` session not ready, or invalid `chatId`/`muteUntil` · `401` missing/invalid API key · `404` session not found · `409` the session is not connected (engine exists but is not `ready`) · `503` WhatsApp did not answer within the request budget, or the engine’s browser page died — the change may or may not have been applied+**Errors:** `400` session not ready, invalid `chatId`/`muteUntil`, or a `chatId` the whatsapp-web.js engine cannot resolve (the Baileys engine writes the mute without resolving the chat first and answers `success: true` for a chat that does not exist) · `401` missing/invalid API key · `404` session not found · `409` the session is not connected (engine exists but is not `ready`) · `503` WhatsApp did not answer within the request budget, or the engine’s browser page died — the change may or may not have been applied#### POST /api/sessions/:sessionId/chats/pin@@ -1042,7 +1047,7 @@ Pin a chat to the top of the chat list, or unpin it. Chat-level — distinct fro> not "the chat is pinned". Unlike `chats/archive` the patch is not keyed to the chat's last message,> so a chat with no known history pins normally.-**Errors:** `400` session not ready · `401` missing/invalid API key · `404` session not found · `409` the session is not connected (engine exists but is not `ready`) · `503` WhatsApp did not answer within the request budget, or the engine’s browser page died — the change may or may not have been applied+**Errors:** `400` session not ready, or a `chatId` the whatsapp-web.js engine cannot resolve (the Baileys engine answers `success: true` for a chat that does not exist) · `401` missing/invalid API key · `404` session not found · `409` the session is not connected (engine exists but is not `ready`) · `503` WhatsApp did not answer within the request budget, or the engine’s browser page died — the change may or may not have been applied#### POST /api/sessions/:sessionId/chats/delete@@ -1303,7 +1308,7 @@ Pin a message in its chat for a bounded window.**Response** `200` — `{ "success": true }`-**Errors:** `400` session not active, or `durationSeconds` outside the three accepted values · `401` missing/invalid API key · `403` the engine refused the pin (in a group only admins may pin) · `404` message not found in the chat · `409` conflict or engine not ready (retryable)+**Errors:** `400` session not active, or `durationSeconds` outside the three accepted values · `401` missing/invalid API key · `403` the whatsapp-web.js engine refused the pin (in a group only admins may pin; the Baileys engine has no acceptance signal and answers `200`) · `404` message not found in the chat · `409` conflict or engine not ready (retryable)> On whatsapp-web.js the message must be within the 100-message fetch window for the chat, the same> limit that applies to react/delete/edit. On Baileys it must be in the adapter's message store.@@ -1347,7 +1352,7 @@ Remove a message's pin. Takes no duration.**Response** `200` — `{ "success": true }`-**Errors:** `400` session not active · `401` missing/invalid API key · `403` the engine refused the unpin (in a group only admins may unpin) · `404` message not found in the chat · `409` conflict or engine not ready (retryable)+**Errors:** `400` session not active · `401` missing/invalid API key · `403` the whatsapp-web.js engine refused the unpin (in a group only admins may unpin; the Baileys engine has no acceptance signal and answers `200`) · `404` message not found in the chat · `409` conflict or engine not ready (retryable)#### GET /api/sessions/:sessionId/messages/:chatId/:messageId/media@@ -2063,7 +2068,7 @@ The edited message keeps its original id.{ "messageId": "[email protected]_3EB0ABCD", "timestamp": 1760000000 }```-**Errors:** `400` session not active / unknown body field · `401` missing/invalid API key · `403` key role below OPERATOR, or the engine refused the edit (only the account's own messages are editable, which WhatsApp enforces) · `404` message not found · `409` conflict or engine not ready (retryable)+**Errors:** `400` session not active / unknown body field · `401` missing/invalid API key · `403` key role below OPERATOR, or the engine refused the edit (both engines refuse a message the account did not send; whatsapp-web.js also refuses one that is not text, where the Baileys engine has no acceptance signal and answers `200`) · `404` message not found · `409` conflict or engine not ready (retryable)#### POST /api/sessions/:sessionId/messages/send-bulk@@ -3508,14 +3513,14 @@ List all channels/newsletters the session is subscribed to."description": "Release notes and tips","inviteCode": "ABC123xyz","subscriberCount": 1042,- "picture": "https://example.com/ch.jpg",- "verified": true,- "createdAt": 1717200000+ "verified": true}]```-Bare array, no envelope.+Bare array, no envelope. Only the whatsapp-web.js engine serves this route, and its channel mapping+fills neither `picture` nor `createdAt`, so neither field appears here even though the channel schema+declares them.**Errors:** `400` `Session is not started` · `401` missing/invalid API key · `409` conflict or engine not ready (retryable) · `501` not supported on the active engine@@ -3547,7 +3552,13 @@ Get a single channel/newsletter by its id.}```-**Errors:** `400` `Session is not started` · `401` missing/invalid API key · `404` `Channel <channelId> not found` (engine returned null) · `409` conflict or engine not ready (retryable) · `503` session not ready or dependency unavailable (retryable)+> **`picture` and `createdAt` are Baileys-only, and the lookup reaches further there.** The+> whatsapp-web.js engine exposes no per-id channel lookup, so the adapter scans the subscribed-channel+> list: a channel the account does not follow answers `404` even though it exists, and those two+> fields are always absent from the payload. The Baileys engine resolves any channel by id and fills+> both.++**Errors:** `400` `Session is not started` · `401` missing/invalid API key · `404` `Channel <channelId> not found` (engine returned null; on whatsapp-web.js this includes a channel the account does not follow) · `409` conflict or engine not ready (retryable) · `503` session not ready or dependency unavailable (retryable)#### GET /api/sessions/:sessionId/channels/:channelId/messages@@ -6128,7 +6139,7 @@ Set the account display name (max 25 chars).**Response** `200` — `{ "success": true, "message": "Profile name updated" }`-**Errors:** `400` session is not started / invalid name · `401` · `403` engine refused the change · `409` conflict or engine not ready (retryable) · `503` session not ready or dependency unavailable (retryable)+**Errors:** `400` session is not started / invalid name · `401` · `403` the whatsapp-web.js engine refused the change (the Baileys engine has no acceptance signal and answers `200`) · `409` conflict or engine not ready (retryable) · `503` session not ready or dependency unavailable (retryable)#### PUT /api/sessions/:sessionId/profile/status@@ -6162,7 +6173,7 @@ or**Response** `200` — `{ "success": true, "message": "Profile picture updated" }`-**Errors:** `400` neither `url` nor `base64` provided / base64 without `mimetype` · `401` · `403` engine refused the change · `409` conflict or engine not ready (retryable) · `413` payload too large · `503` session not ready or dependency unavailable (retryable)+**Errors:** `400` neither `url` nor `base64` provided / base64 without `mimetype` · `401` · `403` the whatsapp-web.js engine refused the change (the Baileys engine has no acceptance signal and answers `200`) · `409` conflict or engine not ready (retryable) · `413` payload too large · `503` session not ready or dependency unavailable (retryable)#### DELETE /api/sessions/:sessionId/profile/picturediff --git a/docs/29-engine-capability-matrix.md b/docs/29-engine-capability-matrix.mdindex 4c706fd0a..ee742c79c 100644--- a/docs/29-engine-capability-matrix.md+++ b/docs/29-engine-capability-matrix.md@@ -903,8 +903,33 @@ adapter boundary — none silently stubs.only).- **`getContactStatus` / `getContactStatuses` (wwjs).** `Status.type` is the `text|image|video`union — audio/other story types collapse to `text`.-- **`archiveChat` / `clearChatMessages` (baileys).** `chatModify` needs the chat's last known- message; a chat with no known history resolves `false` rather than throwing.+- **`archiveChat` / `clearChatMessages` / `deleteChat` / `sendSeen` / `markUnread` (baileys).** All+ five need the chat's last known message: `chatModify` carries it for the first three and for the+ unread mark, and the read receipt is `readMessages([key])`. A chat the session has seen no message+ in resolves `false` rather than throwing, so `POST chats/read` answers `{"success": false}` for a+ chat whatsapp-web.js marks read from the page-side chat object without needing any local history.+- **`setProfileName` / `setProfilePicture` / `deleteProfilePicture` refusals (baileys).**+ whatsapp-web.js reads a page-side verdict for all three (`setDisplayName` and `setProfilePicture`+ resolve `false`, `deleteProfilePicture` resolves an explicit `false`) and raises a `403`. The+ Baileys calls resolve with no acceptance signal, so a change WhatsApp declined answers `200`. Only+ `setProfileStatus` is symmetric: neither engine surfaces a refusal for it.+- **`editMessage` / `pinMessage` / `unpinMessage` refusals (baileys).** Both engines refuse what they+ can judge locally: the target must be addressable inside the given chat, and the Baileys adapter+ additionally refuses an edit of a message the account did not send. Past those guards they diverge.+ whatsapp-web.js reads a page-side verdict (`message.edit()` resolves `null`, `message.pin()`+ resolves `false`) and raises a `403`; Baileys sends the edit or pin as an ordinary protocol message+ and is never told the outcome. So a pin refused because the account is not a group admin, or an+ edit refused because the target is not a text message, answers `403` on whatsapp-web.js and `200`+ on Baileys.+- **`muteChat` addressing.** whatsapp-web.js resolves the chat before writing and answers `400` for a+ chatId it cannot resolve; Baileys writes the app-state patch without a lookup and answers `200` for+ a chat that does not exist. `pinChat` splits the same way.+- **`getChannelById` reach and payload.** Baileys resolves any channel by JID+ (`newsletterMetadata('jid', …)`), including one the account does not follow. whatsapp-web.js 1.34.x+ exposes no per-id lookup, so the adapter scans the subscribed-channel list and returns `null` (a+ `404`) for every channel the account is not subscribed to. The `Channel` payload differs too:+ whatsapp-web.js never fills `picture` or `createdAt`, both of which Baileys reads off the newsletter+ metadata.- **`starMessage` (baileys).** Needs the stored key's `fromMe` — the same id means differentmessages depending on direction.- **`addParticipants` result shape.** wwjs returns a per-participant `{code,message}` object or adiff --git a/openapi.json b/openapi.jsonindex cca95c915..fcbfc1e8c 100644--- a/openapi.json+++ b/openapi.json@@ -1038,7 +1038,7 @@},"responses": {"200": {- "description": "Chat marked as read successfully",+ "description": "Returns `{ success }`. `false` means the engine declined to act: the Baileys engine sends the read receipt against the chat's last known message, so a chat it has seen no message in is reported as declined rather than marked read. The whatsapp-web.js engine reads the chat from the page and needs no local history.","content": {"application/json": {"schema": {@@ -1415,7 +1415,7 @@}},"400": {- "description": "Session not ready, or an invalid chatId / muteUntil"+ "description": "Session not ready, an invalid chatId / muteUntil, or a chatId the whatsapp-web.js engine cannot resolve. The Baileys engine writes the mute without resolving the chat first and answers `success: true` for a chat that does not exist."},"404": {"description": "Session not found"@@ -3334,7 +3334,7 @@"description": "Session not active, or durationSeconds is not one of 86400 / 604800 / 2592000"},"403": {- "description": "The engine refused the pin — in a group only admins may pin"+ "description": "The whatsapp-web.js engine refused the pin (in a group only admins may pin). The Baileys engine has no acceptance signal and answers 200."},"404": {"description": "Message not found in the chat"@@ -3388,7 +3388,7 @@"description": "Session not active"},"403": {- "description": "The engine refused the unpin — in a group only admins may unpin"+ "description": "The whatsapp-web.js engine refused the unpin (in a group only admins may unpin). The Baileys engine has no acceptance signal and answers 200."},"404": {"description": "Message not found in the chat"@@ -3496,7 +3496,7 @@"description": "Session not active, invalid request, or the send was blocked by a plugin"},"403": {- "description": "The message was not sent by this account, or the engine refused the edit"+ "description": "The engine refused the edit. The Baileys adapter refuses a message the account did not send; whatsapp-web.js reads the refusal from the page, which also covers a message that is not text. Past its own guard the Baileys engine has no acceptance signal and answers 200."},"404": {"description": "Message not found"@@ -5970,7 +5970,7 @@"description": "Session is not started"},"403": {- "description": "The engine refused the name change"+ "description": "The whatsapp-web.js engine refused the name change. The Baileys engine has no acceptance signal and answers 200 for a rename WhatsApp declined."},"409": {"description": "The session is not connected — an engine exists for it but is not `ready`: disconnected, reconnecting, or still initializing, so the request never reached WhatsApp. Wait for `ready` and retry. A session that was never started answers `400` instead, and the session lifecycle routes answer `409` for a conflicting state rather than this. One window answers this while the session still reads `ready`: WhatsApp Web periodically reloads its own page and the engine re-injects into it — for those few seconds the answer is a `409` naming the reload; retry shortly."@@ -6075,7 +6075,7 @@"description": "Neither url nor base64 provided, base64 without mimetype, or session is not started"},"403": {- "description": "The engine refused the picture change"+ "description": "The whatsapp-web.js engine refused the picture change. The Baileys engine has no acceptance signal and answers 200 for an upload WhatsApp declined."},"409": {"description": "The session is not connected — an engine exists for it but is not `ready`: disconnected, reconnecting, or still initializing, so the request never reached WhatsApp. Wait for `ready` and retry. A session that was never started answers `400` instead, and the session lifecycle routes answer `409` for a conflicting state rather than this. One window answers this while the session still reads `ready`: WhatsApp Web periodically reloads its own page and the engine re-injects into it — for those few seconds the answer is a `409` naming the reload; retry shortly."@@ -6120,7 +6120,7 @@"description": "Session is not started"},"403": {- "description": "The engine refused the picture removal"+ "description": "The whatsapp-web.js engine refused the picture removal. The Baileys engine has no acceptance signal and answers 200 for a removal WhatsApp declined."},"409": {"description": "The session is not connected — an engine exists for it but is not `ready`: disconnected, reconnecting, or still initializing, so the request never reached WhatsApp. Wait for `ready` and retry. A session that was never started answers `400` instead, and the session lifecycle routes answer `409` for a conflicting state rather than this. One window answers this while the session still reads `ready`: WhatsApp Web periodically reloads its own page and the engine re-injects into it — for those few seconds the answer is a `409` naming the reload; retry shortly."@@ -6805,7 +6805,7 @@],"responses": {"200": {- "description": "Channel details",+ "description": "Channel details. The whatsapp-web.js engine never fills `picture` or `createdAt`; the Baileys engine reads both off the newsletter metadata.","content": {"application/json": {"schema": {@@ -6815,7 +6815,7 @@}},"404": {- "description": "Channel not found"+ "description": "Channel not found. On the whatsapp-web.js engine this also covers a channel that exists but the account does not follow, because the lookup scans the subscribed-channel list; the Baileys engine resolves any channel by id."},"409": {"description": "The session is not connected — an engine exists for it but is not `ready`: disconnected, reconnecting, or still initializing, so the request never reached WhatsApp. Wait for `ready` and retry. A session that was never started answers `400` instead, and the session lifecycle routes answer `409` for a conflicting state rather than this. One window answers this while the session still reads `ready`: WhatsApp Web periodically reloads its own page and the engine re-injects into it — for those few seconds the answer is a `409` naming the reload; retry shortly."diff --git a/src/modules/channel/channel.controller.ts b/src/modules/channel/channel.controller.tsindex 7c841a36a..e1478353d 100644--- a/src/modules/channel/channel.controller.ts+++ b/src/modules/channel/channel.controller.ts@@ -39,12 +39,24 @@ export class ChannelController {@ApiOperation({ summary: 'Get a specific channel by ID' })@ApiParam({ name: 'sessionId', description: 'Session ID' })@ApiParam({ name: 'channelId', description: 'Channel ID' })- @ApiResponse({ status: 200, description: 'Channel details', type: ChannelDto })+ @ApiResponse({+ status: 200,+ description:+ 'Channel details. The whatsapp-web.js engine never fills `picture` or `createdAt`; the Baileys ' ++ 'engine reads both off the newsletter metadata.',+ type: ChannelDto,+ })@ApiResponse({status: 503,description: 'WhatsApp did not answer within the request budget — the operation may or may not have applied.',})- @ApiResponse({ status: 404, description: 'Channel not found' })+ @ApiResponse({+ status: 404,+ description:+ 'Channel not found. On the whatsapp-web.js engine this also covers a channel that exists but ' ++ 'the account does not follow, because the lookup scans the subscribed-channel list; the Baileys ' ++ 'engine resolves any channel by id.',+ })@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })async findOne(@Param('sessionId') sessionId: string, @Param('channelId') channelId: string) {return this.channelService.getChannelById(sessionId, channelId);diff --git a/src/modules/message/message.controller.ts b/src/modules/message/message.controller.tsindex 999ae9042..a15ef14c6 100644--- a/src/modules/message/message.controller.ts+++ b/src/modules/message/message.controller.ts@@ -531,7 +531,12 @@ export class MessageController {status: 400,description: 'Session not active, or durationSeconds is not one of 86400 / 604800 / 2592000',})- @ApiResponse({ status: 403, description: 'The engine refused the pin — in a group only admins may pin' })+ @ApiResponse({+ status: 403,+ description:+ 'The whatsapp-web.js engine refused the pin (in a group only admins may pin). The Baileys ' ++ 'engine has no acceptance signal and answers 200.',+ })@ApiResponse({ status: 404, description: 'Message not found in the chat' })@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })async pinMessage(@Param('sessionId') sessionId: string, @Body() dto: PinMessageDto): Promise<{ success: boolean }> {@@ -545,7 +550,12 @@ export class MessageController {@ApiParam({ name: 'sessionId', description: 'Session ID' })@ApiResponse({ status: 200, description: 'Message unpinned', type: MessageActionResponseDto })@ApiResponse({ status: 400, description: 'Session not active' })- @ApiResponse({ status: 403, description: 'The engine refused the unpin — in a group only admins may unpin' })+ @ApiResponse({+ status: 403,+ description:+ 'The whatsapp-web.js engine refused the unpin (in a group only admins may unpin). The Baileys ' ++ 'engine has no acceptance signal and answers 200.',+ })@ApiResponse({ status: 404, description: 'Message not found in the chat' })@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })async unpinMessage(@@ -598,7 +608,10 @@ export class MessageController {})@ApiResponse({status: 403,- description: 'The message was not sent by this account, or the engine refused the edit',+ description:+ 'The engine refused the edit. The Baileys adapter refuses a message the account did not send; ' ++ 'whatsapp-web.js reads the refusal from the page, which also covers a message that is not text. ' ++ 'Past its own guard the Baileys engine has no acceptance signal and answers 200.',})@ApiResponse({ status: 404, description: 'Message not found' })@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })diff --git a/src/modules/profile/profile.controller.ts b/src/modules/profile/profile.controller.tsindex 10cccd733..0eded215f 100644--- a/src/modules/profile/profile.controller.ts+++ b/src/modules/profile/profile.controller.ts@@ -19,7 +19,12 @@ export class ProfileController {@ApiBody({ type: SetProfileNameDto })@ApiResponse({ status: 200, description: 'Profile name updated', type: ProfileAckResponseDto })@ApiResponse({ status: 400, description: 'Session is not started' })- @ApiResponse({ status: 403, description: 'The engine refused the name change' })+ @ApiResponse({+ status: 403,+ description:+ 'The whatsapp-web.js engine refused the name change. The Baileys engine has no acceptance ' ++ 'signal and answers 200 for a rename WhatsApp declined.',+ })@ApiResponse({status: 503,description:@@ -61,7 +66,12 @@ export class ProfileController {status: 400,description: 'Neither url nor base64 provided, base64 without mimetype, or session is not started',})- @ApiResponse({ status: 403, description: 'The engine refused the picture change' })+ @ApiResponse({+ status: 403,+ description:+ 'The whatsapp-web.js engine refused the picture change. The Baileys engine has no acceptance ' ++ 'signal and answers 200 for an upload WhatsApp declined.',+ })@ApiResponse({ status: 413, description: 'Decoded base64 image exceeds the configured media cap' })@ApiResponse({status: 503,@@ -81,7 +91,12 @@ export class ProfileController {@ApiParam({ name: 'sessionId', description: 'Session ID' })@ApiResponse({ status: 200, description: 'Profile picture removed', type: ProfileAckResponseDto })@ApiResponse({ status: 400, description: 'Session is not started' })- @ApiResponse({ status: 403, description: 'The engine refused the picture removal' })+ @ApiResponse({+ status: 403,+ description:+ 'The whatsapp-web.js engine refused the picture removal. The Baileys engine has no acceptance ' ++ 'signal and answers 200 for a removal WhatsApp declined.',+ })@ApiResponse({status: 503,description:diff --git a/src/modules/session/session.controller.ts b/src/modules/session/session.controller.tsindex c3a0130e8..b43955db4 100644--- a/src/modules/session/session.controller.ts+++ b/src/modules/session/session.controller.ts@@ -447,7 +447,15 @@ export class SessionController {@HttpCode(HttpStatus.OK)@ApiOperation({ summary: 'Mark a chat as read/seen' })@ApiParam({ name: 'sessionId', description: 'Session ID' })- @ApiResponse({ status: 200, description: 'Chat marked as read successfully', type: SessionActionResponseDto })+ @ApiResponse({+ status: 200,+ description:+ 'Returns `{ success }`. `false` means the engine declined to act: the Baileys engine sends the ' ++ "read receipt against the chat's last known message, so a chat it has seen no message in is " ++ 'reported as declined rather than marked read. The whatsapp-web.js engine reads the chat from ' ++ 'the page and needs no local history.',+ type: SessionActionResponseDto,+ })@ApiResponse({ status: 400, description: 'Session not ready' })@ApiResponse({ status: 404, description: 'Session not found' })@ApiResponse({@@ -642,7 +650,13 @@ export class SessionController {'history mutes like any other.',type: SessionActionResponseDto,})- @ApiResponse({ status: 400, description: 'Session not ready, or an invalid chatId / muteUntil' })+ @ApiResponse({+ status: 400,+ description:+ 'Session not ready, an invalid chatId / muteUntil, or a chatId the whatsapp-web.js engine ' ++ 'cannot resolve. The Baileys engine writes the mute without resolving the chat first and ' ++ 'answers `success: true` for a chat that does not exist.',+ })@ApiResponse({ status: 404, description: 'Session not found' })@ApiResponse({status: 503,