About login authentication
Wawp’s Authentication & Login endpoints are designed to make device onboarding and re-authentication fast, secure, and developer-friendly.
Best practices
Store the 'instance_id' in your database linked to your internal user ID.
Implement a 'Session Manager' page where users can see their current connection status.
Listen for 'DISCONNECTED' or 'LOGOUT' webhook events to notify users they need to re-scan.
Use the /v2/logout endpoint before deleting an instance to ensure a clean disconnection from WhatsApp servers.
Seamless Onboarding: The Architecture of Wawp Authentication
Wawp’s Authentication & Login infrastructure is engineered to solve the most difficult hurdle in WhatsApp automation: Secure, reliable, and frictionless device linking. Our system treats authentication not as a one-time event, but as a continuous, interactive handshake between your application, our high-performance engine, and the official WhatsApp network.
🏗️ The "Interactive Handshake" Philosophy
Unlike legacy solutions that require manual session-file management, Wawp uses an Isolated Engine Model. When you initiate an authentication flow, we spin up a dedicated, containerized instance specifically for your session. This provides several critical advantages:
- Sandboxed Security: Each session’s encryption keys and WebSocket bridges are physically separated from other users.
- State Transparency: Through our Authentication endpoints, you can visualize exactly what the headless engine "sees" in real-time.
- Automated Recovery: Our system monitors the health of the authentication bridge. If a handshake stalls or the WhatsApp WebSocket disconnects unexpectedly, the engine performs a "Warm Reset" to restore the link without losing your paired status.
🛡️ Strategic Best Practices for Developers
1. Hybrid Authentication Strategy
For the best User Experience (UX), we recommend implementing a hybrid approach in your application dashboard:
- Default (QR Image): Provide the direct
/v2/auth/qr-imagefor desktop users. It’s the fastest and most familiar way to link. - Advanced (Pairing Code): Offer the
/v2/auth/request-codemethod as a primary option for mobile-to-mobile onboarding or users with broken cameras. This allows a user to simply copy an 8-digit code and paste it into their WhatsApp settings.
2. The "Trust but Verify" Security Model
Wawp adheres to a Zero-Secrets Policy. We do not log your API Access Tokens or WhatsApp Session Keys in our persistent application logs.
- Developer Action: Ensure that your frontend never exposes the
access_tokenin client-side logs. Always proxy authentication requests through your own backend to maintain a secure "Server-to-Server" relationship with Wawp.
3. Implementing "Live" UI Updates
WhatsApp QR codes are dynamic and expire every 20-30 seconds.
- The Ideal Workflow: Use a WebSocket or a 5-second polling loop to refresh the QR image on your screen. If our API returns a
422status, it signals that the engine is refreshing its state. Your UI should show a "Generating fresh code..." spinner rather than an error message.
⚖️ QR Code vs. Pairing Code: Which to Use?
| Comparison | QR Code Method | Pairing Code Method |
|---|---|---|
| User Effort | Scan with Camera (Fast) | Manual Entry (Medium) |
| Supported Devices | All (Standard) | Modern Android/iOS |
| Reliability | High | Extremely High (Headless) |
| Best For | Web-based Dashboards | CLI tools, VPS, Mobile Apps |
🧪 Technical Flow & Deployment Logic
To build a professional onboarding flow, your orchestration logic should follow these steps:
- State Audit: Call
/v2/session/info. - Logic Branching:
- if WORKING: Redirect user to their active dashboard.
- if STOPPED: Call
/v2/session/startand wait 5 seconds. - if SCAN_QR_CODE: The engine is ready for an identity link.
- Visual Presentation:
- Fetch the latest image via
/v2/auth/qr-image. - Render it in a responsive container with a 30-second countdown timer to manage user expectations.
- Fetch the latest image via
- Verification: Poll
/v2/session/infoevery 3 seconds. The moment the status transitions to WORKING, trigger a "Success" animation and fetch the account details via/v2/session/me.
⚠️ Common Pitfalls to Avoid
- Token Exposure: Never append the
access_tokento a public URL that might be cached by CDNs or proxies. Use POST requests whenever possible. - Poll Flooding: Do not poll for authentication status faster than once every 2 seconds. Excessive requests can cause transient latency in the engine’s encryption handshake.
Summary of Capabilities:
- Power a white-labeled "Connect WhatsApp" experience.
- Choose between QR image, raw QR string, or Pairing codes.
- Monitor session persistence with high-fidelity screenshots.
- Leverage automatic background engine restarts for 99.9% pairing reliability.
Command Palette
Search for a command to run...