🚀 Getting Started
WAGate API memungkinkan Anda mengirim pesan WhatsApp dari aplikasi atau website Anda sendiri. Setiap device WhatsApp memiliki API token unik yang digunakan untuk autentikasi.
📖 Cara Kerja:
- Generate API Token dari dashboard untuk device WhatsApp Anda
- Simpan token dengan aman (hanya ditampilkan sekali)
- Gunakan token untuk autentikasi setiap request API
- Kirim pesan WhatsApp dari aplikasi Anda!
⚠️ Keamanan: Jangan share API token Anda ke siapapun! Token memberikan akses penuh untuk mengirim pesan dari device WhatsApp Anda.
🌐 Base URL
https://wagate.in/api/v1
🔐 Authentication
Semua endpoint API menggunakan Bearer Token authentication. Sertakan token Anda di header:
Authorization: Bearer YOUR_API_TOKEN_HERE
📝 Cara Mendapatkan API Token:
- Login ke dashboard WAGate
- Hubungkan device WhatsApp Anda (scan QR code)
- Token otomatis di-generate saat device pertama kali dibuat
- Lihat token di dashboard → klik device → lihat di card "🔑 API Token"
- Klik tombol 🔑 untuk view/regenerate token
💡 Tips Token:
- Token ditampilkan sekali saat pertama generate/regenerate
- Simpan token di tempat aman (environment variables, secrets manager)
- Jika kehilangan token, regenerate dari dashboard (token lama jadi invalid)
- Setiap device punya token unik sendiri
💡 Setelah device connected, token sudah bisa langsung digunakan!
/send-message
Kirim pesan teks WhatsApp ke nomor tujuan.
Request Body:
{
"recipient": "628123456789", // Required: nomor WA tujuan (format 62xxx)
"message": "Hello World!", // Required: isi pesan (max 5000 karakter)
"show_typing": true // Optional: tampilkan typing indicator (default: true)
}Example Request:
curl -X POST https://wagate.in/api/v1/send-message \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"recipient": "628123456789",
"message": "Hello from my app!"
}'Success Response (200):
{
"success": true,
"message": "Message sent successfully",
"data": {
"message_id": "3EB0CABA1D0D7BFC2500",
"timestamp": 1702353600
}
}Error Responses:
// 401 Unauthorized - Token tidak valid
{
"success": false,
"message": "Invalid or inactive API token."
}// 400 Bad Request - Nomor tidak terdaftar WhatsApp
{
"success": false,
"message": "Number 628123456789 is not registered on WhatsApp. Please check the number or ask the recipient to activate their WhatsApp account."
}// 400 Bad Request - Device tidak connected
{
"success": false,
"message": "WhatsApp client is not connected. Please reconnect your device from dashboard."
}// 422 Validation Error
{
"success": false,
"message": "session_id, recipient, and message are required"
}/send-media
Kirim pesan WhatsApp dengan media (gambar, video, audio, dokumen) dari URL.
💡 Catatan: Endpoint ini digunakan khusus untuk mengirim media. Untuk pesan teks biasa, gunakan endpoint /send-message
Request Body:
{
"recipient": "628123456789", // Required: nomor WA tujuan (format 62xxx)
"media_url": "https://example.com/image.jpg", // Required: URL media
"media_type": "image", // Optional: image|video|audio|document
"caption": "Ini caption" // Optional: caption untuk media
}Media Type Options:
image → JPEG, PNG, GIF, WebP video → MP4, MOV, WebM audio → MP3, OGG, WAV document → PDF, DOC, DOCX, XLS, XLSX, PPT
Example Request:
curl -X POST https://wagate.in/api/v1/send-media \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"recipient": "628123456789",
"media_url": "https://example.com/photo.jpg",
"media_type": "image",
"caption": "Check out this photo!"
}'Success Response (200):
{
"success": true,
"message": "Media message sent successfully",
"data": {
"message_id": "3EB0CABA1D0D7BFC2500",
"timestamp": 1702353600
}
}Error Responses:
// 400 Bad Request - Media URL tidak valid atau tidak bisa diakses
{
"success": false,
"message": "Failed to download media from URL: connect ENOTFOUND example.com"
}// 422 Validation Error - Parameter kurang
{
"success": false,
"message": "session_id, recipient, and media_url are required"
}Tips:
- Jika tidak set
media_type, sistem akan auto-detect dari Content-Type header URL - Media URL harus accessible dari server (tidak behind authentication)
- Maksimal ukuran media: 100MB
- Timeout download: 30 detik
- URL harus lengkap dengan protocol (https://)
/device
Dapatkan informasi device, user, subscription, dan statistik.
Example Request:
curl -X GET https://wagate.in/api/v1/device \ -H "Authorization: Bearer YOUR_API_TOKEN"
Success Response (200):
{
"success": true,
"data": {
"device": {
"id": 1,
"name": "My WhatsApp",
"phone_number": "6281234567890",
"status": "connected",
"connected_at": "2025-12-10T10:00:00.000000Z",
"last_seen": "2025-12-11T20:00:00.000000Z"
},
"user": {
"name": "John Doe",
"email": "john@example.com"
},
"subscription": {
"package": "Trial",
"message_quota": 100,
"message_remaining": 50,
"device_limit": 1,
"end_date": "2025-12-31",
"is_trial": true
},
"statistics": {
"total_sent": 45,
"total_failed": 5,
"today_sent": 10
}
}
}/messages
Dapatkan riwayat pesan dengan pagination.
Query Parameters:
?limit=50 // Optional: jumlah per halaman (max 100, default 50) &page=1 // Optional: halaman (default 1) &status=sent // Optional: filter by status (sent|failed|pending)
Example Request:
curl -X GET "https://wagate.in/api/v1/messages?limit=10&status=sent" \ -H "Authorization: Bearer YOUR_API_TOKEN"
Success Response (200):
{
"success": true,
"data": [
{
"id": 1,
"recipient": "628123456789",
"message": "Hello World",
"status": "sent",
"created_at": "2025-12-11T20:00:00.000000Z",
"sent_at": "2025-12-11T20:00:05.000000Z"
}
],
"pagination": {
"current_page": 1,
"total_pages": 5,
"per_page": 10,
"total": 45
}
}💻 Code Examples
PHP (cURL) - Send Text Message
<?php
$apiToken = 'YOUR_API_TOKEN';
$apiUrl = 'https://wagate.in/api/v1/send-message';
$data = [
'recipient' => '628123456789',
'message' => 'Hello from PHP!'
];
$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $apiToken,
'Content-Type: application/json'
]);
$response = curl_exec($ch);
$result = json_decode($response, true);
if ($result['success']) {
echo "Message sent successfully!";
} else {
echo "Error: " . $result['message'];
}
curl_close($ch);
?>PHP (cURL) - Send Media
<?php
$apiToken = 'YOUR_API_TOKEN';
$apiUrl = 'https://wagate.in/api/v1/send-media';
$data = [
'recipient' => '628123456789',
'media_url' => 'https://example.com/image.jpg',
'media_type' => 'image',
'caption' => 'Check this out!'
];
$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $apiToken,
'Content-Type: application/json'
]);
$response = curl_exec($ch);
$result = json_decode($response, true);
if ($result['success']) {
echo "Media sent successfully!";
} else {
echo "Error: " . $result['message'];
}
curl_close($ch);
?>JavaScript (Fetch API) - Send Text Message
const apiToken = 'YOUR_API_TOKEN';
const apiUrl = 'https://wagate.in/api/v1/send-message';
fetch(apiUrl, {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
recipient: '628123456789',
message: 'Hello from JavaScript!'
})
})
.then(response => response.json())
.then(data => {
if (data.success) {
console.log('Message sent:', data.data);
} else {
console.error('Error:', data.message);
}
})
.catch(error => console.error('Request failed:', error));JavaScript (Fetch API) - Send Media
const apiToken = 'YOUR_API_TOKEN';
const apiUrl = 'https://wagate.in/api/v1/send-media';
fetch(apiUrl, {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
recipient: '628123456789',
media_url: 'https://example.com/image.jpg',
media_type: 'image',
caption: 'Check this out!'
})
})
.then(response => response.json())
.then(data => {
if (data.success) {
console.log('Media sent:', data.data);
} else {
console.error('Error:', data.message);
}
})
.catch(error => console.error('Request failed:', error));Python (requests) - Send Text Message
import requests
api_token = 'YOUR_API_TOKEN'
api_url = 'https://wagate.in/api/v1/send-message'
headers = {
'Authorization': f'Bearer {api_token}',
'Content-Type': 'application/json'
}
data = {
'recipient': '628123456789',
'message': 'Hello from Python!'
}
response = requests.post(api_url, headers=headers, json=data)
result = response.json()
if result['success']:
print('Message sent:', result['data'])
else:
print('Error:', result['message'])Python (requests) - Send Media
import requests
api_token = 'YOUR_API_TOKEN'
api_url = 'https://wagate.in/api/v1/send-media'
headers = {
'Authorization': f'Bearer {api_token}',
'Content-Type': 'application/json'
}
data = {
'recipient': '628123456789',
'media_url': 'https://example.com/image.jpg',
'media_type': 'image',
'caption': 'Check this out!'
}
response = requests.post(api_url, headers=headers, json=data)
result = response.json()
if result['success']:
print('Media sent:', result['data'])
else:
print('Error:', result['message'])✨ Best Practices
Keamanan Token
Jangan hardcode token di kode. Gunakan environment variables atau secrets management.
Rate Limiting
API memiliki rate limit. Implementasikan retry logic dengan exponential backoff.
Monitor Quota
Gunakan endpoint GET /device untuk cek remaining quota sebelum kirim banyak pesan.
Handle Errors
Selalu cek response status dan handle error dengan baik (401, 403, 422, 500).
Format Nomor
Gunakan format internasional (62xxx) tanpa tanda + atau spasi.