English
English
Appearance
English
English
Appearance
/public/account/whatsapp/sessionReturns the current state of a WhatsApp session, including the latest QR code. Call it repeatedly (every 2 seconds works well) after Create Session WhatsApp: show qrcode to the user while isConnected is false, and move on once it turns true.
Authorization: Basic Base64(AccessKey:SecretKey))| Parameter | Type | Required | Description |
|---|---|---|---|
token | string | Yes | Session token returned by Create Session WhatsApp. |
curl -X GET "https://api.repliz.com/public/account/whatsapp/session?token=a2ee814b0a49d6a55d07a73db97578387e1cb226e16f88715459c4935d0a0edfb5ead48bf964931758db4f476738766fc98bf0181672039791e2b92e1e77347c86fc5cab9f8051a3a8ebbdde7db3dee9" \
-H "Authorization: Basic $(echo -n 'YOUR_ACCESS_KEY:YOUR_SECRET_KEY' | base64)"import axios from 'axios';
const response = await axios.get(
'https://api.repliz.com/public/account/whatsapp/session',
{
params: {
token:
'a2ee814b0a49d6a55d07a73db97578387e1cb226e16f88715459c4935d0a0edfb5ead48bf964931758db4f476738766fc98bf0181672039791e2b92e1e77347c86fc5cab9f8051a3a8ebbdde7db3dee9',
},
auth: {
username: 'YOUR_ACCESS_KEY',
password: 'YOUR_SECRET_KEY',
},
},
);
console.log(response.data);const credentials = btoa('YOUR_ACCESS_KEY:YOUR_SECRET_KEY');
const response = await fetch(
'https://api.repliz.com/public/account/whatsapp/session?token=a2ee814b0a49d6a55d07a73db97578387e1cb226e16f88715459c4935d0a0edfb5ead48bf964931758db4f476738766fc98bf0181672039791e2b92e1e77347c86fc5cab9f8051a3a8ebbdde7db3dee9',
{
headers: {
Authorization: `Basic ${credentials}`,
},
},
);
const data = await response.json();
console.log(data);{
"id": "6a38d93d824af0f1182e7486",
"generatedId": "",
"name": "",
"sessionId": "533e6fca-8c88-48c0-86c2-438d43fbc986",
"isConnected": false,
"qrcode": "iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAABlBMVEX///8AAABVwtN+AAAE/UlEQVR42uyZMY61OhKFy3LgDG8A4W0QIHlLhGR2RsiWLBGwDSM2YDIHls+o4L9vWpNemmDeb6l1peaTmq6yT53jS3/Xv2sJoFKvO6Km7XWUngySKHRGC4RngEANqaWzWUSFOkyIKpngqO352TvAiqZViymkjw1VzgLwlaam7d3+HGCyFvBnpJEsKlm/F9LxXaDtKUoks3nA80uaQKl9DgjUcINXANsSJXRUaV99Qz968dsAUNt+3Ne5...",
"picture": ""
}{
"id": "6a38d93d824af0f1182e7486",
"generatedId": "6281292713426:[email protected]",
"name": "Repliz",
"sessionId": "533e6fca-8c88-48c0-86c2-438d43fbc986",
"isConnected": true,
"qrcode": "",
"picture": "https://pps.whatsapp.net/v/t61.24694-24/627254337_1344133021097063_677218802101077715_n.jpg?..."
}{
"code": 404,
"message": "session not found"
}{
"code": 401,
"message": "unauthorized"
}| Field | Type | Description |
|---|---|---|
isConnected | boolean | true once the user has scanned the QR code. Stop polling and send the token to Connect WhatsApp, or to Reconnect WhatsApp for an existing account. |
qrcode | string | The current QR code as a base64-encoded PNG, without a data: prefix. Empty right after the session is created and again after the scan. |
generatedId | string | WhatsApp ID of the phone number that scanned the code. Empty until the scan. |
name | string | WhatsApp display name of that number. Empty until the scan. |
picture | string | Profile picture URL of that number. Empty until the scan, and stays empty if the number has no picture or hides it. |
id | string | Internal session identifier. You don't need it; use token for every call. |
sessionId | string | Internal session identifier. You don't need it; use token for every call. |
To display the QR code, prefix the value with data:image/png;base64, and use it as an image source:
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDol..." alt="Scan with WhatsApp" />The QR code keeps changing
WhatsApp replaces the QR code every 20 to 60 seconds, so update the image on every poll instead of showing the first code. If nobody scans it within a few minutes, the session is deleted and this endpoint returns 404 session not found. Create a new session to show a fresh code.