Auth
After we have our device(phone) added, we need to login using the device. Logging in would provide a QR code in response which we will need to scan using whatsapp app on our mobile.
TIP
2 ways QR code can be delivered
- Via API response as a base64 string
- Via a telegram message
Login
Request
GET http://localhost:7000/devices/{device_id}/login
Response
HTTP/1.1 200 OK
Date: Mon, 08 May 2023 23:25:00 GMT
Content-Type: application/json
Content-Length: 288
Connection: close
{
"code": "SUCCESS",
"message": "qr code successfully generated",
"data": "<QR_CODE_BASE64>"
}
TIP
QR code received in response is base64 encoded. Incase you provided a webbook url when adding your device the QR will be delivered to your webhook as an event. In case you have your telegram settings, QR will also be delivered to your telegram chat.
Logout
Request
GET http://localhost:7000/devices/{device_id}/logout
Response
HTTP/1.1 200 OK
Date: Mon, 08 May 2023 23:19:37 GMT
Content-Type: application/json
Content-Length: 54
Connection: close
{
"code": "SUCCESS",
"message": "logged out successfully"
}
Reconnect
TIP
Sometimes when you're sending a message or interacting with WAPI you may get a response like below
HTTP/1.1 401 Unauthorized
Date: Mon, 08 May 2023 23:25:00 GMT
Content-Type: application/json
Content-Length: 288
Connection: close
you are not connect to services server, please reconnect
Reason
- The server has restarted
- Connection to whatsapp has closed
In that case you will need to reconnect. Reconnect will also emit connected event.
Request
GET http://localhost:7000/devices/{device_id}/reconnect
Response
{
"code": "SUCCESS",
"message": "device has successfully reconnected"
}