Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

docs(openapi): publish the infrastructure response schemas

Yudhi Armyndharis2503ccad4a25
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2643b6a72..3720bc2c9 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
+- **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.
- **The ten contacts endpoints now publish the shape of what they return** — they documented a status and a sentence but no schema, so the committed OpenAPI snapshot had nothing to diff for any of them and a change to a response body could reach clients without the contract gate noticing; `GET /contacts/{contactId}/phone` returning `null` for an unresolvable id, and the batch picture lookup answering `null` per id rather than failing, are now stated rather than discovered by calling.
- **Fourteen more boolean environment variables are now validated at boot** — they are read with a bare `=== 'true'` / `!== 'false'` comparison, so a spelling like `DATABASE_SSL=require` silently configured the opposite of what was asked for; `DATABASE_SSL` in particular read as OFF and sent credentials in plaintext to a server the operator believed was TLS-protected. Only `true`/`false` (or blank) are accepted now, so a deployment using another spelling will fail startup until it is corrected. `MCP_READONLY` and `PUPPETEER_HEADLESS` stay tolerant deliberately — both fail toward the safe state.
- **The API description now documents the two statuses middleware returns before routing** — `415` for a compressed request body and `503` with `Retry-After` when too much body data is already in flight, neither of which appeared anywhere in the OpenAPI document despite applying to every operation.
diff --git a/openapi.json b/openapi.json
index 9c23b7e3f..4f9e5dffb 100644
--- a/openapi.json
+++ b/openapi.json
@@ -3226,7 +3226,14 @@
"parameters": [],
"responses": {
"200": {
- "description": "Infrastructure status"
+ "description": "Infrastructure status",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/InfraStatusResponseDto"
+ }
+ }
+ }
}
},
"summary": "Get infrastructure status",
@@ -3241,7 +3248,17 @@
"parameters": [],
"responses": {
"200": {
- "description": "List of available engines"
+ "description": "List of available engines",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/AvailableEngineDto"
+ }
+ }
+ }
+ }
}
},
"summary": "Get available WhatsApp engines",
@@ -3256,7 +3273,14 @@
"parameters": [],
"responses": {
"200": {
- "description": "Current engine info"
+ "description": "Current engine info",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/InfraCurrentEngineResponseDto"
+ }
+ }
+ }
}
},
"summary": "Get current active engine",
@@ -3271,7 +3295,14 @@
"parameters": [],
"responses": {
"200": {
- "description": "Server is healthy"
+ "description": "Process is up. This route does not probe dependencies — read /infra/status for those.",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/InfraHealthResponseDto"
+ }
+ }
+ }
}
},
"summary": "Health check endpoint",
@@ -3287,7 +3318,14 @@
"parameters": [],
"responses": {
"200": {
- "description": "Saved configuration (secrets omitted)"
+ "description": "Saved configuration (secrets omitted)",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/InfraConfigResponseDto"
+ }
+ }
+ }
}
},
"summary": "Read the saved infrastructure configuration for the dashboard form",
@@ -3311,7 +3349,14 @@
},
"responses": {
"200": {
- "description": "Configuration saved"
+ "description": "Save outcome. A failed write also answers 200 with `saved: false` — read the flag, not the status.",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/InfraConfigSaveResponseDto"
+ }
+ }
+ }
}
},
"summary": "Save infrastructure configuration to .env file",
@@ -3336,7 +3381,14 @@
},
"responses": {
"200": {
- "description": "Server will restart with new profiles"
+ "description": "Server will restart with new profiles",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/InfraRestartResponseDto"
+ }
+ }
+ }
}
},
"summary": "Request server restart with Docker orchestration",
@@ -3351,7 +3403,14 @@
"parameters": [],
"responses": {
"200": {
- "description": "Exported data as JSON"
+ "description": "Exported data as JSON",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/InfraExportDataResponseDto"
+ }
+ }
+ }
}
},
"summary": "Export all data from Data DB for migration",
@@ -3435,7 +3494,14 @@
},
"responses": {
"200": {
- "description": "Data imported successfully"
+ "description": "Data imported successfully",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/InfraImportDataResponseDto"
+ }
+ }
+ }
},
"409": {
"description": "Refused, with the reason in `code`. IMPORT_ALREADY_RUNNING: another import is running — wait for it. IMPORT_NESTED_TRANSACTION: another database transaction holds this connection, so a restore could not be made durable — retry with nothing else in flight. IMPORT_WOULD_ORPHAN_ENGINES: live engines exist for sessions the backup would remove — retry with stopOrphans=true to stop them in-request, or force=true to proceed and restart after. Only the last of these is retryable with stopOrphans; the others leave nothing to decide"
@@ -3453,7 +3519,14 @@
"parameters": [],
"responses": {
"200": {
- "description": "File count and size"
+ "description": "File count and size",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/StorageFileCountResponseDto"
+ }
+ }
+ }
}
},
"summary": "Get file count in current storage",
@@ -3468,7 +3541,14 @@
"parameters": [],
"responses": {
"200": {
- "description": "Tar.gz archive stream"
+ "description": "JSON pointing at the archive that was written under data/exports/. This route does NOT stream the tar.gz itself — fetch it from the returned `download` path.",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/StorageExportResponseDto"
+ }
+ }
+ }
}
},
"summary": "Export all storage files as tar.gz",
@@ -3494,7 +3574,14 @@
},
"responses": {
"200": {
- "description": "Import result"
+ "description": "Import result",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/StorageImportResponseDto"
+ }
+ }
+ }
}
},
"summary": "Import storage files from tar.gz",
@@ -9171,80 +9258,120 @@
}
}
},
- "DatabaseConfigDto": {
+ "InfraDatabaseStatusDto": {
"type": "object",
"properties": {
+ "connected": {
+ "type": "boolean",
+ "description": "Whether a `SELECT 1` probe succeeded just now.",
+ "example": true
+ },
"type": {
"type": "string",
- "enum": [
- "sqlite",
- "postgres"
- ]
- },
- "builtIn": {
- "type": "boolean"
+ "description": "Configured driver.",
+ "example": "postgres"
},
"host": {
- "type": "string"
- },
- "port": {
- "type": "string"
- },
- "username": {
- "type": "string"
- },
- "password": {
- "type": "string"
- },
- "database": {
- "type": "string"
- },
- "schema": {
- "type": "string"
- },
- "poolSize": {
- "type": "number"
- },
- "sslEnabled": {
- "type": "boolean"
+ "type": "string",
+ "description": "Host the app is configured to reach.",
+ "example": "openwa-postgres"
},
- "sslRejectUnauthorized": {
- "type": "boolean"
+ "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": [
- "type"
+ "connected",
+ "type",
+ "host",
+ "builtIn"
]
},
- "RedisConfigDto": {
+ "InfraRedisStatusDto": {
"type": "object",
"properties": {
"enabled": {
- "type": "boolean"
+ "type": "boolean",
+ "description": "Whether Redis is switched on in configuration.",
+ "example": true
},
- "builtIn": {
- "type": "boolean"
+ "connected": {
+ "type": "boolean",
+ "description": "Whether a live probe reached it.",
+ "example": true
},
"host": {
- "type": "string"
+ "type": "string",
+ "example": "openwa-redis"
},
"port": {
- "type": "string"
+ "type": "number",
+ "example": 6379
},
- "password": {
- "type": "string"
+ "builtIn": {
+ "type": "boolean",
+ "description": "Whether OpenWA's bundled Redis container is backing this.",
+ "example": true
}
- }
+ },
+ "required": [
+ "enabled",
+ "connected",
+ "host",
+ "port",
+ "builtIn"
+ ]
},
- "QueueConfigDto": {
+ "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"
+ ]
+ },
+ "InfraQueueStatusDto": {
"type": "object",
"properties": {
"enabled": {
- "type": "boolean"
+ "type": "boolean",
+ "description": "Whether queue processing is switched on.",
+ "example": true
+ },
+ "webhooks": {
+ "description": "Webhook queue depths.",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/InfraQueueDepthDto"
+ }
+ ]
}
- }
+ },
+ "required": [
+ "enabled",
+ "webhooks"
+ ]
},
- "StorageConfigDto": {
+ "InfraStorageStatusDto": {
"type": "object",
"properties": {
"type": {
@@ -9252,87 +9379,1043 @@
"enum": [
"local",
"s3"
- ]
- },
- "builtIn": {
- "type": "boolean"
- },
- "localPath": {
- "type": "string"
- },
- "s3Bucket": {
- "type": "string"
+ ],
+ "example": "local"
},
- "s3Region": {
- "type": "string"
+ "path": {
+ "type": "string",
+ "description": "Local storage root. Present only for `local`.",
+ "example": "./data/storage"
},
- "s3AccessKey": {
- "type": "string"
+ "bucket": {
+ "type": "string",
+ "description": "Bucket name. Present only for `s3`.",
+ "example": "openwa-media"
},
- "s3SecretKey": {
- "type": "string"
+ "builtIn": {
+ "type": "boolean",
+ "description": "Whether OpenWA's bundled MinIO container is backing this.",
+ "example": false
},
- "s3Endpoint": {
- "type": "string"
+ "s3Available": {
+ "type": "boolean",
+ "description": "Whether the S3 endpoint answered a probe. Present only for `s3`."
}
},
"required": [
- "type"
+ "type",
+ "builtIn"
]
},
- "EngineConfigDto": {
+ "InfraEngineStatusDto": {
"type": "object",
"properties": {
"type": {
- "type": "string"
+ "type": "string",
+ "description": "Active engine.",
+ "example": "baileys"
},
"headless": {
- "type": "boolean"
+ "type": "boolean",
+ "description": "Whether Chromium runs headless. Meaningful for whatsapp-web.js only.",
+ "example": true
},
"sessionDataPath": {
- "type": "string"
+ "type": "string",
+ "example": "./data/sessions"
},
"browserArgs": {
- "type": "string"
+ "type": "string",
+ "description": "Extra Chromium arguments, as configured.",
+ "example": ""
+ },
+ "webVersion": {
+ "type": "string",
+ "nullable": true,
+ "description": "whatsapp-web.js only: the WhatsApp Web build actually in use, which is distinct from the library version. Omitted for other engines.",
+ "example": "2.3000.1234567890"
+ },
+ "webVersionSource": {
+ "type": "string",
+ "enum": [
+ "pinned",
+ "auto",
+ "native"
+ ],
+ "description": "How that build was chosen. Omitted for other engines.",
+ "example": "pinned"
}
- }
+ },
+ "required": [
+ "type",
+ "headless",
+ "sessionDataPath",
+ "browserArgs"
+ ]
},
- "SaveConfigDto": {
+ "InfraStatusResponseDto": {
"type": "object",
"properties": {
"database": {
- "$ref": "#/components/schemas/DatabaseConfigDto"
+ "$ref": "#/components/schemas/InfraDatabaseStatusDto"
},
"redis": {
- "$ref": "#/components/schemas/RedisConfigDto"
+ "$ref": "#/components/schemas/InfraRedisStatusDto"
},
"queue": {
- "$ref": "#/components/schemas/QueueConfigDto"
+ "$ref": "#/components/schemas/InfraQueueStatusDto"
},
"storage": {
- "$ref": "#/components/schemas/StorageConfigDto"
+ "$ref": "#/components/schemas/InfraStorageStatusDto"
},
"engine": {
- "$ref": "#/components/schemas/EngineConfigDto"
- }
- }
- },
- "RestartDto": {
- "type": "object",
- "properties": {
- "profiles": {
- "type": "array",
- "items": {
- "type": "string"
- }
+ "$ref": "#/components/schemas/InfraEngineStatusDto"
},
- "profilesToRemove": {
+ "envPinned": {
+ "description": "Which of the four settings the dashboard can edit are supplied by a layer ABOVE `data/.env.generated` — the container environment or a project `.env` — and so cannot be changed from the dashboard until that layer is. Reported, not inferred from a running-vs-saved mismatch: a save that has not been restarted yet looks identical and needs the opposite advice.",
+ "example": [
+ "ENGINE_TYPE"
+ ],
"type": "array",
"items": {
"type": "string"
}
}
- }
+ },
+ "required": [
+ "database",
+ "redis",
+ "queue",
+ "storage",
+ "engine",
+ "envPinned"
+ ]
+ },
+ "EngineLibraryDto": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "description": "The underlying library, distinct from the engine plugin's own manifest name.",
+ "example": "whatsapp-web.js"
+ },
+ "version": {
+ "type": "string",
+ "description": "Library version actually loaded.",
+ "example": "1.34.7"
+ }
+ },
+ "required": [
+ "name",
+ "version"
+ ]
+ },
+ "AvailableEngineDto": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string",
+ "description": "Engine plugin id — the value ENGINE_TYPE takes.",
+ "example": "baileys"
+ },
+ "name": {
+ "type": "string",
+ "description": "Display name from the plugin manifest.",
+ "example": "Baileys"
+ },
+ "enabled": {
+ "type": "boolean",
+ "description": "Whether the plugin is enabled. Disabled engines are still listed.",
+ "example": true
+ },
+ "features": {
+ "description": "Capabilities the engine declares.",
+ "example": [
+ "send-text"
+ ],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "library": {
+ "description": "Absent when the plugin does not report a library, which includes any disabled engine.",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/EngineLibraryDto"
+ }
+ ]
+ }
+ },
+ "required": [
+ "id",
+ "name",
+ "enabled",
+ "features"
+ ]
+ },
+ "InfraCurrentEngineResponseDto": {
+ "type": "object",
+ "properties": {
+ "engineType": {
+ "type": "string",
+ "description": "Engine the process resolved at boot.",
+ "example": "baileys"
+ }
+ },
+ "required": [
+ "engineType"
+ ]
+ },
+ "InfraHealthResponseDto": {
+ "type": "object",
+ "properties": {
+ "status": {
+ "type": "string",
+ "description": "Liveness marker. This route does not probe dependencies.",
+ "example": "ok"
+ },
+ "timestamp": {
+ "type": "string",
+ "description": "ISO-8601 timestamp of the reply.",
+ "example": "2026-08-07T12:00:00.000Z"
+ }
+ },
+ "required": [
+ "status",
+ "timestamp"
+ ]
+ },
+ "InfraConfigDatabaseDto": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "enum": [
+ "sqlite",
+ "postgres"
+ ],
+ "example": "postgres"
+ },
+ "builtIn": {
+ "type": "boolean",
+ "example": true
+ },
+ "host": {
+ "type": "string",
+ "example": "openwa-postgres"
+ },
+ "port": {
+ "type": "string",
+ "description": "Kept as a string: it is echoed back from the saved env verbatim.",
+ "example": "5432"
+ },
+ "username": {
+ "type": "string",
+ "example": "openwa"
+ },
+ "database": {
+ "type": "string",
+ "description": "Database name, or the SQLite file path.",
+ "example": "openwa"
+ },
+ "schema": {
+ "type": "string",
+ "example": "public"
+ },
+ "poolSize": {
+ "type": "number",
+ "example": 10
+ },
+ "sslEnabled": {
+ "type": "boolean",
+ "example": false
+ },
+ "sslRejectUnauthorized": {
+ "type": "boolean",
+ "example": true
+ },
+ "passwordSet": {
+ "type": "boolean",
+ "description": "Whether a password is stored. The secret itself is never returned.",
+ "example": true
+ }
+ },
+ "required": [
+ "type",
+ "builtIn",
+ "host",
+ "port",
+ "username",
+ "database",
+ "schema",
+ "poolSize",
+ "sslEnabled",
+ "sslRejectUnauthorized",
+ "passwordSet"
+ ]
+ },
+ "InfraConfigRedisDto": {
+ "type": "object",
+ "properties": {
+ "enabled": {
+ "type": "boolean",
+ "example": true
+ },
+ "builtIn": {
+ "type": "boolean",
+ "example": true
+ },
+ "host": {
+ "type": "string",
+ "example": "openwa-redis"
+ },
+ "port": {
+ "type": "string",
+ "description": "Echoed from the saved env verbatim.",
+ "example": "6379"
+ },
+ "passwordSet": {
+ "type": "boolean",
+ "description": "Whether a password is stored. The secret itself is never returned.",
+ "example": false
+ }
+ },
+ "required": [
+ "enabled",
+ "builtIn",
+ "host",
+ "port",
+ "passwordSet"
+ ]
+ },
+ "InfraConfigQueueDto": {
+ "type": "object",
+ "properties": {
+ "enabled": {
+ "type": "boolean",
+ "example": true
+ }
+ },
+ "required": [
+ "enabled"
+ ]
+ },
+ "InfraConfigStorageDto": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "enum": [
+ "local",
+ "s3"
+ ],
+ "example": "local"
+ },
+ "builtIn": {
+ "type": "boolean",
+ "example": false
+ },
+ "localPath": {
+ "type": "string",
+ "example": "./data/storage"
+ },
+ "s3Bucket": {
+ "type": "string",
+ "example": ""
+ },
+ "s3Region": {
+ "type": "string",
+ "example": ""
+ },
+ "s3Endpoint": {
+ "type": "string",
+ "example": ""
+ },
+ "s3CredentialsSet": {
+ "type": "boolean",
+ "description": "Whether both an access key id and a secret are stored. Neither is ever returned.",
+ "example": false
+ }
+ },
+ "required": [
+ "type",
+ "builtIn",
+ "localPath",
+ "s3Bucket",
+ "s3Region",
+ "s3Endpoint",
+ "s3CredentialsSet"
+ ]
+ },
+ "InfraConfigEngineDto": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "example": "whatsapp-web.js"
+ },
+ "headless": {
+ "type": "boolean",
+ "example": true
+ },
+ "sessionDataPath": {
+ "type": "string",
+ "example": "./data/sessions"
+ },
+ "browserArgs": {
+ "type": "string",
+ "example": ""
+ }
+ },
+ "required": [
+ "type",
+ "headless",
+ "sessionDataPath",
+ "browserArgs"
+ ]
+ },
+ "InfraConfigResponseDto": {
+ "type": "object",
+ "properties": {
+ "database": {
+ "$ref": "#/components/schemas/InfraConfigDatabaseDto"
+ },
+ "redis": {
+ "$ref": "#/components/schemas/InfraConfigRedisDto"
+ },
+ "queue": {
+ "$ref": "#/components/schemas/InfraConfigQueueDto"
+ },
+ "storage": {
+ "$ref": "#/components/schemas/InfraConfigStorageDto"
+ },
+ "engine": {
+ "$ref": "#/components/schemas/InfraConfigEngineDto"
+ }
+ },
+ "required": [
+ "database",
+ "redis",
+ "queue",
+ "storage",
+ "engine"
+ ]
+ },
+ "DatabaseConfigDto": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "enum": [
+ "sqlite",
+ "postgres"
+ ]
+ },
+ "builtIn": {
+ "type": "boolean"
+ },
+ "host": {
+ "type": "string"
+ },
+ "port": {
+ "type": "string"
+ },
+ "username": {
+ "type": "string"
+ },
+ "password": {
+ "type": "string"
+ },
+ "database": {
+ "type": "string"
+ },
+ "schema": {
+ "type": "string"
+ },
+ "poolSize": {
+ "type": "number"
+ },
+ "sslEnabled": {
+ "type": "boolean"
+ },
+ "sslRejectUnauthorized": {
+ "type": "boolean"
+ }
+ },
+ "required": [
+ "type"
+ ]
+ },
+ "RedisConfigDto": {
+ "type": "object",
+ "properties": {
+ "enabled": {
+ "type": "boolean"
+ },
+ "builtIn": {
+ "type": "boolean"
+ },
+ "host": {
+ "type": "string"
+ },
+ "port": {
+ "type": "string"
+ },
+ "password": {
+ "type": "string"
+ }
+ }
+ },
+ "QueueConfigDto": {
+ "type": "object",
+ "properties": {
+ "enabled": {
+ "type": "boolean"
+ }
+ }
+ },
+ "StorageConfigDto": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "enum": [
+ "local",
+ "s3"
+ ]
+ },
+ "builtIn": {
+ "type": "boolean"
+ },
+ "localPath": {
+ "type": "string"
+ },
+ "s3Bucket": {
+ "type": "string"
+ },
+ "s3Region": {
+ "type": "string"
+ },
+ "s3AccessKey": {
+ "type": "string"
+ },
+ "s3SecretKey": {
+ "type": "string"
+ },
+ "s3Endpoint": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "type"
+ ]
+ },
+ "EngineConfigDto": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string"
+ },
+ "headless": {
+ "type": "boolean"
+ },
+ "sessionDataPath": {
+ "type": "string"
+ },
+ "browserArgs": {
+ "type": "string"
+ }
+ }
+ },
+ "SaveConfigDto": {
+ "type": "object",
+ "properties": {
+ "database": {
+ "$ref": "#/components/schemas/DatabaseConfigDto"
+ },
+ "redis": {
+ "$ref": "#/components/schemas/RedisConfigDto"
+ },
+ "queue": {
+ "$ref": "#/components/schemas/QueueConfigDto"
+ },
+ "storage": {
+ "$ref": "#/components/schemas/StorageConfigDto"
+ },
+ "engine": {
+ "$ref": "#/components/schemas/EngineConfigDto"
+ }
+ }
+ },
+ "InfraConfigSaveResponseDto": {
+ "type": "object",
+ "properties": {
+ "message": {
+ "type": "string",
+ "example": "Configuration saved successfully. Server restart required to apply changes."
+ },
+ "saved": {
+ "type": "boolean",
+ "description": "False when the write failed. This route answers 200 either way, so a client must read this flag rather than the status code.",
+ "example": true
+ },
+ "envPath": {
+ "type": "string",
+ "description": "Path of the env file written, relative to the working directory so the host layout is not disclosed.",
+ "example": "data/.env.generated"
+ },
+ "profiles": {
+ "description": "Docker profiles the saved selection requires.",
+ "example": [
+ "postgres"
+ ],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "required": [
+ "message",
+ "saved",
+ "envPath",
+ "profiles"
+ ]
+ },
+ "RestartDto": {
+ "type": "object",
+ "properties": {
+ "profiles": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "profilesToRemove": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "InfraRestartResponseDto": {
+ "type": "object",
+ "properties": {
+ "message": {
+ "type": "string",
+ "example": "Restart scheduled."
+ },
+ "restarting": {
+ "type": "boolean",
+ "description": "Whether a restart was actually scheduled.",
+ "example": true
+ },
+ "profiles": {
+ "description": "Docker profiles to bring up.",
+ "example": [
+ "postgres"
+ ],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "profilesToRemove": {
+ "description": "Profiles to tear down. Teardown is stop-only: containers are stopped and retained for re-enable, never deleted.",
+ "example": [],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "estimatedTime": {
+ "type": "number",
+ "description": "Rough seconds before the process is expected back.",
+ "example": 15
+ },
+ "orchestration": {
+ "type": "object",
+ "description": "Raw per-service orchestration outcome, present only when profiles were started."
+ },
+ "removal": {
+ "type": "object",
+ "description": "Raw per-service stop outcome, present only when profiles were torn down."
+ }
+ },
+ "required": [
+ "message",
+ "restarting",
+ "profiles",
+ "profilesToRemove",
+ "estimatedTime"
+ ]
+ },
+ "MigrationTablesDto": {
+ "type": "object",
+ "properties": {
+ "sessions": {
+ "type": "array",
+ "items": {
+ "type": "object"
+ }
+ },
+ "webhooks": {
+ "type": "array",
+ "items": {
+ "type": "object"
+ }
+ },
+ "messages": {
+ "type": "array",
+ "items": {
+ "type": "object"
+ }
+ },
+ "messageBatches": {
+ "type": "array",
+ "items": {
+ "type": "object"
+ }
+ },
+ "templates": {
+ "type": "array",
+ "items": {
+ "type": "object"
+ }
+ },
+ "baileysStoredMessages": {
+ "type": "array",
+ "items": {
+ "type": "object"
+ }
+ },
+ "lidMappings": {
+ "type": "array",
+ "items": {
+ "type": "object"
+ }
+ },
+ "pluginInstances": {
+ "type": "array",
+ "items": {
+ "type": "object"
+ }
+ },
+ "conversationMappings": {
+ "type": "array",
+ "items": {
+ "type": "object"
+ }
+ },
+ "ingressEvents": {
+ "type": "array",
+ "items": {
+ "type": "object"
+ }
+ },
+ "webhookDeliveryFailures": {
+ "type": "array",
+ "items": {
+ "type": "object"
+ }
+ },
+ "integrationDeliveryFailures": {
+ "type": "array",
+ "items": {
+ "type": "object"
+ }
+ },
+ "statusUpdates": {
+ "type": "array",
+ "items": {
+ "type": "object"
+ }
+ },
+ "automationRules": {
+ "type": "array",
+ "items": {
+ "type": "object"
+ }
+ }
+ },
+ "required": [
+ "sessions",
+ "webhooks",
+ "messages",
+ "messageBatches",
+ "templates",
+ "baileysStoredMessages",
+ "lidMappings",
+ "pluginInstances",
+ "conversationMappings",
+ "ingressEvents",
+ "webhookDeliveryFailures",
+ "integrationDeliveryFailures",
+ "statusUpdates",
+ "automationRules"
+ ]
+ },
+ "TableCountsDto": {
+ "type": "object",
+ "properties": {
+ "sessions": {
+ "type": "number",
+ "example": 2
+ },
+ "webhooks": {
+ "type": "number",
+ "example": 1
+ },
+ "messages": {
+ "type": "number",
+ "example": 1024
+ },
+ "messageBatches": {
+ "type": "number",
+ "example": 0
+ },
+ "templates": {
+ "type": "number",
+ "example": 3
+ },
+ "baileysStoredMessages": {
+ "type": "number",
+ "example": 512
+ },
+ "lidMappings": {
+ "type": "number",
+ "example": 64
+ },
+ "pluginInstances": {
+ "type": "number",
+ "example": 12
+ },
+ "conversationMappings": {
+ "type": "number",
+ "example": 8
+ },
+ "ingressEvents": {
+ "type": "number",
+ "example": 40
+ },
+ "webhookDeliveryFailures": {
+ "type": "number",
+ "example": 0
+ },
+ "integrationDeliveryFailures": {
+ "type": "number",
+ "example": 0
+ },
+ "statusUpdates": {
+ "type": "number",
+ "example": 5
+ },
+ "automationRules": {
+ "type": "number",
+ "example": 2
+ }
+ },
+ "required": [
+ "sessions",
+ "webhooks",
+ "messages",
+ "messageBatches",
+ "templates",
+ "baileysStoredMessages",
+ "lidMappings",
+ "pluginInstances",
+ "conversationMappings",
+ "ingressEvents",
+ "webhookDeliveryFailures",
+ "integrationDeliveryFailures",
+ "statusUpdates",
+ "automationRules"
+ ]
+ },
+ "InfraExportDataResponseDto": {
+ "type": "object",
+ "properties": {
+ "exportedAt": {
+ "type": "string",
+ "description": "ISO-8601 timestamp the export was taken.",
+ "example": "2026-08-07T12:00:00.000Z"
+ },
+ "dataDbType": {
+ "type": "string",
+ "description": "Driver the data came from.",
+ "example": "postgres"
+ },
+ "tables": {
+ "$ref": "#/components/schemas/MigrationTablesDto"
+ },
+ "counts": {
+ "description": "Row counts, so a truncated restore is detectable.",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/TableCountsDto"
+ }
+ ]
+ }
+ },
+ "required": [
+ "exportedAt",
+ "dataDbType",
+ "tables",
+ "counts"
+ ]
+ },
+ "InfraImportDataResponseDto": {
+ "type": "object",
+ "properties": {
+ "imported": {
+ "type": "boolean",
+ "example": true
+ },
+ "counts": {
+ "description": "Rows written per table.",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/TableCountsDto"
+ }
+ ]
+ },
+ "warnings": {
+ "description": "Problems that did not stop the import.",
+ "example": [],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "notices": {
+ "description": "Informational messages about what the import did.",
+ "example": [],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "restartRequired": {
+ "type": "boolean",
+ "description": "Whether the process must restart before the imported state is live.",
+ "example": true
+ },
+ "orphanedEngines": {
+ "description": "Sessions running here that the imported set does not contain — they were about to be deleted.",
+ "example": [],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "stoppedOrphanEngines": {
+ "description": "Of those, the ones successfully stopped.",
+ "example": [],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "failedOrphanEngines": {
+ "description": "Of those, the ones that could not be stopped.",
+ "example": [],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "required": [
+ "imported",
+ "counts",
+ "warnings",
+ "notices",
+ "restartRequired",
+ "orphanedEngines",
+ "stoppedOrphanEngines",
+ "failedOrphanEngines"
+ ]
+ },
+ "StorageFileCountResponseDto": {
+ "type": "object",
+ "properties": {
+ "storageType": {
+ "type": "string",
+ "enum": [
+ "local",
+ "s3"
+ ],
+ "example": "local"
+ },
+ "count": {
+ "type": "number",
+ "description": "Number of stored objects.",
+ "example": 128
+ },
+ "sizeBytes": {
+ "type": "number",
+ "description": "Total size in bytes.",
+ "example": 10485760
+ },
+ "sizeMB": {
+ "type": "string",
+ "description": "The same size in MB, pre-rendered to two decimals.",
+ "example": "10.00"
+ }
+ },
+ "required": [
+ "storageType",
+ "count",
+ "sizeBytes",
+ "sizeMB"
+ ]
+ },
+ "StorageExportResponseDto": {
+ "type": "object",
+ "properties": {
+ "message": {
+ "type": "string",
+ "example": "Storage archive created."
+ },
+ "download": {
+ "type": "string",
+ "description": "Path to download the archive from.",
+ "example": "/api/infra/storage/download/xyz.tar"
+ }
+ },
+ "required": [
+ "message",
+ "download"
+ ]
+ },
+ "StorageImportResponseDto": {
+ "type": "object",
+ "properties": {
+ "imported": {
+ "type": "boolean",
+ "example": true
+ },
+ "count": {
+ "type": "number",
+ "description": "Objects written.",
+ "example": 128
+ },
+ "storageType": {
+ "type": "string",
+ "enum": [
+ "local",
+ "s3"
+ ],
+ "example": "local"
+ }
+ },
+ "required": [
+ "imported",
+ "count",
+ "storageType"
+ ]
},
"ContactDto": {
"type": "object",
diff --git a/src/modules/infra/dto/infra-response.dto.ts b/src/modules/infra/dto/infra-response.dto.ts
new file mode 100644
index 000000000..d0d2156ea
--- /dev/null
+++ b/src/modules/infra/dto/infra-response.dto.ts
@@ -0,0 +1,487 @@
+import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
+
+/**
+ * Response shapes for the infrastructure routes. These describe what the handlers already return —
+ * the payload is the raw handler value, not an envelope — so that a change to the shape shows up as
+ * a diff in the committed OpenAPI snapshot instead of reaching clients unannounced.
+ *
+ * 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.
+ */
+
+// ---------- GET /infra/status ----------
+
+export class InfraDatabaseStatusDto {
+ @ApiProperty({ description: 'Whether a `SELECT 1` probe succeeded just now.', example: true })
+ connected!: boolean;
+
+ @ApiProperty({ description: 'Configured driver.', example: 'postgres' })
+ type!: string;
+
+ @ApiProperty({ description: 'Host the app is configured to reach.', example: 'openwa-postgres' })
+ host!: string;
+
+ @ApiProperty({
+ 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,
+ })
+ builtIn!: boolean;
+}
+
+export class InfraRedisStatusDto {
+ @ApiProperty({ description: 'Whether Redis is switched on in configuration.', example: true })
+ enabled!: boolean;
+
+ @ApiProperty({ description: 'Whether a live probe reached it.', example: true })
+ connected!: boolean;
+
+ @ApiProperty({ example: 'openwa-redis' })
+ host!: string;
+
+ @ApiProperty({ example: 6379 })
+ port!: number;
+
+ @ApiProperty({ description: "Whether OpenWA's bundled Redis container is backing this.", example: true })
+ builtIn!: boolean;
+}
+
+export class InfraQueueDepthDto {
+ @ApiProperty({ description: 'Jobs waiting to be delivered.', example: 0 })
+ pending!: number;
+
+ @ApiProperty({ description: 'Jobs delivered successfully.', example: 128 })
+ completed!: number;
+
+ @ApiProperty({ description: 'Jobs that exhausted their retries.', example: 2 })
+ failed!: number;
+}
+
+export class InfraQueueStatusDto {
+ @ApiProperty({ description: 'Whether queue processing is switched on.', example: true })
+ enabled!: boolean;
+
+ @ApiProperty({ type: InfraQueueDepthDto, description: 'Webhook queue depths.' })
+ webhooks!: InfraQueueDepthDto;
+}
+
+export class InfraStorageStatusDto {
+ @ApiProperty({ enum: ['local', 's3'], example: 'local' })
+ type!: string;
+
+ @ApiPropertyOptional({ description: 'Local storage root. Present only for `local`.', example: './data/storage' })
+ path?: string;
+
+ @ApiPropertyOptional({ description: 'Bucket name. Present only for `s3`.', example: 'openwa-media' })
+ bucket?: string;
+
+ @ApiProperty({ description: "Whether OpenWA's bundled MinIO container is backing this.", example: false })
+ builtIn!: boolean;
+
+ @ApiPropertyOptional({ description: 'Whether the S3 endpoint answered a probe. Present only for `s3`.' })
+ s3Available?: boolean;
+}
+
+export class InfraEngineStatusDto {
+ @ApiProperty({ description: 'Active engine.', example: 'baileys' })
+ type!: string;
+
+ @ApiProperty({ description: 'Whether Chromium runs headless. Meaningful for whatsapp-web.js only.', example: true })
+ headless!: boolean;
+
+ @ApiProperty({ example: './data/sessions' })
+ sessionDataPath!: string;
+
+ @ApiProperty({ description: 'Extra Chromium arguments, as configured.', example: '' })
+ browserArgs!: string;
+
+ @ApiPropertyOptional({
+ type: String,
+ nullable: true,
+ description:
+ 'whatsapp-web.js only: the WhatsApp Web build actually in use, which is distinct from the ' +
+ 'library version. Omitted for other engines.',
+ example: '2.3000.1234567890',
+ })
+ webVersion?: string | null;
+
+ @ApiPropertyOptional({
+ enum: ['pinned', 'auto', 'native'],
+ description: 'How that build was chosen. Omitted for other engines.',
+ example: 'pinned',
+ })
+ webVersionSource?: string;
+}
+
+export class InfraStatusResponseDto {
+ @ApiProperty({ type: InfraDatabaseStatusDto })
+ database!: InfraDatabaseStatusDto;
+
+ @ApiProperty({ type: InfraRedisStatusDto })
+ redis!: InfraRedisStatusDto;
+
+ @ApiProperty({ type: InfraQueueStatusDto })
+ queue!: InfraQueueStatusDto;
+
+ @ApiProperty({ type: InfraStorageStatusDto })
+ storage!: InfraStorageStatusDto;
+
+ @ApiProperty({ type: InfraEngineStatusDto })
+ engine!: InfraEngineStatusDto;
+
+ @ApiProperty({
+ type: [String],
+ description:
+ 'Which of the four settings the dashboard can edit are supplied by a layer ABOVE ' +
+ '`data/.env.generated` — the container environment or a project `.env` — and so cannot be ' +
+ 'changed from the dashboard until that layer is. Reported, not inferred from a running-vs-saved ' +
+ 'mismatch: a save that has not been restarted yet looks identical and needs the opposite advice.',
+ example: ['ENGINE_TYPE'],
+ })
+ envPinned!: string[];
+}
+
+// ---------- GET /infra/health, /infra/engines, /infra/engines/current ----------
+
+export class InfraHealthResponseDto {
+ @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;
+}
+
+export class EngineLibraryDto {
+ @ApiProperty({
+ description: "The underlying library, distinct from the engine plugin's own manifest name.",
+ example: 'whatsapp-web.js',
+ })
+ name!: string;
+
+ @ApiProperty({ description: 'Library version actually loaded.', example: '1.34.7' })
+ version!: string;
+}
+
+export class AvailableEngineDto {
+ @ApiProperty({ description: 'Engine plugin id — the value ENGINE_TYPE takes.', example: 'baileys' })
+ id!: string;
+
+ @ApiProperty({ description: 'Display name from the plugin manifest.', example: 'Baileys' })
+ name!: string;
+
+ @ApiProperty({ description: 'Whether the plugin is enabled. Disabled engines are still listed.', example: true })
+ enabled!: boolean;
+
+ @ApiProperty({ type: [String], description: 'Capabilities the engine declares.', example: ['send-text'] })
+ features!: string[];
+
+ @ApiPropertyOptional({
+ type: EngineLibraryDto,
+ description: 'Absent when the plugin does not report a library, which includes any disabled engine.',
+ })
+ library?: EngineLibraryDto;
+}
+
+export class InfraCurrentEngineResponseDto {
+ @ApiProperty({ description: 'Engine the process resolved at boot.', example: 'baileys' })
+ engineType!: string;
+}
+
+// ---------- GET /infra/config ----------
+
+export class InfraConfigDatabaseDto {
+ @ApiProperty({ enum: ['sqlite', 'postgres'], example: 'postgres' })
+ type!: string;
+
+ @ApiProperty({ example: true })
+ builtIn!: boolean;
+
+ @ApiProperty({ example: 'openwa-postgres' })
+ host!: string;
+
+ @ApiProperty({ description: 'Kept as a string: it is echoed back from the saved env verbatim.', example: '5432' })
+ port!: string;
+
+ @ApiProperty({ example: 'openwa' })
+ username!: string;
+
+ @ApiProperty({ description: 'Database name, or the SQLite file path.', example: 'openwa' })
+ database!: string;
+
+ @ApiProperty({ example: 'public' })
+ schema!: string;
+
+ @ApiProperty({ example: 10 })
+ poolSize!: number;
+
+ @ApiProperty({ example: false })
+ sslEnabled!: boolean;
+
+ @ApiProperty({ example: true })
+ sslRejectUnauthorized!: boolean;
+
+ @ApiProperty({ description: 'Whether a password is stored. The secret itself is never returned.', example: true })
+ passwordSet!: boolean;
+}
+
+export class InfraConfigRedisDto {
+ @ApiProperty({ example: true })
+ enabled!: boolean;
+
+ @ApiProperty({ example: true })
+ builtIn!: boolean;
+
+ @ApiProperty({ example: 'openwa-redis' })
+ host!: string;
+
+ @ApiProperty({ description: 'Echoed from the saved env verbatim.', example: '6379' })
+ port!: string;
+
+ @ApiProperty({ description: 'Whether a password is stored. The secret itself is never returned.', example: false })
+ passwordSet!: boolean;
+}
+
+export class InfraConfigQueueDto {
+ @ApiProperty({ example: true })
+ enabled!: boolean;
+}
+
+export class InfraConfigStorageDto {
+ @ApiProperty({ enum: ['local', 's3'], example: 'local' })
+ type!: string;
+
+ @ApiProperty({ example: false })
+ builtIn!: boolean;
+
+ @ApiProperty({ example: './data/storage' })
+ localPath!: string;
+
+ @ApiProperty({ example: '' })
+ s3Bucket!: string;
+
+ @ApiProperty({ example: '' })
+ s3Region!: string;
+
+ @ApiProperty({ example: '' })
+ s3Endpoint!: string;
+
+ @ApiProperty({
+ description: 'Whether both an access key id and a secret are stored. Neither is ever returned.',
+ example: false,
+ })
+ s3CredentialsSet!: boolean;
+}
+
+export class InfraConfigEngineDto {
+ @ApiProperty({ example: 'whatsapp-web.js' })
+ type!: string;
+
+ @ApiProperty({ example: true })
+ headless!: boolean;
+
+ @ApiProperty({ example: './data/sessions' })
+ sessionDataPath!: string;
+
+ @ApiProperty({ example: '' })
+ browserArgs!: string;
+}
+
+export class InfraConfigResponseDto {
+ @ApiProperty({ type: InfraConfigDatabaseDto })
+ database!: InfraConfigDatabaseDto;
+
+ @ApiProperty({ type: InfraConfigRedisDto })
+ redis!: InfraConfigRedisDto;
+
+ @ApiProperty({ type: InfraConfigQueueDto })
+ queue!: InfraConfigQueueDto;
+
+ @ApiProperty({ type: InfraConfigStorageDto })
+ storage!: InfraConfigStorageDto;
+
+ @ApiProperty({ type: InfraConfigEngineDto })
+ engine!: InfraConfigEngineDto;
+}
+
+export class InfraConfigSaveResponseDto {
+ @ApiProperty({ example: 'Configuration saved successfully. Server restart required to apply changes.' })
+ message!: string;
+
+ @ApiProperty({
+ description:
+ 'False when the write failed. This route answers 200 either way, so a client must read this ' +
+ 'flag rather than the status code.',
+ example: true,
+ })
+ saved!: boolean;
+
+ @ApiProperty({
+ description: 'Path of the env file written, relative to the working directory so the host layout is not disclosed.',
+ example: 'data/.env.generated',
+ })
+ envPath!: string;
+
+ @ApiProperty({ type: [String], description: 'Docker profiles the saved selection requires.', example: ['postgres'] })
+ profiles!: string[];
+}
+
+// ---------- POST /infra/restart ----------
+
+export class InfraRestartResponseDto {
+ @ApiProperty({ example: 'Restart scheduled.' })
+ message!: string;
+
+ @ApiProperty({ description: 'Whether a restart was actually scheduled.', example: true })
+ restarting!: boolean;
+
+ @ApiProperty({ type: [String], description: 'Docker profiles to bring up.', example: ['postgres'] })
+ profiles!: string[];
+
+ @ApiProperty({
+ type: [String],
+ description:
+ 'Profiles to tear down. Teardown is stop-only: containers are stopped and retained for ' +
+ 're-enable, never deleted.',
+ example: [],
+ })
+ profilesToRemove!: string[];
+
+ @ApiProperty({ description: 'Rough seconds before the process is expected back.', example: 15 })
+ estimatedTime!: number;
+
+ @ApiPropertyOptional({
+ type: Object,
+ description: 'Raw per-service orchestration outcome, present only when profiles were started.',
+ })
+ orchestration?: object;
+
+ @ApiPropertyOptional({
+ type: Object,
+ description: 'Raw per-service stop outcome, present only when profiles were torn down.',
+ })
+ removal?: object;
+}
+
+// ---------- GET /infra/export-data, POST /infra/import-data ----------
+
+/**
+ * One array per table. The row shapes are deliberately not enumerated: this is the backup/restore
+ * migration payload, mirroring the database entities, not a public data model — spelling every row
+ * out here would duplicate those definitions and drift from them. The table NAMES are pinned, so
+ * adding or dropping a table still shows up as a contract diff.
+ */
+export class MigrationTablesDto {
+ @ApiProperty({ type: [Object] }) sessions!: object[];
+ @ApiProperty({ type: [Object] }) webhooks!: object[];
+ @ApiProperty({ type: [Object] }) messages!: object[];
+ @ApiProperty({ type: [Object] }) messageBatches!: object[];
+ @ApiProperty({ type: [Object] }) templates!: object[];
+ @ApiProperty({ type: [Object] }) baileysStoredMessages!: object[];
+ @ApiProperty({ type: [Object] }) lidMappings!: object[];
+ @ApiProperty({ type: [Object] }) pluginInstances!: object[];
+ @ApiProperty({ type: [Object] }) conversationMappings!: object[];
+ @ApiProperty({ type: [Object] }) ingressEvents!: object[];
+ @ApiProperty({ type: [Object] }) webhookDeliveryFailures!: object[];
+ @ApiProperty({ type: [Object] }) integrationDeliveryFailures!: object[];
+ @ApiProperty({ type: [Object] }) statusUpdates!: object[];
+ @ApiProperty({ type: [Object] }) automationRules!: object[];
+}
+
+/** Row count per table, with the same keys as {@link MigrationTablesDto}. */
+export class TableCountsDto {
+ @ApiProperty({ example: 2 }) sessions!: number;
+ @ApiProperty({ example: 1 }) webhooks!: number;
+ @ApiProperty({ example: 1024 }) messages!: number;
+ @ApiProperty({ example: 0 }) messageBatches!: number;
+ @ApiProperty({ example: 3 }) templates!: number;
+ @ApiProperty({ example: 512 }) baileysStoredMessages!: number;
+ @ApiProperty({ example: 64 }) lidMappings!: number;
+ @ApiProperty({ example: 12 }) pluginInstances!: number;
+ @ApiProperty({ example: 8 }) conversationMappings!: number;
+ @ApiProperty({ example: 40 }) ingressEvents!: number;
+ @ApiProperty({ example: 0 }) webhookDeliveryFailures!: number;
+ @ApiProperty({ example: 0 }) integrationDeliveryFailures!: number;
+ @ApiProperty({ example: 5 }) statusUpdates!: number;
+ @ApiProperty({ example: 2 }) automationRules!: number;
+}
+
+export class InfraExportDataResponseDto {
+ @ApiProperty({ description: 'ISO-8601 timestamp the export was taken.', example: '2026-08-07T12:00:00.000Z' })
+ exportedAt!: string;
+
+ @ApiProperty({ description: 'Driver the data came from.', example: 'postgres' })
+ dataDbType!: string;
+
+ @ApiProperty({ type: MigrationTablesDto })
+ tables!: MigrationTablesDto;
+
+ @ApiProperty({ type: TableCountsDto, description: 'Row counts, so a truncated restore is detectable.' })
+ counts!: TableCountsDto;
+}
+
+export class InfraImportDataResponseDto {
+ @ApiProperty({ example: true })
+ imported!: boolean;
+
+ @ApiProperty({ type: TableCountsDto, description: 'Rows written per table.' })
+ counts!: TableCountsDto;
+
+ @ApiProperty({ type: [String], description: 'Problems that did not stop the import.', example: [] })
+ warnings!: string[];
+
+ @ApiProperty({ type: [String], description: 'Informational messages about what the import did.', example: [] })
+ notices!: string[];
+
+ @ApiProperty({ description: 'Whether the process must restart before the imported state is live.', example: true })
+ restartRequired!: boolean;
+
+ @ApiProperty({
+ type: [String],
+ description: 'Sessions running here that the imported set does not contain — they were about to be deleted.',
+ example: [],
+ })
+ orphanedEngines!: string[];
+
+ @ApiProperty({ type: [String], description: 'Of those, the ones successfully stopped.', example: [] })
+ stoppedOrphanEngines!: string[];
+
+ @ApiProperty({ type: [String], description: 'Of those, the ones that could not be stopped.', example: [] })
+ failedOrphanEngines!: string[];
+}
+
+// ---------- /infra/storage/* ----------
+
+export class StorageFileCountResponseDto {
+ @ApiProperty({ enum: ['local', 's3'], example: 'local' })
+ storageType!: string;
+
+ @ApiProperty({ description: 'Number of stored objects.', example: 128 })
+ count!: number;
+
+ @ApiProperty({ description: 'Total size in bytes.', example: 10485760 })
+ sizeBytes!: number;
+
+ @ApiProperty({ description: 'The same size in MB, pre-rendered to two decimals.', example: '10.00' })
+ sizeMB!: string;
+}
+
+export class StorageExportResponseDto {
+ @ApiProperty({ example: 'Storage archive created.' })
+ message!: string;
+
+ @ApiProperty({ description: 'Path to download the archive from.', example: '/api/infra/storage/download/xyz.tar' })
+ download!: string;
+}
+
+export class StorageImportResponseDto {
+ @ApiProperty({ example: true })
+ imported!: boolean;
+
+ @ApiProperty({ description: 'Objects written.', example: 128 })
+ count!: number;
+
+ @ApiProperty({ enum: ['local', 's3'], example: 'local' })
+ storageType!: string;
+}
diff --git a/src/modules/infra/infra-config.controller.ts b/src/modules/infra/infra-config.controller.ts
index 442ea01cd..9a6bdac8b 100644
--- a/src/modules/infra/infra-config.controller.ts
+++ b/src/modules/infra/infra-config.controller.ts
@@ -11,6 +11,7 @@ import {
Optional,
} from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse, ApiBody, ApiPropertyOptional } from '@nestjs/swagger';
+import { InfraConfigResponseDto, InfraConfigSaveResponseDto, InfraRestartResponseDto } from './dto/infra-response.dto';
import { IsArray, IsOptional, IsString } from 'class-validator';
import { RequireRole, RequireUnscopedKey } from '../auth/decorators/auth.decorators';
import { ApiKeyRole } from '../auth/entities/api-key.entity';
@@ -109,7 +110,7 @@ export class InfraConfigController {
@Get('config')
@RequireRole(ApiKeyRole.ADMIN)
@ApiOperation({ summary: 'Read the saved infrastructure configuration for the dashboard form' })
- @ApiResponse({ status: 200, description: 'Saved configuration (secrets omitted)' })
+ @ApiResponse({ status: 200, description: 'Saved configuration (secrets omitted)', type: InfraConfigResponseDto })
getConfig(): SavedConfigResponse {
const saved = readGeneratedEnv();
@@ -159,7 +160,11 @@ export class InfraConfigController {
@Put('config')
@RequireRole(ApiKeyRole.ADMIN)
@ApiOperation({ summary: 'Save infrastructure configuration to .env file' })
- @ApiResponse({ status: 200, description: 'Configuration saved' })
+ @ApiResponse({
+ status: 200,
+ description: 'Save outcome. A failed write also answers 200 with `saved: false` — read the flag, not the status.',
+ type: InfraConfigSaveResponseDto,
+ })
@ApiBody({ description: 'Configuration to save', type: SaveConfigDto })
saveConfig(@Body() config: SaveConfigDto): { message: string; saved: boolean; envPath: string; profiles: string[] } {
try {
@@ -354,7 +359,7 @@ export class InfraConfigController {
@HttpCode(HttpStatus.OK)
@RequireRole(ApiKeyRole.ADMIN)
@ApiOperation({ summary: 'Request server restart with Docker orchestration' })
- @ApiResponse({ status: 200, description: 'Server will restart with new profiles' })
+ @ApiResponse({ status: 200, description: 'Server will restart with new profiles', type: InfraRestartResponseDto })
@ApiBody({ required: false, type: RestartDto })
async requestRestart(@Body() body?: RestartDto): Promise<{
message: string;
diff --git a/src/modules/infra/infra-data.controller.ts b/src/modules/infra/infra-data.controller.ts
index ddf4ccebb..5b7cc9538 100644
--- a/src/modules/infra/infra-data.controller.ts
+++ b/src/modules/infra/infra-data.controller.ts
@@ -1,5 +1,6 @@
import { Controller, Get, Post, Body, ConflictException, HttpCode, HttpStatus, Optional } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse, ApiBody } from '@nestjs/swagger';
+import { InfraExportDataResponseDto, InfraImportDataResponseDto } from './dto/infra-response.dto';
import { ConfigService } from '@nestjs/config';
import { DataSource, QueryRunner } from 'typeorm';
import { InjectDataSource } from '@nestjs/typeorm';
@@ -327,7 +328,7 @@ export class InfraDataController {
@Get('export-data')
@RequireRole(ApiKeyRole.ADMIN)
@ApiOperation({ summary: 'Export all data from Data DB for migration' })
- @ApiResponse({ status: 200, description: 'Exported data as JSON' })
+ @ApiResponse({ status: 200, description: 'Exported data as JSON', type: InfraExportDataResponseDto })
async exportData(): Promise<{
exportedAt: string;
dataDbType: string;
@@ -512,7 +513,7 @@ export class InfraDataController {
},
},
})
- @ApiResponse({ status: 200, description: 'Data imported successfully' })
+ @ApiResponse({ status: 200, description: 'Data imported successfully', type: InfraImportDataResponseDto })
@ApiResponse({
status: 409,
description:
diff --git a/src/modules/infra/infra-status.controller.ts b/src/modules/infra/infra-status.controller.ts
index 4a85cdc65..324b96caa 100644
--- a/src/modules/infra/infra-status.controller.ts
+++ b/src/modules/infra/infra-status.controller.ts
@@ -1,5 +1,11 @@
import { Controller, Get, Optional } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
+import {
+ AvailableEngineDto,
+ InfraCurrentEngineResponseDto,
+ InfraHealthResponseDto,
+ InfraStatusResponseDto,
+} from './dto/infra-response.dto';
import { InjectQueue } from '@nestjs/bullmq';
import { Queue } from 'bullmq';
import { QUEUE_NAMES } from '../queue/queue-names';
@@ -106,7 +112,7 @@ export class InfraStatusController {
@Get('status')
@RequireRole(ApiKeyRole.ADMIN)
@ApiOperation({ summary: 'Get infrastructure status' })
- @ApiResponse({ status: 200, description: 'Infrastructure status' })
+ @ApiResponse({ status: 200, description: 'Infrastructure status', type: InfraStatusResponseDto })
async getStatus(): Promise<InfraStatus> {
// Active DB liveness probe (SELECT 1) on both connections in parallel — not just isInitialized,
// which stays true after a Postgres backend dies until an explicit .destroy() (see probeDbConnected).
@@ -237,7 +243,7 @@ export class InfraStatusController {
@Get('engines')
@RequireRole(ApiKeyRole.ADMIN)
@ApiOperation({ summary: 'Get available WhatsApp engines' })
- @ApiResponse({ status: 200, description: 'List of available engines' })
+ @ApiResponse({ status: 200, description: 'List of available engines', type: [AvailableEngineDto] })
getEngines(): Array<{ id: string; name: string; enabled: boolean; features: string[] }> {
return this.engineFactory.getAvailableEngines();
}
@@ -245,7 +251,7 @@ export class InfraStatusController {
@Get('engines/current')
@RequireRole(ApiKeyRole.ADMIN)
@ApiOperation({ summary: 'Get current active engine' })
- @ApiResponse({ status: 200, description: 'Current engine info' })
+ @ApiResponse({ status: 200, description: 'Current engine info', type: InfraCurrentEngineResponseDto })
getCurrentEngine(): { engineType: string } {
return { engineType: this.engineFactory.getCurrentEngine() };
}
@@ -253,7 +259,11 @@ export class InfraStatusController {
@Get('health')
@Public()
@ApiOperation({ summary: 'Health check endpoint' })
- @ApiResponse({ status: 200, description: 'Server is healthy' })
+ @ApiResponse({
+ status: 200,
+ description: 'Process is up. This route does not probe dependencies — read /infra/status for those.',
+ type: InfraHealthResponseDto,
+ })
healthCheck(): { status: string; timestamp: string } {
return {
status: 'ok',
diff --git a/src/modules/infra/infra-storage.controller.ts b/src/modules/infra/infra-storage.controller.ts
index 80e4af3af..c5b2d3806 100644
--- a/src/modules/infra/infra-storage.controller.ts
+++ b/src/modules/infra/infra-storage.controller.ts
@@ -10,6 +10,11 @@ import {
Optional,
} from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse, ApiBody } from '@nestjs/swagger';
+import {
+ StorageExportResponseDto,
+ StorageFileCountResponseDto,
+ StorageImportResponseDto,
+} from './dto/infra-response.dto';
import { RequireRole, RequireUnscopedKey } from '../auth/decorators/auth.decorators';
import { ApiKeyRole } from '../auth/entities/api-key.entity';
import { isPathWithin } from '../../common/utils/path-safety';
@@ -105,7 +110,7 @@ export class InfraStorageController implements OnApplicationBootstrap {
@Get('storage/files/count')
@RequireRole(ApiKeyRole.ADMIN)
@ApiOperation({ summary: 'Get file count in current storage' })
- @ApiResponse({ status: 200, description: 'File count and size' })
+ @ApiResponse({ status: 200, description: 'File count and size', type: StorageFileCountResponseDto })
async getStorageFileCount(): Promise<{
storageType: string;
count: number;
@@ -124,7 +129,13 @@ export class InfraStorageController implements OnApplicationBootstrap {
@Get('storage/export')
@RequireRole(ApiKeyRole.ADMIN)
@ApiOperation({ summary: 'Export all storage files as tar.gz' })
- @ApiResponse({ status: 200, description: 'Tar.gz archive stream' })
+ @ApiResponse({
+ status: 200,
+ description:
+ 'JSON pointing at the archive that was written under data/exports/. This route does NOT stream ' +
+ 'the tar.gz itself — fetch it from the returned `download` path.',
+ type: StorageExportResponseDto,
+ })
async exportStorage(): Promise<{ message: string; download: string }> {
// Note: In production, this would return a StreamableFile
// For simplicity, we'll save to a temp file and return the path
@@ -181,7 +192,7 @@ export class InfraStorageController implements OnApplicationBootstrap {
@RequireRole(ApiKeyRole.ADMIN)
@ApiOperation({ summary: 'Import storage files from tar.gz' })
@ApiBody({ description: 'Path to tar.gz file to import' })
- @ApiResponse({ status: 200, description: 'Import result' })
+ @ApiResponse({ status: 200, description: 'Import result', type: StorageImportResponseDto })
async importStorage(
@Body() body: ImportStorageDto,
): Promise<{ imported: boolean; count: number; storageType: string }> {