WA Gateway API
Self-hosted WhatsApp API. Kirim pesan teks, gambar, dan file ke nomor WhatsApp manapun menggunakan HTTP request sederhana.
https://wa.amrzaki.my.id
Quick Start
Login ke Dashboard
Buka wa.amrzaki.my.id dan login menggunakan akun Google atau GitHub.
Tambah Device
Klik + Add Device, beri nama (misal: "Marketing"), lalu scan QR code menggunakan WhatsApp di HP kamu.
WhatsApp → Perangkat Tertaut → Tautkan Perangkat
Ambil API Key
Setelah device Connected, klik card device → klik Show lalu Copy API key.
Kirim Pesan Pertama
curl -X POST https://wa.amrzaki.my.id/api/send \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"target":"6281234567890","message":"Hello!"}'
Authentication
Setiap request harus menyertakan API Key milik device di header Authorization.
Authorization: Bearer your_api_key_here
Atau via query parameter:
GET /api/send?token=your_api_key_here
Send Text Message
/api/send
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
target | string | required | Nomor tujuan (format internasional) |
message | string | required | Isi pesan teks |
type | string | optional | Default: text |
Request
{
"target": "6281234567890",
"message": "Halo! Ini pesan dari WA Gateway 👋"
}
Response
{
"success": true,
"message_id": "550e8400-e29b-41d4-a716-446655440000",
"wa_id": "3EB0C767D97B2C123456"
}
Send Image
/api/send
| Parameter | Type | Required | Description |
|---|---|---|---|
target | string | required | Nomor tujuan |
type | string | required | Isi: image |
url | string | required | URL gambar (jpg, png, gif, webp) |
caption | string | optional | Teks di bawah gambar |
{
"target": "6281234567890",
"type": "image",
"url": "https://example.com/gambar.jpg",
"caption": "Ini caption gambarnya"
}
Send File / Document
/api/send
{
"target": "6281234567890",
"type": "document",
"url": "https://example.com/laporan.pdf",
"caption": "Laporan Bulan Ini"
}
Mendukung: PDF, DOCX, XLSX, ZIP, dan format file lainnya.
Message Logs
/api/messages/logs
| Query Param | Default | Description |
|---|---|---|
device_id | — | ID device (lihat di dashboard) |
direction | all | inbound atau outbound |
limit | 50 | Maks 200 |
offset | 0 | Untuk pagination |
{
"success": true,
"messages": [
{
"id": "550e8400-...",
"direction": "outbound",
"to_number": "6281234567890",
"type": "text",
"content": "Halo!",
"status": "sent",
"created_at": 1745590800
}
]
}
Webhook (Pesan Masuk)
Setiap pesan masuk akan dikirim via HTTP POST ke URL webhook yang kamu set di dashboard (klik device → isi Webhook URL → Save).
Payload yang diterima
{
"event": "message",
"device_id": "uuid-device-kamu",
"from": "6281234567890",
"type": "chat",
"message": "Halo, saya mau tanya...",
"timestamp": 1745590800000
}
Contoh handler webhook (Express.js)
app.post('/webhook/wa', (req, res) => { const { from, message, device_id } = req.body; console.log(`Pesan dari ${from}: ${message}`); // Balas otomatis if (message.toLowerCase() === 'halo') { sendWA(device_id, from, 'Halo juga! Ada yang bisa dibantu?'); } res.json({ received: true }); });
JavaScript / Node.js
const API_KEY = 'your_api_key_here'; const BASE_URL = 'https://wa.amrzaki.my.id'; async function sendMessage(target, message) { const res = await fetch(`${BASE_URL}/api/send`, { method: 'POST', headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ target, message }), }); return res.json(); } // Kirim pesan sendMessage('6281234567890', 'Halo dari Node.js! 👋') .then(console.log); // Kirim gambar async function sendImage(target, url, caption = '') { const res = await fetch(`${BASE_URL}/api/send`, { method: 'POST', headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ target, type: 'image', url, caption }), }); return res.json(); }
PHP
<?php function sendWhatsApp($target, $message, $apiKey) { $ch = curl_init('https://wa.amrzaki.my.id/api/send'); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ "Authorization: Bearer {$apiKey}", 'Content-Type: application/json', ], CURLOPT_POSTFIELDS => json_encode([ 'target' => $target, 'message' => $message, ]), ]); $result = json_decode(curl_exec($ch), true); curl_close($ch); return $result; } // Pemakaian $response = sendWhatsApp( '6281234567890', 'Notifikasi dari sistem kami!', 'your_api_key_here' ); if ($response['success']) { echo "Pesan terkirim: " . $response['message_id']; }
Python
import requests API_KEY = "your_api_key_here" BASE_URL = "https://wa.amrzaki.my.id" def send_message(target: str, message: str) -> dict: headers = { "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json", } payload = {"target": target, "message": message} res = requests.post(f"{BASE_URL}/api/send", json=payload, headers=headers) return res.json() def send_image(target: str, url: str, caption: str = "") -> dict: headers = { "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json", } payload = {"target": target, "type": "image", "url": url, "caption": caption} res = requests.post(f"{BASE_URL}/api/send", json=payload, headers=headers) return res.json() # Pemakaian result = send_message("6281234567890", "Hello dari Python! 🐍") print(result)
cURL
Kirim teks
curl -X POST https://wa.amrzaki.my.id/api/send \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"target":"6281234567890","message":"Halo!"}'
Kirim gambar
curl -X POST https://wa.amrzaki.my.id/api/send \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"target":"6281234567890","type":"image","url":"https://example.com/img.jpg","caption":"Lihat ini!"}'
Cek message logs
curl "https://wa.amrzaki.my.id/api/messages/logs?device_id=DEVICE_ID&limit=10" \
-H "Authorization: Bearer YOUR_API_KEY"
Error Codes
| HTTP Status | Message | Penyebab |
|---|---|---|
| 401 | API key required | Header Authorization tidak ada |
| 401 | Invalid API key | API key salah atau sudah di-regenerate |
| 400 | Device not connected | WhatsApp device belum terhubung / scan QR |
| 400 | target is required | Parameter target tidak ada di request body |
| 500 | Internal server error | Gagal kirim (nomor tidak valid, dll) |
Format Nomor Telepon
Gunakan format internasional tanpa tanda plus (+) dan tanpa leading zero.
| Format | Contoh | Status |
|---|---|---|
| Kode negara + nomor | 6281234567890 | ✓ Benar |
| Dengan tanda + | +6281234567890 | ✗ Salah |
| Dengan leading 0 | 081234567890 | ✗ Salah |