Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(api): declare the 503 the single-contact read answers

Yudhi Armyndharisd997d86b50c3
diff --git a/docs/06-api-specification.md b/docs/06-api-specification.md
index 33e4f7b60..9c5148a88 100644
--- a/docs/06-api-specification.md
+++ b/docs/06-api-specification.md
@@ -2358,7 +2358,7 @@ Get a single contact by its WhatsApp id.
}
```
-**Errors:** `400` session is not started · `401` missing/invalid API key · `404` `Contact <id> not found` (engine returned null) · `409` conflict or engine not ready (retryable)
+**Errors:** `400` session is not started · `401` missing/invalid API key · `404` `Contact <id> not found` (engine returned null) · `409` conflict or engine not ready (retryable) · `503` the whatsapp-web.js page died mid-read, so the lookup reached no answer (distinct from the `404`, which asserts the contact does not exist)
#### GET /api/sessions/:sessionId/contacts/:contactId/profile-picture
diff --git a/openapi.json b/openapi.json
index 6f44144a6..5f9f316f4 100644
--- a/openapi.json
+++ b/openapi.json
@@ -4595,6 +4595,9 @@
},
"409": {
"description": "The session is not connected — an engine exists for it but is not `ready`: disconnected, reconnecting, or still initializing, so the request never reached WhatsApp. Wait for `ready` and retry. A session that was never started answers `400` instead, and the session lifecycle routes answer `409` for a conflicting state rather than this. One window answers this while the session still reads `ready`: WhatsApp Web periodically reloads its own page and the engine re-injects into it — for those few seconds the answer is a `409` naming the reload; retry shortly."
+ },
+ "503": {
+ "description": "The whatsapp-web.js page connection died mid-read, so the lookup could not reach an answer. Distinct from the `404` above, which asserts the contact does not exist: this one asserts nothing about the contact. Retry once the session is ready again."
}
},
"summary": "Get a specific contact by ID",
diff --git a/src/modules/contact/contact.controller.ts b/src/modules/contact/contact.controller.ts
index 0f93f230a..ff578f9a0 100644
--- a/src/modules/contact/contact.controller.ts
+++ b/src/modules/contact/contact.controller.ts
@@ -93,6 +93,13 @@ export class ContactController {
})
@ApiResponse({ status: 404, description: 'Contact not found' })
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
+ @ApiResponse({
+ status: 503,
+ description:
+ 'The whatsapp-web.js page connection died mid-read, so the lookup could not reach an answer. ' +
+ 'Distinct from the `404` above, which asserts the contact does not exist: this one asserts ' +
+ 'nothing about the contact. Retry once the session is ready again.',
+ })
async findOne(@Param('sessionId') sessionId: string, @Param('contactId') contactId: string) {
return this.contactService.getContactById(sessionId, contactId);
}