Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
docs(openapi): publish the labels, channels and status response schemas
Yudhi Armyndhariscf7d13c7a044
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 68eecd1a8..01cc3a8d2 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 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.- **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.diff --git a/openapi.json b/openapi.jsonindex 07038c4f9..7a1111936 100644--- a/openapi.json+++ b/openapi.json@@ -5079,7 +5079,17 @@],"responses": {"200": {- "description": "List of labels"+ "description": "List of labels",+ "content": {+ "application/json": {+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/LabelDto"+ }+ }+ }+ }},"400": {"description": "Session not ready or not a business account"@@ -5119,7 +5129,14 @@],"responses": {"200": {- "description": "Label details"+ "description": "Label details",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/LabelDto"+ }+ }+ }},"404": {"description": "Label not found"@@ -5165,7 +5182,14 @@},"responses": {"200": {- "description": "Label created or updated"+ "description": "Label created or updated",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/LabelAckResponseDto"+ }+ }+ }},"400": {"description": "Session not started, or validation failed"@@ -5204,7 +5228,14 @@],"responses": {"200": {- "description": "Label deleted"+ "description": "Label deleted",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/LabelAckResponseDto"+ }+ }+ }},"400": {"description": "Session not started"@@ -5245,7 +5276,17 @@],"responses": {"200": {- "description": "Chats carrying the label"+ "description": "Chats carrying the label",+ "content": {+ "application/json": {+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/LabelChatDto"+ }+ }+ }+ }},"400": {"description": "Session not started"@@ -5285,7 +5326,17 @@],"responses": {"200": {- "description": "List of labels for the chat"+ "description": "List of labels for the chat",+ "content": {+ "application/json": {+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/LabelDto"+ }+ }+ }+ }}},"summary": "Get labels for a specific chat",@@ -5336,7 +5387,14 @@},"responses": {"200": {- "description": "Label added to chat"+ "description": "Label added to chat",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/LabelAckResponseDto"+ }+ }+ }},"422": {"description": "Labels require a WhatsApp Business account, or the chat type has no labels"@@ -5382,7 +5440,14 @@],"responses": {"200": {- "description": "Label removed from chat"+ "description": "Label removed from chat",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/LabelAckResponseDto"+ }+ }+ }},"422": {"description": "Labels require a WhatsApp Business account, or the chat type has no labels"@@ -5410,7 +5475,17 @@],"responses": {"200": {- "description": "List of subscribed channels"+ "description": "List of subscribed channels",+ "content": {+ "application/json": {+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/ChannelDto"+ }+ }+ }+ }},"400": {"description": "Session not ready"@@ -5447,7 +5522,14 @@},"responses": {"201": {- "description": "The created channel"+ "description": "The created channel",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ChannelDto"+ }+ }+ }},"400": {"description": "Session not started, or validation failed"@@ -5487,7 +5569,14 @@],"responses": {"200": {- "description": "Channel details"+ "description": "Channel details",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ChannelDto"+ }+ }+ }},"404": {"description": "Channel not found"@@ -5522,7 +5611,14 @@],"responses": {"200": {- "description": "Successfully unsubscribed from channel"+ "description": "Successfully unsubscribed from channel",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ChannelAckResponseDto"+ }+ }+ }}},"summary": "Unsubscribe from a channel",@@ -5565,7 +5661,17 @@],"responses": {"200": {- "description": "List of channel messages"+ "description": "List of channel messages",+ "content": {+ "application/json": {+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/ChannelMessageDto"+ }+ }+ }+ }}},"summary": "Get messages from a channel",@@ -5600,7 +5706,14 @@],"responses": {"200": {- "description": "Channel deleted"+ "description": "Channel deleted",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ChannelAckResponseDto"+ }+ }+ }},"400": {"description": "Session not started"@@ -5651,7 +5764,14 @@},"responses": {"200": {- "description": "Channel muted or unmuted"+ "description": "Channel muted or unmuted",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ChannelAckResponseDto"+ }+ }+ }},"400": {"description": "Session not started, or validation failed"@@ -5702,7 +5822,14 @@},"responses": {"201": {- "description": "Successfully subscribed to channel"+ "description": "Successfully subscribed to channel",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ChannelDto"+ }+ }+ }}},"summary": "Subscribe to a channel using invite code",@@ -5806,7 +5933,14 @@],"responses": {"200": {- "description": "Status updates visible to the session, grouped by contact."+ "description": "Status updates visible to the session, grouped by contact.",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/StatusListResponseDto"+ }+ }+ }}},"summary": "Get all contact status updates",@@ -5838,7 +5972,14 @@],"responses": {"200": {- "description": "Status updates from the requested contact."+ "description": "Status updates from the requested contact.",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/StatusListResponseDto"+ }+ }+ }}},"summary": "Get status updates from a specific contact",@@ -5870,7 +6011,15 @@],"responses": {"200": {- "description": "The status image/video bytes."+ "description": "The status image/video bytes.",+ "content": {+ "application/octet-stream": {+ "schema": {+ "type": "string",+ "format": "binary"+ }+ }+ }},"404": {"description": "No stored media (text status, omitted, or expired)."@@ -5907,7 +6056,14 @@},"responses": {"201": {- "description": "Text status posted. The recipients allow-list is honored on Baileys only; whatsapp-web.js broadcasts to the account's status-privacy audience."+ "description": "Text status posted. The recipients allow-list is honored on Baileys only; whatsapp-web.js broadcasts to the account's status-privacy audience.",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/StatusResultDto"+ }+ }+ }},"400": {"description": "Invalid request, or the post was blocked by a plugin."@@ -5944,7 +6100,14 @@},"responses": {"201": {- "description": "Image status posted. The recipients allow-list is honored on Baileys only; whatsapp-web.js broadcasts to the account's status-privacy audience."+ "description": "Image status posted. The recipients allow-list is honored on Baileys only; whatsapp-web.js broadcasts to the account's status-privacy audience.",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/StatusResultDto"+ }+ }+ }},"400": {"description": "Neither url nor base64 provided, or the post was blocked by a plugin."@@ -5984,7 +6147,14 @@},"responses": {"201": {- "description": "Video status posted. The recipients allow-list is honored on Baileys only; whatsapp-web.js broadcasts to the account's status-privacy audience."+ "description": "Video status posted. The recipients allow-list is honored on Baileys only; whatsapp-web.js broadcasts to the account's status-privacy audience.",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/StatusResultDto"+ }+ }+ }},"400": {"description": "Neither url nor base64 provided, or the post was blocked by a plugin."@@ -6024,7 +6194,14 @@},"responses": {"201": {- "description": "Voice status posted. WhatsApp plays a status voice note only as Ogg/Opus and neither engine transcodes, so convert first via POST /media/convert/voice. The recipients allow-list is honored on Baileys only; whatsapp-web.js broadcasts to the account's status-privacy audience."+ "description": "Voice status posted. WhatsApp plays a status voice note only as Ogg/Opus and neither engine transcodes, so convert first via POST /media/convert/voice. The recipients allow-list is honored on Baileys only; whatsapp-web.js broadcasts to the account's status-privacy audience.",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/StatusResultDto"+ }+ }+ }},"400": {"description": "Neither url nor base64 provided, or the post was blocked by a plugin."@@ -6062,7 +6239,14 @@],"responses": {"200": {- "description": "Status deleted."+ "description": "Status deleted.",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/StatusDeletedResponseDto"+ }+ }+ }}},"summary": "Delete own status",@@ -11295,6 +11479,79 @@}}},+ "LabelDto": {+ "type": "object",+ "properties": {+ "id": {+ "type": "string",+ "description": "Label id, assigned by WhatsApp.",+ "example": "1"+ },+ "name": {+ "type": "string",+ "description": "Label text.",+ "example": "Paid"+ },+ "hexColor": {+ "type": "string",+ "description": "Display colour as hex. The write path takes a colour INDEX (0-19) instead — neither engine exposes the index-to-hex mapping, so the two directions deliberately differ.",+ "example": "#5bc0de"+ }+ },+ "required": [+ "id",+ "name",+ "hexColor"+ ]+ },+ "LabelChatDto": {+ "type": "object",+ "properties": {+ "id": {+ "type": "string",+ "description": "Chat id in the engine's native format.",+ "example": "[email protected]"+ },+ "name": {+ "type": "string",+ "description": "Chat title — contact name or group subject.",+ "example": "Ada Lovelace"+ },+ "isGroup": {+ "type": "boolean",+ "description": "Retained for back-compat; `kind` is the full discriminator.",+ "example": false+ },+ "kind": {+ "type": "string",+ "description": "User-facing chat kind.",+ "example": "individual"+ },+ "unreadCount": {+ "type": "number",+ "description": "Unread messages in this chat.",+ "example": 0+ },+ "timestamp": {+ "type": "number",+ "description": "Unix SECONDS of the most recent activity.",+ "example": 1786000000+ },+ "lastMessage": {+ "type": "string",+ "description": "Preview of the last message, when there is one.",+ "example": "See you then"+ }+ },+ "required": [+ "id",+ "name",+ "isGroup",+ "kind",+ "unreadCount",+ "timestamp"+ ]+ },"UpsertLabelDto": {"type": "object","properties": {@@ -11314,6 +11571,101 @@}}},+ "LabelAckResponseDto": {+ "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"+ ]+ },+ "ChannelDto": {+ "type": "object",+ "properties": {+ "id": {+ "type": "string",+ "description": "Channel (newsletter) id.",+ "example": "120363000000000000@newsletter"+ },+ "name": {+ "type": "string",+ "description": "Channel name.",+ "example": "Release notes"+ },+ "description": {+ "type": "string",+ "description": "Channel description, when set."+ },+ "inviteCode": {+ "type": "string",+ "description": "Invite code, when the engine discloses one. Absent does not mean the channel is private.",+ "example": "0029Va..."+ },+ "subscriberCount": {+ "type": "number",+ "description": "Subscriber count, when the engine reports it.",+ "example": 1024+ },+ "picture": {+ "type": "string",+ "description": "Channel picture URL, when set."+ },+ "verified": {+ "type": "boolean",+ "description": "Whether WhatsApp marks the channel verified.",+ "example": false+ },+ "createdAt": {+ "type": "number",+ "description": "Unix SECONDS the channel was created, when reported.",+ "example": 1786000000+ }+ },+ "required": [+ "id",+ "name"+ ]+ },+ "ChannelMessageDto": {+ "type": "object",+ "properties": {+ "id": {+ "type": "string",+ "description": "Message id.",+ "example": "ABCD1234"+ },+ "body": {+ "type": "string",+ "description": "Message text. Empty for a media-only post.",+ "example": "v0.14.4 is out"+ },+ "timestamp": {+ "type": "number",+ "description": "Unix SECONDS the message was posted.",+ "example": 1786000000+ },+ "hasMedia": {+ "type": "boolean",+ "description": "Whether the post carries media.",+ "example": false+ },+ "mediaUrl": {+ "type": "string",+ "description": "Media URL, when the engine resolved one."+ }+ },+ "required": [+ "id",+ "body",+ "timestamp",+ "hasMedia"+ ]+ },"CreateChannelDto": {"type": "object","properties": {@@ -11333,6 +11685,19 @@"name"]},+ "ChannelAckResponseDto": {+ "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"+ ]+ },"MuteChannelDto": {"type": "object","properties": {@@ -11346,6 +11711,111 @@"mute"]},+ "StatusContactDto": {+ "type": "object",+ "properties": {+ "id": {+ "type": "string",+ "description": "Poster id.",+ "example": "[email protected]"+ },+ "name": {+ "type": "string",+ "description": "Name from the account's addressbook, when saved."+ },+ "pushName": {+ "type": "string",+ "description": "Name the poster set for themselves.",+ "example": "Ada"+ }+ },+ "required": [+ "id"+ ]+ },+ "StatusDto": {+ "type": "object",+ "properties": {+ "id": {+ "type": "string",+ "description": "Status id.",+ "example": "ABCD1234"+ },+ "contact": {+ "description": "Who posted it.",+ "allOf": [+ {+ "$ref": "#/components/schemas/StatusContactDto"+ }+ ]+ },+ "type": {+ "type": "string",+ "enum": [+ "text",+ "image",+ "video",+ "voice"+ ],+ "description": "`voice` is an audio status posted as a voice note. Before voice posting existed, such a status read back as `text`, because anything that was not an image or a video collapsed to it.",+ "example": "image"+ },+ "caption": {+ "type": "string",+ "description": "Caption, for an image or video status."+ },+ "mediaUrl": {+ "type": "string",+ "description": "Media URL as the engine reported it."+ },+ "media": {+ "type": "object",+ "description": "Downloaded media bytes, present only when the engine fetched them and they fit the inbound media cap. Absent is not an error — fetch the bytes from the media route instead."+ },+ "backgroundColor": {+ "type": "string",+ "description": "Background colour of a text or voice status.",+ "example": "#0a5c36"+ },+ "font": {+ "type": "number",+ "description": "Font index of a text or voice status.",+ "example": 2+ },+ "timestamp": {+ "type": "string",+ "description": "ISO-8601 timestamp the status was posted.",+ "example": "2026-08-07T12:00:00.000Z"+ },+ "expiresAt": {+ "type": "string",+ "description": "ISO-8601 timestamp the status expires.",+ "example": "2026-08-08T12:00:00.000Z"+ }+ },+ "required": [+ "id",+ "contact",+ "type",+ "timestamp",+ "expiresAt"+ ]+ },+ "StatusListResponseDto": {+ "type": "object",+ "properties": {+ "statuses": {+ "description": "Statuses, newest first.",+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/StatusDto"+ }+ }+ },+ "required": [+ "statuses"+ ]+ },"SendTextStatusDto": {"type": "object","properties": {@@ -11391,6 +11861,31 @@"text"]},+ "StatusResultDto": {+ "type": "object",+ "properties": {+ "statusId": {+ "type": "string",+ "description": "Id of the status that was posted.",+ "example": "ABCD1234"+ },+ "timestamp": {+ "type": "string",+ "description": "ISO-8601 timestamp the engine stamped on it.",+ "example": "2026-08-07T12:00:00.000Z"+ },+ "expiresAt": {+ "type": "string",+ "description": "ISO-8601 timestamp it expires — 24 hours later.",+ "example": "2026-08-08T12:00:00.000Z"+ }+ },+ "required": [+ "statusId",+ "timestamp",+ "expiresAt"+ ]+ },"StatusMediaInput": {"type": "object","properties": {@@ -11509,6 +12004,18 @@"audio"]},+ "StatusDeletedResponseDto": {+ "type": "object",+ "properties": {+ "message": {+ "type": "string",+ "example": "Status deleted successfully"+ }+ },+ "required": [+ "message"+ ]+ },"ConvertMediaDto": {"type": "object","properties": {diff --git a/src/modules/channel/channel.controller.ts b/src/modules/channel/channel.controller.tsindex 3a6269912..104c4d19b 100644--- a/src/modules/channel/channel.controller.ts+++ b/src/modules/channel/channel.controller.ts@@ -1,5 +1,6 @@import { Controller, Get, Post, Delete, Param, Body, Query, HttpCode, HttpStatus } from '@nestjs/common';import { ApiTags, ApiOperation, ApiResponse, ApiParam, ApiBody, ApiQuery } from '@nestjs/swagger';+import { ChannelAckResponseDto, ChannelDto, ChannelMessageDto } from './dto/channel-response.dto';import { ChannelService } from './channel.service';import { SubscribeChannelDto } from './dto/subscribe-channel.dto';import { CreateChannelDto } from './dto/create-channel.dto';@@ -15,10 +16,7 @@ export class ChannelController {@Get()@ApiOperation({ summary: 'Get all subscribed channels/newsletters' })@ApiParam({ name: 'sessionId', description: 'Session ID' })- @ApiResponse({- status: 200,- description: 'List of subscribed channels',- })+ @ApiResponse({ status: 200, description: 'List of subscribed channels', type: [ChannelDto] })@ApiResponse({ status: 400, description: 'Session not ready' })async findAll(@Param('sessionId') sessionId: string) {return this.channelService.getSubscribedChannels(sessionId);@@ -28,10 +26,7 @@ export class ChannelController {@ApiOperation({ summary: 'Get a specific channel by ID' })@ApiParam({ name: 'sessionId', description: 'Session ID' })@ApiParam({ name: 'channelId', description: 'Channel ID' })- @ApiResponse({- status: 200,- description: 'Channel details',- })+ @ApiResponse({ status: 200, description: 'Channel details', type: ChannelDto })@ApiResponse({ status: 404, description: 'Channel not found' })async findOne(@Param('sessionId') sessionId: string, @Param('channelId') channelId: string) {return this.channelService.getChannelById(sessionId, channelId);@@ -47,10 +42,7 @@ export class ChannelController {type: Number,description: 'Max messages to return (default 50, max 100)',})- @ApiResponse({- status: 200,- description: 'List of channel messages',- })+ @ApiResponse({ status: 200, description: 'List of channel messages', type: [ChannelMessageDto] })async getMessages(@Param('sessionId') sessionId: string,@Param('channelId') channelId: string,@@ -73,7 +65,7 @@ export class ChannelController {})@ApiParam({ name: 'sessionId', description: 'Session ID' })@ApiBody({ type: CreateChannelDto })- @ApiResponse({ status: 201, description: 'The created channel' })+ @ApiResponse({ status: 201, description: 'The created channel', type: ChannelDto })@ApiResponse({ status: 400, description: 'Session not started, or validation failed' })@ApiResponse({ status: 403, description: 'The engine refused — channel creation may be disabled for this account' })async create(@Param('sessionId') sessionId: string, @Body() dto: CreateChannelDto) {@@ -92,7 +84,7 @@ export class ChannelController {})@ApiParam({ name: 'sessionId', description: 'Session ID' })@ApiParam({ name: 'channelId', description: 'Channel ID' })- @ApiResponse({ status: 200, description: 'Channel deleted' })+ @ApiResponse({ status: 200, description: 'Channel deleted', type: ChannelAckResponseDto })@ApiResponse({ status: 400, description: 'Session not started' })@ApiResponse({ status: 403, description: 'The engine refused — not found, or this account does not own it' })async remove(@@ -113,7 +105,7 @@ export class ChannelController {@ApiParam({ name: 'sessionId', description: 'Session ID' })@ApiParam({ name: 'channelId', description: 'Channel ID' })@ApiBody({ type: MuteChannelDto })- @ApiResponse({ status: 200, description: 'Channel muted or unmuted' })+ @ApiResponse({ status: 200, description: 'Channel muted or unmuted', type: ChannelAckResponseDto })@ApiResponse({ status: 400, description: 'Session not started, or validation failed' })@ApiResponse({ status: 403, description: 'The engine refused' })async mute(@@ -142,10 +134,7 @@ export class ChannelController {required: ['inviteCode'],},})- @ApiResponse({- status: 201,- description: 'Successfully subscribed to channel',- })+ @ApiResponse({ status: 201, description: 'Successfully subscribed to channel', type: ChannelDto })async subscribe(@Param('sessionId') sessionId: string, @Body() body: SubscribeChannelDto) {return this.channelService.subscribeToChannel(sessionId, body.inviteCode);}@@ -155,10 +144,7 @@ export class ChannelController {@ApiOperation({ summary: 'Unsubscribe from a channel' })@ApiParam({ name: 'sessionId', description: 'Session ID' })@ApiParam({ name: 'channelId', description: 'Channel ID to unsubscribe from' })- @ApiResponse({- status: 200,- description: 'Successfully unsubscribed from channel',- })+ @ApiResponse({ status: 200, description: 'Successfully unsubscribed from channel', type: ChannelAckResponseDto })async unsubscribe(@Param('sessionId') sessionId: string, @Param('channelId') channelId: string) {await this.channelService.unsubscribeFromChannel(sessionId, channelId);return { success: true };diff --git a/src/modules/channel/dto/channel-response.dto.ts b/src/modules/channel/dto/channel-response.dto.tsnew file mode 100644index 000000000..f28b24c06--- /dev/null+++ b/src/modules/channel/dto/channel-response.dto.ts@@ -0,0 +1,59 @@+import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';++/**+ * Response shapes for the channel routes. These describe what the handlers already return — the+ * payload is the raw handler value, not an 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 ChannelDto {+ @ApiProperty({ description: 'Channel (newsletter) id.', example: '120363000000000000@newsletter' })+ id!: string;++ @ApiProperty({ description: 'Channel name.', example: 'Release notes' })+ name!: string;++ @ApiPropertyOptional({ description: 'Channel description, when set.' })+ description?: string;++ @ApiPropertyOptional({+ description: 'Invite code, when the engine discloses one. Absent does not mean the channel is private.',+ example: '0029Va...',+ })+ inviteCode?: string;++ @ApiPropertyOptional({ description: 'Subscriber count, when the engine reports it.', example: 1024 })+ subscriberCount?: number;++ @ApiPropertyOptional({ description: 'Channel picture URL, when set.' })+ picture?: string;++ @ApiPropertyOptional({ description: 'Whether WhatsApp marks the channel verified.', example: false })+ verified?: boolean;++ @ApiPropertyOptional({ description: 'Unix SECONDS the channel was created, when reported.', example: 1786000000 })+ createdAt?: number;+}++export class ChannelMessageDto {+ @ApiProperty({ description: 'Message id.', example: 'ABCD1234' })+ id!: string;++ @ApiProperty({ description: 'Message text. Empty for a media-only post.', example: 'v0.14.4 is out' })+ body!: string;++ @ApiProperty({ description: 'Unix SECONDS the message was posted.', example: 1786000000 })+ timestamp!: number;++ @ApiProperty({ description: 'Whether the post carries media.', example: false })+ hasMedia!: boolean;++ @ApiPropertyOptional({ description: 'Media URL, when the engine resolved one.' })+ mediaUrl?: string;+}++export class ChannelAckResponseDto {+ @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/label/dto/label-response.dto.ts b/src/modules/label/dto/label-response.dto.tsnew file mode 100644index 000000000..f889c0058--- /dev/null+++ b/src/modules/label/dto/label-response.dto.ts@@ -0,0 +1,53 @@+import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';++/**+ * Response shapes for the label routes. These describe what the handlers already return — the+ * payload is the raw handler value, not an 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 LabelDto {+ @ApiProperty({ description: 'Label id, assigned by WhatsApp.', example: '1' })+ id!: string;++ @ApiProperty({ description: 'Label text.', example: 'Paid' })+ name!: string;++ @ApiProperty({+ description:+ 'Display colour as hex. The write path takes a colour INDEX (0-19) instead — neither engine ' ++ 'exposes the index-to-hex mapping, so the two directions deliberately differ.',+ example: '#5bc0de',+ })+ hexColor!: string;+}++/** A chat carrying a label. Same summary projection the chats list uses. */+export class LabelChatDto {+ @ApiProperty({ description: "Chat id in the engine's native format.", example: '[email protected]' })+ id!: string;++ @ApiProperty({ description: 'Chat title — contact name or group subject.', example: 'Ada Lovelace' })+ name!: string;++ @ApiProperty({ description: 'Retained for back-compat; `kind` is the full discriminator.', example: false })+ isGroup!: boolean;++ @ApiProperty({ description: 'User-facing chat kind.', example: 'individual' })+ kind!: string;++ @ApiProperty({ description: 'Unread messages in this chat.', example: 0 })+ unreadCount!: number;++ @ApiProperty({ description: 'Unix SECONDS of the most recent activity.', example: 1786000000 })+ timestamp!: number;++ @ApiPropertyOptional({ description: 'Preview of the last message, when there is one.', example: 'See you then' })+ lastMessage?: string;+}++export class LabelAckResponseDto {+ @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/label/label.controller.ts b/src/modules/label/label.controller.tsindex 4bc19f451..e9efc7cb0 100644--- a/src/modules/label/label.controller.ts+++ b/src/modules/label/label.controller.ts@@ -1,5 +1,6 @@import { Controller, Get, Post, Put, Delete, Param, Body, HttpCode, HttpStatus } from '@nestjs/common';import { ApiTags, ApiOperation, ApiResponse, ApiParam, ApiBody } from '@nestjs/swagger';+import { LabelAckResponseDto, LabelChatDto, LabelDto } from './dto/label-response.dto';import { LabelService } from './label.service';import { AddLabelDto } from './dto/add-label.dto';import { UpsertLabelDto } from './dto/upsert-label.dto';@@ -14,10 +15,7 @@ export class LabelController {@Get()@ApiOperation({ summary: 'Get all labels (WhatsApp Business only)' })@ApiParam({ name: 'sessionId', description: 'Session ID' })- @ApiResponse({- status: 200,- description: 'List of labels',- })+ @ApiResponse({ status: 200, description: 'List of labels', type: [LabelDto] })@ApiResponse({ status: 400, description: 'Session not ready or not a business account' })@ApiResponse({ status: 404, description: 'Session not found' })async findAll(@Param('sessionId') sessionId: string) {@@ -28,10 +26,7 @@ export class LabelController {@ApiOperation({ summary: 'Get a specific label by ID' })@ApiParam({ name: 'sessionId', description: 'Session ID' })@ApiParam({ name: 'labelId', description: 'Label ID' })- @ApiResponse({- status: 200,- description: 'Label details',- })+ @ApiResponse({ status: 200, description: 'Label details', type: LabelDto })@ApiResponse({ status: 404, description: 'Label not found' })async findOne(@Param('sessionId') sessionId: string, @Param('labelId') labelId: string) {return this.labelService.getLabelById(sessionId, labelId);@@ -45,7 +40,7 @@ export class LabelController {})@ApiParam({ name: 'sessionId', description: 'Session ID' })@ApiParam({ name: 'labelId', description: 'Label ID' })- @ApiResponse({ status: 200, description: 'Chats carrying the label' })+ @ApiResponse({ status: 200, description: 'Chats carrying the label', type: [LabelChatDto] })@ApiResponse({ status: 400, description: 'Session not started' })@ApiResponse({ status: 501, description: 'The active engine cannot list chats by label (Baileys)' })async getChatsByLabel(@Param('sessionId') sessionId: string, @Param('labelId') labelId: string) {@@ -68,7 +63,7 @@ export class LabelController {@ApiParam({ name: 'sessionId', description: 'Session ID' })@ApiParam({ name: 'labelId', description: 'Label ID — caller-chosen' })@ApiBody({ type: UpsertLabelDto })- @ApiResponse({ status: 200, description: 'Label created or updated' })+ @ApiResponse({ status: 200, description: 'Label created or updated', type: LabelAckResponseDto })@ApiResponse({ status: 400, description: 'Session not started, or validation failed' })@ApiResponse({ status: 501, description: 'The active engine cannot edit labels (whatsapp-web.js)' })async upsertLabel(@@ -91,7 +86,7 @@ export class LabelController {})@ApiParam({ name: 'sessionId', description: 'Session ID' })@ApiParam({ name: 'labelId', description: 'Label ID' })- @ApiResponse({ status: 200, description: 'Label deleted' })+ @ApiResponse({ status: 200, description: 'Label deleted', type: LabelAckResponseDto })@ApiResponse({ status: 400, description: 'Session not started' })@ApiResponse({ status: 501, description: 'The active engine cannot edit labels (whatsapp-web.js)' })async deleteLabel(@@ -106,10 +101,7 @@ export class LabelController {@ApiOperation({ summary: 'Get labels for a specific chat' })@ApiParam({ name: 'sessionId', description: 'Session ID' })@ApiParam({ name: 'chatId', description: 'Chat ID' })- @ApiResponse({- status: 200,- description: 'List of labels for the chat',- })+ @ApiResponse({ status: 200, description: 'List of labels for the chat', type: [LabelDto] })async getChatLabels(@Param('sessionId') sessionId: string, @Param('chatId') chatId: string) {return this.labelService.getChatLabels(sessionId, chatId);}@@ -129,10 +121,7 @@ export class LabelController {required: ['labelId'],},})- @ApiResponse({- status: 200,- description: 'Label added to chat',- })+ @ApiResponse({ status: 200, description: 'Label added to chat', type: LabelAckResponseDto })@ApiResponse({status: 422,description: 'Labels require a WhatsApp Business account, or the chat type has no labels',@@ -152,10 +141,7 @@ export class LabelController {@ApiParam({ name: 'sessionId', description: 'Session ID' })@ApiParam({ name: 'chatId', description: 'Chat ID' })@ApiParam({ name: 'labelId', description: 'Label ID to remove' })- @ApiResponse({- status: 200,- description: 'Label removed from chat',- })+ @ApiResponse({ status: 200, description: 'Label removed from chat', type: LabelAckResponseDto })@ApiResponse({status: 422,description: 'Labels require a WhatsApp Business account, or the chat type has no labels',diff --git a/src/modules/status/dto/status-response.dto.ts b/src/modules/status/dto/status-response.dto.tsnew file mode 100644index 000000000..9ffc2d8bd--- /dev/null+++ b/src/modules/status/dto/status-response.dto.ts@@ -0,0 +1,83 @@+import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';++/**+ * Response shapes for the status routes. These describe what the handlers already return — the+ * payload is the raw handler value, not an 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 StatusContactDto {+ @ApiProperty({ description: 'Poster id.', example: '[email protected]' })+ id!: string;++ @ApiPropertyOptional({ description: "Name from the account's addressbook, when saved." })+ name?: string;++ @ApiPropertyOptional({ description: 'Name the poster set for themselves.', example: 'Ada' })+ pushName?: string;+}++export class StatusDto {+ @ApiProperty({ description: 'Status id.', example: 'ABCD1234' })+ id!: string;++ @ApiProperty({ type: StatusContactDto, description: 'Who posted it.' })+ contact!: StatusContactDto;++ @ApiProperty({+ enum: ['text', 'image', 'video', 'voice'],+ description:+ '`voice` is an audio status posted as a voice note. Before voice posting existed, such a ' ++ 'status read back as `text`, because anything that was not an image or a video collapsed to it.',+ example: 'image',+ })+ type!: string;++ @ApiPropertyOptional({ description: 'Caption, for an image or video status.' })+ caption?: string;++ @ApiPropertyOptional({ description: 'Media URL as the engine reported it.' })+ mediaUrl?: string;++ @ApiPropertyOptional({+ type: Object,+ description:+ 'Downloaded media bytes, present only when the engine fetched them and they fit the inbound ' ++ 'media cap. Absent is not an error — fetch the bytes from the media route instead.',+ })+ media?: object;++ @ApiPropertyOptional({ description: 'Background colour of a text or voice status.', example: '#0a5c36' })+ backgroundColor?: string;++ @ApiPropertyOptional({ description: 'Font index of a text or voice status.', example: 2 })+ font?: number;++ @ApiProperty({ description: 'ISO-8601 timestamp the status was posted.', example: '2026-08-07T12:00:00.000Z' })+ timestamp!: string;++ @ApiProperty({ description: 'ISO-8601 timestamp the status expires.', example: '2026-08-08T12:00:00.000Z' })+ expiresAt!: string;+}++export class StatusListResponseDto {+ @ApiProperty({ type: [StatusDto], description: 'Statuses, newest first.' })+ statuses!: StatusDto[];+}++export class StatusResultDto {+ @ApiProperty({ description: 'Id of the status that was posted.', example: 'ABCD1234' })+ statusId!: string;++ @ApiProperty({ description: 'ISO-8601 timestamp the engine stamped on it.', example: '2026-08-07T12:00:00.000Z' })+ timestamp!: string;++ @ApiProperty({ description: 'ISO-8601 timestamp it expires — 24 hours later.', example: '2026-08-08T12:00:00.000Z' })+ expiresAt!: string;+}++export class StatusDeletedResponseDto {+ @ApiProperty({ example: 'Status deleted successfully' })+ message!: string;+}diff --git a/src/modules/status/status.controller.ts b/src/modules/status/status.controller.tsindex e52a721b7..456c0b68f 100644--- a/src/modules/status/status.controller.ts+++ b/src/modules/status/status.controller.ts@@ -1,6 +1,7 @@import { Controller, Get, Post, Delete, Param, Body, Res, StreamableFile } from '@nestjs/common';import type { Response } from 'express';import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';+import { StatusDeletedResponseDto, StatusListResponseDto, StatusResultDto } from './dto/status-response.dto';import { StatusService } from './status.service';import { SendTextStatusDto } from './dto/send-text-status.dto';import { SendImageStatusDto, SendVideoStatusDto, SendVoiceStatusDto } from './dto/send-media-status.dto';@@ -14,14 +15,18 @@ export class StatusController {@Get()@ApiOperation({ summary: 'Get all contact status updates' })- @ApiResponse({ status: 200, description: 'Status updates visible to the session, grouped by contact.' })+ @ApiResponse({+ status: 200,+ description: 'Status updates visible to the session, grouped by contact.',+ type: StatusListResponseDto,+ })async getStatuses(@Param('sessionId') sessionId: string) {return { statuses: await this.statusService.getStatuses(sessionId) };}@Get(':contactId')@ApiOperation({ summary: 'Get status updates from a specific contact' })- @ApiResponse({ status: 200, description: 'Status updates from the requested contact.' })+ @ApiResponse({ status: 200, description: 'Status updates from the requested contact.', type: StatusListResponseDto })async getContactStatus(@Param('sessionId') sessionId: string, @Param('contactId') contactId: string) {return { statuses: await this.statusService.getContactStatus(sessionId, contactId) };}@@ -30,7 +35,11 @@ export class StatusController {// route above regardless of declaration order — Nest/Express match on segment count.@Get(':statusId/media')@ApiOperation({ summary: 'Stream a stored status media file' })- @ApiResponse({ status: 200, description: 'The status image/video bytes.' })+ @ApiResponse({+ status: 200,+ description: 'The status image/video bytes.',+ content: { 'application/octet-stream': { schema: { type: 'string', format: 'binary' } } },+ })@ApiResponse({ status: 404, description: 'No stored media (text status, omitted, or expired).' })async getStatusMedia(@Param('sessionId') sessionId: string,@@ -50,6 +59,7 @@ export class StatusController {description:'Text status posted. The recipients allow-list is honored on Baileys only; whatsapp-web.js broadcasts ' +"to the account's status-privacy audience.",+ type: StatusResultDto,})@ApiResponse({ status: 400, description: 'Invalid request, or the post was blocked by a plugin.' })async sendTextStatus(@Param('sessionId') sessionId: string, @Body() dto: SendTextStatusDto) {@@ -68,6 +78,7 @@ export class StatusController {description:'Image status posted. The recipients allow-list is honored on Baileys only; whatsapp-web.js broadcasts ' +"to the account's status-privacy audience.",+ type: StatusResultDto,})@ApiResponse({status: 400,@@ -89,6 +100,7 @@ export class StatusController {description:'Video status posted. The recipients allow-list is honored on Baileys only; whatsapp-web.js broadcasts ' +"to the account's status-privacy audience.",+ type: StatusResultDto,})@ApiResponse({status: 400,@@ -111,6 +123,7 @@ export class StatusController {'Voice status posted. WhatsApp plays a status voice note only as Ogg/Opus and neither engine ' +'transcodes, so convert first via POST /media/convert/voice. The recipients allow-list is honored ' +"on Baileys only; whatsapp-web.js broadcasts to the account's status-privacy audience.",+ type: StatusResultDto,})@ApiResponse({status: 400,@@ -127,7 +140,7 @@ export class StatusController {@Delete(':statusId')@RequireRole(ApiKeyRole.OPERATOR)@ApiOperation({ summary: 'Delete own status' })- @ApiResponse({ status: 200, description: 'Status deleted.' })+ @ApiResponse({ status: 200, description: 'Status deleted.', type: StatusDeletedResponseDto })async deleteStatus(@Param('sessionId') sessionId: string, @Param('statusId') statusId: string) {await this.statusService.deleteStatus(sessionId, statusId);return { message: 'Status deleted successfully' };