Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

docs(sdk): warn that requestPairingCode can revoke a linked number

Yudhi Armyndharis1585783caefa
diff --git a/docs/07-api-collection.md b/docs/07-api-collection.md
index d59a81ea2..b0f63df55 100644
--- a/docs/07-api-collection.md
+++ b/docs/07-api-collection.md
@@ -185,7 +185,7 @@ curl -X POST "$BASE/api/sessions/8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a/force-kill
#### POST /api/sessions/:sessionId/pairing-code
-Request an 8-char pairing code via phone number (OPERATOR).
+Request an 8-char pairing code via phone number (OPERATOR). On whatsapp-web.js, request a code only for a number you are prepared to re-link: a request for a number that already has a linked session has been observed to end with WhatsApp revoking that device. Baileys was not affected in the same tests; link by QR when a session of that number must stay up.
```bash
curl -X POST "$BASE/api/sessions/8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a/pairing-code" \
diff --git a/sdk/go/sessions.go b/sdk/go/sessions.go
index 5afff7322..3d1eb89ed 100644
--- a/sdk/go/sessions.go
+++ b/sdk/go/sessions.go
@@ -150,7 +150,8 @@ func (s *SessionsService) QRCode(ctx context.Context, sessionID string) (*QrCode
return &out, nil
}
-// RequestPairingCode requests a phone-pairing code.
+// RequestPairingCode requests a phone-pairing code. On whatsapp-web.js, never request one for a number that
+// already has a linked session: WhatsApp can revoke that device. Link it by QR instead.
func (s *SessionsService) RequestPairingCode(ctx context.Context, sessionID string, body RequestPairingCodeRequest) (*PairingCodeResponse, error) {
var out PairingCodeResponse
err := s.client.do(ctx, "POST", "/api/sessions/"+pathEscape(sessionID)+"/pairing-code", nil, body, &out)
diff --git a/sdk/java/src/main/java/com/rmyndharis/openwa/resources/SessionsResource.java b/sdk/java/src/main/java/com/rmyndharis/openwa/resources/SessionsResource.java
index f49bf5656..5616b741e 100644
--- a/sdk/java/src/main/java/com/rmyndharis/openwa/resources/SessionsResource.java
+++ b/sdk/java/src/main/java/com/rmyndharis/openwa/resources/SessionsResource.java
@@ -133,7 +133,10 @@ public final class SessionsResource {
return client.request(HttpMethod.GET, "/api/sessions/" + encodeSegment(id) + "/qr", null, null, QrCodeResponse.class);
}
- /** Request an 8-character pairing code for phone-based login. */
+ /**
+ * Request an 8-character pairing code for phone-based login. On whatsapp-web.js, never request one for a
+ * number that already has a linked session: WhatsApp can revoke that device. Link it by QR instead.
+ */
public PairingCodeResponse requestPairingCode(String id, RequestPairingCodeRequest body) {
return client.request(HttpMethod.POST, "/api/sessions/" + encodeSegment(id) + "/pairing-code", null, body, PairingCodeResponse.class);
}
diff --git a/sdk/javascript/src/resources/sessions.ts b/sdk/javascript/src/resources/sessions.ts
index 066cb577d..c120b312d 100644
--- a/sdk/javascript/src/resources/sessions.ts
+++ b/sdk/javascript/src/resources/sessions.ts
@@ -146,7 +146,10 @@ export class SessionsResource {
return this.client.request<QrCodeResponse>({ method: 'GET', path: `/api/sessions/${encodeSegment(id)}/qr` });
}
- /** Request an 8-character pairing code for phone-based login. */
+ /**
+ * Request an 8-character pairing code for phone-based login. On whatsapp-web.js, never request one for a
+ * number that already has a linked session: WhatsApp can revoke that device. Link it by QR instead.
+ */
requestPairingCode(id: string, body: RequestPairingCodeRequest): Promise<PairingCodeResponse> {
return this.client.request<PairingCodeResponse>({
method: 'POST',
diff --git a/sdk/php/src/Resources/SessionsResource.php b/sdk/php/src/Resources/SessionsResource.php
index f9067406e..d68f9f09b 100644
--- a/sdk/php/src/Resources/SessionsResource.php
+++ b/sdk/php/src/Resources/SessionsResource.php
@@ -164,6 +164,9 @@ class SessionsResource
}
/**
+ * Request an 8-character pairing code for phone-based login. On whatsapp-web.js, never request one for a
+ * number that already has a linked session: WhatsApp can revoke that device. Link it by QR instead.
+ *
* @param array<string,mixed> $body
* @return array<string,mixed>
*/
diff --git a/sdk/python/openwa/resources/sessions.py b/sdk/python/openwa/resources/sessions.py
index 2ac799be7..5410a14d2 100644
--- a/sdk/python/openwa/resources/sessions.py
+++ b/sdk/python/openwa/resources/sessions.py
@@ -134,7 +134,11 @@ class SessionsResource:
return self._http.request("GET", f"/api/sessions/{quote_segment(session_id)}/qr")
def request_pairing_code(self, session_id: str, body: RequestPairingCodeRequest) -> PairingCodeResponse:
- """Request a phone-pairing code."""
+ """Request a phone-pairing code.
+
+ On whatsapp-web.js, never request one for a number that already has a linked session: WhatsApp can
+ revoke that device. Link it by QR instead.
+ """
return self._http.request("POST", f"/api/sessions/{quote_segment(session_id)}/pairing-code", body=body)
def stats(self) -> SessionStatsOverview: