Autentikasi
Setiap request ke protected endpoint wajib menyertakan API key. Ada dua cara:
Cara 1 — Header X-API-Key (direkomendasikan)
curl -X POST https://wa.codepod.my.id/api/send \
-H "Content-Type: application/json" \
-H "X-API-Key: wa_your_api_key_here" \
-d '{"to":"6281234567890","message":"Halo dari cURL"}'
const BASE = 'https://wa.codepod.my.id';
const API_KEY = 'wa_your_api_key_here';
const res = await fetch(BASE + '/api/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': API_KEY
},
body: JSON.stringify({
to: '6281234567890',
message: 'Halo dari Node.js'
})
});
const data = await res.json();
console.log(data);
<?php
$ch = curl_init('https://wa.codepod.my.id/api/send');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-API-Key: wa_your_api_key_here'
],
CURLOPT_POSTFIELDS => json_encode([
'to' => '6281234567890',
'message' => 'Halo dari PHP'
])
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
import requests
BASE = "https://wa.codepod.my.id"
API_KEY = "wa_your_api_key_here"
res = requests.post(
f"{BASE}/api/send",
headers={
"Content-Type": "application/json",
"X-API-Key": API_KEY
},
json={
"to": "6281234567890",
"message": "Halo dari Python"
}
)
print(res.json())
Cara 2 — Header Authorization: Bearer
curl -X POST https://wa.codepod.my.id/api/send \
-H "Content-Type: application/json" \
-H "Authorization: Bearer wa_your_api_key_here" \
-d '{"to":"6281234567890","message":"Halo"}'
Admin key (untuk generate/revoke API key & pairing) hanya bisa via X-API-Key, tidak bisa via Bearer.
Base URL
https://wa.codepod.my.id
Semua endpoint dimulai dari base URL di atas. Wajib HTTPS — HTTP tidak didukung.
Format Response
Response Sukses
{
"success": true,
"message_id": "BAE5A1F2C3D4E5F6",
"to": "6281234567890",
"status": "sent"
}
❌ Response Error
{
"success": false,
"error": "Pesan error yang menjelaskan masalah"
}
⛔ Rate Limit / Jam Operasional
{
"error": "Batas harian tercapai (300/300). Coba lagi besok.",
"remaining": 0,
"limit": 300
}
Kode HTTP & Artinya
| Kode | Arti | Kapan |
|---|---|---|
200 | OK | Request berhasil |
201 | Created | Resource berhasil dibuat (generate key, tambah kontak) |
400 | Bad Request | Parameter wajib tidak diisi / format salah |
403 | Forbidden | API key tidak valid |
404 | Not Found | Endpoint atau resource tidak ditemukan |
429 | Too Many Requests | Rate limit harian tercapai / terlalu cepat |
500 | Server Error | WA tidak terhubung atau error internal |
Rate Limit & Batasan
| Aturan | Nilai |
|---|---|
| Maksimal pesan per hari | 300 / API key (customizable per key) |
| Minimal jeda antar pesan | 2 detik (anti-spam) |
| Jam operasional | 06:00 — 21:00 WIB |
| Timeout webhook | 10 detik |
Saat limit tercapai, response HTTP 429 dengan field remaining: 0. Cek sisa kuota via GET /api/status/me.
Kirim Pesan Teks
Mengirim pesan teks ke satu nomor WhatsApp. Nomor otomatis tersimpan sebagai kontak.
Request Body
| Field | Tipe | Wajib | Keterangan |
|---|---|---|---|
to | string | Ya | Nomor tujuan, format 628xxxxxxxxxx |
message | string | Ya | Isi pesan teks |
type | string | Tidak | Default "text". Opsi: text, image, document |
curl -X POST https://wa.codepod.my.id/api/send \
-H "Content-Type: application/json" \
-H "X-API-Key: wa_your_api_key_here" \
-d '{
"to": "6281234567890",
"message": "Halo, ini pesan otomatis dari aplikasi kami."
}'
const BASE = 'https://wa.codepod.my.id';
const API_KEY = 'wa_your_api_key_here';
const res = await fetch(BASE + '/api/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': API_KEY
},
body: JSON.stringify({
to: '6281234567890',
message: 'Halo, ini pesan otomatis dari aplikasi kami.'
})
});
const data = await res.json();
if (data.success) {
console.log('Terkirim! ID:', data.message_id);
} else {
console.error('Gagal:', data.error);
}
<?php
$ch = curl_init('https://wa.codepod.my.id/api/send');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-API-Key: wa_your_api_key_here'
],
CURLOPT_POSTFIELDS => json_encode([
'to' => '6281234567890',
'message' => 'Halo, ini pesan otomatis dari aplikasi kami.'
])
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$data = json_decode($response, true);
if ($data['success']) {
echo "Terkirim! ID: " . $data['message_id'];
} else {
echo "Gagal: " . $data['error'];
}
import requests
BASE = "https://wa.codepod.my.id"
API_KEY = "wa_your_api_key_here"
res = requests.post(
f"{BASE}/api/send",
headers={
"Content-Type": "application/json",
"X-API-Key": API_KEY
},
json={
"to": "6281234567890",
"message": "Halo, ini pesan otomatis dari aplikasi kami."
}
)
data = res.json()
if data.get("success"):
print(f"Terkirim! ID: {data['message_id']}")
else:
print(f"Gagal: {data.get('error')}")
Response Sukses (200)
{
"success": true,
"message_id": "BAE5A1F2C3D4E5F6",
"log_id": 42,
"to": "6281234567890",
"status": "sent"
}
Response Error
{
"success": false,
"error": "Parameter \"to\" (nomor tujuan) wajib"
}
Terlalu Cepat (429)
{
"error": "Terlalu cepat. Tunggu 2 detik.",
"retry_after_ms": 2000
}
Upload File
Upload file (gambar, PDF, dokumen) untuk dikirim via WhatsApp. File disimpan di server dan bisa digunakan di /api/send via media.path atau media.url.
Request (multipart/form-data)
| Field | Tipe | Wajib | Keterangan |
|---|---|---|---|
file | file | Ya | File yang akan diupload (max 10MB) |
curl -X POST https://wa.codepod.my.id/api/upload \
-H "X-API-Key: wa_your_api_key_here" \
-F "file=@/path/ke/foto-produk.jpg"
import fs from 'fs';
const form = new FormData();
form.append('file', fs.createReadStream('/path/ke/foto.jpg'));
const res = await fetch(BASE + '/api/upload', {
method: 'POST',
headers: { 'X-API-Key': API_KEY },
body: form
});
const data = await res.json();
console.log('Uploaded:', data.file.url);
<?php
$ch = curl_init('https://wa.codepod.my.id/api/upload');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: wa_your_api_key_here'],
CURLOPT_POSTFIELDS => [
'file' => new CURLFile('/path/ke/foto.jpg')
]
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
echo 'Uploaded: ' . $data['file']['url'];
import requests
with open('/path/ke/foto.jpg', 'rb') as f:
res = requests.post(
f"{BASE}/api/upload",
headers={"X-API-Key": API_KEY},
files={"file": f}
)
data = res.json()
print(f"Uploaded: {data['file']['url']}")
Response Sukses (201)
{
"success": true,
"file": {
"original_name": "foto-produk.jpg",
"filename": "a1b2c3d4e5f6.jpg",
"size": 245760,
"mimetype": "image/jpeg",
"url": "https://wa.codepod.my.id/uploads/a1b2c3d4e5f6.jpg",
"path": "/opt/wa-gateway/uploads/a1b2c3d4e5f6.jpg"
},
"usage": {
"via_url": "Gunakan di /api/send: {\"type\":\"image\",\"media\":{\"url\":\"https://wa.codepod.my.id/uploads/a1b2c3d4e5f6.jpg\"}}",
"via_path": "Atau via path: {\"type\":\"image\",\"media\":{\"path\":\"/opt/wa-gateway/uploads/a1b2c3d4e5f6.jpg\"}}"
}
}
Tipe File yang Didukung
| Kategori | Tipe MIME |
|---|---|
| Gambar | image/jpeg, image/png, image/webp |
| Dokumen | application/pdf, .doc, .docx, .xls, .xlsx |
| Audio | audio/mp4, audio/mpeg, audio/ogg, audio/opus |
| Lainnya | text/plain, text/csv, application/zip |
Kelola File Upload
Endpoint untuk list dan hapus file yang sudah di-upload. Admin only — gunakan admin key.
List semua file yang ada di server upload, diurut dari terbaru.
curl -H "X-API-Key: ADMIN_KEY" \
https://wa.codepod.my.id/api/uploads
Response
{
"success": true,
"total": 5,
"total_size": 2457600,
"total_size_formatted": "2.3 MB",
"files": [
{
"filename": "a1b2c3d4e5f6.jpg",
"size": 245760,
"size_formatted": "240.0 KB",
"uploaded_at": "2025-07-21T07:24:30.000Z",
"url": "https://wa.codepod.my.id/uploads/a1b2c3d4e5f6.jpg",
"path": "/opt/wa-gateway/uploads/a1b2c3d4e5f6.jpg"
}
]
}
Hapus satu file berdasarkan nama file (dari response list).
curl -X DELETE \
-H "X-API-Key: ADMIN_KEY" \
https://wa.codepod.my.id/api/uploads/a1b2c3d4e5f6.jpg
Response
{
"success": true,
"message": "File dihapus",
"file": {
"filename": "a1b2c3d4e5f6.jpg",
"size": 245760,
"size_formatted": "240.0 KB",
"deleted_at": "2025-07-21T07:30:00.000Z"
}
}
Hapus banyak file sekaligus (bulk delete).
curl -X DELETE https://wa.codepod.my.id/api/uploads \
-H "Content-Type: application/json" \
-H "X-API-Key: ADMIN_KEY" \
-d '{"files":["a1b2.jpg","b3c4.pdf"]}'
Response
{
"success": true,
"total": 2,
"deleted": 2,
"not_found": 0,
"freed_space": 491520,
"freed_space_formatted": "480.0 KB",
"results": [
{"filename": "a1b2.jpg", "deleted": true, "size": 245760},
{"filename": "b3c4.pdf", "deleted": true, "size": 245760}
]
}
Kirim Gambar
Mengirim gambar dengan URL publik atau path file lokal (hasil upload). Bisa ditambahkan caption.
Request Body
| Field | Tipe | Wajib | Keterangan |
|---|---|---|---|
to | string | Ya | Nomor tujuan |
type | string | Ya | Harus "image" |
media.url | string | Salah satu | URL gambar publik (https) — atau — |
media.path | string | Salah satu | Path file lokal (hasil /api/upload) |
media.caption | string | Tidak | Teks caption di bawah gambar |
message | string | Tidak | Fallback teks jika media gagal |
Gunakan media.url untuk file yang sudah online, atau media.path untuk file hasil upload dari endpoint POST /api/upload.
curl -X POST https://wa.codepod.my.id/api/send \
-H "Content-Type: application/json" \
-H "X-API-Key: wa_your_api_key_here" \
-d '{
"to": "6281234567890",
"type": "image",
"media": {
"url": "https://example.com/foto-produk.jpg",
"caption": "Produk terbaru kami!"
}
}'
const res = await fetch(BASE + '/api/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': API_KEY
},
body: JSON.stringify({
to: '6281234567890',
type: 'image',
media: {
url: 'https://example.com/foto-produk.jpg',
caption: 'Produk terbaru kami!'
}
})
});
const data = await res.json();
<?php
$payload = json_encode([
'to' => '6281234567890',
'type' => 'image',
'media' => [
'url' => 'https://example.com/foto-produk.jpg',
'caption' => 'Produk terbaru kami!'
]
]);
$ch = curl_init('https://wa.codepod.my.id/api/send');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-API-Key: wa_your_api_key_here'
],
CURLOPT_POSTFIELDS => $payload
]);
echo curl_exec($ch);
curl_close($ch);
import requests
res = requests.post(
f"{BASE}/api/send",
headers={
"Content-Type": "application/json",
"X-API-Key": API_KEY
},
json={
"to": "6281234567890",
"type": "image",
"media": {
"url": "https://example.com/foto-produk.jpg",
"caption": "Produk terbaru kami!"
}
}
)
print(res.json())
Response Sukses
{
"success": true,
"message_id": "BAE5A1F2C3D4E5F6",
"log_id": 43,
"to": "6281234567890",
"status": "sent"
}
Kirim Dokumen
Mengirim file dokumen (PDF, Word, Excel, dll) via URL publik atau path file lokal.
Request Body
| Field | Tipe | Wajib | Keterangan |
|---|---|---|---|
to | string | Ya | Nomor tujuan |
type | string | Ya | "document" atau "audio" |
media.url | string | Salah satu | URL file publik (https) — atau — |
media.path | string | Salah satu | Path file lokal (hasil /api/upload) |
media.filename | string | Tidak | Nama file yang ditampilkan (default: "document") |
message | string | Tidak | Fallback teks jika media gagal |
Gunakan media.url untuk file yang sudah online, atau media.path untuk file hasil upload dari endpoint POST /api/upload.
curl -X POST https://wa.codepod.my.id/api/send \
-H "Content-Type: application/json" \
-H "X-API-Key: wa_your_api_key_here" \
-d '{
"to": "6281234567890",
"type": "document",
"media": {
"url": "https://example.com/invoice-001.pdf"
}
}'
const res = await fetch(BASE + '/api/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': API_KEY
},
body: JSON.stringify({
to: '6281234567890',
type: 'document',
media: {
url: 'https://example.com/invoice-001.pdf'
}
})
});
const data = await res.json();
<?php
$ch = curl_init('https://wa.codepod.my.id/api/send');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-API-Key: wa_your_api_key_here'
],
CURLOPT_POSTFIELDS => json_encode([
'to' => '6281234567890',
'type' => 'document',
'media' => ['url' => 'https://example.com/invoice-001.pdf']
])
]);
echo curl_exec($ch);
curl_close($ch);
import requests
res = requests.post(
f"{BASE}/api/send",
headers={
"Content-Type": "application/json",
"X-API-Key": API_KEY
},
json={
"to": "6281234567890",
"type": "document",
"media": {
"url": "https://example.com/invoice-001.pdf"
}
}
)
print(res.json())
Response Sukses
{
"success": true,
"message_id": "BAE5A1F2C3D4E5F6",
"log_id": 44,
"to": "6281234567890",
"status": "sent"
}
Kirim ke Grup
Mengirim pesan teks ke grup WhatsApp. Gunakan ID grup dengan suffix @g.us (dari GET /api/groups). Grup terdeteksi otomatis dari JID — tidak perlu set type: "group".
"type": "group" lagi. Cukup gunakan JID berakhiran @g.us — sistem otomatis mendeteksi sebagai grup. Ini mencegah error "hang" yang terjadi jika type lupa di-set ke "group".
| Field | Tipe | Wajib | Keterangan |
|---|---|---|---|
to | string | Ya | ID grup dengan @g.us (dari GET /api/groups) |
message | string | Ya | Isi pesan |
type | string | Tidak | Abaikan (default "text"). Grup auto-deteksi dari @g.us |
curl -X POST https://wa.codepod.my.id/api/send \
-H "Content-Type: application/json" \
-H "X-API-Key: wa_you...ere" \
-d '{
"to": "6281234567890-123456@g.us",
"message": "Pengumuman penting untuk semua anggota!"
}'
const res = await fetch(BASE + '/api/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': API_KEY
},
body: JSON.stringify({
to: '6281234567890-123456@g.us',
message: 'Pengumuman penting untuk semua anggota!'
})
});
const data = await res.json();
<?php
$ch = curl_init('https://wa.codepod.my.id/api/send');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-API-Key: wa_you...ere'
],
CURLOPT_POSTFIELDS => json_encode([
'to' => '6281234567890-123456@g.us',
'message' => 'Pengumuman penting untuk semua anggota!'
])
]);
echo curl_exec($ch);
curl_close($ch);
import requests
res = requests.post(
f"{BASE}/api/send",
headers={
"Content-Type": "application/json",
"X-API-Key": API_KEY
},
json={
"to": "6281234567890-123456@g.us",
"message": "Pengumuman penting untuk semua anggota!"
}
)
print(res.json())
Response Sukses
{
"success": true,
"message_id": "BAE5A1F2C3D4E5F6",
"log_id": 45,
"to": "6281234567890-123456@g.us",
"status": "sent"
}
Kirim Gambar ke Grup
Mengirim gambar ke grup. Gunakan JID grup dengan @g.us + type: "image".
| Field | Tipe | Wajib | Keterangan |
|---|---|---|---|
to | string | Ya | ID grup dengan @g.us |
type | string | Ya | "image" |
media | object | Ya | {"url": "..."} atau {"path": "..."} |
message | string | Tidak | Caption gambar |
curl -X POST https://wa.codepod.my.id/api/send \
-H "Content-Type: application/json" \
-H "X-API-Key: wa_you...ere" \
-d '{
"to": "6281234567890-123456@g.us",
"type": "image",
"message": "Foto kegiatan terbaru",
"media": { "url": "https://example.com/foto.jpg" }
}'
const res = await fetch(BASE + '/api/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': API_KEY
},
body: JSON.stringify({
to: '6281234567890-123456@g.us',
type: 'image',
message: 'Foto kegiatan terbaru',
media: { url: 'https://example.com/foto.jpg' }
})
});
const data = await res.json();
<?php
$ch = curl_init('https://wa.codepod.my.id/api/send');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-API-Key: wa_you...ere'
],
CURLOPT_POSTFIELDS => json_encode([
'to' => '6281234567890-123456@g.us',
'type' => 'image',
'message' => 'Foto kegiatan terbaru',
'media' => ['url' => 'https://example.com/foto.jpg']
])
]);
echo curl_exec($ch);
curl_close($ch);
import requests
res = requests.post(
f"{BASE}/api/send",
headers={
"Content-Type": "application/json",
"X-API-Key": API_KEY
},
json={
"to": "6281234567890-123456@g.us",
"type": "image",
"message": "Foto kegiatan terbaru",
"media": {"url": "https://example.com/foto.jpg"}
}
)
print(res.json())
Response Sukses
{
"success": true,
"message_id": "BAE5A1F2C3D4E5F6",
"log_id": 46,
"to": "6281234567890-123456@g.us",
"status": "sent"
}
Kirim Dokumen ke Grup
Mengirim dokumen ke grup. Gunakan JID grup dengan @g.us + type: "document".
| Field | Tipe | Wajib | Keterangan |
|---|---|---|---|
to | string | Ya | ID grup dengan @g.us |
type | string | Ya | "document" |
media | object | Ya | {"url": "...", "filename": "doc.pdf"} atau {"path": "..."} |
message | string | Tidak | Nama file (fallback) |
curl -X POST https://wa.codepod.my.id/api/send \
-H "Content-Type: application/json" \
-H "X-API-Key: wa_you...ere" \
-d '{
"to": "6281234567890-123456@g.us",
"type": "document",
"message": "Materi Pertemuan.pdf",
"media": { "url": "https://example.com/materi.pdf", "filename": "Materi Pertemuan.pdf" }
}'
const res = await fetch(BASE + '/api/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': API_KEY
},
body: JSON.stringify({
to: '6281234567890-123456@g.us',
type: 'document',
message: 'Materi Pertemuan.pdf',
media: { url: 'https://example.com/materi.pdf', filename: 'Materi Pertemuan.pdf' }
})
});
const data = await res.json();
<?php
$ch = curl_init('https://wa.codepod.my.id/api/send');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-API-Key: wa_you...ere'
],
CURLOPT_POSTFIELDS => json_encode([
'to' => '6281234567890-123456@g.us',
'type' => 'document',
'message' => 'Materi Pertemuan.pdf',
'media' => ['url' => 'https://example.com/materi.pdf', 'filename' => 'Materi Pertemuan.pdf']
])
]);
echo curl_exec($ch);
curl_close($ch);
import requests
res = requests.post(
f"{BASE}/api/send",
headers={
"Content-Type": "application/json",
"X-API-Key": API_KEY
},
json={
"to": "6281234567890-123456@g.us",
"type": "document",
"message": "Materi Pertemuan.pdf",
"media": {"url": "https://example.com/materi.pdf", "filename": "Materi Pertemuan.pdf"}
}
)
print(res.json())
Response Sukses
{
"success": true,
"message_id": "BAE5A1F2C3D4E5F6",
"log_id": 47,
"to": "6281234567890-123456@g.us",
"status": "sent"
}
Broadcast (Kirim Banyak)
Mengirim pesan yang sama ke banyak nomor sekaligus. Hanya teks.
| Field | Tipe | Wajib | Keterangan |
|---|---|---|---|
to | array | Ya | Array nomor tujuan, format ["628xx","628yy"] |
message | string | Ya | Isi pesan |
curl -X POST https://wa.codepod.my.id/api/send/bulk \
-H "Content-Type: application/json" \
-H "X-API-Key: wa_your_api_key_here" \
-d '{
"to": ["6281234567890", "6289876543210", "628111222333"],
"message": "Info penting: besok libur!"
}'
const res = await fetch(BASE + '/api/send/bulk', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': API_KEY
},
body: JSON.stringify({
to: ['6281234567890', '6289876543210', '628111222333'],
message: 'Info penting: besok libur!'
})
});
const data = await res.json();
console.log(`Terkirim: ${data.sent}/${data.total}, Gagal: ${data.failed}`);
<?php
$ch = curl_init('https://wa.codepod.my.id/api/send/bulk');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-API-Key: wa_your_api_key_here'
],
CURLOPT_POSTFIELDS => json_encode([
'to' => ['6281234567890', '6289876543210'],
'message' => 'Info penting: besok libur!'
])
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
echo "Terkirim: {$data['sent']}/{$data['total']}, Gagal: {$data['failed']}";
import requests
res = requests.post(
f"{BASE}/api/send/bulk",
headers={
"Content-Type": "application/json",
"X-API-Key": API_KEY
},
json={
"to": ["6281234567890", "6289876543210", "628111222333"],
"message": "Info penting: besok libur!"
}
)
data = res.json()
print(f"Terkirim: {data['sent']}/{data['total']}, Gagal: {data['failed']}")
# Detail per nomor: data['results']
Response Sukses
{
"success": true,
"total": 3,
"sent": 3,
"failed": 0,
"results": [
{"to": "6281234567890", "success": true, "message_id": "ABC123"},
{"to": "6289876543210", "success": true, "message_id": "DEF456"},
{"to": "628111222333", "success": true, "message_id": "GHI789"}
]
}
Kuota Tidak Cukup (429)
{
"error": "Sisa kuota hari ini tidak cukup untuk 50 pesan",
"remaining": 5,
"needed": 50
}
List Grup
Mendapatkan daftar grup WhatsApp yang diikuti oleh nomor gateway.
curl -H "X-API-Key: wa_your_api_key_here" \
https://wa.codepod.my.id/api/groups
const res = await fetch(BASE + '/api/groups', {
headers: { 'X-API-Key': API_KEY }
});
const data = await res.json();
data.groups.forEach(g => console.log(g.id, g.name));
<?php
$ch = curl_init('https://wa.codepod.my.id/api/groups');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['X-API-Key: wa_your_api_key_here']);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
foreach ($data['groups'] as $g) echo $g['id'] . ' ' . $g['name'] . "\n";
import requests
res = requests.get(
f"{BASE}/api/groups",
headers={"X-API-Key": API_KEY}
)
data = res.json()
for g in data.get("groups", []):
print(g["id"], g["name"])
Response
{
"success": true,
"total": 3,
"groups": [
{
"id": "6281234567890-123456@g.us",
"name": "Komunitas Codepod",
"participants": 45
}
]
}
Detail Grup
Mendapatkan info detail + daftar anggota grup.
curl -H "X-API-Key: wa_your_api_key_here" \
https://wa.codepod.my.id/api/groups/6281234567890-123456@g.us
Response
{
"success": true,
"group": {
"id": "6281234567890-123456@g.us",
"name": "Komunitas Codepod",
"description": "Grup diskusi programming",
"participants": [
{"id": "6281234567890@s.whatsapp.net", "name": "Admin"},
{"id": "6289876543210@s.whatsapp.net", "name": "Member 1"}
]
}
}
List Kontak
Melihat daftar kontak yang tersimpan. Support pencarian via ?search=.
# Semua kontak
curl -H "X-API-Key: wa_your_api_key_here" \
https://wa.codepod.my.id/api/contacts
# Cari kontak
curl -H "X-API-Key: wa_your_api_key_here" \
"https://wa.codepod.my.id/api/contacts?search=budi"
const res = await fetch(
BASE + '/api/contacts?search=budi',
{ headers: { 'X-API-Key': API_KEY } }
);
const data = await res.json();
console.log(data.contacts);
<?php
$ch = curl_init('https://wa.codepod.my.id/api/contacts?search=budi');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: wa_your_api_key_here']
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
print_r($data['contacts']);
import requests
res = requests.get(
f"{BASE}/api/contacts",
headers={"X-API-Key": API_KEY},
params={"search": "budi"}
)
print(res.json())
Response
{
"success": true,
"total": 2,
"contacts": [
{"id": 1, "name": "Budi Santoso", "phone": "6281234567890"},
{"id": 2, "name": "Siti Aminah", "phone": "6289876543210"}
]
}
Tambah Kontak
Menambah kontak secara manual. Nomor otomatis juga tersimpan saat kamu mengirim pesan.
| Field | Tipe | Wajib | Keterangan |
|---|---|---|---|
name | string | Ya | Nama kontak |
phone | string | Ya | Nomor WA, format 628xxxxxxxxxx |
curl -X POST https://wa.codepod.my.id/api/contacts \
-H "Content-Type: application/json" \
-H "X-API-Key: wa_your_api_key_here" \
-d '{"name":"Budi Santoso","phone":"6281234567890"}'
const res = await fetch(BASE + '/api/contacts', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': API_KEY
},
body: JSON.stringify({
name: 'Budi Santoso',
phone: '6281234567890'
})
});
const data = await res.json();
console.log(data.contact);
<?php
$ch = curl_init('https://wa.codepod.my.id/api/contacts');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-API-Key: wa_your_api_key_here'
],
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Budi Santoso',
'phone' => '6281234567890'
])
]);
echo curl_exec($ch);
curl_close($ch);
import requests
res = requests.post(
f"{BASE}/api/contacts",
headers={
"Content-Type": "application/json",
"X-API-Key": API_KEY
},
json={
"name": "Budi Santoso",
"phone": "6281234567890"
}
)
print(res.json())
Response (201 Created)
{
"success": true,
"contact": {
"id": 3,
"name": "Budi Santoso",
"phone": "6281234567890"
}
}
Hapus Kontak
Menghapus kontak berdasarkan ID (didapat dari list contacts).
curl -X DELETE https://wa.codepod.my.id/api/contacts/3 \
-H "X-API-Key: wa_your_api_key_here"
Response
{"success": true, "message": "Kontak dihapus"}
Daftar Webhook
Mendaftarkan URL webhook untuk menerima notifikasi pesan masuk secara real-time. Satu API key hanya bisa punya satu webhook.
| Field | Tipe | Wajib | Keterangan |
|---|---|---|---|
url | string | Ya | URL endpoint kamu yang akan menerima POST |
events | string | Tidak | Default "incoming" |
curl -X POST https://wa.codepod.my.id/api/webhook \
-H "Content-Type: application/json" \
-H "X-API-Key: wa_your_api_key_here" \
-d '{"url":"https://app-anda.com/webhook"}'
const res = await fetch(BASE + '/api/webhook', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': API_KEY
},
body: JSON.stringify({
url: 'https://app-anda.com/webhook'
})
});
const data = await res.json();
<?php
$ch = curl_init('https://wa.codepod.my.id/api/webhook');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-API-Key: wa_your_api_key_here'
],
CURLOPT_POSTFIELDS => json_encode([
'url' => 'https://app-anda.com/webhook'
])
]);
echo curl_exec($ch);
curl_close($ch);
import requests
res = requests.post(
f"{BASE}/api/webhook",
headers={
"Content-Type": "application/json",
"X-API-Key": API_KEY
},
json={"url": "https://app-anda.com/webhook"}
)
print(res.json())
Response
{
"success": true,
"webhook": {
"id": 1,
"url": "https://app-anda.com/webhook",
"events": "incoming",
"active": true
}
}
Lihat / Hapus Webhook
Melihat webhook yang terdaftar.
curl -H "X-API-Key: wa_your_api_key_here" \
https://wa.codepod.my.id/api/webhook
Menghapus webhook.
curl -X DELETE https://wa.codepod.my.id/api/webhook \
-H "X-API-Key: wa_your_api_key_here"
Format Payload Webhook
Setiap kali ada pesan masuk, gateway mengirim POST ke URL webhook kamu. Untuk pesan dari grup, payload berisi metadata grup lengkap sehingga aplikasi kamu bisa membalas ke grup yang benar.
Payload — Pesan Personal
{
"event": "message",
"from": "6281234567890",
"fromJid": "6281234567890@s.whatsapp.net",
"isGroup": false,
"groupId": null,
"groupName": null,
"participant": "6281234567890",
"participantJid": "6281234567890@s.whatsapp.net",
"participantName": null,
"pushName": "Budi",
"messageId": "3EB06F91DF28D23A185B77",
"type": "text",
"content": "Halo, saya mau tanya...",
"media": null,
"timestamp": 1794789000,
"api_key_prefix": "wa_abc"
}
Payload — Pesan Grup
{
"event": "message.group",
"from": "6282331128463-1575696480",
"fromJid": "6282331128463-1575696480@g.us",
"isGroup": true,
"groupId": "6282331128463-1575696480@g.us",
"groupName": "PPDB 2027/2028",
"participant": "6285222800746",
"participantJid": "6285222800746@s.whatsapp.net",
"participantName": "Anam Khoir",
"pushName": "Anam Khoir",
"messageId": "3EB06F91DF28D23A185B77",
"type": "text",
"content": "/sosialisasi-ppdb",
"media": null,
"timestamp": 1794789000,
"api_key_prefix": "wa_abc"
}
| Field | Tipe | Keterangan |
|---|---|---|
event | string | message (personal) atau message.group (grup) |
from | string | Nomor/JID tanpa suffix. Grup: JID grup tanpa @g.us |
fromJid | string | JID utuh — pakai ini untuk membalas |
isGroup | boolean | true jika pesan dari grup |
groupId | string/null | JID grup (xxx@g.us) — untuk POST /api/send |
groupName | string/null | Nama grup (mis. "PPDB 2027/2028") |
participant | string/null | Nomor anggota yang mengirim (khusus grup) |
participantJid | string/null | JID anggota pengirim |
participantName | string/null | Nama anggota pengirim dari metadata grup |
pushName | string | Nama tampilan WhatsApp pengirim |
messageId | string | ID unik pesan WhatsApp |
type | string | text, image, document, audio, video, location, contact, other |
content | string | Isi pesan (teks / caption / nama file) |
media | object/null | { mimetype, url, filename, size } jika ada lampiran |
timestamp | number | Unix timestamp pesan |
api_key_prefix | string | Prefix API key pemilik webhook |
Header Request
| Header | Nilai |
|---|---|
Content-Type | application/json |
X-Webhook-Event | message atau message.group |
2xx dalam 10 detik, kalau tidak gateway menganggap webhook gagal.
Command Otomatis di Grup
Pola umum: anggota grup mengetik command (mis. /sosialisasi-ppdb), aplikasi kamu memproses lalu membalas ke grup. Parsing command dilakukan di aplikasi kamu, bukan di gateway — gateway hanya meneruskan pesan beserta metadata grup.
Alur
[Anggota grup] /sosialisasi-ppdb
│
▼
[Gateway] POST https://app-kamu.com/wa-hook
{ event: "message.group", groupId, participant, content }
│
▼
[Aplikasi kamu] cek content === "/sosialisasi-ppdb"
│
▼
[Aplikasi kamu] POST https://wa.codepod.my.id/api/send
{ to: groupId, message: "..." }
│
▼
[Terkirim ke grup]
Contoh handler Node.js (Express)
const COMMANDS = {
'/sosialisasi-ppdb': async () => {
return '📢 SOSIALISASI PPDB 2027/2028\n\n'
+ 'Pendaftaran: 1 Juli - 31 Agustus 2027\n'
+ 'Syarat: FC KK, FC Akta, Pas Foto 3x4\n'
+ 'Info: https://smkmefa.sch.id/ppdb';
},
};
app.post('/wa-hook', express.json(), async (req, res) => {
// WAJIB balas cepat, proses async
res.sendStatus(200);
const { isGroup, groupId, participant, participantName, content } = req.body;
// Hanya proses command dari grup
if (!isGroup || !content || !content.startsWith('/')) return;
const handler = COMMANDS[content.trim().toLowerCase()];
if (!handler) return;
const reply = await handler();
await fetch('https://wa.codepod.my.id/api/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': process.env.WA_API_KEY,
},
body: JSON.stringify({
to: groupId, // xxx@g.us — suffix wajib
message: reply,
}),
});
console.log(`Command ${content} dari ${participantName || participant} di grup ${groupId}`);
});
Contoh handler PHP
<?php
$data = json_decode(file_get_contents('php://input'), true);
// Balas cepat
http_response_code(200);
if (empty($data['isGroup']) || empty($data['content'])) exit;
if (strpos($data['content'], '/') !== 0) exit;
$commands = [
'/sosialisasi-ppdb' => "📢 SOSIALISASI PPDB 2027/2028\n\nPendaftaran: 1 Juli - 31 Agustus 2027\nSyarat: FC KK, FC Akta, Pas Foto 3x4",
];
$cmd = strtolower(trim($data['content']));
if (!isset($commands[$cmd])) exit;
$payload = json_encode([
'to' => $data['groupId'], // xxx@g.us
'message' => $commands[$cmd],
]);
$ch = curl_init('https://wa.codepod.my.id/api/send');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-API-Key: ' . getenv('WA_API_KEY'),
],
]);
$result = curl_exec($ch);
curl_close($ch);
Tips
- Gunakan
groupIddari payload sebagaitosaat membalas — jangan susun manual. - Suffix
@g.uswajib ada dito; tanpa itu pesan dianggap ke nomor personal. - Simpan daftar command di database agar bisa diubah tanpa deploy ulang.
- Balas
200dulu, proses berat di background — batas waktu webhook 10 detik. - Filter
if (!isGroup) return;bila command hanya untuk grup. - Cek
participantuntuk membatasi command ke admin tertentu.
Log Pesan
Melihat riwayat pengiriman pesan (metadata saja, bukan isi pesan).
| Param | Tipe | Default | Keterangan |
|---|---|---|---|
limit | integer | 50 | Maksimal 200 |
offset | integer | 0 | Untuk pagination |
status | string | - | Filter: sent, pending, failed |
curl -H "X-API-Key: wa_your_api_key_here" \
"https://wa.codepod.my.id/api/messages?limit=20&status=sent"
Response
{
"success": true,
"total": 2,
"messages": [
{
"id": 42,
"recipient": "6281234567890",
"message_type": "personal",
"status": "sent",
"wa_message_id": "BAE5A1F2C3D4E5F6",
"error": null,
"created_at": "2025-07-21 10:30:00"
}
]
}
Cek Kuota API Key
Melihat sisa kuota harian untuk API key kamu.
curl -H "X-API-Key: wa_your_api_key_here" \
https://wa.codepod.my.id/api/status/me
Response
{
"success": true,
"wa": {
"status": "connected",
"user": { "phone": "628xxxxxxxxxx" }
},
"api_key": {
"name": "Aplikasi Sekolah",
"prefix": "wa_abc",
"daily_limit": 300,
"remaining_today": 247
}
}
Status WA (Public)
Endpoint publik — tidak perlu API key. Mengecek status koneksi WhatsApp dan statistik global.
curl https://wa.codepod.my.id/api/status
Response (Connected)
{
"success": true,
"wa": {
"status": "connected",
"user": { "phone": "628xxxxxxxxxx" },
"qr_available": false
},
"stats": {
"active_keys": 5,
"today_sent": 142,
"pending": 0,
"today_failed": 3
}
}
Response (Menunggu Pairing)
{
"success": true,
"wa": {
"status": "qr",
"user": null,
"qr_available": true
},
"stats": { ... }
}