Untuk TypeScript, pakai @wazapin/sdk resmi — sudah termasuk pembuat bertipe (typed builders), percobaan kembali (retries), dan pembantu webhook.
Untuk setiap runtime lainnya, panggil REST API dengan kunci API kamu (X-Api-Key). Endpoint yang sama, payload yang sama.
cURL
curl -X POST "https://api.wazapin.com/v1/messages" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"channel_id": "wzp_ch_123",
"to": "6281234567890",
"type": "text",
"content": { "body": "Hello from Wazapin" }
}'Python
import os
import requests
response = requests.post(
"https://api.wazapin.com/v1/messages",
headers={
"X-Api-Key": os.environ["WAZAPIN_API_KEY"],
"Content-Type": "application/json",
},
json={
"channel_id": "wzp_ch_123",
"to": "6281234567890",
"type": "text",
"content": {"body": "Hello from Wazapin"},
},
timeout=20,
)
response.raise_for_status()
print(response.json())Go
package main
import (
"bytes"
"encoding/json"
"net/http"
"os"
)
func main() {
payload := map[string]any{
"channel_id": "wzp_ch_123",
"to": "6281234567890",
"type": "text",
"content": map[string]any{"body": "Hello from Wazapin"},
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest(http.MethodPost, "https://api.wazapin.com/v1/messages", bytes.NewReader(body))
req.Header.Set("X-Api-Key", os.Getenv("WAZAPIN_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
}PHP
<?php
$payload = '{
"channel_id": "wzp_ch_123",
"to": "6281234567890",
"type": "text",
"content": {"body": "Hello from Wazapin"}
}';
$ch = curl_init("https://api.wazapin.com/v1/messages");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"X-Api-Key: " . getenv("WAZAPIN_API_KEY"),
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $httpCode . "\n" . $response . "\n";