Endpoint:
POST /api/whatsapp/{token}/sendMessage
Before calling this, make sure the session status is ONLINE.
| Field | Type | Required | Notes |
|---|---|---|---|
phone |
string | yes | Digits only (no +) |
message |
string | yes | Message text |
963912345678import crypto from "crypto";
const BASE_URL = "https://stagging.digichat.digiworld-dev.com";
const token = process.env.DIGICHAT_API_TOKEN;
const secret = process.env.DIGICHAT_API_SECRET;
const timestamp = String(Date.now());
const body = JSON.stringify({ phone: "963912345678", message: "Hello!" });
const signature = crypto
.createHmac("sha256", secret)
.update(timestamp + token + body)
.digest("hex");
const res = await fetch(`${BASE_URL}/api/whatsapp/${token}/sendMessage`, {
method: "POST",
headers: {
"Accept": "application/json",
"Content-Type": "application/json",
"X-API-Timestamp": timestamp,
"X-API-Signature": signature
},
body
});
console.log(await res.json());
| Code | Meaning |
|---|---|
200 |
Message accepted/sent |
401 |
Missing/invalid signature headers |
402 |
Insufficient wallet balance |
422 |
Validation error (missing phone/message) |
429 |
Rate limit or PAYG window limit |