Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

docs(session): note the qr_ready wait before requesting a pairing code

m7fz7f6d0469a9c39
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 98aa234fc..af95f642b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [Unreleased]
+
+### Fixed
+
+- Baileys: requesting a pairing code in the first second or two after `POST /sessions/{id}/start` returns the
+ documented 409 instead of a 500 with a `Connection Closed` stack trace. The socket object exists before its
+ WebSocket has finished connecting, so the send threw a raw Boom 428; the request is now gated on the session
+ reaching `qr_ready`, the same guard the whatsapp-web.js engine already carried. Clients that retry on 409 ride
+ through the window instead of surfacing an error.
+
## [0.23.2] - 2026-08-23
### Fixed
diff --git a/docs/examples/session-phone-number-pairing.md b/docs/examples/session-phone-number-pairing.md
index fff936492..d47061b90 100644
--- a/docs/examples/session-phone-number-pairing.md
+++ b/docs/examples/session-phone-number-pairing.md
@@ -44,7 +44,9 @@ curl -X POST http://localhost:2785/api/sessions/{sessionId}/start \
-H "X-API-Key: $API_KEY"
```
-The session must be started before requesting a pairing code.
+The session must be started before requesting a pairing code, and the engine needs a moment to
+connect after `start` returns. Poll `GET /api/sessions/{sessionId}` until `status` is `qr_ready` —
+that is the point the engine can accept a pairing request. Asking earlier returns 409.
## 3. Request a Pairing Code
@@ -92,5 +94,6 @@ After the code is accepted, the OpenWA session should move to a connected/ready
- If OpenWA returns `Session is not started`, call `POST /api/sessions/{sessionId}/start` first.
- If OpenWA returns `Session is already authenticated`, the account is already linked and no pairing code is needed.
+- If OpenWA returns 409 `Session is not waiting to be linked`, the engine is still connecting (or reconnecting after a drop). Wait for `status` to read `qr_ready` and request again.
- If the phone number is rejected, send digits only in international format, without `+`, spaces, or punctuation.
- If you want to create a brand-new WhatsApp account programmatically, that is outside OpenWA's scope. OpenWA only links an existing WhatsApp account.