Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
docs(openapi): document the 503 five more routes already answer
Yudhi Armyndharis780728706b96
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 58762cc9d..35702e865 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]+### Changed++- **Five routes now document a `503` they have been answering for releases** — the four group participant writes have spent the shared request budget since 0.14.5 and listing chats by label has answered `503` on a dead whatsapp-web.js page since 0.14.0, but all five published only their success statuses, so a client generated from the contract had no branch for a failure the gateway was already returning; the participant `503` in particular is the one status that separates "WhatsApp never answered" from the per-participant refusals a `200` reports inside `results`.+## [0.14.6] - 2026-08-08### Addeddiff --git a/openapi.json b/openapi.jsonindex bfb02485e..9df2a5ab4 100644--- a/openapi.json+++ b/openapi.json@@ -4553,6 +4553,9 @@}}}+ },+ "503": {+ "description": "WhatsApp did not answer within the request budget, so no per-participant outcome was read at all. Deliberately not folded into the 200 above — a participant WhatsApp turned down is reported inside `results` and is an answer; an update that never came back is not."}},"summary": "Add participants to a group",@@ -4602,6 +4605,9 @@}}}+ },+ "503": {+ "description": "WhatsApp did not answer within the request budget, so no per-participant outcome was read at all. Deliberately not folded into the 200 above — a participant WhatsApp turned down is reported inside `results` and is an answer; an update that never came back is not."}},"summary": "Remove participants from a group",@@ -4653,6 +4659,9 @@}}}+ },+ "503": {+ "description": "WhatsApp did not answer within the request budget, so no per-participant outcome was read at all. Deliberately not folded into the 200 above — a participant WhatsApp turned down is reported inside `results` and is an answer; an update that never came back is not."}},"summary": "Promote participants to admin",@@ -4704,6 +4713,9 @@}}}+ },+ "503": {+ "description": "WhatsApp did not answer within the request budget, so no per-participant outcome was read at all. Deliberately not folded into the 200 above — a participant WhatsApp turned down is reported inside `results` and is an answer; an update that never came back is not."}},"summary": "Demote participants from admin",@@ -5550,6 +5562,9 @@},"501": {"description": "The active engine cannot list chats by label (Baileys)"+ },+ "503": {+ "description": "The whatsapp-web.js page connection died mid-read, so nothing could be read. Deliberately not reported as a missing label — a page that went away says nothing about whether the label exists. The other engine never answers this: Baileys has no label query at all and answers 501 above."}},"summary": "Get every chat carrying a label",diff --git a/src/config/openapi-contract.spec.ts b/src/config/openapi-contract.spec.tsindex c98cc5db7..e201a3c92 100644--- a/src/config/openapi-contract.spec.ts+++ b/src/config/openapi-contract.spec.ts@@ -73,6 +73,37 @@ describe('openapi.json structural invariants', () => {expect(untyped).toEqual([]);});+ // Every participant write goes through runParticipantsUpdate, which spends the shared request+ // budget (baileys-groups.ts), so each can answer 503 — and each ALSO reports per-participant+ // refusals inside its 200, which is the neighbouring claim it is easiest to mistake the 503 for.+ // Keyed off the response schema rather than a list of paths: these four were missed when the rest+ // of the module gained its 503s, and a hand-written list would miss a fifth route the same way.+ it('every participant write documents the 503 its request budget can produce', () => {+ const doc = snapshot();+ const participantWrites: string[] = [];+ const undocumented: string[] = [];++ for (const [route, item] of Object.entries(doc.paths)) {+ for (const [method, operation] of Object.entries(item)) {+ if (!OPERATION_KEYS.has(method)) continue;+ const responses =+ (operation as { responses?: Record<string, { content?: Record<string, { schema?: { $ref?: string } }> }> })+ .responses ?? {};+ const ref = responses['200']?.content?.['application/json']?.schema?.$ref;+ if (!ref?.endsWith('/ParticipantsOperationResponseDto')) continue;++ const id = `${method.toUpperCase()} ${route}`;+ participantWrites.push(id);+ if (!responses['503']) undocumented.push(id);+ }+ }++ // A renamed DTO would match nothing and leave the assertion below vacuously true — an empty+ // result from a selector that can no longer match is not evidence of compliance.+ expect(participantWrites.length).toBeGreaterThan(0);+ expect(undocumented).toEqual([]);+ });+it('every operation declares at least one response', () => {const doc = snapshot();const silent = Object.entries(doc.paths).flatMap(([route, item]) =>diff --git a/src/modules/group/group.controller.ts b/src/modules/group/group.controller.tsindex 6a975530e..075f5cc6f 100644--- a/src/modules/group/group.controller.ts+++ b/src/modules/group/group.controller.ts@@ -30,6 +30,13 @@ import {const INVITE_CODE_403 = 'The engine refused the request — admin rights required for this group';const INVITE_CODE_503 = 'WhatsApp did not answer the invite-code query — retry shortly';+// Shared by the four participant writes, whose 200 reports per-participant refusals inside `results` —+// so this 503 has to say, on all four, that it is not one of those.+const PARTICIPANTS_503 =+ 'WhatsApp did not answer within the request budget, so no per-participant outcome was read at all. ' ++ 'Deliberately not folded into the 200 above — a participant WhatsApp turned down is reported inside ' ++ '`results` and is an answer; an update that never came back is not.';+// NOTE: the session→groups LIST lives on the SessionController at GET /sessions/:id/groups (it// registered first and owns the canonical narrow projection). A bare @Get() here would collide on// the same path pattern (/sessions/{x}/groups) and be shadowed, so this controller owns only the@@ -163,6 +170,7 @@ export class GroupController {'Participants processed — `results` carries the per-participant outcome (a partial refusal does not fail the batch; a total refusal is an error)',type: ParticipantsOperationResponseDto,})+ @ApiResponse({ status: 503, description: PARTICIPANTS_503 })@HttpCode(HttpStatus.OK)async addParticipants(@Param('sessionId') sessionId: string,@@ -185,6 +193,7 @@ export class GroupController {'Participants processed — `results` carries the per-participant outcome (a partial refusal does not fail the batch; a total refusal is an error)',type: ParticipantsOperationResponseDto,})+ @ApiResponse({ status: 503, description: PARTICIPANTS_503 })async removeParticipants(@Param('sessionId') sessionId: string,@Param('groupId') groupId: string,@@ -206,6 +215,7 @@ export class GroupController {'Participants processed — `results` carries the per-participant outcome (a partial refusal does not fail the batch; a total refusal is an error)',type: ParticipantsOperationResponseDto,})+ @ApiResponse({ status: 503, description: PARTICIPANTS_503 })@HttpCode(HttpStatus.OK)async promoteParticipants(@Param('sessionId') sessionId: string,@@ -228,6 +238,7 @@ export class GroupController {'Participants processed — `results` carries the per-participant outcome (a partial refusal does not fail the batch; a total refusal is an error)',type: ParticipantsOperationResponseDto,})+ @ApiResponse({ status: 503, description: PARTICIPANTS_503 })@HttpCode(HttpStatus.OK)async demoteParticipants(@Param('sessionId') sessionId: string,diff --git a/src/modules/label/label.controller.ts b/src/modules/label/label.controller.tsindex ac53eeb96..d24589ab7 100644--- a/src/modules/label/label.controller.ts+++ b/src/modules/label/label.controller.ts@@ -43,6 +43,13 @@ export class LabelController {@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)' })+ @ApiResponse({+ status: 503,+ description:+ 'The whatsapp-web.js page connection died mid-read, so nothing could be read. Deliberately not ' ++ 'reported as a missing label — a page that went away says nothing about whether the label exists. ' ++ 'The other engine never answers this: Baileys has no label query at all and answers 501 above.',+ })async getChatsByLabel(@Param('sessionId') sessionId: string, @Param('labelId') labelId: string) {return this.labelService.getChatsByLabel(sessionId, labelId);}