Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
docs(openapi): publish the response schemas for the last nine modules
Yudhi Armyndharis996a815789ca
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 01cc3a8d2..b2e1d9cf4 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Changed+- **Every remaining module now publishes the shape of what it returns** — health, profile, statistics, media, settings, audit, calls, metrics and search were the last nine with no response schema anywhere, so three quarters of the API had nothing for the contract gate to diff; `/api/metrics` is now typed as the Prometheus text it serves rather than implying JSON, and `PUT /api/settings` keeps no success schema because it always answers 501 by design.- **The labels, channels and status endpoints now publish the shape of what they return** — all twenty-four carried a status and a sentence but no schema, so the committed OpenAPI snapshot had nothing to diff for three whole modules; the status media route is now typed as the binary stream it is rather than implying JSON, and a status timestamp is documented as the ISO-8601 string it serialises to rather than the `Date` the engine hands over.- **The catalog endpoints now publish the shape of what they return, including one that disagrees with the rest of the API** — `POST /messages/send-product` answers `{id, timestamp}` while every send served by the message module answers `{messageId, timestamp}` for the same value, because this route passes the engine result through unmapped; the schema records the field the code actually sends rather than the one the neighbouring routes use. `send-catalog` is left with no success schema on purpose: no engine can send a catalog link, so a 2xx there would document a response that cannot occur.- **The twelve infrastructure endpoints now publish the shape of what they return, and one of them no longer describes the wrong thing** — `GET /infra/storage/export` was documented as a "Tar.gz archive stream" but answers JSON pointing at an archive it wrote under `data/exports/`, so a client following the contract would have waited for a binary body that never comes; the save and restart payloads also now state that a failed config write still answers `200` with `saved: false`, which is the flag a caller has to read.diff --git a/openapi.json b/openapi.jsonindex 7a1111936..10154deb5 100644--- a/openapi.json+++ b/openapi.json@@ -101,7 +101,14 @@],"responses": {"200": {- "description": "Paginated list of audit logs"+ "description": "Paginated list of audit logs",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/AuditListResponseDto"+ }+ }+ }}},"summary": "List audit logs with optional filters",@@ -3147,7 +3154,14 @@"parameters": [],"responses": {"200": {- "description": "Application is healthy"+ "description": "Application is healthy",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/HealthCheckResponseDto"+ }+ }+ }}},"summary": "Basic health check",@@ -3163,7 +3177,14 @@"parameters": [],"responses": {"200": {- "description": "Application is alive"+ "description": "Application is alive",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/LivenessResponseDto"+ }+ }+ }}},"summary": "Liveness probe for Kubernetes",@@ -3179,7 +3200,14 @@"parameters": [],"responses": {"200": {- "description": "Application is ready to accept traffic"+ "description": "Application is ready to accept traffic",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ReadinessResponseDto"+ }+ }+ }},"503": {"description": "A required dependency is down"@@ -3198,7 +3226,14 @@"parameters": [],"responses": {"200": {- "description": "Current settings"+ "description": "Current settings",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/SettingsResponseDto"+ }+ }+ }}},"summary": "Get application settings",@@ -4926,7 +4961,14 @@},"responses": {"200": {- "description": "Profile name updated"+ "description": "Profile name updated",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ProfileAckResponseDto"+ }+ }+ }},"400": {"description": "Session is not started"@@ -4967,7 +5009,14 @@},"responses": {"200": {- "description": "Profile status updated"+ "description": "Profile status updated",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ProfileAckResponseDto"+ }+ }+ }},"400": {"description": "Session is not started"@@ -5005,7 +5054,14 @@},"responses": {"200": {- "description": "Profile picture updated"+ "description": "Profile picture updated",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ProfileAckResponseDto"+ }+ }+ }},"400": {"description": "Neither url nor base64 provided, base64 without mimetype, or session is not started"@@ -5048,7 +5104,14 @@],"responses": {"200": {- "description": "Call rejected"+ "description": "Call rejected",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/CallAckResponseDto"+ }+ }+ }},"400": {"description": "Session is not started"@@ -5844,7 +5907,14 @@"parameters": [],"responses": {"200": {- "description": "Cross-session aggregate statistics (sessions, messages, etc.)."+ "description": "Cross-session aggregate statistics (sessions, messages, etc.).",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/OverviewStatsResponseDto"+ }+ }+ }}},"summary": "Get overall statistics",@@ -5859,7 +5929,14 @@"parameters": [],"responses": {"200": {- "description": "Message statistics with a time series for the requested period."+ "description": "Message statistics with a time series for the requested period.",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/MessageStatsResponseDto"+ }+ }+ }}},"summary": "Get message statistics with time series",@@ -5883,7 +5960,14 @@],"responses": {"200": {- "description": "Per-session statistics for the requested session."+ "description": "Per-session statistics for the requested session.",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/SessionStatsResponseDto"+ }+ }+ }}},"summary": "Get statistics for a specific session",@@ -5898,7 +5982,14 @@"parameters": [],"responses": {"200": {- "description": "Prometheus exposition text"+ "description": "Prometheus exposition text",+ "content": {+ "text/plain": {+ "schema": {+ "type": "string"+ }+ }+ }},"401": {"description": "METRICS_TOKEN is configured but the bearer is missing or wrong"@@ -6261,7 +6352,14 @@"parameters": [],"responses": {"200": {- "description": "Reports whether conversion is switched on AND the ffmpeg binary can be run, so a client can decide between converting here and converting before it sends."+ "description": "Reports whether conversion is switched on AND the ffmpeg binary can be run, so a client can decide between converting here and converting before it sends.",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ConversionStatusResponseDto"+ }+ }+ }}},"summary": "Whether server-side media conversion is available",@@ -6286,7 +6384,14 @@},"responses": {"200": {- "description": "Converted bytes, ready to post to send-audio with ptt=true. WhatsApp only renders a playable mic bubble for Ogg/Opus; other formats arrive as an audio file that will not play."+ "description": "Converted bytes, ready to post to send-audio with ptt=true. WhatsApp only renders a playable mic bubble for Ogg/Opus; other formats arrive as an audio file that will not play.",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ConvertedMediaResponseDto"+ }+ }+ }},"400": {"description": "Neither url nor base64 given, or ffmpeg refused the input."@@ -6320,7 +6425,14 @@},"responses": {"200": {- "description": "Converted bytes: baseline H.264 with AAC audio, long edge bounded at 1280, index moved to the front so the recipient can start playing before the whole file arrives."+ "description": "Converted bytes: baseline H.264 with AAC audio, long edge bounded at 1280, index moved to the front so the recipient can start playing before the whole file arrives.",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ConvertedMediaResponseDto"+ }+ }+ }},"400": {"description": "Neither url nor base64 given, or ffmpeg refused the input."@@ -7717,7 +7829,14 @@],"responses": {"200": {- "description": "Search results from the active provider"+ "description": "Search results from the active provider",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/SearchResultsResponseDto"+ }+ }+ }},"400": {"description": "Empty or whitespace-only \"q\""@@ -7867,6 +7986,123 @@}},"schemas": {+ "AuditLogDto": {+ "type": "object",+ "properties": {+ "id": {+ "type": "string",+ "example": "4f1c9b2a-..."+ },+ "action": {+ "type": "string",+ "description": "What happened.",+ "example": "session.create"+ },+ "severity": {+ "type": "string",+ "enum": [+ "info",+ "warning",+ "error"+ ],+ "example": "info"+ },+ "apiKeyId": {+ "type": "string",+ "nullable": true,+ "description": "Null for an unauthenticated or system action."+ },+ "apiKeyName": {+ "type": "string",+ "nullable": true+ },+ "sessionId": {+ "type": "string",+ "nullable": true,+ "description": "Null for a deployment-global action."+ },+ "sessionName": {+ "type": "string",+ "nullable": true+ },+ "ipAddress": {+ "type": "string",+ "nullable": true+ },+ "userAgent": {+ "type": "string",+ "nullable": true+ },+ "method": {+ "type": "string",+ "nullable": true,+ "example": "POST"+ },+ "path": {+ "type": "string",+ "nullable": true,+ "example": "/api/sessions"+ },+ "statusCode": {+ "type": "number",+ "nullable": true,+ "example": 201+ },+ "metadata": {+ "type": "object",+ "nullable": true,+ "description": "Free-form context for the action. Shape varies per action and is not part of the contract."+ },+ "errorMessage": {+ "type": "string",+ "nullable": true,+ "description": "Present only for a failed action."+ },+ "createdAt": {+ "type": "string",+ "description": "ISO-8601 timestamp the entry was written.",+ "example": "2026-08-07T12:00:00.000Z"+ }+ },+ "required": [+ "id",+ "action",+ "severity",+ "apiKeyId",+ "apiKeyName",+ "sessionId",+ "sessionName",+ "ipAddress",+ "userAgent",+ "method",+ "path",+ "statusCode",+ "metadata",+ "errorMessage",+ "createdAt"+ ]+ },+ "AuditListResponseDto": {+ "type": "object",+ "properties": {+ "data": {+ "description": "The requested page. A session-scoped API key sees only entries within its scope.",+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/AuditLogDto"+ }+ },+ "total": {+ "type": "number",+ "description": "Total matching entries, for paging.",+ "example": 128+ }+ },+ "required": [+ "data",+ "total"+ ]+ },"CreateApiKeyDto": {"type": "object","properties": {@@ -9608,94 +9844,249 @@}}},- "InfraDatabaseStatusDto": {+ "HealthCheckResponseDto": {"type": "object","properties": {- "connected": {- "type": "boolean",- "description": "Whether a `SELECT 1` probe succeeded just now.",- "example": true- },- "type": {+ "status": {"type": "string",- "description": "Configured driver.",- "example": "postgres"+ "description": "Liveness marker. This route does not probe dependencies.",+ "example": "ok"},- "host": {+ "timestamp": {"type": "string",- "description": "Host the app is configured to reach.",- "example": "openwa-postgres"+ "description": "ISO-8601 timestamp of the reply.",+ "example": "2026-08-07T12:00:00.000Z"},- "builtIn": {- "type": "boolean",- "description": "Whether OpenWA's own bundled container is actually running and backing this service, detected live from the labelled container rather than read from the saved intent. Falls back to the saved flag when Docker is unavailable.",- "example": true+ "version": {+ "type": "string",+ "description": "Running application version.",+ "example": "0.14.4"}},"required": [- "connected",- "type",- "host",- "builtIn"+ "status",+ "timestamp",+ "version"]},- "InfraRedisStatusDto": {+ "LivenessResponseDto": {"type": "object","properties": {- "enabled": {- "type": "boolean",- "description": "Whether Redis is switched on in configuration.",- "example": true- },- "connected": {- "type": "boolean",- "description": "Whether a live probe reached it.",- "example": true- },- "host": {+ "status": {"type": "string",- "example": "openwa-redis"- },- "port": {- "type": "number",- "example": 6379- },- "builtIn": {- "type": "boolean",- "description": "Whether OpenWA's bundled Redis container is backing this.",- "example": true+ "description": "Always `ok` when the process can answer at all.",+ "example": "ok"}},"required": [- "enabled",- "connected",- "host",- "port",- "builtIn"+ "status"]},- "InfraQueueDepthDto": {+ "ReadinessResponseDto": {"type": "object","properties": {- "pending": {- "type": "number",- "description": "Jobs waiting to be delivered.",- "example": 0- },- "completed": {- "type": "number",- "description": "Jobs delivered successfully.",- "example": 128+ "status": {+ "type": "string",+ "description": "Only `ok` reaches a 200 — a failing dependency answers 503 with this same shape.",+ "example": "ok"},- "failed": {- "type": "number",- "description": "Jobs that exhausted their retries.",- "example": 2- }- },- "required": [- "pending",- "completed",+ "details": {+ "type": "object",+ "description": "Per-dependency outcome, keyed by dependency name. Present on both the 200 and the 503.",+ "example": {+ "database": {+ "status": "up"+ }+ },+ "additionalProperties": {+ "type": "object"+ }+ }+ },+ "required": [+ "status",+ "details"+ ]+ },+ "SettingsGeneralDto": {+ "type": "object",+ "properties": {+ "apiBaseUrl": {+ "type": "string",+ "description": "The advertised base URL (BASE_URL), the same value the startup banner and ingress URLs use.",+ "example": "https://wa.example.com"+ },+ "autoReconnect": {+ "type": "boolean",+ "description": "Always true: the engine auto-reconnects on a transient disconnect and there is no global off switch — reconnection is bounded per session by RECONNECT_MAX_ATTEMPTS.",+ "example": true+ },+ "debugMode": {+ "type": "boolean",+ "description": "Whether database query logging is on.",+ "example": false+ }+ },+ "required": [+ "apiBaseUrl",+ "autoReconnect",+ "debugMode"+ ]+ },+ "SettingsApiDto": {+ "type": "object",+ "properties": {+ "rateLimit": {+ "type": "number",+ "description": "Requests allowed per window.",+ "example": 100+ },+ "rateLimitWindow": {+ "type": "number",+ "description": "Window length in milliseconds.",+ "example": 60000+ },+ "enableDocs": {+ "type": "boolean",+ "description": "Whether Swagger is actually served — off by default in production.",+ "example": false+ }+ },+ "required": [+ "rateLimit",+ "rateLimitWindow",+ "enableDocs"+ ]+ },+ "SettingsNotificationsDto": {+ "type": "object",+ "properties": {+ "emailEnabled": {+ "type": "boolean",+ "example": false+ },+ "notificationEmail": {+ "type": "string",+ "example": ""+ },+ "webhookAlerts": {+ "type": "boolean",+ "example": true+ }+ },+ "required": [+ "emailEnabled",+ "notificationEmail",+ "webhookAlerts"+ ]+ },+ "SettingsResponseDto": {+ "type": "object",+ "properties": {+ "general": {+ "$ref": "#/components/schemas/SettingsGeneralDto"+ },+ "api": {+ "$ref": "#/components/schemas/SettingsApiDto"+ },+ "notifications": {+ "$ref": "#/components/schemas/SettingsNotificationsDto"+ }+ },+ "required": [+ "general",+ "api",+ "notifications"+ ]+ },+ "InfraDatabaseStatusDto": {+ "type": "object",+ "properties": {+ "connected": {+ "type": "boolean",+ "description": "Whether a `SELECT 1` probe succeeded just now.",+ "example": true+ },+ "type": {+ "type": "string",+ "description": "Configured driver.",+ "example": "postgres"+ },+ "host": {+ "type": "string",+ "description": "Host the app is configured to reach.",+ "example": "openwa-postgres"+ },+ "builtIn": {+ "type": "boolean",+ "description": "Whether OpenWA's own bundled container is actually running and backing this service, detected live from the labelled container rather than read from the saved intent. Falls back to the saved flag when Docker is unavailable.",+ "example": true+ }+ },+ "required": [+ "connected",+ "type",+ "host",+ "builtIn"+ ]+ },+ "InfraRedisStatusDto": {+ "type": "object",+ "properties": {+ "enabled": {+ "type": "boolean",+ "description": "Whether Redis is switched on in configuration.",+ "example": true+ },+ "connected": {+ "type": "boolean",+ "description": "Whether a live probe reached it.",+ "example": true+ },+ "host": {+ "type": "string",+ "example": "openwa-redis"+ },+ "port": {+ "type": "number",+ "example": 6379+ },+ "builtIn": {+ "type": "boolean",+ "description": "Whether OpenWA's bundled Redis container is backing this.",+ "example": true+ }+ },+ "required": [+ "enabled",+ "connected",+ "host",+ "port",+ "builtIn"+ ]+ },+ "InfraQueueDepthDto": {+ "type": "object",+ "properties": {+ "pending": {+ "type": "number",+ "description": "Jobs waiting to be delivered.",+ "example": 0+ },+ "completed": {+ "type": "number",+ "description": "Jobs delivered successfully.",+ "example": 128+ },+ "failed": {+ "type": "number",+ "description": "Jobs that exhausted their retries.",+ "example": 2+ }+ },+ "required": [+ "pending",+ "completed","failed"]},@@ -11447,6 +11838,25 @@"name"]},+ "ProfileAckResponseDto": {+ "type": "object",+ "properties": {+ "success": {+ "type": "boolean",+ "description": "Always true — a failure is reported as a non-2xx status, not as false.",+ "example": true+ },+ "message": {+ "type": "string",+ "description": "Human-readable confirmation of what was changed.",+ "example": "Profile name updated"+ }+ },+ "required": [+ "success",+ "message"+ ]+ },"SetProfileStatusDto": {"type": "object","properties": {@@ -11479,6 +11889,19 @@}}},+ "CallAckResponseDto": {+ "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"+ ]+ },"LabelDto": {"type": "object","properties": {@@ -11711,6 +12134,347 @@"mute"]},+ "OverviewSessionsDto": {+ "type": "object",+ "properties": {+ "active": {+ "type": "number",+ "description": "Sessions currently connected.",+ "example": 2+ },+ "total": {+ "type": "number",+ "description": "Sessions on record, connected or not.",+ "example": 5+ },+ "byStatus": {+ "type": "object",+ "description": "Session count per status value.",+ "example": {+ "ready": 2,+ "disconnected": 3+ },+ "additionalProperties": {+ "type": "integer"+ }+ }+ },+ "required": [+ "active",+ "total",+ "byStatus"+ ]+ },+ "OverviewTodayDto": {+ "type": "object",+ "properties": {+ "sent": {+ "type": "number",+ "example": 12+ },+ "received": {+ "type": "number",+ "example": 34+ }+ },+ "required": [+ "sent",+ "received"+ ]+ },+ "OverviewMessagesDto": {+ "type": "object",+ "properties": {+ "sent": {+ "type": "number",+ "description": "All-time sent count.",+ "example": 1024+ },+ "received": {+ "type": "number",+ "description": "All-time received count.",+ "example": 2048+ },+ "failed": {+ "type": "number",+ "description": "Sends the gateway recorded as failed.",+ "example": 3+ },+ "today": {+ "description": "Today's counts, in the server's timezone.",+ "allOf": [+ {+ "$ref": "#/components/schemas/OverviewTodayDto"+ }+ ]+ }+ },+ "required": [+ "sent",+ "received",+ "failed",+ "today"+ ]+ },+ "OverviewStatsResponseDto": {+ "type": "object",+ "properties": {+ "sessions": {+ "$ref": "#/components/schemas/OverviewSessionsDto"+ },+ "messages": {+ "$ref": "#/components/schemas/OverviewMessagesDto"+ }+ },+ "required": [+ "sessions",+ "messages"+ ]+ },+ "TimeSeriesPointDto": {+ "type": "object",+ "properties": {+ "timestamp": {+ "type": "string",+ "description": "Bucket start, ISO-8601.",+ "example": "2026-08-07T12:00:00.000Z"+ },+ "sent": {+ "type": "number",+ "example": 12+ },+ "received": {+ "type": "number",+ "example": 34+ }+ },+ "required": [+ "timestamp",+ "sent",+ "received"+ ]+ },+ "StatsBySessionDto": {+ "type": "object",+ "properties": {+ "sessionId": {+ "type": "string",+ "example": "0a941dac-a965-45e7-b318-74ae8be134f0"+ },+ "name": {+ "type": "string",+ "example": "primary"+ },+ "sent": {+ "type": "number",+ "example": 12+ },+ "received": {+ "type": "number",+ "example": 34+ }+ },+ "required": [+ "sessionId",+ "name",+ "sent",+ "received"+ ]+ },+ "StatsTopChatDto": {+ "type": "object",+ "properties": {+ "chatId": {+ "type": "string",+ "example": "[email protected]"+ },+ "chatName": {+ "type": "string",+ "nullable": true,+ "description": "Null when no name is known for the chat."+ },+ "messageCount": {+ "type": "number",+ "example": 42+ }+ },+ "required": [+ "chatId",+ "chatName",+ "messageCount"+ ]+ },+ "MessageStatsResponseDto": {+ "type": "object",+ "properties": {+ "timeSeries": {+ "description": "One point per bucket over the requested period.",+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/TimeSeriesPointDto"+ }+ },+ "byType": {+ "type": "object",+ "description": "Message count per message type.",+ "example": {+ "text": 900,+ "image": 124+ },+ "additionalProperties": {+ "type": "integer"+ }+ },+ "bySession": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/StatsBySessionDto"+ }+ },+ "topChats": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/StatsTopChatDto"+ }+ }+ },+ "required": [+ "timeSeries",+ "byType",+ "bySession",+ "topChats"+ ]+ },+ "SessionStatsSessionDto": {+ "type": "object",+ "properties": {+ "id": {+ "type": "string",+ "example": "0a941dac-a965-45e7-b318-74ae8be134f0"+ },+ "name": {+ "type": "string",+ "example": "primary"+ },+ "status": {+ "type": "string",+ "example": "ready"+ }+ },+ "required": [+ "id",+ "name",+ "status"+ ]+ },+ "SessionStatsMessagesDto": {+ "type": "object",+ "properties": {+ "sent": {+ "type": "number",+ "example": 1024+ },+ "received": {+ "type": "number",+ "example": 2048+ },+ "today": {+ "type": "number",+ "example": 46+ },+ "failed": {+ "type": "number",+ "example": 3+ }+ },+ "required": [+ "sent",+ "received",+ "today",+ "failed"+ ]+ },+ "SessionStatsTopChatDto": {+ "type": "object",+ "properties": {+ "chatId": {+ "type": "string",+ "example": "[email protected]"+ },+ "chatName": {+ "type": "string",+ "nullable": true,+ "description": "Null when no name is known for the chat."+ },+ "count": {+ "type": "number",+ "example": 42+ },+ "lastActive": {+ "type": "string",+ "description": "ISO-8601 timestamp of the last message.",+ "example": "2026-08-07T12:00:00.000Z"+ }+ },+ "required": [+ "chatId",+ "chatName",+ "count",+ "lastActive"+ ]+ },+ "SessionHourlyActivityDto": {+ "type": "object",+ "properties": {+ "hour": {+ "type": "number",+ "description": "Hour of day, 0-23.",+ "example": 9+ },+ "sent": {+ "type": "number",+ "example": 12+ },+ "received": {+ "type": "number",+ "example": 34+ }+ },+ "required": [+ "hour",+ "sent",+ "received"+ ]+ },+ "SessionStatsResponseDto": {+ "type": "object",+ "properties": {+ "session": {+ "$ref": "#/components/schemas/SessionStatsSessionDto"+ },+ "messages": {+ "$ref": "#/components/schemas/SessionStatsMessagesDto"+ },+ "topChats": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/SessionStatsTopChatDto"+ }+ },+ "hourlyActivity": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/SessionHourlyActivityDto"+ }+ }+ },+ "required": [+ "session",+ "messages",+ "topChats",+ "hourlyActivity"+ ]+ },"StatusContactDto": {"type": "object","properties": {@@ -12016,6 +12780,19 @@"message"]},+ "ConversionStatusResponseDto": {+ "type": "object",+ "properties": {+ "available": {+ "type": "boolean",+ "description": "True only when conversion is switched on AND the ffmpeg binary is runnable. False means a convert call will be refused, so check this before offering conversion in a UI.",+ "example": true+ }+ },+ "required": [+ "available"+ ]+ },"ConvertMediaDto": {"type": "object","properties": {@@ -12031,6 +12808,31 @@}}},+ "ConvertedMediaResponseDto": {+ "type": "object",+ "properties": {+ "base64": {+ "type": "string",+ "description": "The converted bytes, ready to hand straight to a send endpoint's `base64` field.",+ "example": "T2dnUwACAAAAAAAAAAA..."+ },+ "mimetype": {+ "type": "string",+ "description": "The type the bytes now are — not the type they were.",+ "example": "audio/ogg; codecs=opus"+ },+ "bytes": {+ "type": "number",+ "description": "Decoded size, so a caller can check a send limit without decoding.",+ "example": 20480+ }+ },+ "required": [+ "base64",+ "mimetype",+ "bytes"+ ]+ },"CatalogDto": {"type": "object","properties": {@@ -12537,6 +13339,110 @@"description": "Per-instance config slice passed to the adapter."}}+ },+ "SearchHitDto": {+ "type": "object",+ "properties": {+ "messageId": {+ "type": "string",+ "description": "Gateway message row id.",+ "example": "4f1c9b2a-..."+ },+ "waMessageId": {+ "type": "string",+ "description": "WhatsApp's own message id.",+ "example": "[email protected]_3EB0123"+ },+ "sessionId": {+ "type": "string",+ "example": "0a941dac-a965-45e7-b318-74ae8be134f0"+ },+ "chatId": {+ "type": "string",+ "example": "[email protected]"+ },+ "body": {+ "type": "string",+ "description": "Full message text.",+ "example": "See you at 10"+ },+ "snippet": {+ "type": "string",+ "description": "Excerpt with `<mark>` highlight markers. Render it as TEXT, never as HTML — the markers come from the provider and the body is user-supplied.",+ "example": "See you at <mark>10</mark>"+ },+ "timestamp": {+ "type": "number",+ "description": "Unix SECONDS of the message.",+ "example": 1786000000+ },+ "type": {+ "type": "string",+ "example": "text"+ },+ "direction": {+ "type": "string",+ "enum": [+ "inbound",+ "outbound"+ ],+ "example": "inbound"+ },+ "from": {+ "type": "string",+ "description": "Sender id.",+ "example": "[email protected]"+ },+ "score": {+ "type": "number",+ "description": "Relevance score, when the provider reports one.",+ "example": 0.87+ }+ },+ "required": [+ "messageId",+ "waMessageId",+ "sessionId",+ "chatId",+ "body",+ "snippet",+ "timestamp",+ "type",+ "direction",+ "from"+ ]+ },+ "SearchResultsResponseDto": {+ "type": "object",+ "properties": {+ "hits": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/SearchHitDto"+ }+ },+ "total": {+ "type": "number",+ "description": "Bounded exact count for pagination.",+ "example": 42+ },+ "tookMs": {+ "type": "number",+ "description": "How long the provider took, in milliseconds.",+ "example": 12+ },+ "provider": {+ "type": "string",+ "description": "Which provider answered.",+ "example": "builtin-db"+ }+ },+ "required": [+ "hits",+ "total",+ "tookMs",+ "provider"+ ]}}},diff --git a/src/modules/audit/audit.controller.ts b/src/modules/audit/audit.controller.tsindex 6022e38e6..afd13dcf9 100644--- a/src/modules/audit/audit.controller.ts+++ b/src/modules/audit/audit.controller.ts@@ -1,5 +1,6 @@import { Controller, Get, Query } from '@nestjs/common';import { ApiTags, ApiOperation, ApiResponse, ApiQuery } from '@nestjs/swagger';+import { AuditListResponseDto } from './dto/audit-response.dto';import { AuditService, AuditQueryOptions } from './audit.service';import { AuditLog, AuditAction, AuditSeverity } from './entities/audit-log.entity';import { RequireRole, CurrentApiKey } from '../auth/decorators/auth.decorators';@@ -19,10 +20,7 @@ export class AuditController {@ApiQuery({ name: 'apiKeyId', required: false })@ApiQuery({ name: 'limit', required: false, type: Number })@ApiQuery({ name: 'offset', required: false, type: Number })- @ApiResponse({- status: 200,- description: 'Paginated list of audit logs',- })+ @ApiResponse({ status: 200, description: 'Paginated list of audit logs', type: AuditListResponseDto })async findAll(@CurrentApiKey() apiKey?: ApiKey,@Query('action') action?: AuditAction,diff --git a/src/modules/audit/dto/audit-response.dto.ts b/src/modules/audit/dto/audit-response.dto.tsnew file mode 100644index 000000000..f4b362ffd--- /dev/null+++ b/src/modules/audit/dto/audit-response.dto.ts@@ -0,0 +1,56 @@+import { ApiProperty } from '@nestjs/swagger';++/**+ * Response shapes for the audit 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 AuditLogDto {+ @ApiProperty({ example: '4f1c9b2a-...' }) id!: string;++ @ApiProperty({ description: 'What happened.', example: 'session.create' })+ action!: string;++ @ApiProperty({ enum: ['info', 'warning', 'error'], example: 'info' })+ severity!: string;++ @ApiProperty({ type: String, nullable: true, description: 'Null for an unauthenticated or system action.' })+ apiKeyId!: string | null;++ @ApiProperty({ type: String, nullable: true }) apiKeyName!: string | null;++ @ApiProperty({ type: String, nullable: true, description: 'Null for a deployment-global action.' })+ sessionId!: string | null;++ @ApiProperty({ type: String, nullable: true }) sessionName!: string | null;+ @ApiProperty({ type: String, nullable: true }) ipAddress!: string | null;+ @ApiProperty({ type: String, nullable: true }) userAgent!: string | null;+ @ApiProperty({ type: String, nullable: true, example: 'POST' }) method!: string | null;+ @ApiProperty({ type: String, nullable: true, example: '/api/sessions' }) path!: string | null;+ @ApiProperty({ type: Number, nullable: true, example: 201 }) statusCode!: number | null;++ @ApiProperty({+ type: Object,+ nullable: true,+ description: 'Free-form context for the action. Shape varies per action and is not part of the contract.',+ })+ metadata!: object | null;++ @ApiProperty({ type: String, nullable: true, description: 'Present only for a failed action.' })+ errorMessage!: string | null;++ @ApiProperty({ description: 'ISO-8601 timestamp the entry was written.', example: '2026-08-07T12:00:00.000Z' })+ createdAt!: string;+}++export class AuditListResponseDto {+ @ApiProperty({+ type: [AuditLogDto],+ description: 'The requested page. A session-scoped API key sees only entries within its scope.',+ })+ data!: AuditLogDto[];++ @ApiProperty({ description: 'Total matching entries, for paging.', example: 128 })+ total!: number;+}diff --git a/src/modules/call/call.controller.ts b/src/modules/call/call.controller.tsindex c77c91ad8..8148f7f94 100644--- a/src/modules/call/call.controller.ts+++ b/src/modules/call/call.controller.ts@@ -1,5 +1,6 @@import { Controller, Post, Param, HttpCode, HttpStatus } from '@nestjs/common';import { ApiTags, ApiOperation, ApiResponse, ApiParam } from '@nestjs/swagger';+import { CallAckResponseDto } from './dto/call-response.dto';import { CallService } from './call.service';import { RequireRole } from '../auth/decorators/auth.decorators';import { ApiKeyRole } from '../auth/entities/api-key.entity';@@ -15,7 +16,7 @@ export class CallController {@ApiOperation({ summary: 'Reject a ringing incoming call' })@ApiParam({ name: 'sessionId', description: 'Session ID' })@ApiParam({ name: 'callId', description: 'Call ID from the call.received event' })- @ApiResponse({ status: 200, description: 'Call rejected' })+ @ApiResponse({ status: 200, description: 'Call rejected', type: CallAckResponseDto })@ApiResponse({ status: 400, description: 'Session is not started' })@ApiResponse({ status: 404, description: 'Call not found or no longer ringing' })async reject(@Param('sessionId') sessionId: string, @Param('callId') callId: string) {diff --git a/src/modules/call/dto/call-response.dto.ts b/src/modules/call/dto/call-response.dto.tsnew file mode 100644index 000000000..211a9a638--- /dev/null+++ b/src/modules/call/dto/call-response.dto.ts@@ -0,0 +1,12 @@+import { ApiProperty } from '@nestjs/swagger';++/**+ * Response shapes for the call 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 CallAckResponseDto {+ @ApiProperty({ description: 'Always true — a failure is reported as a non-2xx status, not as false.', example: true })+ success!: boolean;+}diff --git a/src/modules/health/dto/health-response.dto.ts b/src/modules/health/dto/health-response.dto.tsnew file mode 100644index 000000000..f7a444884--- /dev/null+++ b/src/modules/health/dto/health-response.dto.ts@@ -0,0 +1,38 @@+import { ApiProperty } from '@nestjs/swagger';++/**+ * Response shapes for the health 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 HealthCheckResponseDto {+ @ApiProperty({ description: 'Liveness marker. This route does not probe dependencies.', example: 'ok' })+ status!: string;++ @ApiProperty({ description: 'ISO-8601 timestamp of the reply.', example: '2026-08-07T12:00:00.000Z' })+ timestamp!: string;++ @ApiProperty({ description: 'Running application version.', example: '0.14.4' })+ version!: string;+}++export class LivenessResponseDto {+ @ApiProperty({ description: 'Always `ok` when the process can answer at all.', example: 'ok' })+ status!: string;+}++export class ReadinessResponseDto {+ @ApiProperty({+ description: 'Only `ok` reaches a 200 — a failing dependency answers 503 with this same shape.',+ example: 'ok',+ })+ status!: string;++ @ApiProperty({+ description: 'Per-dependency outcome, keyed by dependency name. Present on both the 200 and the 503.',+ example: { database: { status: 'up' } },+ additionalProperties: { type: 'object' },+ })+ details!: { [dependency: string]: object };+}diff --git a/src/modules/health/health.controller.ts b/src/modules/health/health.controller.tsindex 1ccaa95c8..7388ccefe 100644--- a/src/modules/health/health.controller.ts+++ b/src/modules/health/health.controller.ts@@ -1,5 +1,6 @@import { Controller, Get, ServiceUnavailableException } from '@nestjs/common';import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';+import { HealthCheckResponseDto, LivenessResponseDto, ReadinessResponseDto } from './dto/health-response.dto';import { InjectDataSource } from '@nestjs/typeorm';import { DataSource } from 'typeorm';import { Public } from '../auth/decorators/auth.decorators';@@ -36,7 +37,7 @@ export class HealthController {@Get()@ApiOperation({ summary: 'Basic health check' })- @ApiResponse({ status: 200, description: 'Application is healthy' })+ @ApiResponse({ status: 200, description: 'Application is healthy', type: HealthCheckResponseDto })check(): { status: string; timestamp: string; version: string } {return {status: 'ok',@@ -47,7 +48,7 @@ export class HealthController {@Get('live')@ApiOperation({ summary: 'Liveness probe for Kubernetes' })- @ApiResponse({ status: 200, description: 'Application is alive' })+ @ApiResponse({ status: 200, description: 'Application is alive', type: LivenessResponseDto })liveness(): { status: string } {// Liveness only reflects process liveness — deliberately static so a transient// dependency outage doesn't trigger a pod KILL (that's readiness' job).@@ -56,7 +57,7 @@ export class HealthController {@Get('ready')@ApiOperation({ summary: 'Readiness probe — verifies the auth/audit + data databases respond' })- @ApiResponse({ status: 200, description: 'Application is ready to accept traffic' })+ @ApiResponse({ status: 200, description: 'Application is ready to accept traffic', type: ReadinessResponseDto })@ApiResponse({ status: 503, description: 'A required dependency is down' })async readiness(): Promise<HealthCheckResult> {// While draining (shutdown started), report 503 so the LB/orchestrator stopsdiff --git a/src/modules/media/dto/media-response.dto.ts b/src/modules/media/dto/media-response.dto.tsnew file mode 100644index 000000000..deefd74a4--- /dev/null+++ b/src/modules/media/dto/media-response.dto.ts@@ -0,0 +1,34 @@+import { ApiProperty } from '@nestjs/swagger';++/**+ * Response shapes for the media conversion 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 ConversionStatusResponseDto {+ @ApiProperty({+ description:+ 'True only when conversion is switched on AND the ffmpeg binary is runnable. False means a ' ++ 'convert call will be refused, so check this before offering conversion in a UI.',+ example: true,+ })+ available!: boolean;+}++export class ConvertedMediaResponseDto {+ @ApiProperty({+ description: "The converted bytes, ready to hand straight to a send endpoint's `base64` field.",+ example: 'T2dnUwACAAAAAAAAAAA...',+ })+ base64!: string;++ @ApiProperty({+ description: 'The type the bytes now are — not the type they were.',+ example: 'audio/ogg; codecs=opus',+ })+ mimetype!: string;++ @ApiProperty({ description: 'Decoded size, so a caller can check a send limit without decoding.', example: 20480 })+ bytes!: number;+}diff --git a/src/modules/media/media.controller.ts b/src/modules/media/media.controller.tsindex 7ba09f901..18a28a51e 100644--- a/src/modules/media/media.controller.ts+++ b/src/modules/media/media.controller.ts@@ -1,5 +1,6 @@import { Body, Controller, Get, HttpCode, HttpStatus, Post } from '@nestjs/common';import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';+import { ConversionStatusResponseDto, ConvertedMediaResponseDto } from './dto/media-response.dto';import { MediaConversionService } from './media-conversion.service';import { ConvertMediaDto } from './dto/convert-media.dto';import { RequireRole } from '../auth/decorators/auth.decorators';@@ -25,6 +26,7 @@ export class MediaController {description:'Reports whether conversion is switched on AND the ffmpeg binary can be run, so a client can ' +'decide between converting here and converting before it sends.',+ type: ConversionStatusResponseDto,})async conversionStatus(): Promise<{ available: boolean }> {return { available: await this.mediaConversion.isAvailable() };@@ -40,6 +42,7 @@ export class MediaController {description:'Converted bytes, ready to post to send-audio with ptt=true. WhatsApp only renders a playable ' +'mic bubble for Ogg/Opus; other formats arrive as an audio file that will not play.',+ type: ConvertedMediaResponseDto,})@ApiResponse({ status: 400, description: 'Neither url nor base64 given, or ffmpeg refused the input.' })@ApiResponse({ status: 413, description: 'The supplied media is above the media size cap.' })@@ -61,6 +64,7 @@ export class MediaController {description:'Converted bytes: baseline H.264 with AAC audio, long edge bounded at 1280, index moved to the ' +'front so the recipient can start playing before the whole file arrives.',+ type: ConvertedMediaResponseDto,})@ApiResponse({ status: 400, description: 'Neither url nor base64 given, or ffmpeg refused the input.' })@ApiResponse({ status: 413, description: 'The supplied media is above the media size cap.' })diff --git a/src/modules/metrics/metrics.controller.ts b/src/modules/metrics/metrics.controller.tsindex bc1fdedbc..1fdcdefb6 100644--- a/src/modules/metrics/metrics.controller.ts+++ b/src/modules/metrics/metrics.controller.ts@@ -21,7 +21,11 @@ export class MetricsController {@Get()@ApiOperation({ summary: 'Prometheus metrics (requires METRICS_TOKEN bearer)' })@ApiSecurity(METRICS_BEARER_SCHEME)- @ApiResponse({ status: 200, description: 'Prometheus exposition text' })+ @ApiResponse({+ status: 200,+ description: 'Prometheus exposition text',+ content: { 'text/plain': { schema: { type: 'string' } } },+ })@ApiResponse({ status: 401, description: 'METRICS_TOKEN is configured but the bearer is missing or wrong' })@ApiResponse({ status: 404, description: 'Metrics endpoint is disabled (METRICS_TOKEN unset)' })@Header('Content-Type', 'text/plain; version=0.0.4; charset=utf-8')diff --git a/src/modules/profile/dto/profile-response.dto.ts b/src/modules/profile/dto/profile-response.dto.tsnew file mode 100644index 000000000..b44bb9ee8--- /dev/null+++ b/src/modules/profile/dto/profile-response.dto.ts@@ -0,0 +1,15 @@+import { ApiProperty } from '@nestjs/swagger';++/**+ * Response shapes for the profile 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 ProfileAckResponseDto {+ @ApiProperty({ description: 'Always true — a failure is reported as a non-2xx status, not as false.', example: true })+ success!: boolean;++ @ApiProperty({ description: 'Human-readable confirmation of what was changed.', example: 'Profile name updated' })+ message!: string;+}diff --git a/src/modules/profile/profile.controller.ts b/src/modules/profile/profile.controller.tsindex 42e239f2a..e3f09fc6d 100644--- a/src/modules/profile/profile.controller.ts+++ b/src/modules/profile/profile.controller.ts@@ -1,5 +1,6 @@import { Controller, Put, Param, Body } from '@nestjs/common';import { ApiTags, ApiOperation, ApiResponse, ApiParam, ApiBody } from '@nestjs/swagger';+import { ProfileAckResponseDto } from './dto/profile-response.dto';import { ProfileService } from './profile.service';import { SetProfileNameDto, SetProfileStatusDto, SetProfilePictureDto } from './dto/profile.dto';import { RequireRole } from '../auth/decorators/auth.decorators';@@ -15,7 +16,7 @@ export class ProfileController {@ApiOperation({ summary: 'Set the account display name' })@ApiParam({ name: 'sessionId', description: 'Session ID' })@ApiBody({ type: SetProfileNameDto })- @ApiResponse({ status: 200, description: 'Profile name updated' })+ @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' })async setName(@Param('sessionId') sessionId: string, @Body() dto: SetProfileNameDto) {@@ -28,7 +29,7 @@ export class ProfileController {@ApiOperation({ summary: 'Set the account about/status text' })@ApiParam({ name: 'sessionId', description: 'Session ID' })@ApiBody({ type: SetProfileStatusDto })- @ApiResponse({ status: 200, description: 'Profile status updated' })+ @ApiResponse({ status: 200, description: 'Profile status updated', type: ProfileAckResponseDto })@ApiResponse({ status: 400, description: 'Session is not started' })async setStatus(@Param('sessionId') sessionId: string, @Body() dto: SetProfileStatusDto) {await this.profileService.setProfileStatus(sessionId, dto.status);@@ -40,7 +41,7 @@ export class ProfileController {@ApiOperation({ summary: 'Set the account profile picture (URL or base64 image)' })@ApiParam({ name: 'sessionId', description: 'Session ID' })@ApiBody({ type: SetProfilePictureDto })- @ApiResponse({ status: 200, description: 'Profile picture updated' })+ @ApiResponse({ status: 200, description: 'Profile picture updated', type: ProfileAckResponseDto })@ApiResponse({status: 400,description: 'Neither url nor base64 provided, base64 without mimetype, or session is not started',diff --git a/src/modules/search/dto/search-response.dto.ts b/src/modules/search/dto/search-response.dto.tsnew file mode 100644index 000000000..a2eff1e05--- /dev/null+++ b/src/modules/search/dto/search-response.dto.ts@@ -0,0 +1,55 @@+import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';++/**+ * Response shapes for the search 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 SearchHitDto {+ @ApiProperty({ description: 'Gateway message row id.', example: '4f1c9b2a-...' })+ messageId!: string;++ @ApiProperty({ description: "WhatsApp's own message id.", example: '[email protected]_3EB0123' })+ waMessageId!: string;++ @ApiProperty({ example: '0a941dac-a965-45e7-b318-74ae8be134f0' }) sessionId!: string;+ @ApiProperty({ example: '[email protected]' }) chatId!: string;++ @ApiProperty({ description: 'Full message text.', example: 'See you at 10' })+ body!: string;++ @ApiProperty({+ description:+ 'Excerpt with `<mark>` highlight markers. Render it as TEXT, never as HTML — the markers come ' ++ 'from the provider and the body is user-supplied.',+ example: 'See you at <mark>10</mark>',+ })+ snippet!: string;++ @ApiProperty({ description: 'Unix SECONDS of the message.', example: 1786000000 })+ timestamp!: number;++ @ApiProperty({ example: 'text' }) type!: string;+ @ApiProperty({ enum: ['inbound', 'outbound'], example: 'inbound' }) direction!: string;++ @ApiProperty({ description: 'Sender id.', example: '[email protected]' })+ from!: string;++ @ApiPropertyOptional({ description: 'Relevance score, when the provider reports one.', example: 0.87 })+ score?: number;+}++export class SearchResultsResponseDto {+ @ApiProperty({ type: [SearchHitDto] })+ hits!: SearchHitDto[];++ @ApiProperty({ description: 'Bounded exact count for pagination.', example: 42 })+ total!: number;++ @ApiProperty({ description: 'How long the provider took, in milliseconds.', example: 12 })+ tookMs!: number;++ @ApiProperty({ description: 'Which provider answered.', example: 'builtin-db' })+ provider!: string;+}diff --git a/src/modules/search/search.controller.ts b/src/modules/search/search.controller.tsindex 63ac6df09..9a254c176 100644--- a/src/modules/search/search.controller.ts+++ b/src/modules/search/search.controller.ts@@ -1,5 +1,6 @@import { Controller, Get, Query, BadRequestException } from '@nestjs/common';import { ApiTags, ApiOperation, ApiResponse, ApiQuery } from '@nestjs/swagger';+import { SearchResultsResponseDto } from './dto/search-response.dto';import { RequireRole, CurrentApiKey } from '../auth/decorators/auth.decorators';import { ApiKey, ApiKeyRole } from '../auth/entities/api-key.entity';import { SearchService } from './search.service';@@ -14,7 +15,7 @@ export class SearchController {@Get()@RequireRole(ApiKeyRole.OPERATOR)@ApiOperation({ summary: 'Search messages across sessions (active search provider)' })- @ApiResponse({ status: 200, description: 'Search results from the active provider' })+ @ApiResponse({ status: 200, description: 'Search results from the active provider', type: SearchResultsResponseDto })@ApiResponse({ status: 400, description: 'Empty or whitespace-only "q"' })@ApiResponse({ status: 501, description: 'No search provider configured' })@ApiQuery({ name: 'q', required: true, description: 'Search term (required, non-empty)' })diff --git a/src/modules/settings/dto/settings-response.dto.ts b/src/modules/settings/dto/settings-response.dto.tsnew file mode 100644index 000000000..27855e71e--- /dev/null+++ b/src/modules/settings/dto/settings-response.dto.ts@@ -0,0 +1,54 @@+import { ApiProperty } from '@nestjs/swagger';++/**+ * Response shapes for the settings 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 SettingsGeneralDto {+ @ApiProperty({+ description: 'The advertised base URL (BASE_URL), the same value the startup banner and ingress URLs use.',+ example: 'https://wa.example.com',+ })+ apiBaseUrl!: string;++ @ApiProperty({+ description:+ 'Always true: the engine auto-reconnects on a transient disconnect and there is no global off ' ++ 'switch — reconnection is bounded per session by RECONNECT_MAX_ATTEMPTS.',+ example: true,+ })+ autoReconnect!: boolean;++ @ApiProperty({ description: 'Whether database query logging is on.', example: false })+ debugMode!: boolean;+}++export class SettingsApiDto {+ @ApiProperty({ description: 'Requests allowed per window.', example: 100 })+ rateLimit!: number;++ @ApiProperty({ description: 'Window length in milliseconds.', example: 60000 })+ rateLimitWindow!: number;++ @ApiProperty({ description: 'Whether Swagger is actually served — off by default in production.', example: false })+ enableDocs!: boolean;+}++export class SettingsNotificationsDto {+ @ApiProperty({ example: false }) emailEnabled!: boolean;+ @ApiProperty({ example: '' }) notificationEmail!: string;+ @ApiProperty({ example: true }) webhookAlerts!: boolean;+}++export class SettingsResponseDto {+ @ApiProperty({ type: SettingsGeneralDto })+ general!: SettingsGeneralDto;++ @ApiProperty({ type: SettingsApiDto })+ api!: SettingsApiDto;++ @ApiProperty({ type: SettingsNotificationsDto })+ notifications!: SettingsNotificationsDto;+}diff --git a/src/modules/settings/settings.controller.ts b/src/modules/settings/settings.controller.tsindex 86e6a9884..612abb158 100644--- a/src/modules/settings/settings.controller.ts+++ b/src/modules/settings/settings.controller.ts@@ -1,5 +1,6 @@import { Controller, Get, Put, NotImplementedException } from '@nestjs/common';import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';+import { SettingsResponseDto } from './dto/settings-response.dto';import { ConfigService } from '@nestjs/config';import { RequireRole, RequireUnscopedKey } from '../auth/decorators/auth.decorators';import { ApiKeyRole } from '../auth/entities/api-key.entity';@@ -62,7 +63,7 @@ export class SettingsController {@RequireRole(ApiKeyRole.ADMIN)@RequireUnscopedKey()@ApiOperation({ summary: 'Get application settings' })- @ApiResponse({ status: 200, description: 'Current settings' })+ @ApiResponse({ status: 200, description: 'Current settings', type: SettingsResponseDto })get(): Settings {// Settings expose environment-derived configuration (debug flag, reconnect policy, rate-limit// thresholds, base URL) that describes the deployment rather than any one session. Gate the readdiff --git a/src/modules/stats/dto/stats-response.dto.ts b/src/modules/stats/dto/stats-response.dto.tsnew file mode 100644index 000000000..29452047b--- /dev/null+++ b/src/modules/stats/dto/stats-response.dto.ts@@ -0,0 +1,138 @@+import { ApiProperty } from '@nestjs/swagger';++/**+ * Response shapes for the statistics 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 OverviewSessionsDto {+ @ApiProperty({ description: 'Sessions currently connected.', example: 2 })+ active!: number;++ @ApiProperty({ description: 'Sessions on record, connected or not.', example: 5 })+ total!: number;++ @ApiProperty({+ description: 'Session count per status value.',+ example: { ready: 2, disconnected: 3 },+ additionalProperties: { type: 'integer' },+ })+ byStatus!: { [status: string]: number };+}++export class OverviewTodayDto {+ @ApiProperty({ example: 12 }) sent!: number;+ @ApiProperty({ example: 34 }) received!: number;+}++export class OverviewMessagesDto {+ @ApiProperty({ description: 'All-time sent count.', example: 1024 })+ sent!: number;++ @ApiProperty({ description: 'All-time received count.', example: 2048 })+ received!: number;++ @ApiProperty({ description: 'Sends the gateway recorded as failed.', example: 3 })+ failed!: number;++ @ApiProperty({ type: OverviewTodayDto, description: "Today's counts, in the server's timezone." })+ today!: OverviewTodayDto;+}++export class OverviewStatsResponseDto {+ @ApiProperty({ type: OverviewSessionsDto })+ sessions!: OverviewSessionsDto;++ @ApiProperty({ type: OverviewMessagesDto })+ messages!: OverviewMessagesDto;+}++export class TimeSeriesPointDto {+ @ApiProperty({ description: 'Bucket start, ISO-8601.', example: '2026-08-07T12:00:00.000Z' })+ timestamp!: string;++ @ApiProperty({ example: 12 }) sent!: number;+ @ApiProperty({ example: 34 }) received!: number;+}++export class StatsBySessionDto {+ @ApiProperty({ example: '0a941dac-a965-45e7-b318-74ae8be134f0' }) sessionId!: string;+ @ApiProperty({ example: 'primary' }) name!: string;+ @ApiProperty({ example: 12 }) sent!: number;+ @ApiProperty({ example: 34 }) received!: number;+}++export class StatsTopChatDto {+ @ApiProperty({ example: '[email protected]' })+ chatId!: string;++ @ApiProperty({ type: String, nullable: true, description: 'Null when no name is known for the chat.' })+ chatName!: string | null;++ @ApiProperty({ example: 42 }) messageCount!: number;+}++export class MessageStatsResponseDto {+ @ApiProperty({ type: [TimeSeriesPointDto], description: 'One point per bucket over the requested period.' })+ timeSeries!: TimeSeriesPointDto[];++ @ApiProperty({+ description: 'Message count per message type.',+ example: { text: 900, image: 124 },+ additionalProperties: { type: 'integer' },+ })+ byType!: { [messageType: string]: number };++ @ApiProperty({ type: [StatsBySessionDto] })+ bySession!: StatsBySessionDto[];++ @ApiProperty({ type: [StatsTopChatDto] })+ topChats!: StatsTopChatDto[];+}++export class SessionStatsSessionDto {+ @ApiProperty({ example: '0a941dac-a965-45e7-b318-74ae8be134f0' }) id!: string;+ @ApiProperty({ example: 'primary' }) name!: string;+ @ApiProperty({ example: 'ready' }) status!: string;+}++export class SessionStatsMessagesDto {+ @ApiProperty({ example: 1024 }) sent!: number;+ @ApiProperty({ example: 2048 }) received!: number;+ @ApiProperty({ example: 46 }) today!: number;+ @ApiProperty({ example: 3 }) failed!: number;+}++export class SessionStatsTopChatDto {+ @ApiProperty({ example: '[email protected]' })+ chatId!: string;++ @ApiProperty({ type: String, nullable: true, description: 'Null when no name is known for the chat.' })+ chatName!: string | null;++ @ApiProperty({ example: 42 }) count!: number;++ @ApiProperty({ description: 'ISO-8601 timestamp of the last message.', example: '2026-08-07T12:00:00.000Z' })+ lastActive!: string;+}++export class SessionHourlyActivityDto {+ @ApiProperty({ description: 'Hour of day, 0-23.', example: 9 }) hour!: number;+ @ApiProperty({ example: 12 }) sent!: number;+ @ApiProperty({ example: 34 }) received!: number;+}++export class SessionStatsResponseDto {+ @ApiProperty({ type: SessionStatsSessionDto })+ session!: SessionStatsSessionDto;++ @ApiProperty({ type: SessionStatsMessagesDto })+ messages!: SessionStatsMessagesDto;++ @ApiProperty({ type: [SessionStatsTopChatDto] })+ topChats!: SessionStatsTopChatDto[];++ @ApiProperty({ type: [SessionHourlyActivityDto] })+ hourlyActivity!: SessionHourlyActivityDto[];+}diff --git a/src/modules/stats/stats.controller.ts b/src/modules/stats/stats.controller.tsindex 7aa0a943f..571643f97 100644--- a/src/modules/stats/stats.controller.ts+++ b/src/modules/stats/stats.controller.ts@@ -1,5 +1,6 @@import { Controller, Get, Param, Query } from '@nestjs/common';import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';+import { MessageStatsResponseDto, OverviewStatsResponseDto, SessionStatsResponseDto } from './dto/stats-response.dto';import { StatsService } from './stats.service';import { StatsQueryDto } from './dto/stats-query.dto';import { RequireRole, RequireUnscopedKey } from '../auth/decorators/auth.decorators';@@ -17,7 +18,11 @@ export class StatsController {@RequireRole(ApiKeyRole.ADMIN)@RequireUnscopedKey()@ApiOperation({ summary: 'Get overall statistics' })- @ApiResponse({ status: 200, description: 'Cross-session aggregate statistics (sessions, messages, etc.).' })+ @ApiResponse({+ status: 200,+ description: 'Cross-session aggregate statistics (sessions, messages, etc.).',+ type: OverviewStatsResponseDto,+ })async getOverview() {return this.statsService.getOverview();}@@ -26,14 +31,22 @@ export class StatsController {@RequireRole(ApiKeyRole.ADMIN)@RequireUnscopedKey()@ApiOperation({ summary: 'Get message statistics with time series' })- @ApiResponse({ status: 200, description: 'Message statistics with a time series for the requested period.' })+ @ApiResponse({+ status: 200,+ description: 'Message statistics with a time series for the requested period.',+ type: MessageStatsResponseDto,+ })async getMessageStats(@Query() query: StatsQueryDto) {return this.statsService.getMessageStats(query.period || '24h');}@Get('sessions/:sessionId')@ApiOperation({ summary: 'Get statistics for a specific session' })- @ApiResponse({ status: 200, description: 'Per-session statistics for the requested session.' })+ @ApiResponse({+ status: 200,+ description: 'Per-session statistics for the requested session.',+ type: SessionStatsResponseDto,+ })async getSessionStats(@Param('sessionId') sessionId: string) {return this.statsService.getSessionStats(sessionId);}