Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
docs: publish 2xx JSON response schemas for the remaining schemaless operations
Yudhi Armyndharis75effcf2e76f
diff --git a/openapi.json b/openapi.jsonindex cd1573d47..b1afed295 100644--- a/openapi.json+++ b/openapi.json@@ -320,7 +320,14 @@],"responses": {"200": {- "description": "API key is valid"+ "description": "API key is valid",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ValidateApiKeyResponseDto"+ }+ }+ }},"401": {"description": "Invalid or missing API key"@@ -854,7 +861,17 @@],"responses": {"200": {- "description": "List of groups the session is a member of"+ "description": "List of groups the session is a member of",+ "content": {+ "application/json": {+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/SessionGroupSummaryDto"+ }+ }+ }+ }},"400": {"description": "Session not ready"@@ -1018,7 +1035,14 @@},"responses": {"200": {- "description": "Chat marked as read successfully"+ "description": "Chat marked as read successfully",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/SessionActionResponseDto"+ }+ }+ }},"400": {"description": "Session not ready"@@ -1066,7 +1090,14 @@},"responses": {"200": {- "description": "Subscribed; updates now arrive as presence.update events"+ "description": "Subscribed; updates now arrive as presence.update events",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/SessionActionResponseDto"+ }+ }+ }},"400": {"description": "Session not started"@@ -1114,7 +1145,14 @@},"responses": {"200": {- "description": "Presence published"+ "description": "Presence published",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/SessionActionResponseDto"+ }+ }+ }},"400": {"description": "Session not started, or validation failed"@@ -1203,7 +1241,14 @@},"responses": {"200": {- "description": "Chat marked as unread successfully"+ "description": "Chat marked as unread successfully",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/SessionActionResponseDto"+ }+ }+ }},"400": {"description": "Session not ready"@@ -1249,7 +1294,14 @@],"responses": {"200": {- "description": "Returns `{ success }`. `false` means the engine declined to act — an unknown chat, or on the Baileys engine a chat with no known history, since the change is keyed to its last message."+ "description": "Returns `{ success }`. `false` means the engine declined to act — an unknown chat, or on the Baileys engine a chat with no known history, since the change is keyed to its last message.",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/SessionActionResponseDto"+ }+ }+ }},"400": {"description": "Session not ready"@@ -1296,7 +1348,14 @@},"responses": {"200": {- "description": "Returns `{ success }`. `false` means the engine declined to act — on the Baileys engine a chat with no known history cannot be archived, since the change is keyed to its last message."+ "description": "Returns `{ success }`. `false` means the engine declined to act — on the Baileys engine a chat with no known history cannot be archived, since the change is keyed to its last message.",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/SessionActionResponseDto"+ }+ }+ }},"400": {"description": "Session not ready"@@ -1343,7 +1402,14 @@},"responses": {"200": {- "description": "Returns `{ success: true }`. Unlike the archive route there is no declined outcome: the mute change is not keyed to the chat's last message on either engine, so a chat with no known history mutes like any other."+ "description": "Returns `{ success: true }`. Unlike the archive route there is no declined outcome: the mute change is not keyed to the chat's last message on either engine, so a chat with no known history mutes like any other.",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/SessionActionResponseDto"+ }+ }+ }},"400": {"description": "Session not ready, or an invalid chatId / muteUntil"@@ -1390,7 +1456,14 @@},"responses": {"200": {- "description": "Returns `{ success }`. `false` means the engine declined, and only a pin can: WhatsApp allows at most three pinned chats and the whatsapp-web.js engine reports the refusal. Unpinning always succeeds, and the Baileys engine always reports success because it cannot observe the cap."+ "description": "Returns `{ success }`. `false` means the engine declined, and only a pin can: WhatsApp allows at most three pinned chats and the whatsapp-web.js engine reports the refusal. Unpinning always succeeds, and the Baileys engine always reports success because it cannot observe the cap.",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/SessionActionResponseDto"+ }+ }+ }},"400": {"description": "Session not ready, or a chatId the session cannot resolve. An unknown chat is reported here rather than as `success: false`, which on this route means only that the three-pin cap refused a real chat. The Baileys engine cannot resolve chats ahead of the write and answers `success: true` for an unknown chat."@@ -1437,7 +1510,14 @@},"responses": {"200": {- "description": "Chat deleted successfully"+ "description": "Chat deleted successfully",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/SessionActionResponseDto"+ }+ }+ }},"400": {"description": "Session not ready"@@ -1484,7 +1564,14 @@},"responses": {"200": {- "description": "Presence sent"+ "description": "Presence sent",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/SessionActionResponseDto"+ }+ }+ }},"404": {"description": "Session not found"@@ -1505,7 +1592,14 @@"parameters": [],"responses": {"200": {- "description": "Session statistics including counts and memory usage"+ "description": "Session statistics including counts and memory usage",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/SessionsOverviewResponseDto"+ }+ }+ }}},"summary": "Get session statistics for multi-session monitoring",@@ -1745,7 +1839,14 @@],"responses": {"200": {- "description": "Test result"+ "description": "Test result",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/WebhookTestResponseDto"+ }+ }+ }},"404": {"description": "Webhook not found"@@ -1791,7 +1892,17 @@],"responses": {"200": {- "description": "Permanently-failed webhook deliveries, most recent first"+ "description": "Permanently-failed webhook deliveries, most recent first",+ "content": {+ "application/json": {+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/WebhookDeliveryFailureDto"+ }+ }+ }+ }}},"summary": "List recently-failed webhook deliveries (all retries exhausted)",@@ -2105,7 +2216,14 @@],"responses": {"200": {- "description": "Message history"+ "description": "Message history",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/MessageListResponseDto"+ }+ }+ }}},"summary": "Get message history for a session",@@ -2847,7 +2965,14 @@},"responses": {"200": {- "description": "Reaction added or removed. Send empty emoji to remove reaction."+ "description": "Reaction added or removed. Send empty emoji to remove reaction.",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/MessageActionResponseDto"+ }+ }+ }},"400": {"description": "Session not active or message not found"@@ -2918,7 +3043,17 @@],"responses": {"200": {- "description": "Chat history (most recent messages)"+ "description": "Chat history (most recent messages)",+ "content": {+ "application/json": {+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/ChatHistoryMessageDto"+ }+ }+ }+ }},"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."@@ -2967,7 +3102,17 @@],"responses": {"200": {- "description": "List of reactions with senders"+ "description": "List of reactions with senders",+ "content": {+ "application/json": {+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/MessageReactionDto"+ }+ }+ }+ }},"404": {"description": "No such message — the id is outside the engine's lookup window (roughly the last hundred messages of the chat, or absent from the Baileys store) or the message was revoked."@@ -3065,7 +3210,14 @@},"responses": {"200": {- "description": "Message deleted"+ "description": "Message deleted",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/MessageActionResponseDto"+ }+ }+ }},"400": {"description": "Session not active or message not found"@@ -3112,7 +3264,14 @@},"responses": {"200": {- "description": "Vote cast"+ "description": "Vote cast",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/MessageActionResponseDto"+ }+ }+ }},"400": {"description": "Session not active, or the target message is not a poll"@@ -3159,7 +3318,14 @@},"responses": {"200": {- "description": "Message pinned"+ "description": "Message pinned",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/MessageActionResponseDto"+ }+ }+ }},"400": {"description": "Session not active, or durationSeconds is not one of 86400 / 604800 / 2592000"@@ -3206,7 +3372,14 @@},"responses": {"200": {- "description": "Message unpinned"+ "description": "Message unpinned",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/MessageActionResponseDto"+ }+ }+ }},"400": {"description": "Session not active"@@ -3253,7 +3426,14 @@},"responses": {"200": {- "description": "Instruction delivered. On whatsapp-web.js the engine silently ignores a message it will not star, so this does not guarantee the star is set."+ "description": "Instruction delivered. On whatsapp-web.js the engine silently ignores a message it will not star, so this does not guarantee the star is set.",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/MessageActionResponseDto"+ }+ }+ }},"400": {"description": "Session not active"@@ -3398,7 +3578,14 @@],"responses": {"200": {- "description": "Batch status and progress"+ "description": "Batch status and progress",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/BatchStatusResponseDto"+ }+ }+ }},"404": {"description": "Batch not found"@@ -3435,7 +3622,14 @@],"responses": {"200": {- "description": "Batch cancelled"+ "description": "Batch cancelled",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/BatchCancelResponseDto"+ }+ }+ }},"400": {"description": "Batch already completed, cancelled, or failed (terminal statuses are exclusive)"@@ -8072,7 +8266,17 @@"parameters": [],"responses": {"200": {- "description": "Catalog entries"+ "description": "Catalog entries",+ "content": {+ "application/json": {+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/PluginCatalogEntryDto"+ }+ }+ }+ }},"400": {"description": "Catalog could not be fetched or parsed"@@ -8131,7 +8335,14 @@],"responses": {"200": {- "description": "Plugin uninstalled"+ "description": "Plugin uninstalled",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/PluginActionResponseDto"+ }+ }+ }},"400": {"description": "Cannot uninstall (e.g. built-in)"@@ -8161,7 +8372,14 @@],"responses": {"200": {- "description": "Plugin enabled successfully"+ "description": "Plugin enabled successfully",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/PluginActionResponseDto"+ }+ }+ }}},"summary": "Enable a plugin",@@ -8185,7 +8403,14 @@],"responses": {"200": {- "description": "Plugin disabled successfully"+ "description": "Plugin disabled successfully",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/PluginActionResponseDto"+ }+ }+ }}},"summary": "Disable a plugin",@@ -8219,7 +8444,14 @@},"responses": {"200": {- "description": "Plugin configuration updated"+ "description": "Plugin configuration updated",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/PluginActionResponseDto"+ }+ }+ }}},"summary": "Update plugin configuration",@@ -8295,7 +8527,14 @@},"responses": {"200": {- "description": "Per-session plugin configuration updated"+ "description": "Per-session plugin configuration updated",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/PluginActionResponseDto"+ }+ }+ }},"400": {"description": "Plugin is global (not session-scoped)"@@ -8422,7 +8661,14 @@],"responses": {"200": {- "description": "Plugin health status"+ "description": "Plugin health status",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/PluginHealthResponseDto"+ }+ }+ }}},"summary": "Check plugin health",@@ -8862,7 +9108,14 @@],"responses": {"201": {- "description": "One bounded batch of dead-lettered ingress deliveries re-dispatched, with remaining depth."+ "description": "One bounded batch of dead-lettered ingress deliveries re-dispatched, with remaining depth.",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/RedriveResultDto"+ }+ }+ }}},"tags": [@@ -9678,6 +9931,28 @@}}},+ "ValidateApiKeyResponseDto": {+ "type": "object",+ "properties": {+ "valid": {+ "type": "boolean",+ "description": "Whether the presented API key is valid.",+ "example": true+ },+ "role": {+ "type": "string",+ "enum": [+ "admin",+ "operator",+ "viewer"+ ],+ "description": "The key's role; present only when valid."+ }+ },+ "required": [+ "valid"+ ]+ },"CreateSessionDto": {"type": "object","properties": {@@ -9949,30 +10224,55 @@"status"]},- "ChatSummaryDto": {+ "SessionGroupSummaryDto": {"type": "object","properties": {"id": {"type": "string",- "example": "[email protected]"+ "description": "Group id.",+ "example": "[email protected]"},"name": {"type": "string",- "example": "Alice"- },- "isGroup": {- "type": "boolean",- "description": "Retained for back-compat; true for @g.us chats.",- "example": false+ "description": "Group subject.",+ "example": "Engineering"},- "kind": {+ "linkedParentJID": {"type": "string",- "enum": [- "individual",- "group",- "channel",- "status",- "broadcast",+ "nullable": true,+ "description": "JID of the parent community, or null when the group is standalone.",+ "example": null+ }+ },+ "required": [+ "id",+ "name"+ ]+ },+ "ChatSummaryDto": {+ "type": "object",+ "properties": {+ "id": {+ "type": "string",+ "example": "[email protected]"+ },+ "name": {+ "type": "string",+ "example": "Alice"+ },+ "isGroup": {+ "type": "boolean",+ "description": "Retained for back-compat; true for @g.us chats.",+ "example": false+ },+ "kind": {+ "type": "string",+ "enum": [+ "individual",+ "group",+ "channel",+ "status",+ "broadcast","unknown"],"description": "User-facing chat kind.",@@ -10014,6 +10314,19 @@"chatId"]},+ "SessionActionResponseDto": {+ "type": "object",+ "properties": {+ "success": {+ "type": "boolean",+ "description": "Whether the engine applied the change. Routes where the engine can decline spell out what `false` means in their own description; on the rest it is always `true`.",+ "example": true+ }+ },+ "required": [+ "success"+ ]+ },"SubscribePresenceDto": {"type": "object","properties": {@@ -10195,6 +10508,83 @@"state"]},+ "SessionMemoryUsageDto": {+ "type": "object",+ "properties": {+ "heapUsed": {+ "type": "number",+ "description": "V8 heap in use, in MiB.",+ "example": 128+ },+ "heapTotal": {+ "type": "number",+ "description": "V8 heap reserved, in MiB.",+ "example": 256+ },+ "rss": {+ "type": "number",+ "description": "Resident set size, in MiB.",+ "example": 512+ }+ },+ "required": [+ "heapUsed",+ "heapTotal",+ "rss"+ ]+ },+ "SessionsOverviewResponseDto": {+ "type": "object",+ "properties": {+ "total": {+ "type": "number",+ "description": "Sessions on record, connected or not.",+ "example": 5+ },+ "active": {+ "type": "number",+ "description": "Sessions with a live engine in this process.",+ "example": 2+ },+ "ready": {+ "type": "number",+ "description": "Sessions whose status is 'ready'.",+ "example": 2+ },+ "disconnected": {+ "type": "number",+ "description": "Sessions whose status is 'disconnected'.",+ "example": 3+ },+ "byStatus": {+ "type": "object",+ "description": "Session count per status value.",+ "example": {+ "ready": 2,+ "disconnected": 3+ },+ "additionalProperties": {+ "type": "integer"+ }+ },+ "memoryUsage": {+ "description": "Process memory usage of this gateway.",+ "allOf": [+ {+ "$ref": "#/components/schemas/SessionMemoryUsageDto"+ }+ ]+ }+ },+ "required": [+ "total",+ "active",+ "ready",+ "disconnected",+ "byStatus",+ "memoryUsage"+ ]+ },"CreateWebhookDto": {"type": "object","properties": {@@ -10439,6 +10829,93 @@}}},+ "WebhookTestResponseDto": {+ "type": "object",+ "properties": {+ "success": {+ "type": "boolean",+ "description": "True when the receiver answered 2xx.",+ "example": true+ },+ "statusCode": {+ "type": "number",+ "description": "The HTTP status the receiver answered, when it answered.",+ "example": 200+ },+ "error": {+ "type": "string",+ "description": "The delivery error, when the attempt failed.",+ "example": "timeout"+ }+ },+ "required": [+ "success"+ ]+ },+ "WebhookDeliveryFailureDto": {+ "type": "object",+ "properties": {+ "id": {+ "type": "string",+ "example": "0a941dac-a965-45e7-b318-74ae8be134f0"+ },+ "webhookId": {+ "type": "string",+ "example": "0a941dac-a965-45e7-b318-74ae8be134f0"+ },+ "sessionId": {+ "type": "string",+ "example": "0a941dac-a965-45e7-b318-74ae8be134f0"+ },+ "event": {+ "type": "string",+ "example": "message.received"+ },+ "url": {+ "type": "string",+ "example": "https://receiver.example.com/hook"+ },+ "idempotencyKey": {+ "type": "string",+ "nullable": true,+ "description": "The idempotency key the receiver would have deduped on."+ },+ "deliveryId": {+ "type": "string",+ "nullable": true+ },+ "attempts": {+ "type": "number",+ "description": "Total attempts made before giving up.",+ "example": 5+ },+ "lastStatusCode": {+ "type": "number",+ "nullable": true,+ "description": "Last HTTP status when the failure was a non-2xx response; null for a network/timeout error.",+ "example": null+ },+ "lastError": {+ "type": "string",+ "example": "connect ECONNREFUSED 10.0.0.1:443"+ },+ "createdAt": {+ "type": "string",+ "format": "date-time",+ "description": "When the delivery was finally abandoned."+ }+ },+ "required": [+ "id",+ "webhookId",+ "sessionId",+ "event",+ "url",+ "attempts",+ "lastError",+ "createdAt"+ ]+ },"CreateAutomationRuleDto": {"type": "object","properties": {@@ -10551,93 +11028,225 @@}}},- "CustomLinkPreviewDto": {+ "MessageListItemDto": {"type": "object","properties": {- "url": {+ "id": {"type": "string",- "description": "The URL as it appears in the message text — WhatsApp anchors the preview to it.",- "example": "https://example.com/launch"+ "example": "0a941dac-a965-45e7-b318-74ae8be134f0"},- "title": {+ "sessionId": {"type": "string",- "description": "Required: WhatsApp will not render a preview without a title.",- "example": "We just launched",- "maxLength": 256+ "example": "0a941dac-a965-45e7-b318-74ae8be134f0"},- "description": {+ "waMessageId": {"type": "string",- "description": "Preview description",- "example": "Read the announcement.",- "maxLength": 1024- }- },- "required": [- "url",- "title"- ]- },- "SendTextMessageDto": {- "type": "object",- "properties": {+ "nullable": true,+ "description": "WhatsApp message id, once the engine has assigned one.",+ "example": "[email protected]_3EB0123456789"+ },"chatId": {"type": "string",- "description": "WhatsApp chat ID ([email protected] for individual, [email protected] for groups)","example": "[email protected]"},- "text": {+ "chatName": {"type": "string",- "description": "Text message content",- "example": "Hello from OpenWA!",- "maxLength": 4096+ "nullable": true,+ "description": "Human-readable chat name when known (contact pushName, group subject).",+ "example": "Alice"},- "mentions": {- "description": "WIDs to @mention (e.g. [\"[email protected]\"]). The text/caption must also contain the @<number> token.",- "example": [- ],- "type": "array",- "items": {- "type": "string"- }+ "author": {+ "type": "string",+ "nullable": true,+ "description": "Group participant who posted the message (`from` is the group JID there).",+ "example": "[email protected]"},- "linkPreview": {- "type": "boolean",- "description": "Controls the URL preview, and the engines differ. On whatsapp-web.js WhatsApp Web builds one by default and `false` suppresses it. On Baileys previews are OPT-IN: `true` asks the gateway to fetch the page and attach one, while unset or `false` sends none — generating a preview is a blocking outbound fetch per URL in the text, so it is never done unless asked for.",- "example": false+ "from": {+ "type": "string",+ "example": "[email protected]"},- "customLinkPreview": {- "description": "Attach a preview you supply yourself, instead of one fetched from the URL. Nothing is fetched for these, so a preview can be attached even for a URL this server cannot reach. **Baileys only** — whatsapp-web.js takes a boolean and answers `501`. Cannot be combined with `linkPreview: false`, which asks for the opposite.",- "allOf": [- {- "$ref": "#/components/schemas/CustomLinkPreviewDto"- }- ]+ "to": {+ "type": "string",+ "example": "[email protected]"},- "quotedMessageId": {+ "body": {"type": "string",- "description": "Quote an earlier message, turning this send into a reply. The id is engine-specific: whatsapp-web.js matches the serialized message id, Baileys matches the raw message key id and can only quote a message it has already stored. An id that cannot be resolved fails the send rather than delivering it unquoted.",- "example": "[email protected]_3EB0ABCD"- }- },- "required": [- "chatId",- "text"- ]- },- "MessageResponseDto": {- "type": "object",- "properties": {- "messageId": {+ "nullable": true,+ "description": "Message text body.",+ "example": "hi"+ },+ "type": {"type": "string",- "description": "The message id, assigned when the gateway accepts the message for sending. A 201 here means the message was handed to the WhatsApp client — it does NOT confirm delivery. WhatsApp does not reject an unregistered recipient synchronously, so a message to a number that is not on WhatsApp still returns 201 with a valid messageId; whether it later delivers, stalls, or is reported as an error reaches you asynchronously, if at all. To confirm a number is on WhatsApp before sending, use GET /api/sessions/{sessionId}/contacts/check/{number}; track real delivery via the message `status` field (sent → delivered → read, or failed if WhatsApp reports an error for it). A message resting at `sent` is not diagnostic on its own: a registered recipient whose device has not come online since the send stays at `sent` too.",- "example": "[email protected]_3EB0123456789"+ "description": "Engine-neutral message type.",+ "example": "text"},- "timestamp": {- "type": "number",- "description": "Unix timestamp (seconds) at which the gateway accepted the message for sending.",- "example": 1706868000- }+ "direction": {+ "type": "string",+ "enum": [+ "incoming",+ "outgoing"+ ],+ "example": "incoming"+ },+ "timestamp": {+ "type": "number",+ "nullable": true,+ "description": "Unix seconds the message was sent, when the engine reported one.",+ "example": 1700000010+ },+ "metadata": {+ "type": "object",+ "nullable": true,+ "description": "Engine-specific extras (media inline copy, poll data, …). Absent when none were stored.",+ "additionalProperties": true+ },+ "mediaPath": {+ "type": "string",+ "nullable": true,+ "description": "Storage key of the archived media, when one was archived."+ },+ "mediaMimetype": {+ "type": "string",+ "nullable": true,+ "description": "Mimetype of the archived media."+ },+ "status": {+ "type": "string",+ "enum": [+ "pending",+ "sent",+ "delivered",+ "read",+ "failed"+ ],+ "example": "delivered"+ },+ "createdAt": {+ "type": "string",+ "format": "date-time",+ "example": "2026-08-13T09:00:00Z"+ }+ },+ "required": [+ "id",+ "sessionId",+ "chatId",+ "from",+ "to",+ "type",+ "direction",+ "status",+ "createdAt"+ ]+ },+ "MessageListResponseDto": {+ "type": "object",+ "properties": {+ "messages": {+ "description": "Newest first.",+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/MessageListItemDto"+ }+ },+ "total": {+ "type": "number",+ "description": "Total rows matching the filters (before pagination).",+ "example": 132+ }+ },+ "required": [+ "messages",+ "total"+ ]+ },+ "CustomLinkPreviewDto": {+ "type": "object",+ "properties": {+ "url": {+ "type": "string",+ "description": "The URL as it appears in the message text — WhatsApp anchors the preview to it.",+ "example": "https://example.com/launch"+ },+ "title": {+ "type": "string",+ "description": "Required: WhatsApp will not render a preview without a title.",+ "example": "We just launched",+ "maxLength": 256+ },+ "description": {+ "type": "string",+ "description": "Preview description",+ "example": "Read the announcement.",+ "maxLength": 1024+ }+ },+ "required": [+ "url",+ "title"+ ]+ },+ "SendTextMessageDto": {+ "type": "object",+ "properties": {+ "chatId": {+ "type": "string",+ "description": "WhatsApp chat ID ([email protected] for individual, [email protected] for groups)",+ "example": "[email protected]"+ },+ "text": {+ "type": "string",+ "description": "Text message content",+ "example": "Hello from OpenWA!",+ "maxLength": 4096+ },+ "mentions": {+ "description": "WIDs to @mention (e.g. [\"[email protected]\"]). The text/caption must also contain the @<number> token.",+ "example": [+ ],+ "type": "array",+ "items": {+ "type": "string"+ }+ },+ "linkPreview": {+ "type": "boolean",+ "description": "Controls the URL preview, and the engines differ. On whatsapp-web.js WhatsApp Web builds one by default and `false` suppresses it. On Baileys previews are OPT-IN: `true` asks the gateway to fetch the page and attach one, while unset or `false` sends none — generating a preview is a blocking outbound fetch per URL in the text, so it is never done unless asked for.",+ "example": false+ },+ "customLinkPreview": {+ "description": "Attach a preview you supply yourself, instead of one fetched from the URL. Nothing is fetched for these, so a preview can be attached even for a URL this server cannot reach. **Baileys only** — whatsapp-web.js takes a boolean and answers `501`. Cannot be combined with `linkPreview: false`, which asks for the opposite.",+ "allOf": [+ {+ "$ref": "#/components/schemas/CustomLinkPreviewDto"+ }+ ]+ },+ "quotedMessageId": {+ "type": "string",+ "description": "Quote an earlier message, turning this send into a reply. The id is engine-specific: whatsapp-web.js matches the serialized message id, Baileys matches the raw message key id and can only quote a message it has already stored. An id that cannot be resolved fails the send rather than delivering it unquoted.",+ "example": "[email protected]_3EB0ABCD"+ }+ },+ "required": [+ "chatId",+ "text"+ ]+ },+ "MessageResponseDto": {+ "type": "object",+ "properties": {+ "messageId": {+ "type": "string",+ "description": "The message id, assigned when the gateway accepts the message for sending. A 201 here means the message was handed to the WhatsApp client — it does NOT confirm delivery. WhatsApp does not reject an unregistered recipient synchronously, so a message to a number that is not on WhatsApp still returns 201 with a valid messageId; whether it later delivers, stalls, or is reported as an error reaches you asynchronously, if at all. To confirm a number is on WhatsApp before sending, use GET /api/sessions/{sessionId}/contacts/check/{number}; track real delivery via the message `status` field (sent → delivered → read, or failed if WhatsApp reports an error for it). A message resting at `sent` is not diagnostic on its own: a registered recipient whose device has not come online since the send stays at `sent` too.",+ "example": "[email protected]_3EB0123456789"+ },+ "timestamp": {+ "type": "number",+ "description": "Unix timestamp (seconds) at which the gateway accepted the message for sending.",+ "example": 1706868000+ }},"required": ["messageId",@@ -10907,44 +11516,416 @@"text"]},- "ForwardMessageDto": {+ "ForwardMessageDto": {+ "type": "object",+ "properties": {+ "fromChatId": {+ "type": "string"+ },+ "toChatId": {+ "type": "string"+ },+ "messageId": {+ "type": "string"+ }+ },+ "required": [+ "fromChatId",+ "toChatId",+ "messageId"+ ]+ },+ "ReactMessageDto": {+ "type": "object",+ "properties": {+ "chatId": {+ "type": "string"+ },+ "messageId": {+ "type": "string"+ },+ "emoji": {+ "type": "string",+ "description": "Emoji to react with. Send an empty string to remove the reaction.",+ "maxLength": 32+ }+ },+ "required": [+ "chatId",+ "messageId",+ "emoji"+ ]+ },+ "MessageActionResponseDto": {+ "type": "object",+ "properties": {+ "success": {+ "type": "boolean",+ "description": "Always true — a failure is reported as a non-2xx status, not as false.",+ "example": true+ }+ },+ "required": [+ "success"+ ]+ },+ "ChatHistoryCallDto": {+ "type": "object",+ "properties": {+ "video": {+ "type": "boolean",+ "description": "Video (true) vs voice (false) call.",+ "example": false+ },+ "missed": {+ "type": "boolean",+ "description": "Whether an incoming call went unanswered.",+ "example": true+ }+ },+ "required": [+ "video",+ "missed"+ ]+ },+ "ChatHistoryContactDto": {+ "type": "object",+ "properties": {+ "id": {+ "type": "string",+ "description": "Sender JID (`…@c.us` or a `…@lid` privacy id).",+ "example": "[email protected]"+ },+ "number": {+ "type": "string",+ "description": "Phone digits, best-effort.",+ "example": "628123456789"+ },+ "name": {+ "type": "string",+ "example": "Alice"+ },+ "pushName": {+ "type": "string",+ "example": "Alice"+ },+ "shortName": {+ "type": "string",+ "example": "Al"+ },+ "type": {+ "type": "string",+ "description": "Engine contact type token.",+ "example": "in"+ },+ "isMyContact": {+ "type": "boolean",+ "description": "Saved in the account address book.",+ "example": true+ },+ "isWAContact": {+ "type": "boolean",+ "description": "Is a WhatsApp user.",+ "example": true+ },+ "isBusiness": {+ "type": "boolean",+ "example": false+ },+ "isEnterprise": {+ "type": "boolean",+ "example": false+ },+ "verifiedName": {+ "type": "string",+ "description": "Business verified name."+ },+ "verifiedLevel": {+ "type": "number",+ "description": "Business verification level.",+ "example": 2+ },+ "isBlocked": {+ "type": "boolean",+ "example": false+ },+ "labels": {+ "description": "Label ids (CRM); names are not resolved.",+ "type": "array",+ "items": {+ "type": "string"+ }+ }+ }+ },+ "ChatHistoryMediaDto": {+ "type": "object",+ "properties": {+ "mimetype": {+ "type": "string",+ "example": "image/jpeg"+ },+ "filename": {+ "type": "string",+ "example": "photo.jpg"+ },+ "data": {+ "type": "string",+ "description": "Base64 payload; absent when the blob was omitted."+ },+ "omitted": {+ "type": "boolean",+ "description": "True when the blob was dropped by a size cap, timeout, or saturation."+ },+ "sizeBytes": {+ "type": "number",+ "description": "Decoded byte size of the media; always set when omitted.",+ "example": 102400+ }+ },+ "required": [+ "mimetype"+ ]+ },+ "ChatHistoryQuotedMessageDto": {+ "type": "object",+ "properties": {+ "id": {+ "type": "string",+ "example": "[email protected]_3EB0123456789"+ },+ "body": {+ "type": "string",+ "example": "original text"+ }+ },+ "required": [+ "id",+ "body"+ ]+ },+ "ChatHistoryLocationDto": {+ "type": "object",+ "properties": {+ "latitude": {+ "type": "number",+ "example": -6.2088+ },+ "longitude": {+ "type": "number",+ "example": 106.8456+ },+ "description": {+ "type": "string",+ "example": "Monas"+ },+ "address": {+ "type": "string",+ "example": "Jakarta"+ },+ "url": {+ "type": "string",+ "example": "https://maps.example.com/…"+ }+ },+ "required": [+ "latitude",+ "longitude"+ ]+ },+ "ChatHistoryMessageDto": {+ "type": "object",+ "properties": {+ "id": {+ "type": "string",+ "example": "[email protected]_3EB0123456789"+ },+ "from": {+ "type": "string",+ "example": "[email protected]"+ },+ "to": {+ "type": "string",+ "example": "[email protected]"+ },+ "chatId": {+ "type": "string",+ "example": "[email protected]"+ },+ "body": {+ "type": "string",+ "example": "hi"+ },+ "type": {+ "type": "string",+ "enum": [+ "text",+ "image",+ "video",+ "audio",+ "voice",+ "document",+ "sticker",+ "location",+ "contact",+ "poll",+ "call",+ "revoked",+ "masked",+ "unknown"+ ],+ "description": "Engine-neutral message type.",+ "example": "text"+ },+ "timestamp": {+ "type": "number",+ "description": "Unix seconds the message was sent.",+ "example": 1700000010+ },+ "fromMe": {+ "type": "boolean",+ "example": false+ },+ "isGroup": {+ "type": "boolean",+ "example": false+ },+ "kind": {+ "type": "string",+ "enum": [+ "individual",+ "group",+ "channel",+ "status",+ "broadcast",+ "unknown"+ ],+ "description": "User-facing chat kind of the conversation.",+ "example": "individual"+ },+ "isStatusBroadcast": {+ "type": "boolean",+ "description": "True for a status/story broadcast.",+ "example": false+ },+ "ephemeralDuration": {+ "type": "number",+ "description": "Disappearing-messages timer in seconds; 0 or absent means off.",+ "example": 0+ },+ "author": {+ "type": "string",+ "description": "Group participant who actually sent it (`from` is the group JID there).",+ "example": "[email protected]"+ },+ "mentionedIds": {+ "description": "WIDs @mentioned in the message.",+ "type": "array",+ "items": {+ "type": "string"+ }+ },+ "call": {+ "description": "Set for `call` messages.",+ "allOf": [+ {+ "$ref": "#/components/schemas/ChatHistoryCallDto"+ }+ ]+ },+ "isLidSender": {+ "type": "boolean",+ "description": "Sender is identified by a privacy id rather than a phone number."+ },+ "senderPhone": {+ "type": "string",+ "nullable": true,+ "description": "Best-effort phone digits of a privacy-id sender, when resolved.",+ "example": null+ },+ "contact": {+ "description": "Sender contact info, best-effort.",+ "allOf": [+ {+ "$ref": "#/components/schemas/ChatHistoryContactDto"+ }+ ]+ },+ "backgroundColor": {+ "type": "string",+ "description": "Text-status background as `#RRGGBB`.",+ "example": "#FF5733"+ },+ "font": {+ "type": "number",+ "description": "Text-status WhatsApp font index.",+ "example": 1+ },+ "media": {+ "$ref": "#/components/schemas/ChatHistoryMediaDto"+ },+ "quotedMessage": {+ "$ref": "#/components/schemas/ChatHistoryQuotedMessageDto"+ },+ "location": {+ "$ref": "#/components/schemas/ChatHistoryLocationDto"+ }+ },+ "required": [+ "id",+ "from",+ "to",+ "chatId",+ "body",+ "type",+ "timestamp",+ "fromMe",+ "isGroup",+ "kind"+ ]+ },+ "MessageReactionSenderDto": {"type": "object","properties": {- "fromChatId": {- "type": "string"+ "senderId": {+ "type": "string",+ "example": "[email protected]"},- "toChatId": {- "type": "string"+ "emoji": {+ "type": "string",+ "example": "👍"},- "messageId": {- "type": "string"+ "timestamp": {+ "type": "number",+ "description": "Unix seconds the reaction was placed.",+ "example": 1700000010}},"required": [- "fromChatId",- "toChatId",- "messageId"+ "senderId",+ "emoji",+ "timestamp"]},- "ReactMessageDto": {+ "MessageReactionDto": {"type": "object","properties": {- "chatId": {- "type": "string"- },- "messageId": {- "type": "string"- },"emoji": {"type": "string",- "description": "Emoji to react with. Send an empty string to remove the reaction.",- "maxLength": 32+ "description": "The emoji this entry groups.",+ "example": "👍"+ },+ "senders": {+ "description": "Who placed this emoji.",+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/MessageReactionSenderDto"+ }}},"required": [- "chatId",- "messageId",- "emoji"+ "emoji",+ "senders"]},"DeleteMessageDto": {@@ -11257,6 +12238,173 @@"statusUrl"]},+ "BatchProgressDto": {+ "type": "object",+ "properties": {+ "total": {+ "type": "number",+ "example": 10+ },+ "sent": {+ "type": "number",+ "example": 7+ },+ "failed": {+ "type": "number",+ "example": 1+ },+ "pending": {+ "type": "number",+ "example": 2+ },+ "cancelled": {+ "type": "number",+ "example": 0+ }+ },+ "required": [+ "total",+ "sent",+ "failed",+ "pending",+ "cancelled"+ ]+ },+ "BatchMessageErrorDto": {+ "type": "object",+ "properties": {+ "code": {+ "type": "string",+ "description": "Machine-readable failure code.",+ "example": "RECIPIENT_UNREACHABLE"+ },+ "message": {+ "type": "string",+ "example": "The number is not registered on WhatsApp"+ }+ },+ "required": [+ "code",+ "message"+ ]+ },+ "BatchMessageResultDto": {+ "type": "object",+ "properties": {+ "chatId": {+ "type": "string",+ "example": "[email protected]"+ },+ "status": {+ "type": "string",+ "enum": [+ "pending",+ "sent",+ "failed",+ "cancelled"+ ],+ "example": "sent"+ },+ "messageId": {+ "type": "string",+ "description": "Assigned on a successful send.",+ "example": "[email protected]_3EB0123456789"+ },+ "error": {+ "description": "Present on a failed send.",+ "allOf": [+ {+ "$ref": "#/components/schemas/BatchMessageErrorDto"+ }+ ]+ },+ "sentAt": {+ "type": "string",+ "format": "date-time",+ "description": "When the send completed."+ }+ },+ "required": [+ "chatId",+ "status"+ ]+ },+ "BatchStatusResponseDto": {+ "type": "object",+ "properties": {+ "batchId": {+ "type": "string",+ "example": "batch_abc123"+ },+ "status": {+ "type": "string",+ "enum": [+ "pending",+ "processing",+ "completed",+ "cancelled",+ "failed"+ ],+ "example": "processing"+ },+ "progress": {+ "$ref": "#/components/schemas/BatchProgressDto"+ },+ "results": {+ "description": "One entry per recipient already attempted.",+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/BatchMessageResultDto"+ }+ },+ "startedAt": {+ "type": "string",+ "format": "date-time",+ "nullable": true,+ "description": "When processing started; null while the batch is pending."+ },+ "completedAt": {+ "type": "string",+ "format": "date-time",+ "nullable": true,+ "description": "When the batch reached a terminal status; null while it is still running."+ }+ },+ "required": [+ "batchId",+ "status",+ "progress",+ "results"+ ]+ },+ "BatchCancelResponseDto": {+ "type": "object",+ "properties": {+ "batchId": {+ "type": "string",+ "example": "batch_abc123"+ },+ "status": {+ "type": "string",+ "enum": [+ "pending",+ "processing",+ "completed",+ "cancelled",+ "failed"+ ],+ "example": "cancelled"+ },+ "progress": {+ "$ref": "#/components/schemas/BatchProgressDto"+ }+ },+ "required": [+ "batchId",+ "status",+ "progress"+ ]+ },"CreateTemplateDto": {"type": "object","properties": {@@ -14928,6 +16076,113 @@"url"]},+ "PluginCatalogEntryDto": {+ "type": "object",+ "properties": {+ "id": {+ "type": "string",+ "example": "echo"+ },+ "name": {+ "type": "string",+ "example": "Echo Bot"+ },+ "version": {+ "type": "string",+ "example": "1.2.0"+ },+ "type": {+ "type": "string",+ "example": "utility"+ },+ "status": {+ "type": "string",+ "example": "stable"+ },+ "description": {+ "type": "string"+ },+ "author": {+ "type": "string"+ },+ "license": {+ "type": "string",+ "example": "MIT"+ },+ "keywords": {+ "type": "array",+ "items": {+ "type": "string"+ }+ },+ "minOpenWAVersion": {+ "type": "string",+ "example": "0.18.0"+ },+ "testedOpenWAVersion": {+ "type": "string",+ "example": "0.18.0"+ },+ "releasedAt": {+ "type": "string",+ "example": "2026-08-01"+ },+ "repoUrl": {+ "type": "string",+ "example": "https://github.com/example/echo-plugin"+ },+ "homepage": {+ "type": "string"+ },+ "download": {+ "type": "string",+ "description": "Download URL of the plugin package."+ },+ "installed": {+ "type": "boolean",+ "description": "Whether this instance has the plugin installed.",+ "example": false+ },+ "installedVersion": {+ "type": "string",+ "nullable": true,+ "description": "The installed version, or null when not installed.",+ "example": null+ },+ "updateAvailable": {+ "type": "boolean",+ "description": "True when installed and the catalog version is strictly newer.",+ "example": false+ }+ },+ "required": [+ "id",+ "name",+ "version",+ "installed",+ "installedVersion",+ "updateAvailable"+ ]+ },+ "PluginActionResponseDto": {+ "type": "object",+ "properties": {+ "success": {+ "type": "boolean",+ "description": "Whether the change was applied; a refusal is carried in `message`.",+ "example": true+ },+ "message": {+ "type": "string",+ "description": "Human-readable outcome.",+ "example": "Plugin echo configuration updated"+ }+ },+ "required": [+ "success",+ "message"+ ]+ },"PluginConfigDto": {"type": "object","properties": {@@ -14958,6 +16213,49 @@"sessions"]},+ "PluginHealthResponseDto": {+ "type": "object",+ "properties": {+ "healthy": {+ "type": "boolean",+ "description": "Whether the plugin reports healthy.",+ "example": true+ },+ "message": {+ "type": "string",+ "description": "Failure detail when unhealthy.",+ "example": "worker did not answer in time"+ }+ },+ "required": [+ "healthy"+ ]+ },+ "RedriveResultDto": {+ "type": "object",+ "properties": {+ "redriven": {+ "type": "number",+ "description": "Deliveries re-dispatched by this call.",+ "example": 25+ },+ "remaining": {+ "type": "number",+ "description": "Dead-lettered deliveries still retained after this batch.",+ "example": 75+ },+ "batchSize": {+ "type": "number",+ "description": "The bounded batch size this call processed.",+ "example": 25+ }+ },+ "required": [+ "redriven",+ "remaining",+ "batchSize"+ ]+ },"CreateInstanceDto": {"type": "object","properties": {diff --git a/src/modules/auth/auth-validate.controller.ts b/src/modules/auth/auth-validate.controller.tsindex 53387b6ce..a8cac2139 100644--- a/src/modules/auth/auth-validate.controller.ts+++ b/src/modules/auth/auth-validate.controller.ts@@ -2,6 +2,7 @@ import { Controller, Post, HttpCode, HttpStatus } from '@nestjs/common';import { ApiTags, ApiOperation, ApiResponse, ApiHeader } from '@nestjs/swagger';import { CurrentApiKey } from './decorators/auth.decorators';import { ApiKey } from './entities/api-key.entity';+import { ValidateApiKeyResponseDto } from './dto';@ApiTags('auth')@Controller('auth')@@ -10,7 +11,7 @@ export class AuthValidateController {@HttpCode(HttpStatus.OK)@ApiOperation({ summary: 'Validate an API key' })@ApiHeader({ name: 'X-API-Key', description: 'API key to validate' })- @ApiResponse({ status: 200, description: 'API key is valid' })+ @ApiResponse({ status: 200, description: 'API key is valid', type: ValidateApiKeyResponseDto })@ApiResponse({ status: 401, description: 'Invalid or missing API key' })validate(@CurrentApiKey() apiKey?: ApiKey): { valid: boolean; role?: string } {// This route is behind the global API-key guard, so only a validated key reaches this handlerdiff --git a/src/modules/auth/dto/api-key.dto.ts b/src/modules/auth/dto/api-key.dto.tsindex ac9a30ed8..e1c4817fa 100644--- a/src/modules/auth/dto/api-key.dto.ts+++ b/src/modules/auth/dto/api-key.dto.ts@@ -98,6 +98,15 @@ export class ApiKeyCreatedResponseDto extends ApiKeyResponseDto {apiKey!: string;}+/** Result of `POST /auth/validate` — the guard's verdict on the presented key. */+export class ValidateApiKeyResponseDto {+ @ApiProperty({ description: 'Whether the presented API key is valid.', example: true })+ valid!: boolean;++ @ApiPropertyOptional({ enum: ApiKeyRole, description: "The key's role; present only when valid." })+ role?: ApiKeyRole;+}+export class UpdateApiKeyDto {@ApiPropertyOptional()@IsOptional()diff --git a/src/modules/integration/dto/instance.dto.ts b/src/modules/integration/dto/instance.dto.tsindex e084c948a..0e0ba4c17 100644--- a/src/modules/integration/dto/instance.dto.ts+++ b/src/modules/integration/dto/instance.dto.ts@@ -139,3 +139,15 @@ export class InstanceView {})ingressUrls!: IngressUrl[];}++/** Outcome of one redrive batch over an instance's dead-lettered ingress deliveries. */+export class RedriveResultDto {+ @ApiProperty({ description: 'Deliveries re-dispatched by this call.', example: 25 })+ redriven!: number;++ @ApiProperty({ description: 'Dead-lettered deliveries still retained after this batch.', example: 75 })+ remaining!: number;++ @ApiProperty({ description: 'The bounded batch size this call processed.', example: 25 })+ batchSize!: number;+}diff --git a/src/modules/integration/redrive.controller.ts b/src/modules/integration/redrive.controller.tsindex fe8a246a5..e8b41c28e 100644--- a/src/modules/integration/redrive.controller.ts+++ b/src/modules/integration/redrive.controller.ts@@ -7,6 +7,7 @@ import { AuditService } from '../audit/audit.service';import { sessionScopeVisible } from '../../common/security/session-scope';import { PluginInstanceService } from './plugin-instance.service';import { RedriveService } from './redrive.service';+import { RedriveResultDto } from './dto/instance.dto';// Re-dispatching DLQ'd inbound payloads can cause real downstream sends, so this operator action is// ADMIN-gated — matching the sibling IntegrationInstanceController. (A bare API key, even VIEWER,@@ -25,6 +26,7 @@ export class RedriveController {@ApiResponse({status: 201,description: 'One bounded batch of dead-lettered ingress deliveries re-dispatched, with remaining depth.',+ type: RedriveResultDto,})async redriveInstance(@Param('pluginId') pluginId: string,diff --git a/src/modules/message/dto/bulk-message.dto.ts b/src/modules/message/dto/bulk-message.dto.tsindex e0e88105a..c07194fa8 100644--- a/src/modules/message/dto/bulk-message.dto.ts+++ b/src/modules/message/dto/bulk-message.dto.ts@@ -15,6 +15,7 @@ import {} from 'class-validator';import { Type } from 'class-transformer';import { ToStrictBoolean } from '../../../common/utils/strict-boolean';+import { BatchMessageStatus, BatchStatus } from '../entities/message-batch.entity';class BulkMediaDto {@ApiPropertyOptional({ description: 'Media URL (http/https)' })@@ -171,3 +172,90 @@ export class BulkMessageResponseDto {@ApiProperty()statusUrl!: string;}++export class BatchProgressDto {+ @ApiProperty({ example: 10 })+ total!: number;++ @ApiProperty({ example: 7 })+ sent!: number;++ @ApiProperty({ example: 1 })+ failed!: number;++ @ApiProperty({ example: 2 })+ pending!: number;++ @ApiProperty({ example: 0 })+ cancelled!: number;+}++export class BatchMessageErrorDto {+ @ApiProperty({ description: 'Machine-readable failure code.', example: 'RECIPIENT_UNREACHABLE' })+ code!: string;++ @ApiProperty({ example: 'The number is not registered on WhatsApp' })+ message!: string;+}++/** Per-recipient outcome of a batch send. */+export class BatchMessageResultDto {+ @ApiProperty({ example: '[email protected]' })+ chatId!: string;++ @ApiProperty({ enum: BatchMessageStatus, example: BatchMessageStatus.SENT })+ status!: BatchMessageStatus;++ @ApiPropertyOptional({+ description: 'Assigned on a successful send.',+ example: '[email protected]_3EB0123456789',+ })+ messageId?: string;++ @ApiPropertyOptional({ type: BatchMessageErrorDto, description: 'Present on a failed send.' })+ error?: BatchMessageErrorDto;++ @ApiPropertyOptional({ type: String, format: 'date-time', description: 'When the send completed.' })+ sentAt?: Date;+}++export class BatchStatusResponseDto {+ @ApiProperty({ example: 'batch_abc123' })+ batchId!: string;++ @ApiProperty({ enum: BatchStatus, example: BatchStatus.PROCESSING })+ status!: BatchStatus;++ @ApiProperty({ type: BatchProgressDto })+ progress!: BatchProgressDto;++ @ApiProperty({ type: [BatchMessageResultDto], description: 'One entry per recipient already attempted.' })+ results!: BatchMessageResultDto[];++ @ApiPropertyOptional({+ type: String,+ format: 'date-time',+ nullable: true,+ description: 'When processing started; null while the batch is pending.',+ })+ startedAt?: Date | null;++ @ApiPropertyOptional({+ type: String,+ format: 'date-time',+ nullable: true,+ description: 'When the batch reached a terminal status; null while it is still running.',+ })+ completedAt?: Date | null;+}++export class BatchCancelResponseDto {+ @ApiProperty({ example: 'batch_abc123' })+ batchId!: string;++ @ApiProperty({ enum: BatchStatus, example: BatchStatus.CANCELLED })+ status!: BatchStatus;++ @ApiProperty({ type: BatchProgressDto })+ progress!: BatchProgressDto;+}diff --git a/src/modules/message/dto/message-responses.dto.ts b/src/modules/message/dto/message-responses.dto.tsnew file mode 100644index 000000000..2495dd7eb--- /dev/null+++ b/src/modules/message/dto/message-responses.dto.ts@@ -0,0 +1,319 @@+import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';+import type { MessageType } from '../../../engine/interfaces/whatsapp-engine.interface';+import type { ChatKind } from '../../../engine/identity/wa-id';+import { MessageDirection, MessageStatus } from '../entities/message.entity';++/**+ * Response shapes for the message read/action routes — the raw handler value, no envelope.+ * Decorated properties avoid named utility types: emitDecoratorMetadata wraps a named type in a+ * runtime guard whose other arm can never execute, leaving an uncoverable branch.+ */++const MESSAGE_TYPES: MessageType[] = [+ 'text',+ 'image',+ 'video',+ 'audio',+ 'voice',+ 'document',+ 'sticker',+ 'location',+ 'contact',+ 'poll',+ 'call',+ 'revoked',+ 'masked',+ 'unknown',+];++const CHAT_KINDS: ChatKind[] = ['individual', 'group', 'channel', 'status', 'broadcast', 'unknown'];++export class MessageActionResponseDto {+ @ApiProperty({ description: 'Always true — a failure is reported as a non-2xx status, not as false.', example: true })+ success!: boolean;+}++/** OpenAPI mirror of the persisted `Message` row served by the list route. */+export class MessageListItemDto {+ @ApiProperty({ example: '0a941dac-a965-45e7-b318-74ae8be134f0' })+ id!: string;++ @ApiProperty({ example: '0a941dac-a965-45e7-b318-74ae8be134f0' })+ sessionId!: string;++ @ApiPropertyOptional({+ type: String,+ nullable: true,+ description: 'WhatsApp message id, once the engine has assigned one.',+ example: '[email protected]_3EB0123456789',+ })+ waMessageId?: string | null;++ @ApiProperty({ example: '[email protected]' })+ chatId!: string;++ @ApiPropertyOptional({+ type: String,+ nullable: true,+ description: 'Human-readable chat name when known (contact pushName, group subject).',+ example: 'Alice',+ })+ chatName?: string | null;++ @ApiPropertyOptional({+ type: String,+ nullable: true,+ description: 'Group participant who posted the message (`from` is the group JID there).',+ example: '[email protected]',+ })+ author?: string | null;++ @ApiProperty({ example: '[email protected]' })+ from!: string;++ @ApiProperty({ example: '[email protected]' })+ to!: string;++ @ApiPropertyOptional({ type: String, nullable: true, description: 'Message text body.', example: 'hi' })+ body?: string | null;++ @ApiProperty({ description: 'Engine-neutral message type.', example: 'text' })+ type!: string;++ @ApiProperty({ enum: MessageDirection, example: MessageDirection.INCOMING })+ direction!: MessageDirection;++ @ApiPropertyOptional({+ type: Number,+ nullable: true,+ description: 'Unix seconds the message was sent, when the engine reported one.',+ example: 1700000010,+ })+ timestamp?: number | null;++ @ApiPropertyOptional({+ nullable: true,+ description: 'Engine-specific extras (media inline copy, poll data, …). Absent when none were stored.',+ additionalProperties: true,+ })+ metadata?: { [key: string]: unknown } | null;++ @ApiPropertyOptional({+ type: String,+ nullable: true,+ description: 'Storage key of the archived media, when one was archived.',+ })+ mediaPath?: string | null;++ @ApiPropertyOptional({ type: String, nullable: true, description: 'Mimetype of the archived media.' })+ mediaMimetype?: string | null;++ @ApiProperty({ enum: MessageStatus, example: MessageStatus.DELIVERED })+ status!: MessageStatus;++ @ApiProperty({ type: String, format: 'date-time', example: '2026-08-13T09:00:00Z' })+ createdAt!: Date;+}++export class MessageListResponseDto {+ @ApiProperty({ type: [MessageListItemDto], description: 'Newest first.' })+ messages!: MessageListItemDto[];++ @ApiProperty({ description: 'Total rows matching the filters (before pagination).', example: 132 })+ total!: number;+}++/** Synchronous sender-contact fields carried on a history message (see the engine `MessageContact`). */+export class ChatHistoryContactDto {+ @ApiPropertyOptional({ description: 'Sender JID (`…@c.us` or a `…@lid` privacy id).', example: '[email protected]' })+ id?: string;++ @ApiPropertyOptional({ description: 'Phone digits, best-effort.', example: '628123456789' })+ number?: string;++ @ApiPropertyOptional({ example: 'Alice' })+ name?: string;++ @ApiPropertyOptional({ example: 'Alice' })+ pushName?: string;++ @ApiPropertyOptional({ example: 'Al' })+ shortName?: string;++ @ApiPropertyOptional({ description: 'Engine contact type token.', example: 'in' })+ type?: string;++ @ApiPropertyOptional({ description: 'Saved in the account address book.', example: true })+ isMyContact?: boolean;++ @ApiPropertyOptional({ description: 'Is a WhatsApp user.', example: true })+ isWAContact?: boolean;++ @ApiPropertyOptional({ example: false })+ isBusiness?: boolean;++ @ApiPropertyOptional({ example: false })+ isEnterprise?: boolean;++ @ApiPropertyOptional({ description: 'Business verified name.' })+ verifiedName?: string;++ @ApiPropertyOptional({ description: 'Business verification level.', example: 2 })+ verifiedLevel?: number;++ @ApiPropertyOptional({ example: false })+ isBlocked?: boolean;++ @ApiPropertyOptional({ type: [String], description: 'Label ids (CRM); names are not resolved.' })+ labels?: string[];+}++export class ChatHistoryMediaDto {+ @ApiProperty({ example: 'image/jpeg' })+ mimetype!: string;++ @ApiPropertyOptional({ example: 'photo.jpg' })+ filename?: string;++ @ApiPropertyOptional({ description: 'Base64 payload; absent when the blob was omitted.' })+ data?: string;++ @ApiPropertyOptional({ description: 'True when the blob was dropped by a size cap, timeout, or saturation.' })+ omitted?: boolean;++ @ApiPropertyOptional({ description: 'Decoded byte size of the media; always set when omitted.', example: 102400 })+ sizeBytes?: number;+}++export class ChatHistoryQuotedMessageDto {+ @ApiProperty({ example: '[email protected]_3EB0123456789' })+ id!: string;++ @ApiProperty({ example: 'original text' })+ body!: string;+}++export class ChatHistoryLocationDto {+ @ApiProperty({ example: -6.2088 })+ latitude!: number;++ @ApiProperty({ example: 106.8456 })+ longitude!: number;++ @ApiPropertyOptional({ example: 'Monas' })+ description?: string;++ @ApiPropertyOptional({ example: 'Jakarta' })+ address?: string;++ @ApiPropertyOptional({ example: 'https://maps.example.com/…' })+ url?: string;+}++export class ChatHistoryCallDto {+ @ApiProperty({ description: 'Video (true) vs voice (false) call.', example: false })+ video!: boolean;++ @ApiProperty({ description: 'Whether an incoming call went unanswered.', example: true })+ missed!: boolean;+}++/** OpenAPI mirror of the engine `IncomingMessage` served by the live chat-history route. */+export class ChatHistoryMessageDto {+ @ApiProperty({ example: '[email protected]_3EB0123456789' })+ id!: string;++ @ApiProperty({ example: '[email protected]' })+ from!: string;++ @ApiProperty({ example: '[email protected]' })+ to!: string;++ @ApiProperty({ example: '[email protected]' })+ chatId!: string;++ @ApiProperty({ example: 'hi' })+ body!: string;++ @ApiProperty({ enum: MESSAGE_TYPES, description: 'Engine-neutral message type.', example: 'text' })+ type!: MessageType;++ @ApiProperty({ description: 'Unix seconds the message was sent.', example: 1700000010 })+ timestamp!: number;++ @ApiProperty({ example: false })+ fromMe!: boolean;++ @ApiProperty({ example: false })+ isGroup!: boolean;++ @ApiProperty({ enum: CHAT_KINDS, description: 'User-facing chat kind of the conversation.', example: 'individual' })+ kind!: ChatKind;++ @ApiPropertyOptional({ description: 'True for a status/story broadcast.', example: false })+ isStatusBroadcast?: boolean;++ @ApiPropertyOptional({ description: 'Disappearing-messages timer in seconds; 0 or absent means off.', example: 0 })+ ephemeralDuration?: number;++ @ApiPropertyOptional({+ description: 'Group participant who actually sent it (`from` is the group JID there).',+ example: '[email protected]',+ })+ author?: string;++ @ApiPropertyOptional({ type: [String], description: 'WIDs @mentioned in the message.' })+ mentionedIds?: string[];++ @ApiPropertyOptional({ type: ChatHistoryCallDto, description: 'Set for `call` messages.' })+ call?: ChatHistoryCallDto;++ @ApiPropertyOptional({ description: 'Sender is identified by a privacy id rather than a phone number.' })+ isLidSender?: boolean;++ @ApiPropertyOptional({+ type: String,+ nullable: true,+ description: 'Best-effort phone digits of a privacy-id sender, when resolved.',+ example: null,+ })+ senderPhone?: string | null;++ @ApiPropertyOptional({ type: ChatHistoryContactDto, description: 'Sender contact info, best-effort.' })+ contact?: ChatHistoryContactDto;++ @ApiPropertyOptional({ description: 'Text-status background as `#RRGGBB`.', example: '#FF5733' })+ backgroundColor?: string;++ @ApiPropertyOptional({ description: 'Text-status WhatsApp font index.', example: 1 })+ font?: number;++ @ApiPropertyOptional({ type: ChatHistoryMediaDto })+ media?: ChatHistoryMediaDto;++ @ApiPropertyOptional({ type: ChatHistoryQuotedMessageDto })+ quotedMessage?: ChatHistoryQuotedMessageDto;++ @ApiPropertyOptional({ type: ChatHistoryLocationDto })+ location?: ChatHistoryLocationDto;+}++export class MessageReactionSenderDto {+ @ApiProperty({ example: '[email protected]' })+ senderId!: string;++ @ApiProperty({ example: '👍' })+ emoji!: string;++ @ApiProperty({ description: 'Unix seconds the reaction was placed.', example: 1700000010 })+ timestamp!: number;+}++/** OpenAPI mirror of the engine `MessageReaction` served by the reactions route. */+export class MessageReactionDto {+ @ApiProperty({ description: 'The emoji this entry groups.', example: '👍' })+ emoji!: string;++ @ApiProperty({ type: [MessageReactionSenderDto], description: 'Who placed this emoji.' })+ senders!: MessageReactionSenderDto[];+}diff --git a/src/modules/message/message.controller.ts b/src/modules/message/message.controller.tsindex cc49243dd..141bea3d6 100644--- a/src/modules/message/message.controller.ts+++ b/src/modules/message/message.controller.ts@@ -19,7 +19,18 @@ import {SEND_POLL_BODY_EXAMPLES,} from './dto';import { SendTemplateMessageDto } from './dto/send-template.dto';-import { SendBulkMessageDto, BulkMessageResponseDto } from './dto/bulk-message.dto';+import {+ SendBulkMessageDto,+ BulkMessageResponseDto,+ BatchStatusResponseDto,+ BatchCancelResponseDto,+} from './dto/bulk-message.dto';+import {+ MessageActionResponseDto,+ MessageListResponseDto,+ ChatHistoryMessageDto,+ MessageReactionDto,+} from './dto/message-responses.dto';import {SendLocationDto,SendContactDto,@@ -68,6 +79,7 @@ export class MessageController {@ApiResponse({status: 200,description: 'Message history',+ type: MessageListResponseDto,})async getMessages(@Param('sessionId') sessionId: string,@@ -335,6 +347,7 @@ export class MessageController {@ApiResponse({status: 200,description: 'Reaction added or removed. Send empty emoji to remove reaction.',+ type: MessageActionResponseDto,})@ApiResponse({status: 400,@@ -372,7 +385,7 @@ export class MessageController {'(whatsapp-web.js only; loads earlier messages on demand). Forces metadata-only (includeMedia ' +'is ignored). Large/slow requests may increase WhatsApp rate-limiting risk; default false.',})- @ApiResponse({ status: 200, description: 'Chat history (most recent messages)' })+ @ApiResponse({ status: 200, description: 'Chat history (most recent messages)', type: [ChatHistoryMessageDto] })@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })@ApiResponse({ status: 501, description: ENGINE_NOT_SUPPORTED_501 })async getChatHistory(@@ -409,6 +422,7 @@ export class MessageController {@ApiResponse({status: 200,description: 'List of reactions with senders',+ type: [MessageReactionDto],})@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })@ApiResponse({ status: 404, description: MESSAGE_NOT_FOUND_404 })@@ -470,6 +484,7 @@ export class MessageController {@ApiResponse({status: 200,description: 'Message deleted',+ type: MessageActionResponseDto,})@ApiResponse({status: 400,@@ -496,7 +511,7 @@ export class MessageController {@RequireRole(ApiKeyRole.OPERATOR)@ApiOperation({ summary: 'Cast a vote on a poll' })@ApiParam({ name: 'sessionId', description: 'Session ID' })- @ApiResponse({ status: 200, description: 'Vote cast' })+ @ApiResponse({ status: 200, description: 'Vote cast', type: MessageActionResponseDto })@ApiResponse({ status: 400, description: 'Session not active, or the target message is not a poll' })@ApiResponse({ status: 404, description: 'Poll not found in the chat’s recent history' })@ApiResponse({ status: 501, description: 'Not supported on the Baileys engine' })@@ -512,7 +527,7 @@ export class MessageController {@RequireRole(ApiKeyRole.OPERATOR)@ApiOperation({ summary: 'Pin a message in its chat' })@ApiParam({ name: 'sessionId', description: 'Session ID' })- @ApiResponse({ status: 200, description: 'Message pinned' })+ @ApiResponse({ status: 200, description: 'Message pinned', type: MessageActionResponseDto })@ApiResponse({status: 400,description: 'Session not active, or durationSeconds is not one of 86400 / 604800 / 2592000',@@ -529,7 +544,7 @@ export class MessageController {@RequireRole(ApiKeyRole.OPERATOR)@ApiOperation({ summary: 'Remove a message’s pin' })@ApiParam({ name: 'sessionId', description: 'Session ID' })- @ApiResponse({ status: 200, description: 'Message unpinned' })+ @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: 404, description: 'Message not found in the chat' })@@ -551,6 +566,7 @@ export class MessageController {description:'Instruction delivered. On whatsapp-web.js the engine silently ignores a message it will not ' +'star, so this does not guarantee the star is set.',+ type: MessageActionResponseDto,})@ApiResponse({ status: 400, description: 'Session not active' })@ApiResponse({ status: 404, description: 'Message not found in the chat' })@@ -633,6 +649,7 @@ export class MessageController {@ApiResponse({status: 200,description: 'Batch status and progress',+ type: BatchStatusResponseDto,})@ApiResponse({status: 404,@@ -659,6 +676,7 @@ export class MessageController {@ApiResponse({status: 200,description: 'Batch cancelled',+ type: BatchCancelResponseDto,})@ApiResponse({status: 400,diff --git a/src/modules/plugins/dto/plugin.dto.ts b/src/modules/plugins/dto/plugin.dto.tsindex 6c7e11f81..99eabd2a9 100644--- a/src/modules/plugins/dto/plugin.dto.ts+++ b/src/modules/plugins/dto/plugin.dto.ts@@ -98,3 +98,82 @@ export class InstallFromUrlDto {)url!: string;}++/** Shared shape of the plugin lifecycle writes (enable/disable/config/uninstall). */+export class PluginActionResponseDto {+ @ApiProperty({ description: 'Whether the change was applied; a refusal is carried in `message`.', example: true })+ success!: boolean;++ @ApiProperty({ description: 'Human-readable outcome.', example: 'Plugin echo configuration updated' })+ message!: string;+}++export class PluginHealthResponseDto {+ @ApiProperty({ description: 'Whether the plugin reports healthy.', example: true })+ healthy!: boolean;++ @ApiPropertyOptional({ description: 'Failure detail when unhealthy.', example: 'worker did not answer in time' })+ message?: string;+}++/** A remote-catalog entry annotated with this instance's install state. Extra catalog fields pass through. */+export class PluginCatalogEntryDto {+ @ApiProperty({ example: 'echo' })+ id!: string;++ @ApiProperty({ example: 'Echo Bot' })+ name!: string;++ @ApiProperty({ example: '1.2.0' })+ version!: string;++ @ApiPropertyOptional({ example: 'utility' })+ type?: string;++ @ApiPropertyOptional({ example: 'stable' })+ status?: string;++ @ApiPropertyOptional()+ description?: string;++ @ApiPropertyOptional()+ author?: string;++ @ApiPropertyOptional({ example: 'MIT' })+ license?: string;++ @ApiPropertyOptional({ type: [String] })+ keywords?: string[];++ @ApiPropertyOptional({ example: '0.18.0' })+ minOpenWAVersion?: string;++ @ApiPropertyOptional({ example: '0.18.0' })+ testedOpenWAVersion?: string;++ @ApiPropertyOptional({ example: '2026-08-01' })+ releasedAt?: string;++ @ApiPropertyOptional({ example: 'https://github.com/example/echo-plugin' })+ repoUrl?: string;++ @ApiPropertyOptional()+ homepage?: string;++ @ApiPropertyOptional({ description: 'Download URL of the plugin package.' })+ download?: string;++ @ApiProperty({ description: 'Whether this instance has the plugin installed.', example: false })+ installed!: boolean;++ @ApiProperty({+ type: String,+ nullable: true,+ description: 'The installed version, or null when not installed.',+ example: null,+ })+ installedVersion!: string | null;++ @ApiProperty({ description: 'True when installed and the catalog version is strictly newer.', example: false })+ updateAvailable!: boolean;+}diff --git a/src/modules/plugins/plugins.controller.ts b/src/modules/plugins/plugins.controller.tsindex fab29eb0b..159aa4da7 100644--- a/src/modules/plugins/plugins.controller.ts+++ b/src/modules/plugins/plugins.controller.ts@@ -15,7 +15,15 @@ import {import { FileInterceptor } from '@nestjs/platform-express';import { ApiTags, ApiOperation, ApiResponse, ApiConsumes, ApiBody } from '@nestjs/swagger';import { PluginsService } from './plugins.service';-import { PluginDto, PluginConfigDto, PluginSessionsDto, InstallFromUrlDto } from './dto/plugin.dto';+import {+ PluginDto,+ PluginConfigDto,+ PluginSessionsDto,+ InstallFromUrlDto,+ PluginActionResponseDto,+ PluginHealthResponseDto,+ PluginCatalogEntryDto,+} from './dto/plugin.dto';import type { CatalogPlugin } from './catalog';import { RequireRole, RequireUnscopedKey } from '../auth/decorators/auth.decorators';import { ApiKeyRole } from '../auth/entities/api-key.entity';@@ -82,7 +90,7 @@ export class PluginsController {@RequireRole(ApiKeyRole.ADMIN)@RequireUnscopedKey()@ApiOperation({ summary: 'List the remote plugin catalog, annotated with install state' })- @ApiResponse({ status: 200, description: 'Catalog entries' })+ @ApiResponse({ status: 200, description: 'Catalog entries', type: [PluginCatalogEntryDto] })@ApiResponse({ status: 400, description: 'Catalog could not be fetched or parsed' })async catalog(): Promise<CatalogPlugin[]> {return await this.pluginsService.getCatalog();@@ -103,7 +111,7 @@ export class PluginsController {@RequireUnscopedKey()@HttpCode(HttpStatus.OK)@ApiOperation({ summary: 'Enable a plugin' })- @ApiResponse({ status: 200, description: 'Plugin enabled successfully' })+ @ApiResponse({ status: 200, description: 'Plugin enabled successfully', type: PluginActionResponseDto })async enable(@Param('id') id: string): Promise<{ success: boolean; message: string }> {return await this.pluginsService.enable(id);}@@ -113,7 +121,7 @@ export class PluginsController {@RequireUnscopedKey()@HttpCode(HttpStatus.OK)@ApiOperation({ summary: 'Disable a plugin' })- @ApiResponse({ status: 200, description: 'Plugin disabled successfully' })+ @ApiResponse({ status: 200, description: 'Plugin disabled successfully', type: PluginActionResponseDto })async disable(@Param('id') id: string): Promise<{ success: boolean; message: string }> {return await this.pluginsService.disable(id);}@@ -122,7 +130,7 @@ export class PluginsController {@RequireRole(ApiKeyRole.ADMIN)@RequireUnscopedKey()@ApiOperation({ summary: 'Update plugin configuration' })- @ApiResponse({ status: 200, description: 'Plugin configuration updated' })+ @ApiResponse({ status: 200, description: 'Plugin configuration updated', type: PluginActionResponseDto })updateConfig(@Param('id') id: string, @Body() configDto: PluginConfigDto): { success: boolean; message: string } {return this.pluginsService.updateConfig(id, configDto.config);}@@ -152,7 +160,7 @@ export class PluginsController {@Put(':id/config/:sessionId')@RequireRole(ApiKeyRole.ADMIN)@ApiOperation({ summary: 'Set a plugin config override for a specific session (empty = clear it)' })- @ApiResponse({ status: 200, description: 'Per-session plugin configuration updated' })+ @ApiResponse({ status: 200, description: 'Per-session plugin configuration updated', type: PluginActionResponseDto })@ApiResponse({ status: 400, description: 'Plugin is global (not session-scoped)' })@ApiResponse({ status: 404, description: 'Plugin not found' })updateSessionConfig(@@ -197,7 +205,7 @@ export class PluginsController {@RequireRole(ApiKeyRole.ADMIN)@RequireUnscopedKey()@ApiOperation({ summary: 'Uninstall a plugin (removes its files; built-ins are protected)' })- @ApiResponse({ status: 200, description: 'Plugin uninstalled' })+ @ApiResponse({ status: 200, description: 'Plugin uninstalled', type: PluginActionResponseDto })@ApiResponse({ status: 400, description: 'Cannot uninstall (e.g. built-in)' })@ApiResponse({ status: 404, description: 'Plugin not found' })async uninstall(@Param('id') id: string): Promise<{ success: boolean; message: string }> {@@ -208,7 +216,7 @@ export class PluginsController {@RequireRole(ApiKeyRole.ADMIN)@RequireUnscopedKey()@ApiOperation({ summary: 'Check plugin health' })- @ApiResponse({ status: 200, description: 'Plugin health status' })+ @ApiResponse({ status: 200, description: 'Plugin health status', type: PluginHealthResponseDto })async healthCheck(@Param('id') id: string): Promise<{ healthy: boolean; message?: string }> {return await this.pluginsService.healthCheck(id);}diff --git a/src/modules/session/dto/index.ts b/src/modules/session/dto/index.tsindex 07352eafd..42b372d44 100644--- a/src/modules/session/dto/index.ts+++ b/src/modules/session/dto/index.ts@@ -10,3 +10,4 @@ export * from './send-chat-state.dto';export * from './request-pairing-code.dto';export * from './chat-summary.dto';export * from './presence.dto';+export * from './session-actions-response.dto';diff --git a/src/modules/session/dto/session-actions-response.dto.ts b/src/modules/session/dto/session-actions-response.dto.tsnew file mode 100644index 000000000..8df04ad23--- /dev/null+++ b/src/modules/session/dto/session-actions-response.dto.ts@@ -0,0 +1,68 @@+import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';++/**+ * Response shapes for the session-scoped chat / presence / group / stats routes — the raw handler+ * value, no envelope. Decorated properties avoid named utility types: emitDecoratorMetadata wraps a+ * named type in a runtime guard whose other arm can never execute, leaving an uncoverable branch.+ */++export class SessionActionResponseDto {+ @ApiProperty({+ description:+ 'Whether the engine applied the change. Routes where the engine can decline spell out what ' ++ '`false` means in their own description; on the rest it is always `true`.',+ example: true,+ })+ success!: boolean;+}++export class SessionGroupSummaryDto {+ @ApiProperty({ description: 'Group id.', example: '[email protected]' })+ id!: string;++ @ApiProperty({ description: 'Group subject.', example: 'Engineering' })+ name!: string;++ @ApiPropertyOptional({+ type: String,+ nullable: true,+ description: 'JID of the parent community, or null when the group is standalone.',+ example: null,+ })+ linkedParentJID?: string | null;+}++export class SessionMemoryUsageDto {+ @ApiProperty({ description: 'V8 heap in use, in MiB.', example: 128 })+ heapUsed!: number;++ @ApiProperty({ description: 'V8 heap reserved, in MiB.', example: 256 })+ heapTotal!: number;++ @ApiProperty({ description: 'Resident set size, in MiB.', example: 512 })+ rss!: number;+}++export class SessionsOverviewResponseDto {+ @ApiProperty({ description: 'Sessions on record, connected or not.', example: 5 })+ total!: number;++ @ApiProperty({ description: 'Sessions with a live engine in this process.', example: 2 })+ active!: number;++ @ApiProperty({ description: "Sessions whose status is 'ready'.", example: 2 })+ ready!: number;++ @ApiProperty({ description: "Sessions whose status is 'disconnected'.", example: 3 })+ disconnected!: number;++ @ApiProperty({+ description: 'Session count per status value.',+ example: { ready: 2, disconnected: 3 },+ additionalProperties: { type: 'integer' },+ })+ byStatus!: { [status: string]: number };++ @ApiProperty({ type: SessionMemoryUsageDto, description: 'Process memory usage of this gateway.' })+ memoryUsage!: SessionMemoryUsageDto;+}diff --git a/src/modules/session/session.controller.ts b/src/modules/session/session.controller.tsindex 8d531462d..62a262dcf 100644--- a/src/modules/session/session.controller.ts+++ b/src/modules/session/session.controller.ts@@ -32,6 +32,9 @@ import {RequestPairingCodeDto,PairingCodeResponseDto,ChatSummaryDto,+ SessionActionResponseDto,+ SessionGroupSummaryDto,+ SessionsOverviewResponseDto,} from './dto';import { Session } from './entities/session.entity';import { ChatSummary } from '../../engine/interfaces/whatsapp-engine.interface';@@ -379,6 +382,7 @@ export class SessionController {@ApiResponse({status: 200,description: 'List of groups the session is a member of',+ type: [SessionGroupSummaryDto],})@ApiResponse({ status: 400, description: 'Session not ready' })@ApiResponse({ status: 404, description: 'Session not found' })@@ -434,7 +438,7 @@ export class SessionController {@HttpCode(HttpStatus.OK)@ApiOperation({ summary: 'Mark a chat as read/seen' })@ApiParam({ name: 'id', description: 'Session ID' })- @ApiResponse({ status: 200, description: 'Chat marked as read successfully' })+ @ApiResponse({ status: 200, description: 'Chat marked as read successfully', type: SessionActionResponseDto })@ApiResponse({ status: 400, description: 'Session not ready' })@ApiResponse({ status: 404, description: 'Session not found' })@ApiResponse({@@ -468,7 +472,11 @@ export class SessionController {'event) and answers `501`.',})@ApiParam({ name: 'id', description: 'Session ID' })- @ApiResponse({ status: 200, description: 'Subscribed; updates now arrive as presence.update events' })+ @ApiResponse({+ status: 200,+ description: 'Subscribed; updates now arrive as presence.update events',+ type: SessionActionResponseDto,+ })@ApiResponse({ status: 400, description: 'Session not started' })@ApiResponse({ status: 404, description: 'Session not found' })@ApiResponse({ status: 501, description: 'The active engine cannot observe presence (whatsapp-web.js)' })@@ -494,7 +502,7 @@ export class SessionController {'per its connect-time behaviour). Supported on both engines.',})@ApiParam({ name: 'id', description: 'Session ID' })- @ApiResponse({ status: 200, description: 'Presence published' })+ @ApiResponse({ status: 200, description: 'Presence published', type: SessionActionResponseDto })@ApiResponse({ status: 400, description: 'Session not started, or validation failed' })@ApiResponse({ status: 404, description: 'Session not found' })@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })@@ -535,7 +543,7 @@ export class SessionController {@HttpCode(HttpStatus.OK)@ApiOperation({ summary: 'Mark a chat as unread' })@ApiParam({ name: 'id', description: 'Session ID' })- @ApiResponse({ status: 200, description: 'Chat marked as unread successfully' })+ @ApiResponse({ status: 200, description: 'Chat marked as unread successfully', type: SessionActionResponseDto })@ApiResponse({ status: 400, description: 'Session not ready' })@ApiResponse({ status: 404, description: 'Session not found' })@ApiResponse({@@ -564,6 +572,7 @@ export class SessionController {description:'Returns `{ success }`. `false` means the engine declined to act — an unknown chat, or on the ' +'Baileys engine a chat with no known history, since the change is keyed to its last message.',+ type: SessionActionResponseDto,})@ApiResponse({ status: 400, description: 'Session not ready' })@ApiResponse({ status: 404, description: 'Session not found' })@@ -592,6 +601,7 @@ export class SessionController {description:'Returns `{ success }`. `false` means the engine declined to act — on the Baileys engine a ' +'chat with no known history cannot be archived, since the change is keyed to its last message.',+ type: SessionActionResponseDto,})@ApiResponse({ status: 400, description: 'Session not ready' })@ApiResponse({ status: 404, description: 'Session not found' })@@ -621,6 +631,7 @@ export class SessionController {'Returns `{ success: true }`. Unlike the archive route there is no declined outcome: the mute ' +"change is not keyed to the chat's last message on either engine, so a chat with no known " +'history mutes like any other.',+ type: SessionActionResponseDto,})@ApiResponse({ status: 400, description: 'Session not ready, or an invalid chatId / muteUntil' })@ApiResponse({ status: 404, description: 'Session not found' })@@ -647,6 +658,7 @@ export class SessionController {'Returns `{ success }`. `false` means the engine declined, and only a pin can: WhatsApp allows ' +'at most three pinned chats and the whatsapp-web.js engine reports the refusal. Unpinning always ' +'succeeds, and the Baileys engine always reports success because it cannot observe the cap.',+ type: SessionActionResponseDto,})@ApiResponse({status: 400,@@ -674,7 +686,7 @@ export class SessionController {@HttpCode(HttpStatus.OK)@ApiOperation({ summary: 'Delete a chat from the chat list (e.g. a group you have left)' })@ApiParam({ name: 'id', description: 'Session ID' })- @ApiResponse({ status: 200, description: 'Chat deleted successfully' })+ @ApiResponse({ status: 200, description: 'Chat deleted successfully', type: SessionActionResponseDto })@ApiResponse({ status: 400, description: 'Session not ready' })@ApiResponse({ status: 404, description: 'Session not found' })@ApiResponse({@@ -694,7 +706,7 @@ export class SessionController {@HttpCode(HttpStatus.OK)@ApiOperation({ summary: "Send a typing/recording presence indicator to a chat (or clear it with 'paused')" })@ApiParam({ name: 'id', description: 'Session ID' })- @ApiResponse({ status: 200, description: 'Presence sent' })+ @ApiResponse({ status: 200, description: 'Presence sent', type: SessionActionResponseDto })@ApiResponse({ status: 404, description: 'Session not found' })@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })async sendChatState(@@ -712,6 +724,7 @@ export class SessionController {@ApiResponse({status: 200,description: 'Session statistics including counts and memory usage',+ type: SessionsOverviewResponseDto,})async getStats(@CurrentApiKey() apiKey?: ApiKey): Promise<{total: number;diff --git a/src/modules/webhook/dto/webhook.dto.ts b/src/modules/webhook/dto/webhook.dto.tsindex d44b6fd1a..e7a5ed8f6 100644--- a/src/modules/webhook/dto/webhook.dto.ts+++ b/src/modules/webhook/dto/webhook.dto.ts@@ -250,3 +250,60 @@ export class WebhookResponseDto {return entities.map(entity => WebhookResponseDto.fromEntity(entity));}}++/** A webhook delivery that exhausted every retry — the shape `GET /webhooks/delivery-failures` serves. */+export class WebhookDeliveryFailureDto {+ @ApiProperty({ example: '0a941dac-a965-45e7-b318-74ae8be134f0' })+ id!: string;++ @ApiProperty({ example: '0a941dac-a965-45e7-b318-74ae8be134f0' })+ webhookId!: string;++ @ApiProperty({ example: '0a941dac-a965-45e7-b318-74ae8be134f0' })+ sessionId!: string;++ @ApiProperty({ example: 'message.received' })+ event!: string;++ @ApiProperty({ example: 'https://receiver.example.com/hook' })+ url!: string;++ @ApiPropertyOptional({+ type: String,+ nullable: true,+ description: 'The idempotency key the receiver would have deduped on.',+ })+ idempotencyKey?: string | null;++ @ApiPropertyOptional({ type: String, nullable: true })+ deliveryId?: string | null;++ @ApiProperty({ description: 'Total attempts made before giving up.', example: 5 })+ attempts!: number;++ @ApiPropertyOptional({+ type: Number,+ nullable: true,+ description: 'Last HTTP status when the failure was a non-2xx response; null for a network/timeout error.',+ example: null,+ })+ lastStatusCode?: number | null;++ @ApiProperty({ example: 'connect ECONNREFUSED 10.0.0.1:443' })+ lastError!: string;++ @ApiProperty({ type: String, format: 'date-time', description: 'When the delivery was finally abandoned.' })+ createdAt!: Date;+}++/** Outcome of `POST /sessions/:sessionId/webhooks/:id/test`. */+export class WebhookTestResponseDto {+ @ApiProperty({ description: 'True when the receiver answered 2xx.', example: true })+ success!: boolean;++ @ApiPropertyOptional({ description: 'The HTTP status the receiver answered, when it answered.', example: 200 })+ statusCode?: number;++ @ApiPropertyOptional({ description: 'The delivery error, when the attempt failed.', example: 'timeout' })+ error?: string;+}diff --git a/src/modules/webhook/webhook.controller.ts b/src/modules/webhook/webhook.controller.tsindex 31dda6fd8..a989d83ae 100644--- a/src/modules/webhook/webhook.controller.ts+++ b/src/modules/webhook/webhook.controller.ts@@ -1,7 +1,7 @@import { Controller, Get, Post, Put, Delete, Param, Body, HttpCode, HttpStatus } from '@nestjs/common';import { ApiTags, ApiOperation, ApiResponse, ApiParam } from '@nestjs/swagger';import { WebhookService } from './webhook.service';-import { CreateWebhookDto, UpdateWebhookDto, WebhookResponseDto } from './dto';+import { CreateWebhookDto, UpdateWebhookDto, WebhookResponseDto, WebhookTestResponseDto } from './dto';import { RequireRole } from '../auth/decorators/auth.decorators';import { ApiKeyRole } from '../auth/entities/api-key.entity';@@ -76,7 +76,7 @@ export class WebhookController {@ApiOperation({ summary: 'Test a webhook by sending a test payload' })@ApiParam({ name: 'sessionId', description: 'Session ID' })@ApiParam({ name: 'id', description: 'Webhook ID' })- @ApiResponse({ status: 200, description: 'Test result' })+ @ApiResponse({ status: 200, description: 'Test result', type: WebhookTestResponseDto })@ApiResponse({ status: 404, description: 'Webhook not found' })async test(@Param('sessionId') sessionId: string,diff --git a/src/modules/webhook/webhooks-list.controller.ts b/src/modules/webhook/webhooks-list.controller.tsindex 0471f83cb..9d905a1a2 100644--- a/src/modules/webhook/webhooks-list.controller.ts+++ b/src/modules/webhook/webhooks-list.controller.ts@@ -1,7 +1,7 @@import { Controller, Get, Query } from '@nestjs/common';import { ApiTags, ApiOperation, ApiResponse, ApiQuery } from '@nestjs/swagger';import { WebhookService } from './webhook.service';-import { WebhookResponseDto } from './dto';+import { WebhookResponseDto, WebhookDeliveryFailureDto } from './dto';import { WebhookDeliveryFailure } from './entities/webhook-delivery-failure.entity';import { RequireRole, CurrentApiKey } from '../auth/decorators/auth.decorators';import { ApiKey, ApiKeyRole } from '../auth/entities/api-key.entity';@@ -14,7 +14,11 @@ export class WebhooksListController {@Get('delivery-failures')@RequireRole(ApiKeyRole.ADMIN)@ApiOperation({ summary: 'List recently-failed webhook deliveries (all retries exhausted)' })- @ApiResponse({ status: 200, description: 'Permanently-failed webhook deliveries, most recent first' })+ @ApiResponse({+ status: 200,+ description: 'Permanently-failed webhook deliveries, most recent first',+ type: [WebhookDeliveryFailureDto],+ })@ApiQuery({ name: 'sessionId', required: false, description: 'Filter to a single session' })@ApiQuery({ name: 'limit', required: false, description: 'Max records to return (1-1000, default 1000)' })@ApiQuery({ name: 'offset', required: false, description: 'Number of records to skip (for paging)' })