Collection: devices
Menyimpan data perangkat WhatsApp yang terhubung ke engine.
Struktur Dokumen
{
"_id": "uuid-string",
"store_id": "uuid-string",
"name": "Device 1",
"sender": "+6281234567890",
"token": "random-token-string",
"webhook_url": "https://backend.dazo.id/webhook",
"status": "active",
"created_at": "2026-01-01T00:00:00.000000Z",
"updated_at": "2026-06-25T14:30:00.000000Z"
}Field
| Field | Type | Deskripsi |
|---|---|---|
_id | string (UUID) | Primary key |
store_id | string (UUID) | Foreign key ke stores._id |
name | string | Nama device |
sender | string | Nomor WhatsApp (format +62) |
token | string | Token untuk autentikasi ke engine |
webhook_url | string | URL webhook untuk receive message |
status | string | Status: active, inactive, disconnected |
Collection: admin_devices
Menyimpan data device yang dikelola oleh admin (bukan store owner).
Struktur Dokumen
{
"_id": "uuid-string",
"name": "Admin Device 1",
"sender": "+6281234567890",
"token": "random-token-string",
"webhook_url": "https://backend.dazo.id/webhook",
"status": "active",
"created_by": "admin@dazo.id",
"created_at": "2026-01-01T00:00:00.000000Z",
"updated_at": "2026-06-25T14:30:00.000000Z"
}Field
| Field | Type | Deskripsi |
|---|---|---|
_id | string (UUID) | Primary key |
name | string | Nama device |
sender | string | Nomor WhatsApp |
token | string | Token untuk autentikasi |
webhook_url | string | URL webhook |
status | string | Status: active, inactive, disconnected |
created_by | string | Email admin yang membuat |
Provisioning Flow
- Admin buat device →
DeviceController::store() - Generate random token
- Simpan ke MongoDB (
admin_devices) - cURL POST ke engine WhatsApp:
{$url_engine}/new - Engine spawn instance WhatsApp baru
- Engine mengembalikan QR code untuk pairing
Query Umum
// Device aktif
db.devices.find({ status: "active" })
// Device by store
db.devices.find({ store_id: "uuid-store" })
// Admin device aktif
db.admin_devices.find({ status: "active" })