Scan Ulang Device (yang sudah ada)
API untuk meminta QR baru pada device yang sudah terdaftar di akun Anda — tanpa login dashboard. Cocok untuk integrasi aplikasi lain saat koneksi WhatsApp putus.
HTTP REQUEST
POST https://api.starsender.online/api/devices/{id}/scan
Catatan: Untuk menambah device baru sekaligus QR, gunakan Tambah Device lalu Scan. Untuk reset sesi tanpa QR, gunakan Relog Device.
Header Parameters
| Parameter | Default | Description |
|---|---|---|
| Authorization | true | Account API key, anda bisa dapatkan di menu profile |
Query Parameters
| Parameter | Default | Description |
|---|---|---|
| id (path) | true | ID device di StarSender (bukan nomor WA) |
| force | false | Jika 1 atau true, paksa generate QR baru (abaikan cache QR di database) |
| wait | false | 1 / true = tunggu hingga WA ter-scan dan status = connected (maks. 120 detik). Angka = detik tunggu (maks. 180). Tanpa wait, sukses = QR siap, belum terkoneksi. |
Implementasi dengan PHP
scan_ulang_device.php
<?php
$curl = curl_init();
$idDevice = 12345;
$force = true;
$url = 'https://api.starsender.online/api/devices/' . $idDevice . '/scan';
if ($force) {
$url .= '?force=1';
}
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => array(
'Content-Type:application/json',
'Authorization: YOUR API KEY'
),
));
$response = curl_exec($curl);
curl_close($curl);
$res = json_decode($response, true);
if (isset($res['data']['kode_gambar'])) {
$kode_gambar = $res['data']['kode_gambar'];
echo "<img src=\"$kode_gambar\" />";
} else {
echo $res['message'] ?? $response;
}
Respon API
{
"success": true,
"data": {
"kode_gambar": "data:image/png;base64,iVBORw0KGgoAAAANSU",
"kode_qr": "...",
"device": {
"id": 12345,
"name": "Device CS",
"status": "not connected"
}
},
"message": "Sukses mengambil QR"
}
Perilaku server / node
- Jika device menempel di server WA yang sudah tidak ada di sistem, scan akan otomatis memindahkan ke node aktif lalu minta QR.
- Untuk pindah server secara eksplisit (meski node lama masih ada), gunakan Pindah Server Device — satu request, langsung dapat QR.
- Tunggu beberapa detik setelah response sebelum menampilkan QR ke user; jika QR belum muncul, ulangi sekali dengan
force=1. - Pairing code belum tersedia lewat API ini — gunakan dashboard (tombol Pairing Code) jika scan QR bermasalah.
Respon setelah scan QR di WhatsApp berhasil
Sama seperti Pindah Server: tambahkan ?wait=1 (bisa digabung ?force=1&wait=1).
{
"success": true,
"data": {
"device": {
"id": 12345,
"status": "connected",
"no_hp": "628..."
}
},
"message": "Device connected"
}
Tanpa wait, setelah tampilkan QR cek lewat Detail Device atau List Device hingga status = connected.