Dokumentasi API

Panduan lengkap untuk mengintegrasikan WhatsApp ke aplikasi Anda

Overview

WACloud menyediakan RESTful API yang powerful untuk mengintegrasikan WhatsApp ke dalam aplikasi Anda. API ini dirancang khusus untuk developer dengan dokumentasi lengkap dan contoh kode yang mudah dipahami.

Base URL

https://app.wacloud.id/api/v1

Fitur Utama

  • RESTful API yang mudah digunakan
  • Dukungan berbagai jenis pesan (text, image, video, document, poll, button, list)
  • Webhook real-time untuk pesan masuk
  • Multi-session management
  • Rate limiting untuk keamanan
  • Dokumentasi lengkap dengan contoh kode

Autentikasi

Semua request ke API memerlukan API Key yang dapat Anda buat di dashboard setelah mendaftar.

Cara Menggunakan API Key

Kirim API Key di header HTTP dengan format berikut:

X-Api-Key: waha_your_api_key_here
Penting: Jangan pernah membagikan API Key Anda kepada pihak lain. Simpan API Key dengan aman dan jangan commit ke repository publik.

Endpoints

Berikut adalah daftar endpoint utama yang tersedia:

GET /devices

Mendapatkan daftar semua device WhatsApp yang terhubung.

POST /messages

Mengirim pesan WhatsApp. Mendukung berbagai jenis pesan.

GET /messages

Mendapatkan daftar pesan yang telah dikirim atau diterima.

POST /devices/{device_id}/messages/sync

Sinkronisasi pesan masuk dari WAHA ke database.

GET /devices/{device_id}

Mendapatkan detail device WhatsApp berdasarkan ID.

GET /devices/{device_id}/pair

Mendapatkan QR code untuk pairing device WhatsApp.

GET /templates

Mendapatkan daftar semua template pesan.

GET /account

Mendapatkan informasi akun dan quota.

POST /messages/otp

Mengirim kode OTP ke nomor tujuan.

GET /devices/{device_id}/contacts

Mendapatkan daftar kontak untuk device tertentu.

GET /devices/{device_id}/contacts/{contactId}

Mendapatkan informasi kontak tertentu.

PUT /devices/{device_id}/contacts/{chatId}

Memperbarui informasi kontak.

GET /devices/{device_id}/contacts/check-exists

Memeriksa apakah nomor telepon terdaftar di WhatsApp.

Mengirim Pesan

Untuk mengirim pesan, gunakan endpoint POST /api/v1/messages dengan format berikut:

Format Request

{ "device_id": "550e8400-e29b-41d4-a716-446655440000", "to": "6281234567890", "message_type": "text", "text": "Halo, ini pesan dari API!" }

Format Response

{ "success": true, "data": { "message_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "whatsapp_message_id": "3EB0...", "status": "sent", "ack": 1, "to": "6281234567890" } }

Contoh Implementasi

curl -X POST "https://app.wacloud.id/api/v1/messages" \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "device_id": "550e8400-e29b-41d4-a716-446655440000", "to": "6281234567890", "message_type": "text", "text": "Halo, ini pesan dari API!" }'
// Kirim pesan text $apiKey = 'YOUR_API_KEY'; $url = 'https://app.wacloud.id/api/v1/messages'; $data = [ 'device_id' => '550e8400-e29b-41d4-a716-446655440000', 'to' => '6281234567890', 'message_type' => 'text', 'text' => 'Halo, ini pesan dari API!' ]; $ch = curl_init($url); 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, [ 'X-Api-Key: ' . $apiKey, 'Content-Type: application/json' ]); $response = curl_exec($ch); curl_close($ch); $result = json_decode($response, true); if ($result['success']) { echo "Message ID: " . $result['data']['message_id']; }
import requests api_key = 'YOUR_API_KEY' url = 'https://app.wacloud.id/api/v1/messages' headers = { 'X-Api-Key': api_key, 'Content-Type': 'application/json' } data = { 'device_id': '550e8400-e29b-41d4-a716-446655440000', 'to': '6281234567890', 'message_type': 'text', 'text': 'Halo, ini pesan dari API!' } response = requests.post(url, headers=headers, json=data) if response.status_code == 201: result = response.json() if result['success']: print(f("Message ID: {result['data']['message_id']}"))
const axios = require('axios'); const apiKey = 'YOUR_API_KEY'; const url = 'https://app.wacloud.id/api/v1/messages'; const data = { device_id: '550e8400-e29b-41d4-a716-446655440000', to: '6281234567890', message_type: 'text', text: 'Halo, ini pesan dari API!' }; axios.post(url, data, { headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' } }) .then(response => { if (response.data.success) { console.log(`Message ID: ${response.data.data.message_id}`); } }) .catch(error => { console.error('Error:', error.response?.data || error.message); });
const apiKey = 'YOUR_API_KEY'; const url = 'https://app.wacloud.id/api/v1/messages'; const data = { device_id: '550e8400-e29b-41d4-a716-446655440000', to: '6281234567890', message_type: 'text', text: 'Halo, ini pesan dari API!' }; fetch(url, { method: 'POST', headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(result => { if (result.success) { console.log(`Message ID: ${result.data.message_id}`); } }) .catch(error => { console.error('Error:', error); });
package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) type SendMessageRequest struct { DeviceID string `json:"device_id"` To string `json:"to"` MessageType string `json:"message_type"` Text string `json:"text"` } func main() { apiKey := "YOUR_API_KEY" url := "https://app.wacloud.id/api/v1/messages" data := SendMessageRequest{ DeviceID: "550e8400-e29b-41d4-a716-446655440000", To: "6281234567890", MessageType: "text", Text: "Halo, ini pesan dari API!", } jsonData, _ := json.Marshal(data) req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) req.Header.Set("X-Api-Key", apiKey) req.Header.Set("Content-Type", "application/json") client := &http.Client{} resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) }

Jenis Pesan yang Didukung

WACloud mendukung berbagai jenis pesan WhatsApp:

1. Text Message

Pesan teks biasa.

curl -X POST "https://app.wacloud.id/api/v1/messages" \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "device_id": "550e8400-e29b-41d4-a716-446655440000", "to": "6281234567890", "message_type": "text", "text": "Pesan teks" }'
$apiKey = 'YOUR_API_KEY'; $url = 'https://app.wacloud.id/api/v1/messages'; $data = [ 'device_id' => '550e8400-e29b-41d4-a716-446655440000', 'to' => '6281234567890', 'message_type' => 'text', 'text' => 'Pesan teks' ]; $ch = curl_init($url); 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, [ 'X-Api-Key: ' . $apiKey, 'Content-Type: application/json' ]); $response = curl_exec($ch); curl_close($ch);
import requests response = requests.post( 'https://app.wacloud.id/api/v1/messages', headers={'X-Api-Key': 'YOUR_API_KEY'}, json={ 'device_id': '550e8400-e29b-41d4-a716-446655440000', 'to': '6281234567890', 'message_type': 'text', 'text': 'Pesan teks' } )
const axios = require('axios'); const apiKey = 'YOUR_API_KEY'; const url = 'https://app.wacloud.id/api/v1/messages'; const data = { device_id: '550e8400-e29b-41d4-a716-446655440000', to: '6281234567890', message_type: 'text', text: 'Pesan teks' }; axios.post(url, data, { headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' } });
const apiKey = 'YOUR_API_KEY'; const url = 'https://app.wacloud.id/api/v1/messages'; const data = { device_id: '550e8400-e29b-41d4-a716-446655440000', to: '6281234567890', message_type: 'text', text: 'Pesan teks' }; fetch(url, { method: 'POST', headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' }, body: JSON.stringify(data) });
package main import ( "bytes" "encoding/json" "net/http" ) type TextMessage struct { DeviceID string `json:"device_id"` To string `json:"to"` MessageType string `json:"message_type"` Text string `json:"text"` } func sendTextMessage() { apiKey := "YOUR_API_KEY" url := "https://app.wacloud.id/api/v1/messages" data := TextMessage{ DeviceID: "550e8400-e29b-41d4-a716-446655440000", To: "6281234567890", MessageType: "text", Text: "Pesan teks", } jsonData, _ := json.Marshal(data) req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) req.Header.Set("X-Api-Key", apiKey) req.Header.Set("Content-Type", "application/json") client := &http.Client{} client.Do(req) }

2. Image Message

Mengirim gambar dengan URL. URL harus dapat diakses secara publik.

curl -X POST "https://app.wacloud.id/api/v1/messages" \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "device_id": "550e8400-e29b-41d4-a716-446655440000", "to": "6281234567890", "message_type": "image", "image_url": "https://example.com/image.jpg", "caption": "Caption gambar" }'
$apiKey = 'YOUR_API_KEY'; $url = 'https://app.wacloud.id/api/v1/messages'; $data = [ 'device_id' => '550e8400-e29b-41d4-a716-446655440000', 'to' => '6281234567890', 'message_type' => 'image', 'image_url' => 'https://example.com/image.jpg', 'caption' => 'Caption gambar' ]; $ch = curl_init($url); 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, [ 'X-Api-Key: ' . $apiKey, 'Content-Type: application/json' ]); $response = curl_exec($ch); curl_close($ch);
import requests response = requests.post( 'https://app.wacloud.id/api/v1/messages', headers={'X-Api-Key': 'YOUR_API_KEY'}, json={ 'device_id': '550e8400-e29b-41d4-a716-446655440000', 'to': '6281234567890', 'message_type': 'image', 'image_url': 'https://example.com/image.jpg', 'caption': 'Caption gambar' } )
const axios = require('axios'); const apiKey = 'YOUR_API_KEY'; const url = 'https://app.wacloud.id/api/v1/messages'; const data = { device_id: '550e8400-e29b-41d4-a716-446655440000', to: '6281234567890', message_type: 'image', image_url: 'https://example.com/image.jpg', caption: 'Caption gambar' }; axios.post(url, data, { headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' } });
const apiKey = 'YOUR_API_KEY'; const url = 'https://app.wacloud.id/api/v1/messages'; const data = { device_id: '550e8400-e29b-41d4-a716-446655440000', to: '6281234567890', message_type: 'image', image_url: 'https://example.com/image.jpg', caption: 'Caption gambar' }; fetch(url, { method: 'POST', headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' }, body: JSON.stringify(data) });
package main import ( "bytes" "encoding/json" "net/http" ) type ImageMessage struct { DeviceID string `json:"device_id"` To string `json:"to"` MessageType string `json:"message_type"` ImageURL string `json:"image_url"` Caption string `json:"caption"` } func sendImageMessage() { apiKey := "YOUR_API_KEY" url := "https://app.wacloud.id/api/v1/messages" data := ImageMessage{ DeviceID: "550e8400-e29b-41d4-a716-446655440000", To: "6281234567890", MessageType: "image", ImageURL: "https://example.com/image.jpg", Caption: "Caption gambar", } jsonData, _ := json.Marshal(data) req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) req.Header.Set("X-Api-Key", apiKey) req.Header.Set("Content-Type", "application/json") client := &http.Client{} client.Do(req) }

3. Video Message

Mengirim video dengan URL. URL harus dapat diakses secara publik.

curl -X POST "https://app.wacloud.id/api/v1/messages" \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "device_id": "550e8400-e29b-41d4-a716-446655440000", "to": "6281234567890", "message_type": "video", "video_url": "https://example.com/video.mp4", "caption": "Caption video", "as_note": false, "convert": false }'
$apiKey = 'YOUR_API_KEY'; $url = 'https://app.wacloud.id/api/v1/messages'; $data = [ 'device_id' => '550e8400-e29b-41d4-a716-446655440000', 'to' => '6281234567890', 'message_type' => 'video', 'video_url' => 'https://example.com/video.mp4', 'caption' => 'Caption video', 'as_note' => false, 'convert' => false ]; $ch = curl_init($url); 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, [ 'X-Api-Key: ' . $apiKey, 'Content-Type: application/json' ]); $response = curl_exec($ch); curl_close($ch);
import requests response = requests.post( 'https://app.wacloud.id/api/v1/messages', headers={'X-Api-Key': 'YOUR_API_KEY'}, json={ 'device_id': '550e8400-e29b-41d4-a716-446655440000', 'to': '6281234567890', 'message_type': 'video', 'video_url': 'https://example.com/video.mp4', 'caption': 'Caption video', 'as_note': False, 'convert': False } )
const axios = require('axios'); const apiKey = 'YOUR_API_KEY'; const url = 'https://app.wacloud.id/api/v1/messages'; const data = { device_id: '550e8400-e29b-41d4-a716-446655440000', to: '6281234567890', message_type: 'video', video_url: 'https://example.com/video.mp4', caption: 'Caption video', as_note: false, convert: false }; axios.post(url, data, { headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' } });
const apiKey = 'YOUR_API_KEY'; const url = 'https://app.wacloud.id/api/v1/messages'; const data = { device_id: '550e8400-e29b-41d4-a716-446655440000', to: '6281234567890', message_type: 'video', video_url: 'https://example.com/video.mp4', caption: 'Caption video', as_note: false, convert: false }; fetch(url, { method: 'POST', headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' }, body: JSON.stringify(data) });
package main import ( "bytes" "encoding/json" "net/http" ) type VideoMessage struct { DeviceID string `json:"device_id"` To string `json:"to"` MessageType string `json:"message_type"` VideoURL string `json:"video_url"` Caption string `json:"caption"` AsNote bool `json:"as_note"` Convert bool `json:"convert"` } func sendVideoMessage() { apiKey := "YOUR_API_KEY" url := "https://app.wacloud.id/api/v1/messages" data := VideoMessage{ DeviceID: "550e8400-e29b-41d4-a716-446655440000", To: "6281234567890", MessageType: "video", VideoURL: "https://example.com/video.mp4", Caption: "Caption video", AsNote: false, Convert: false, } jsonData, _ := json.Marshal(data) req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) req.Header.Set("X-Api-Key", apiKey) req.Header.Set("Content-Type", "application/json") client := &http.Client{} client.Do(req) }

4. Document Message

Mengirim dokumen (PDF, DOC, dll) dengan URL. URL harus dapat diakses secara publik.

curl -X POST "https://app.wacloud.id/api/v1/messages" \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "device_id": "550e8400-e29b-41d4-a716-446655440000", "to": "6281234567890", "message_type": "document", "document_url": "https://example.com/file.pdf", "filename": "document.pdf", "caption": "Caption dokumen" }'
$apiKey = 'YOUR_API_KEY'; $url = 'https://app.wacloud.id/api/v1/messages'; $data = [ 'device_id' => '550e8400-e29b-41d4-a716-446655440000', 'to' => '6281234567890', 'message_type' => 'document', 'document_url' => 'https://example.com/file.pdf', 'filename' => 'document.pdf', 'caption' => 'Caption dokumen' ]; $ch = curl_init($url); 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, [ 'X-Api-Key: ' . $apiKey, 'Content-Type: application/json' ]); $response = curl_exec($ch); curl_close($ch);
import requests response = requests.post( 'https://app.wacloud.id/api/v1/messages', headers={'X-Api-Key': 'YOUR_API_KEY'}, json={ 'device_id': '550e8400-e29b-41d4-a716-446655440000', 'to': '6281234567890', 'message_type': 'document', 'document_url': 'https://example.com/file.pdf', 'filename': 'document.pdf', 'caption': 'Caption dokumen' } )
const axios = require('axios'); const apiKey = 'YOUR_API_KEY'; const url = 'https://app.wacloud.id/api/v1/messages'; const data = { device_id: '550e8400-e29b-41d4-a716-446655440000', to: '6281234567890', message_type: 'document', document_url: 'https://example.com/file.pdf', filename: 'document.pdf', caption: 'Caption dokumen' }; axios.post(url, data, { headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' } });
const apiKey = 'YOUR_API_KEY'; const url = 'https://app.wacloud.id/api/v1/messages'; const data = { device_id: '550e8400-e29b-41d4-a716-446655440000', to: '6281234567890', message_type: 'document', document_url: 'https://example.com/file.pdf', filename: 'document.pdf', caption: 'Caption dokumen' }; fetch(url, { method: 'POST', headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' }, body: JSON.stringify(data) });
package main import ( "bytes" "encoding/json" "net/http" ) type DocumentMessage struct { DeviceID string `json:"device_id"` To string `json:"to"` MessageType string `json:"message_type"` DocumentURL string `json:"document_url"` Filename string `json:"filename"` Caption string `json:"caption"` } func sendDocumentMessage() { apiKey := "YOUR_API_KEY" url := "https://app.wacloud.id/api/v1/messages" data := DocumentMessage{ DeviceID: "550e8400-e29b-41d4-a716-446655440000", To: "6281234567890", MessageType: "document", DocumentURL: "https://example.com/file.pdf", Filename: "document.pdf", Caption: "Caption dokumen", } jsonData, _ := json.Marshal(data) req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) req.Header.Set("X-Api-Key", apiKey) req.Header.Set("Content-Type", "application/json") client := &http.Client{} client.Do(req) }

5. Poll Message

Mengirim polling interaktif.

curl -X POST "https://app.wacloud.id/api/v1/messages" \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "device_id": "550e8400-e29b-41d4-a716-446655440000", "to": "6281234567890", "message_type": "poll", "poll_name": "Pertanyaan?", "poll_options": ["Opsi 1", "Opsi 2"] }'
$apiKey = 'YOUR_API_KEY'; $url = 'https://app.wacloud.id/api/v1/messages'; $data = [ 'device_id' => '550e8400-e29b-41d4-a716-446655440000', 'to' => '6281234567890', 'message_type' => 'poll', 'poll_name' => 'Pertanyaan?', 'poll_options' => ['Opsi 1', 'Opsi 2'] ]; $ch = curl_init($url); 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, [ 'X-Api-Key: ' . $apiKey, 'Content-Type: application/json' ]); $response = curl_exec($ch); curl_close($ch);
import requests response = requests.post( 'https://app.wacloud.id/api/v1/messages', headers={'X-Api-Key': 'YOUR_API_KEY'}, json={ 'device_id': '550e8400-e29b-41d4-a716-446655440000', 'to': '6281234567890', 'message_type': 'poll', 'poll_name': 'Pertanyaan?', 'poll_options': ['Opsi 1', 'Opsi 2'] } )
const axios = require('axios'); const apiKey = 'YOUR_API_KEY'; const url = 'https://app.wacloud.id/api/v1/messages'; const data = { device_id: '550e8400-e29b-41d4-a716-446655440000', to: '6281234567890', message_type: 'poll', poll_name: 'Pertanyaan?', poll_options: ['Opsi 1', 'Opsi 2'] }; axios.post(url, data, { headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' } });
const apiKey = 'YOUR_API_KEY'; const url = 'https://app.wacloud.id/api/v1/messages'; const data = { device_id: '550e8400-e29b-41d4-a716-446655440000', to: '6281234567890', message_type: 'poll', poll_name: 'Pertanyaan?', poll_options: ['Opsi 1', 'Opsi 2'] }; fetch(url, { method: 'POST', headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' }, body: JSON.stringify(data) });
package main import ( "bytes" "encoding/json" "net/http" ) type PollMessage struct { DeviceID string `json:"device_id"` To string `json:"to"` MessageType string `json:"message_type"` PollName string `json:"poll_name"` PollOptions []string `json:"poll_options"` } func sendPollMessage() { apiKey := "YOUR_API_KEY" url := "https://app.wacloud.id/api/v1/messages" data := PollMessage{ DeviceID: "550e8400-e29b-41d4-a716-446655440000", To: "6281234567890", MessageType: "poll", PollName: "Pertanyaan?", PollOptions: []string{"Opsi 1", "Opsi 2"}, } jsonData, _ := json.Marshal(data) req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) req.Header.Set("X-Api-Key", apiKey) req.Header.Set("Content-Type", "application/json") client := &http.Client{} client.Do(req) }

6. List Message

Mengirim pesan dengan format list interaktif.

curl -X POST "https://app.wacloud.id/api/v1/messages" \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "device_id": "550e8400-e29b-41d4-a716-446655440000", "to": "6281234567890", "message_type": "list", "message": { "title": "Judul", "description": "Deskripsi", "button": "Pilih", "sections": [] } }'
$apiKey = 'YOUR_API_KEY'; $url = 'https://app.wacloud.id/api/v1/messages'; $data = [ 'device_id' => '550e8400-e29b-41d4-a716-446655440000', 'to' => '6281234567890', 'message_type' => 'list', 'message' => [ 'title' => 'Judul', 'description' => 'Deskripsi', 'button' => 'Pilih', 'sections' => [] ] ]; $ch = curl_init($url); 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, [ 'X-Api-Key: ' . $apiKey, 'Content-Type: application/json' ]); $response = curl_exec($ch); curl_close($ch);
import requests response = requests.post( 'https://app.wacloud.id/api/v1/messages', headers={'X-Api-Key': 'YOUR_API_KEY'}, json={ 'device_id': '550e8400-e29b-41d4-a716-446655440000', 'to': '6281234567890', 'message_type': 'list', 'message': { 'title': 'Judul', 'description': 'Deskripsi', 'button': 'Pilih', 'sections': [] } } )
const axios = require('axios'); const apiKey = 'YOUR_API_KEY'; const url = 'https://app.wacloud.id/api/v1/messages'; const data = { device_id: '550e8400-e29b-41d4-a716-446655440000', to: '6281234567890', message_type: 'list', message: { title: 'Judul', description: 'Deskripsi', button: 'Pilih', sections: [] } }; axios.post(url, data, { headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' } });
const apiKey = 'YOUR_API_KEY'; const url = 'https://app.wacloud.id/api/v1/messages'; const data = { device_id: '550e8400-e29b-41d4-a716-446655440000', to: '6281234567890', message_type: 'list', message: { title: 'Judul', description: 'Deskripsi', button: 'Pilih', sections: [] } }; fetch(url, { method: 'POST', headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' }, body: JSON.stringify(data) });
package main import ( "bytes" "encoding/json" "net/http" ) type ListMessage struct { DeviceID string `json:"device_id"` To string `json:"to"` MessageType string `json:"message_type"` Message map[string]interface{} `json:"message"` } func sendListMessage() { apiKey := "YOUR_API_KEY" url := "https://app.wacloud.id/api/v1/messages" data := ListMessage{ DeviceID: "550e8400-e29b-41d4-a716-446655440000", To: "6281234567890", MessageType: "list", Message: map[string]interface{}{ "title": "Judul", "description": "Deskripsi", "button": "Pilih", "sections": []interface{}{}, }, } jsonData, _ := json.Marshal(data) req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) req.Header.Set("X-Api-Key", apiKey) req.Header.Set("Content-Type", "application/json") client := &http.Client{} client.Do(req) }

Contoh Kode

Berikut adalah contoh implementasi mengirim pesan menggunakan berbagai bahasa pemrograman:

curl -X POST "https://app.wacloud.id/api/v1/messages" \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "device_id": "550e8400-e29b-41d4-a716-446655440000", "to": "6281234567890", "message_type": "text", "text": "Halo dari API!" }'
// Kirim pesan text $apiKey = 'YOUR_API_KEY'; $url = 'https://app.wacloud.id/api/v1/messages'; $data = [ 'device_id' => '550e8400-e29b-41d4-a716-446655440000', 'to' => '6281234567890', 'message_type' => 'text', 'text' => 'Halo dari API!' ]; $ch = curl_init($url); 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, [ 'X-Api-Key: ' . $apiKey, 'Content-Type: application/json' ]); $response = curl_exec($ch); curl_close($ch); $result = json_decode($response, true); if ($result['success']) { echo "Message ID: " . $result['data']['message_id']; }
import requests # Kirim pesan text api_key = 'YOUR_API_KEY' url = 'https://app.wacloud.id/api/v1/messages' headers = { 'X-Api-Key': api_key, 'Content-Type': 'application/json' } data = { 'device_id': '550e8400-e29b-41d4-a716-446655440000', 'to': '6281234567890', 'message_type': 'text', 'text': 'Halo dari API!' } response = requests.post(url, headers=headers, json=data) if response.status_code == 201: result = response.json() if result['success']: print(f"Message ID: {result['data']['message_id']}")
const axios = require('axios'); const apiKey = 'YOUR_API_KEY'; const url = 'https://app.wacloud.id/api/v1/messages'; const data = { device_id: '550e8400-e29b-41d4-a716-446655440000', to: '6281234567890', message_type: 'text', text: 'Halo dari API!' }; axios.post(url, data, { headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' } }) .then(response => { if (response.data.success) { console.log(`Message ID: ${response.data.data.message_id}`); } }) .catch(error => { console.error('Error:', error.response?.data || error.message); });
const apiKey = 'YOUR_API_KEY'; const url = 'https://app.wacloud.id/api/v1/messages'; const data = { device_id: '550e8400-e29b-41d4-a716-446655440000', to: '6281234567890', message_type: 'text', text: 'Halo dari API!' }; fetch(url, { method: 'POST', headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(result => { if (result.success) { console.log(`Message ID: ${result.data.message_id}`); } }) .catch(error => { console.error('Error:', error); });
package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) type SendMessageRequest struct { DeviceID string `json:"device_id"` To string `json:"to"` MessageType string `json:"message_type"` Text string `json:"text"` } func main() { apiKey := "YOUR_API_KEY" url := "https://app.wacloud.id/api/v1/messages" data := SendMessageRequest{ DeviceID: "550e8400-e29b-41d4-a716-446655440000", To: "6281234567890", MessageType: "text", Text: "Halo dari API!", } jsonData, _ := json.Marshal(data) req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) req.Header.Set("X-Api-Key", apiKey) req.Header.Set("Content-Type", "application/json") client := &http.Client{} resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) }

Webhook

Webhook memungkinkan Anda menerima notifikasi real-time ketika ada pesan masuk ke session WhatsApp Anda. Ini sangat berguna untuk membangun aplikasi yang reaktif dan responsif.

Konfigurasi Webhook

Untuk mengatur webhook, gunakan endpoint berikut:

POST /webhooks

Membuat webhook baru untuk menerima notifikasi pesan masuk.

Format Request

{ "url": "https://your-domain.com/webhook", "events": ["message", "status"], "device_id": "550e8400-e29b-41d4-a716-446655440000" }

Contoh Implementasi

# Membuat webhook curl -X POST "https://app.wacloud.id/api/v1/webhooks" \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "url": "https://your-domain.com/webhook", "events": ["message", "status"], "device_id": "550e8400-e29b-41d4-a716-446655440000" }'
import requests api_key = 'YOUR_API_KEY' url = 'https://app.wacloud.id/api/v1/webhooks' headers = { 'X-Api-Key': api_key, 'Content-Type': 'application/json' } data = { 'url': 'https://your-domain.com/webhook', 'events': ['message', 'status'], 'device_id': '550e8400-e29b-41d4-a716-446655440000' } response = requests.post(url, headers=headers, json=data) if response.status_code == 201: result = response.json() if result['success']: print(f("Webhook created: {result['data']['id']}"))
// Membuat webhook $apiKey = 'YOUR_API_KEY'; $url = 'https://app.wacloud.id/api/v1/webhooks'; $data = [ 'url' => 'https://your-domain.com/webhook', 'events' => ['message', 'status'], 'device_id' => '550e8400-e29b-41d4-a716-446655440000' ]; $ch = curl_init($url); 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, [ 'X-Api-Key: ' . $apiKey, 'Content-Type: application/json' ]); $response = curl_exec($ch); curl_close($ch); // Menerima webhook di endpoint Anda $payload = json_decode(file_get_contents('php://input'), true); if ($payload['event'] === 'message') { $from = $payload['data']['from']; $body = $payload['data']['body']; // Proses pesan masuk echo "Pesan dari {$from}: {$body}"; }
const axios = require('axios'); const express = require('express'); const app = express(); // Membuat webhook const createWebhook = async () => { const apiKey = 'YOUR_API_KEY'; const url = 'https://app.wacloud.id/api/v1/webhooks'; const data = { url: 'https://your-domain.com/webhook', events: ['message', 'status'], device_id: '550e8400-e29b-41d4-a716-446655440000' }; try { const response = await axios.post(url, data, { headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' } }); console.log('Webhook created:', response.data); } catch (error) { console.error('Error:', error.response?.data || error.message); } }; // Menerima webhook app.use(express.json()); app.post('/webhook', (req, res) => { const { event, data } = req.body; if (event === 'message') { console.log(`Pesan dari ${data.from}: ${data.body}`); // Proses pesan masuk } res.status(200).send('OK'); }); app.listen(3000, () => { console.log('Webhook server running on port 3000'); });
// Membuat webhook const apiKey = 'YOUR_API_KEY'; const url = 'https://app.wacloud.id/api/v1/webhooks'; const data = { url: 'https://your-domain.com/webhook', events: ['message', 'status'], device_id: '550e8400-e29b-41d4-a716-446655440000' }; fetch(url, { method: 'POST', headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(result => { if (result.success) { console.log('Webhook created:', result.data); } }) .catch(error => { console.error('Error:', error); });
package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) type WebhookRequest struct { URL string `json:"url"` Events []string `json:"events"` DeviceID string `json:"device_id"` } func createWebhook() { apiKey := "YOUR_API_KEY" url := "https://app.wacloud.id/api/v1/webhooks" data := WebhookRequest{ URL: "https://your-domain.com/webhook", Events: []string{"message", "status"}, DeviceID: "550e8400-e29b-41d4-a716-446655440000", } jsonData, _ := json.Marshal(data) req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) req.Header.Set("X-Api-Key", apiKey) req.Header.Set("Content-Type", "application/json") client := &http.Client{} resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) } // Menerima webhook func webhookHandler(w http.ResponseWriter, r *http.Request) { var payload map[string]interface{} json.NewDecoder(r.Body).Decode(&payload) if payload["event"] == "message" { data := payload["data"].(map[string]interface{}) fmt.Printf("Pesan dari %v: %v\n", data["from"], data["body"]) } w.WriteHeader(http.StatusOK) } func main() { http.HandleFunc("/webhook", webhookHandler) http.ListenAndServe(":3000", nil) }

Format Webhook Payload

Ketika pesan masuk, webhook akan mengirim POST request ke URL yang Anda tentukan dengan payload berikut:

{ "event": "message", "device_id": "550e8400-e29b-41d4-a716-446655440000", "data": { "from": "6281234567890@c.us", "to": "6289876543210@c.us", "body": "Pesan masuk", "message_type": "text", "timestamp": 1234567890 } }

Mengelola Webhook

GET /webhooks

Mendapatkan daftar semua webhook yang telah dibuat.

Contoh cURL:

curl -X GET "https://app.wacloud.id/api/v1/webhooks" \ -H "X-Api-Key: YOUR_API_KEY"

Contoh Python:

import requests response = requests.get( 'https://app.wacloud.id/api/v1/webhooks', headers={'X-Api-Key': 'YOUR_API_KEY'} ) result = response.json()
DELETE /webhooks/{id}

Menghapus webhook tertentu.

Contoh cURL:

curl -X DELETE "https://app.wacloud.id/api/v1/webhooks/webhook-id-here" \ -H "X-Api-Key: YOUR_API_KEY"

Contoh Python:

import requests webhook_id = 'webhook-id-here' response = requests.delete( f('https://app.wacloud.id/api/v1/webhooks/{webhook_id}'), headers={'X-Api-Key': 'YOUR_API_KEY'} )
Tips
  • Pastikan URL webhook Anda dapat diakses dari internet (gunakan HTTPS untuk produksi)
  • Webhook akan otomatis retry jika endpoint Anda tidak merespons
  • Gunakan signature verification untuk memastikan request berasal dari WACloud

Template Management

Template memungkinkan Anda membuat pesan dengan variabel dinamis yang dapat digunakan berulang kali. Sangat berguna untuk pesan otomatis, notifikasi, dan kampanye marketing.

Membuat Template

Untuk membuat template baru, gunakan endpoint berikut:

POST /templates

Membuat template baru dengan variabel yang dapat diganti.

Format Request

{ "name": "Order Confirmation", "content": "Halo @{{name}}, pesanan Anda #@{{order_id}} telah dikonfirmasi. Total: Rp @{{amount}}", "message_type": "text", "variables": ["name", "order_id", "amount"], "description": "Template untuk konfirmasi pesanan" }

Contoh Implementasi - Membuat Template

curl -X POST "https://app.wacloud.id/api/v1/templates" \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Order Confirmation", "content": "Halo @{{name}}, pesanan Anda #@{{order_id}} telah dikonfirmasi. Total: Rp @{{amount}}", "message_type": "text", "description": "Template untuk konfirmasi pesanan" }'
import requests api_key = 'YOUR_API_KEY' url = 'https://app.wacloud.id/api/v1/templates' headers = { 'X-Api-Key': api_key, 'Content-Type': 'application/json' } data = { 'name': 'Order Confirmation', 'content': 'Halo @{{name}}, pesanan Anda #@{{order_id}} telah dikonfirmasi. Total: Rp @{{amount}}', 'message_type': 'text', 'description': 'Template untuk konfirmasi pesanan' } response = requests.post(url, headers=headers, json=data) if response.status_code == 201: result = response.json() if result['success']: print(f("Template ID: {result['data']['id']}"))
// Membuat template $apiKey = 'YOUR_API_KEY'; $url = 'https://app.wacloud.id/api/v1/templates'; $data = [ 'name' => 'Order Confirmation', 'content' => 'Halo @{{name}}, pesanan Anda #@{{order_id}} telah dikonfirmasi. Total: Rp @{{amount}}', 'message_type' => 'text', 'description' => 'Template untuk konfirmasi pesanan' ]; $ch = curl_init($url); 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, [ 'X-Api-Key: ' . $apiKey, 'Content-Type: application/json' ]); $response = curl_exec($ch); curl_close($ch); $result = json_decode($response, true); if ($result['success']) { echo "Template ID: " . $result['data']['id']; }
const axios = require('axios'); const createTemplate = async () => { const apiKey = 'YOUR_API_KEY'; const url = 'https://app.wacloud.id/api/v1/templates'; const data = { name: 'Order Confirmation', content: 'Halo @{{name}}, pesanan Anda #@{{order_id}} telah dikonfirmasi. Total: Rp @{{amount}}', message_type: 'text', description: 'Template untuk konfirmasi pesanan' }; try { const response = await axios.post(url, data, { headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' } }); console.log('Template ID:', response.data.data.id); } catch (error) { console.error('Error:', error.response?.data || error.message); } }; createTemplate();
const apiKey = 'YOUR_API_KEY'; const url = 'https://app.wacloud.id/api/v1/templates'; const data = { name: 'Order Confirmation', content: 'Halo @{{name}}, pesanan Anda #@{{order_id}} telah dikonfirmasi. Total: Rp @{{amount}}', message_type: 'text', description: 'Template untuk konfirmasi pesanan' }; fetch(url, { method: 'POST', headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(result => { if (result.success) { console.log(`Template ID: ${result.data.id}`); } }) .catch(error => { console.error('Error:', error); });
package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) type CreateTemplateRequest struct { Name string `json:"name"` Content string `json:"content"` MessageType string `json:"message_type"` Description string `json:"description"` } func createTemplate() { apiKey := "YOUR_API_KEY" url := "https://app.wacloud.id/api/v1/templates" data := CreateTemplateRequest{ Name: "Order Confirmation", Content: "Halo @{{name}}, pesanan Anda #@{{order_id}} telah dikonfirmasi. Total: Rp @{{amount}}", MessageType: "text", Description: "Template untuk konfirmasi pesanan", } jsonData, _ := json.Marshal(data) req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) req.Header.Set("X-Api-Key", apiKey) req.Header.Set("Content-Type", "application/json") client := &http.Client{} resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) }

Menggunakan Template

Untuk mengirim pesan menggunakan template, gunakan template_id dan variables dalam request:

{ "device_id": "550e8400-e29b-41d4-a716-446655440000", "to": "6281234567890", "template_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "variables": { "name": "John Doe", "order_id": "ORD-12345", "amount": "150.000" } }

Contoh Implementasi - Menggunakan Template

curl -X POST "https://app.wacloud.id/api/v1/messages" \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "device_id": "550e8400-e29b-41d4-a716-446655440000", "to": "6281234567890", "template_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "variables": { "name": "John Doe", "order_id": "ORD-12345", "amount": "150.000" } }'
import requests api_key = 'YOUR_API_KEY' url = 'https://app.wacloud.id/api/v1/messages' headers = { 'X-Api-Key': api_key, 'Content-Type': 'application/json' } data = { 'device_id': '550e8400-e29b-41d4-a716-446655440000', 'to': '6281234567890', 'template_id': 'a1b2c3d4-e5f6-7890-abcd-ef1234567890', 'variables': { 'name': 'John Doe', 'order_id': 'ORD-12345', 'amount': '150.000' } } response = requests.post(url, headers=headers, json=data) if response.status_code == 201: result = response.json() if result['success']: print(f("Message sent: {result['data']['message_id']}"))
// Mengirim pesan menggunakan template $apiKey = 'YOUR_API_KEY'; $url = 'https://app.wacloud.id/api/v1/messages'; $data = [ 'device_id' => '550e8400-e29b-41d4-a716-446655440000', 'to' => '6281234567890', 'template_id' => 'a1b2c3d4-e5f6-7890-abcd-ef1234567890', 'variables' => [ 'name' => 'John Doe', 'order_id' => 'ORD-12345', 'amount' => '150.000' ] ]; $ch = curl_init($url); 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, [ 'X-Api-Key: ' . $apiKey, 'Content-Type: application/json' ]); $response = curl_exec($ch); curl_close($ch); $result = json_decode($response, true); if ($result['success']) { echo "Message sent: " . $result['data']['message_id']; }
const axios = require('axios'); const sendTemplateMessage = async () => { const apiKey = 'YOUR_API_KEY'; const url = 'https://app.wacloud.id/api/v1/messages'; const data = { device_id: '550e8400-e29b-41d4-a716-446655440000', to: '6281234567890', template_id: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890', variables: { name: 'John Doe', order_id: 'ORD-12345', amount: '150.000' } }; try { const response = await axios.post(url, data, { headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' } }); console.log('Message sent:', response.data.data.message_id); } catch (error) { console.error('Error:', error.response?.data || error.message); } }; sendTemplateMessage();
const apiKey = 'YOUR_API_KEY'; const url = 'https://app.wacloud.id/api/v1/messages'; const data = { device_id: '550e8400-e29b-41d4-a716-446655440000', to: '6281234567890', template_id: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890', variables: { name: 'John Doe', order_id: 'ORD-12345', amount: '150.000' } }; fetch(url, { method: 'POST', headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(result => { if (result.success) { console.log(`Message sent: ${result.data.message_id}`); } }) .catch(error => { console.error('Error:', error); });
package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) type SendTemplateMessageRequest struct { DeviceID string `json:"device_id"` To string `json:"to"` TemplateID string `json:"template_id"` Variables map[string]string `json:"variables"` } func sendTemplateMessage() { apiKey := "YOUR_API_KEY" url := "https://app.wacloud.id/api/v1/messages" data := SendTemplateMessageRequest{ DeviceID: "550e8400-e29b-41d4-a716-446655440000", To: "6281234567890", TemplateID: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", Variables: map[string]string{ "name": "John Doe", "order_id": "ORD-12345", "amount": "150.000", }, } jsonData, _ := json.Marshal(data) req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) req.Header.Set("X-Api-Key", apiKey) req.Header.Set("Content-Type", "application/json") client := &http.Client{} resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) }

Mengelola Template

GET /templates

Mendapatkan daftar semua template yang telah dibuat.

Contoh cURL:

curl -X GET "https://app.wacloud.id/api/v1/templates" \ -H "X-Api-Key: YOUR_API_KEY"

Contoh Python:

import requests response = requests.get( 'https://app.wacloud.id/api/v1/templates', headers={'X-Api-Key': 'YOUR_API_KEY'} ) result = response.json()
GET /templates/{id}

Mendapatkan detail template tertentu.

Contoh cURL:

curl -X GET "https://app.wacloud.id/api/v1/templates/a1b2c3d4-e5f6-7890-abcd-ef1234567890" \ -H "X-Api-Key: YOUR_API_KEY"

Contoh Python:

import requests template_id = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890' response = requests.get( f('https://app.wacloud.id/api/v1/templates/{template_id}'), headers={'X-Api-Key': 'YOUR_API_KEY'} ) result = response.json()
PUT /templates/{id}

Memperbarui template yang sudah ada.

Contoh cURL:

curl -X PUT "https://app.wacloud.id/api/v1/templates/a1b2c3d4-e5f6-7890-abcd-ef1234567890" \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Updated Template", "content": "Updated content", "message_type": "text" }'

Contoh Python:

import requests template_id = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890' response = requests.put( f('https://app.wacloud.id/api/v1/templates/{template_id}'), headers={'X-Api-Key': 'YOUR_API_KEY'}, json={ 'name': 'Updated Template', 'content': 'Updated content', 'message_type': 'text' } )
DELETE /templates/{id}

Menghapus template tertentu.

Contoh cURL:

curl -X DELETE "https://app.wacloud.id/api/v1/templates/a1b2c3d4-e5f6-7890-abcd-ef1234567890" \ -H "X-Api-Key: YOUR_API_KEY"

Contoh Python:

import requests template_id = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890' response = requests.delete( f('https://app.wacloud.id/api/v1/templates/{template_id}'), headers={'X-Api-Key': 'YOUR_API_KEY'} )
POST /templates/{id}/preview

Preview template dengan variabel yang sudah diisi.

Contoh cURL:

curl -X POST "https://app.wacloud.id/api/v1/templates/a1b2c3d4-e5f6-7890-abcd-ef1234567890/preview" \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "variables": { "name": "John Doe", "order_id": "ORD-12345", "amount": "150.000" } }'

Contoh Python:

import requests template_id = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890' response = requests.post( f('https://app.wacloud.id/api/v1/templates/{template_id}/preview'), headers={'X-Api-Key': 'YOUR_API_KEY'}, json={ 'variables': { 'name': 'John Doe', 'order_id': 'ORD-12345', 'amount': '150.000' } } )

Format Variabel

Variabel dalam template menggunakan format @{{variable_name}}. Contoh:

"Halo @{{name}}, terima kasih telah memesan. Total pembayaran: Rp @{{total}}"
Tips
  • Nama variabel harus alphanumeric dan underscore (a-z, A-Z, 0-9, _)
  • Variabel akan otomatis diekstrak dari content jika tidak didefinisikan
  • Template dapat digunakan untuk berbagai jenis pesan (text, image, button, list)
  • Gunakan preview untuk melihat hasil sebelum mengirim

Device Management

Device (atau Session) adalah koneksi WhatsApp yang terhubung ke akun Anda. Setiap device memerlukan proses pairing dengan QR code sebelum dapat digunakan untuk mengirim pesan.

Membuat Device Baru

Untuk membuat device baru, gunakan endpoint berikut:

POST /devices

Membuat device baru. Device akan dalam status "pairing" dan memerlukan QR code untuk terhubung.

Format Request

{ "name": "Device Utama", "phone_number": "81234567890" }

Format Response

{ "success": true, "message": "Device created successfully. Use the pair endpoint to get QR code.", "data": { "id": "550e8400-e29b-41d4-a716-446655440000", "name": "Device Utama", "status": "pairing", "created_at": "2025-11-30T10:00:00Z" } }

Mendapatkan Daftar Device

GET /devices

Mendapatkan daftar semua device yang terhubung (status: connected).

Contoh cURL:

curl -X GET "https://app.wacloud.id/api/v1/devices" \ -H "X-Api-Key: YOUR_API_KEY"

Contoh Python:

import requests response = requests.get( 'https://app.wacloud.id/api/v1/devices', headers={'X-Api-Key': 'YOUR_API_KEY'} ) result = response.json()

Mendapatkan Detail Device

GET /devices/{device_id}

Mendapatkan detail lengkap device berdasarkan ID.

Contoh cURL:

curl -X GET "https://app.wacloud.id/api/v1/devices/550e8400-e29b-41d4-a716-446655440000" \ -H "X-Api-Key: YOUR_API_KEY"

Contoh Python:

import requests device_id = '550e8400-e29b-41d4-a716-446655440000' response = requests.get( f('https://app.wacloud.id/api/v1/devices/{device_id}'), headers={'X-Api-Key': 'YOUR_API_KEY'} ) result = response.json()

Mendapatkan Status Device

GET /devices/{device_id}/status

Mendapatkan status device (connected, pairing, disconnected).

Contoh cURL:

curl -X GET "https://app.wacloud.id/api/v1/devices/550e8400-e29b-41d4-a716-446655440000/status" \ -H "X-Api-Key: YOUR_API_KEY"

Contoh Python:

import requests device_id = '550e8400-e29b-41d4-a716-446655440000' response = requests.get( f('https://app.wacloud.id/api/v1/devices/{device_id}/status'), headers={'X-Api-Key': 'YOUR_API_KEY'} ) result = response.json()

Mendapatkan QR Code untuk Pairing

Setelah membuat device, Anda perlu mendapatkan QR code untuk menghubungkan WhatsApp ke device tersebut.

GET /devices/{device_id}/pair

Mendapatkan QR code untuk pairing device dengan WhatsApp. QR code berlaku selama 2 menit.

Format Response QR Code

{ "success": true, "data": { "qr_code": "data:image/png;base64,iVBORw0KGgoAAAANS...", "expires_at": "2025-11-30T10:02:00Z", "device_id": "550e8400-e29b-41d4-a716-446655440000", "status": "pairing" } }

Contoh Implementasi - Membuat dan Pairing Device

# Membuat device baru curl -X POST "https://app.wacloud.id/api/v1/devices" \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Device Utama", "phone_number": "81234567890" }' # Mendapatkan QR code (ganti {device_id} dengan ID dari response di atas) curl -X GET "https://app.wacloud.id/api/v1/devices/{device_id}/pair" \ -H "X-Api-Key: YOUR_API_KEY"
import requests api_key = 'YOUR_API_KEY' headers = { 'X-Api-Key': api_key, 'Content-Type': 'application/json' } # Membuat device baru url = 'https://app.wacloud.id/api/v1/devices' data = { 'name': 'Device Utama', 'phone_number': '81234567890' } response = requests.post(url, headers=headers, json=data) if response.status_code == 201: result = response.json() if result['success']: device_id = result['data']['id'] # Mendapatkan QR code qr_url = f('https://app.wacloud.id/api/v1/devices/{device_id}/pair') qr_response = requests.get(qr_url, headers={'X-Api-Key': api_key}) if qr_response.status_code == 200: qr_result = qr_response.json() if qr_result['success']: print(f("QR Code: {qr_result['data']['qr_code']}"))
// Membuat device baru $apiKey = 'YOUR_API_KEY'; $url = 'https://app.wacloud.id/api/v1/devices'; $data = [ 'name' => 'Device Utama', 'phone_number' => '81234567890' ]; $ch = curl_init($url); 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, [ 'X-Api-Key: ' . $apiKey, 'Content-Type: application/json' ]); $response = curl_exec($ch); curl_close($ch); $result = json_decode($response, true); if ($result['success']) { $deviceId = $result['data']['id']; // Mendapatkan QR code $qrUrl = "https://app.wacloud.id/api/v1/devices/{$deviceId}/pair"; $ch = curl_init($qrUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'X-Api-Key: ' . $apiKey ]); $qrResponse = curl_exec($ch); curl_close($ch); $qrResult = json_decode($qrResponse, true); if ($qrResult['success']) { // QR code dalam format base64, bisa langsung digunakan di tag img $qrCode = $qrResult['data']['qr_code']; echo "<img src='{$qrCode}' alt='QR Code' />"; } }
const axios = require('axios'); const apiKey = 'YOUR_API_KEY'; // Membuat device baru const createDevice = async () => { const url = 'https://app.wacloud.id/api/v1/devices'; const data = { name: 'Device Utama', phone_number: '81234567890' }; try { const response = await axios.post(url, data, { headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' } }); if (response.data.success) { const deviceId = response.data.data.id; // Mendapatkan QR code const qrResponse = await axios.get( `https://app.wacloud.id/api/v1/devices/${deviceId}/pair`, { headers: { 'X-Api-Key': apiKey } } ); if (qrResponse.data.success) { const qrCode = qrResponse.data.data.qr_code; console.log('QR Code:', qrCode); } } } catch (error) { console.error('Error:', error.response?.data || error.message); } }; createDevice();
import requests api_key = 'YOUR_API_KEY' headers = { 'X-Api-Key': api_key, 'Content-Type': 'application/json' } # Membuat device baru url = 'https://app.wacloud.id/api/v1/devices' data = { 'name': 'Device Utama', 'phone_number': '81234567890' } response = requests.post(url, headers=headers, json=data) if response.status_code == 201: result = response.json() if result['success']: device_id = result['data']['id'] # Mendapatkan QR code qr_url = f('https://app.wacloud.id/api/v1/devices/{device_id}/pair') qr_response = requests.get(qr_url, headers={'X-Api-Key': api_key}) if qr_response.status_code == 200: qr_result = qr_response.json() if qr_result['success']: print(f("QR Code: {qr_result['data']['qr_code']}"))
const apiKey = 'YOUR_API_KEY'; // Membuat device baru const url = 'https://app.wacloud.id/api/v1/devices'; const data = { name: 'Device Utama', phone_number: '81234567890' }; fetch(url, { method: 'POST', headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(result => { if (result.success) { const deviceId = result.data.id; // Mendapatkan QR code return fetch( `https://app.wacloud.id/api/v1/devices/${deviceId}/pair`, { headers: { 'X-Api-Key': apiKey } } ); } }) .then(response => response.json()) .then(qrResult => { if (qrResult.success) { console.log('QR Code:', qrResult.data.qr_code); } }) .catch(error => { console.error('Error:', error); });

Status Device

Device dapat memiliki status berikut:

  • pairing - Device sedang menunggu scan QR code
  • connected - Device sudah terhubung dan siap digunakan
  • disconnected - Device terputus atau dihentikan
Tips
  • QR code berlaku selama 2 menit. Jika expired, panggil endpoint pair lagi untuk mendapatkan QR code baru
  • Setiap user memiliki batas jumlah device berdasarkan plan mereka
  • Device harus dalam status "connected" sebelum dapat digunakan untuk mengirim pesan
  • Nomor telepon harus dalam format 9-13 digit tanpa leading 0 (contoh: 81234567890)

OTP (One-Time Password)

Fitur OTP memungkinkan Anda mengirim kode verifikasi satu kali ke nomor WhatsApp. Sangat berguna untuk verifikasi akun, reset password, atau autentikasi dua faktor.

Mengirim OTP

Untuk mengirim kode OTP, gunakan endpoint berikut:

POST /messages/otp

Mengirim kode OTP 6 digit ke nomor tujuan. OTP akan expire dalam waktu yang ditentukan (default: 10 menit).

Format Request

{ "device_id": "550e8400-e29b-41d4-a716-446655440000", "to": "81234567890", "template_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "expiry_minutes": 10 }

Format Response

{ "success": true, "data": { "otp_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "expires_at": "2025-11-30T12:10:00Z", "expires_in_minutes": 10 } }

Verifikasi OTP

Setelah mengirim OTP, verifikasi kode yang dimasukkan user:

POST /messages/verify-otp

Memverifikasi kode OTP yang telah dikirim.

Format Request Verifikasi

{ "phone_number": "81234567890", "code": "123456" }

Format Response Verifikasi

{ "success": true, "message": "OTP verified successfully" }

Mendapatkan Status OTP

GET /messages/otp/{otp_id}/status

Mendapatkan status OTP berdasarkan ID (pending, verified, expired).

Contoh cURL:

curl -X GET "https://app.wacloud.id/api/v1/messages/otp/f47ac10b-58cc-4372-a567-0e02b2c3d479/status" \ -H "X-Api-Key: YOUR_API_KEY"

Contoh Python:

import requests otp_id = 'f47ac10b-58cc-4372-a567-0e02b2c3d479' response = requests.get( f('https://app.wacloud.id/api/v1/messages/otp/{otp_id}/status'), headers={'X-Api-Key': 'YOUR_API_KEY'} ) result = response.json()

Contoh Implementasi - Mengirim dan Verifikasi OTP

# Mengirim OTP curl -X POST "https://app.wacloud.id/api/v1/messages/otp" \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "device_id": "550e8400-e29b-41d4-a716-446655440000", "to": "81234567890", "expiry_minutes": 10 }' # Verifikasi OTP curl -X POST "https://app.wacloud.id/api/v1/messages/verify-otp" \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "phone_number": "81234567890", "code": "123456" }'
// Mengirim OTP $apiKey = 'YOUR_API_KEY'; $url = 'https://app.wacloud.id/api/v1/messages/otp'; $data = [ 'device_id' => '550e8400-e29b-41d4-a716-446655440000', 'to' => '81234567890', 'expiry_minutes' => 10 ]; $ch = curl_init($url); 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, [ 'X-Api-Key: ' . $apiKey, 'Content-Type: application/json' ]); $response = curl_exec($ch); curl_close($ch); $result = json_decode($response, true); if ($result['success']) { $otpId = $result['data']['otp_id']; echo "OTP sent! ID: {$otpId}\n"; // Verifikasi OTP (contoh: user memasukkan kode 123456) $verifyUrl = 'https://app.wacloud.id/api/v1/messages/verify-otp'; $verifyData = [ 'phone_number' => '81234567890', 'code' => '123456' ]; $ch = curl_init($verifyUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($verifyData)); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'X-Api-Key: ' . $apiKey, 'Content-Type: application/json' ]); $verifyResponse = curl_exec($ch); curl_close($ch); $verifyResult = json_decode($verifyResponse, true); if ($verifyResult['success']) { echo "OTP verified successfully!\n"; } else { echo "Error: " . $verifyResult['error'] . "\n"; } }
const axios = require('axios'); const apiKey = 'YOUR_API_KEY'; // Mengirim OTP const sendOTP = async () => { const url = 'https://app.wacloud.id/api/v1/messages/otp'; const data = { device_id: '550e8400-e29b-41d4-a716-446655440000', to: '81234567890', expiry_minutes: 10 }; try { const response = await axios.post(url, data, { headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' } }); if (response.data.success) { console.log(`OTP sent! ID: ${response.data.data.otp_id}`); // Verifikasi OTP (contoh: user memasukkan kode 123456) const verifyResponse = await axios.post( 'https://app.wacloud.id/api/v1/messages/verify-otp', { phone_number: '81234567890', code: '123456' }, { headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' } } ); if (verifyResponse.data.success) { console.log('OTP verified successfully!'); } else { console.error('Error:', verifyResponse.data.error); } } } catch (error) { console.error('Error:', error.response?.data || error.message); } }; sendOTP();
import requests api_key = 'YOUR_API_KEY' headers = { 'X-Api-Key': api_key, 'Content-Type': 'application/json' } # Mengirim OTP url = 'https://app.wacloud.id/api/v1/messages/otp' data = { 'device_id': '550e8400-e29b-41d4-a716-446655440000', 'to': '81234567890', 'expiry_minutes': 10 } response = requests.post(url, headers=headers, json=data) if response.status_code == 200: result = response.json() if result['success']: print(f("OTP sent! ID: {result['data']['otp_id']}")) # Verifikasi OTP (contoh: user memasukkan kode 123456) verify_url = 'https://app.wacloud.id/api/v1/messages/verify-otp' verify_data = { 'phone_number': '81234567890', 'code': '123456' } verify_response = requests.post(verify_url, headers=headers, json=verify_data) if verify_response.status_code == 200: verify_result = verify_response.json() if verify_result['success']: print("OTP verified successfully!") else: print(f("Error: {verify_result['error']}"))
const apiKey = 'YOUR_API_KEY'; // Mengirim OTP const url = 'https://app.wacloud.id/api/v1/messages/otp'; const data = { device_id: '550e8400-e29b-41d4-a716-446655440000', to: '81234567890', expiry_minutes: 10 }; fetch(url, { method: 'POST', headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(result => { if (result.success) { console.log(`OTP sent! ID: ${result.data.otp_id}`); // Verifikasi OTP (contoh: user memasukkan kode 123456) return fetch('https://app.wacloud.id/api/v1/messages/verify-otp', { method: 'POST', headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' }, body: JSON.stringify({ phone_number: '81234567890', code: '123456' }) }); } }) .then(response => response.json()) .then(verifyResult => { if (verifyResult.success) { console.log('OTP verified successfully!'); } else { console.error('Error:', verifyResult.error); } }) .catch(error => { console.error('Error:', error); });

Menggunakan Template OTP

Anda dapat menggunakan template OTP yang sudah dibuat untuk mengirim pesan OTP dengan format yang konsisten:

{ "device_id": "550e8400-e29b-41d4-a716-446655440000", "to": "81234567890", "template_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "expiry_minutes": 10 }

Status OTP

OTP dapat memiliki status berikut:

  • pending - OTP telah dikirim, menunggu verifikasi
  • verified - OTP telah berhasil diverifikasi
  • expired - OTP telah kadaluarsa
Tips
  • Kode OTP adalah 6 digit angka yang di-generate secara acak
  • Default expiry time adalah 10 menit, dapat diubah dari 1-60 menit
  • OTP hanya dapat digunakan sekali (one-time use)
  • Gunakan template OTP untuk format pesan yang konsisten dan profesional
  • Device harus dalam status "connected" sebelum dapat mengirim OTP

Contacts API

Kelola kontak WhatsApp melalui API. Dapatkan daftar kontak, cek nomor terdaftar, update kontak, dapatkan foto profil, blokir/unblokir kontak, dan kelola LIDs (Linked IDs).

Mendapatkan Daftar Kontak

Untuk mendapatkan daftar semua kontak untuk device tertentu dengan pagination:

GET https://app.wacloud.id/api/v1/devices/{session}/contacts

Mendapatkan daftar semua kontak dengan pagination dan sorting.

Query Parameters:

  • limit (optional, default: 100) - Jumlah kontak yang dikembalikan
  • offset (optional, default: 0) - Offset untuk pagination
  • sortBy (optional, default: 'id') - Field untuk sorting ('id' atau 'name')
  • sortOrder (optional, default: 'asc') - Urutan sorting ('asc' atau 'desc')
curl -X GET "https://app.wacloud.id/api/v1/devices/default/contacts?limit=100&offset=0&sortBy=name&sortOrder=asc" \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Content-Type: application/json"
// Get all contacts $apiKey = 'YOUR_API_KEY'; $session = 'default'; $url = 'https://app.wacloud.id/api/v1/devices/' . $session . '/contacts'; $params = [ 'limit' => 100, 'offset' => 0, 'sortBy' => 'name', 'sortOrder' => 'asc' ]; $ch = curl_init($url . '?' . http_build_query($params)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'X-Api-Key: ' . $apiKey, 'Content-Type: application/json' ]); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true); if ($data['success']) { foreach ($data['data'] as $contact) { echo "Contact: " . $contact['name'] . "\n"; } }
import requests api_key = 'YOUR_API_KEY' session = 'default' url = f'https://app.wacloud.id/api/v1/devices/{session}/contacts' headers = { 'X-Api-Key': api_key, 'Content-Type': 'application/json' } params = { 'limit': 100, 'offset': 0, 'sortBy': 'name', 'sortOrder': 'asc' } response = requests.get(url, headers=headers, params=params) if response.status_code == 200: data = response.json() if data['success']: for contact in data['data']: print(f("Contact: {contact['name']}"))
const axios = require('axios'); const apiKey = 'YOUR_API_KEY'; const session = 'default'; const url = `https://app.wacloud.id/api/v1/devices/${session}/contacts`; axios.get(url, { headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' }, params: { limit: 100, offset: 0, sortBy: 'name', sortOrder: 'asc' } }) .then(response => { if (response.data.success) { response.data.data.forEach(contact => { console.log(`Contact: ${contact.name}`); }); } }) .catch(error => console.error(error));
const apiKey = 'YOUR_API_KEY'; const session = 'default'; const url = `https://app.wacloud.id/api/v1/devices/${session}/contacts`; fetch(url + '?limit=100&offset=0&sortBy=name&sortOrder=asc', { method: 'GET', headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json' } }) .then(response => response.json()) .then(data => { if (data.success) { data.data.forEach(contact => { console.log(`Contact: ${contact.name}`); }); } }) .catch(error => console.error(error));

Mendapatkan Kontak Tertentu

GET /devices/{session}/contacts/{contactId}

Mendapatkan informasi kontak tertentu. Contact ID bisa berupa nomor telepon (123123123) atau chat ID (123123@c.us atau 123123@lid).

curl -X GET "https://app.wacloud.id/api/v1/devices/default/contacts/123123123@c.us" \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Content-Type: application/json"
$apiKey = 'YOUR_API_KEY'; $session = 'default'; $contactId = '123123123@c.us'; $url = 'https://app.wacloud.id/api/v1/devices/' . $session . '/contacts/' . $contactId; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'X-Api-Key: ' . $apiKey, 'Content-Type: application/json' ]); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true); if ($data['success']) { echo "Contact Name: " . $data['data']['name'] . "\n"; }
import requests api_key = 'YOUR_API_KEY' session = 'default' contact_id = '123123123@c.us' url = f'https://app.wacloud.id/api/v1/devices/{session}/contacts/{contact_id}' headers = { 'X-Api-Key': api_key, 'Content-Type': 'application/json' } response = requests.get(url, headers=headers) if response.status_code == 200: data = response.json() if data['success']: print(f("Contact Name: {data['data']['name']}"))

Memperbarui Kontak

PUT /devices/{session}/contacts/{chatId}

Memperbarui informasi kontak di buku alamat telepon (dan di WhatsApp).

Request Body:

{ "firstName": "John", "lastName": "Doe" }
curl -X PUT "https://app.wacloud.id/api/v1/devices/default/contacts/123123123@c.us" \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "firstName": "John", "lastName": "Doe" }'
$apiKey = 'YOUR_API_KEY'; $session = 'default'; $chatId = '123123123@c.us'; $url = 'https://app.wacloud.id/api/v1/devices/' . $session . '/contacts/' . $chatId; $data = [ 'firstName' => 'John', 'lastName' => 'Doe' ]; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'X-Api-Key: ' . $apiKey, 'Content-Type: application/json' ]); $response = curl_exec($ch); curl_close($ch); $result = json_decode($response, true); if ($result['success']) { echo "Contact updated successfully\n"; }
import requests api_key = 'YOUR_API_KEY' session = 'default' chat_id = '123123123@c.us' url = f'https://app.wacloud.id/api/v1/devices/{session}/contacts/{chat_id}' headers = { 'X-Api-Key': api_key, 'Content-Type': 'application/json' } data = { 'firstName': 'John', 'lastName': 'Doe' } response = requests.put(url, headers=headers, json=data) if response.status_code == 200: result = response.json() if result['success']: print("Contact updated successfully")

Cek Nomor Terdaftar

GET /devices/{session}/contacts/check-exists

Memeriksa apakah nomor telepon terdaftar di WhatsApp (bahkan jika nomor tidak ada di daftar kontak Anda).

Query Parameters:

  • phone (required) - Nomor telepon yang akan dicek (contoh: 11231231231)
curl -X GET "https://app.wacloud.id/api/v1/devices/default/contacts/check-exists?phone=11231231231" \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Content-Type: application/json"
$apiKey = 'YOUR_API_KEY'; $session = 'default'; $phone = '11231231231'; $url = 'https://app.wacloud.id/api/v1/devices/' . $session . '/contacts/check-exists?phone=' . $phone; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'X-Api-Key: ' . $apiKey, 'Content-Type: application/json' ]); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true); if ($data['success']) { if ($data['data']['numberExists']) { echo "Number exists: " . $data['data']['chatId'] . "\n"; } else { echo "Number does not exist\n"; } }
import requests api_key = 'YOUR_API_KEY' session = 'default' phone = '11231231231' url = f'https://app.wacloud.id/api/v1/devices/{session}/contacts/check-exists' headers = { 'X-Api-Key': api_key, 'Content-Type': 'application/json' } params = { 'phone': phone } response = requests.get(url, headers=headers, params=params) if response.status_code == 200: data = response.json() if data['success']: if data['data']['numberExists']: print(f("Number exists: {data['data']['chatId']}")) else: print("Number does not exist")

Mendapatkan Foto Profil Kontak

GET /devices/{session}/contacts/{contactId}/profile-picture

Mendapatkan foto profil kontak. Secara default, gambar di-cache selama 24 jam. Gunakan parameter refresh=true untuk memaksa refresh.

Query Parameters:

  • refresh (optional, default: false) - Paksa refresh gambar
curl -X GET "https://app.wacloud.id/api/v1/devices/default/contacts/123123123@c.us/profile-picture?refresh=false" \ -H "X-Api-Key: YOUR_API_KEY"

Blokir dan Unblock Kontak

POST /devices/{session}/contacts/{contactId}/block

Memblokir kontak.

POST /devices/{session}/contacts/{contactId}/unblock

Membuka blokir kontak.

LIDs (Linked IDs)

WhatsApp menggunakan identifier Linked ID (lid) untuk menyembunyikan nomor telepon pengguna dari grup publik. Gunakan API di bawah ini untuk memetakan LID ke nomor telepon.

GET /devices/{session}/lids

Mendapatkan semua mapping LID ke nomor telepon untuk session.

GET /devices/{session}/lids/count

Mendapatkan jumlah mapping LID yang diketahui untuk session.

GET /devices/{session}/lids/{lid}

Mendapatkan nomor telepon yang terkait dengan LID tertentu.

GET /devices/{session}/lids/phone/{phoneNumber}

Mendapatkan LID untuk nomor telepon tertentu.

Tips
  • Contact ID bisa berupa nomor telepon (123123123) atau chat ID (123123@c.us atau 123123@lid)
  • Gunakan check-exists sebelum mengirim pesan ke nomor baru untuk mendapatkan chatId yang benar
  • Untuk nomor telepon Brasil, selalu gunakan check-exists karena format nomor yang berbeda
  • Foto profil di-cache selama 24 jam untuk menghindari rate limit
  • LIDs digunakan untuk privasi di grup publik - gunakan API LIDs untuk mapping
Siap untuk Memulai?

Daftar sekarang dan dapatkan akses ke API lengkap dengan paket gratis!

Daftar Sekarang