Instance
Connect Instance
Initiates the WhatsApp connection and returns a QR code or pairing code
GET
Connect Instance
Auth:
TokenAccount or TokenInstance • Rate-limit: Global (100/min) • Idempotent: partial
Description
Starts the connection via whatsmeow. With no parameters, generates a QR code. With?number=..., generates a pairing code (8 characters). Blocks until a code or error is received (internal timeout ~60s).
Examples
QR code (default usage)
With no query params, the server generates the QR code to scan on the phone. Returns the ASCII string and the PNG in base64 ready to render.Pairing code
Passing?number=5511999999999, the server forces login via an 8-character pairing code instead of QR, useful when the user doesn’t have access to a camera to scan.
With 7 days of history
Requests the last 7 days of messages on the first pairing via?history=7. The presence of the parameter forces synchronization even if disableHistorySync=true is in the instance settings.
Success response
- QR code generated
- Pairing code generated
200 OK
qrCode, ASCII string of the QR (what WhatsApp expects). Can be rendered with any QR library.qrCodeBase64, PNG rendered by the server (base64). Ready to use as<img src="data:image/png;base64,...">.
Path parameters
Name of the instance to connect.
Headers
TokenAccount or TokenInstance of the instance in the path.
Query parameters
Phone in international format (e.g.,
5511999999999). If filled, forces login via pairing code instead of QR.Requests the last N days of history on the first pairing (e.g.,
?history=5). Requires WhatsApp server support, not guaranteed. The presence of the parameter forces synchronization even if disableHistorySync=true in the settings.Notes
The QR expires, WhatsApp issues a new QR after ~20s. If the user takes too long and you need another attempt, redo the call.
Errors
| HTTP | error.message | When |
|---|---|---|
| 400 | Instance name is required | Empty path. |
| 401 | Invalid token | Token missing or invalid. |
| 404 | Instance not found | Name does not exist. |
| 429 | Rate limit exceeded. Try again later. | More than 100 req/min. |
| 500 | Failed to generate QR code | Failure to generate QR/pairing (network, proxy, corrupted store). |
Next
Reconnect without QR
POST /api/instance/reconnect/:instance, reuses the saved session.Check state
GET /api/instance/list?instanceName=<name> shows the current state.