Use this flow when a token exists but the WhatsApp device is not scanned yet.
If the token was scanned before and the local session files still exist, calling /session/connect can restore the session without a new QR scan.
Connect the token
curl -X POST http://localhost:1337/session/connect \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN" \
-d '{
"Subscribe": ["All"],
"Immediate": true,
"Phone": ""
}'
Fetch the QR code
curl -H "token: YOUR_TOKEN" \
http://localhost:1337/session/qr
Example response:
{
"code": 200,
"data": {
"QRCode": "data:image/png;base64,..."
},
"success": true
}
Render QRCode as an image in your web app.
Poll while waiting
For browser apps, poll /session/status every few seconds to detect when LoggedIn becomes true. Fetch /session/qr when you need to refresh the displayed QR code.
Do not call /session/logout while polling. Logout unlinks the device and forces a fresh scan.
Disconnect
Disconnect the live WebSocket connection without logging out the device:
curl -X POST http://localhost:1337/session/disconnect \
-H "token: YOUR_TOKEN"
Logout
Logout removes the linked device and requires a fresh QR scan next time:
curl -X POST http://localhost:1337/session/logout \
-H "token: YOUR_TOKEN"