Endpoint:
POST /api/whatsapp/{token}/sendMessage
Before calling this, make sure the session status is ONLINE.
| Field | Type | Required | Notes |
|---|---|---|---|
chatId |
string | yes | Raw digits, @c.us, @g.us, or @newsletter |
type |
string | yes | text, media, or file |
text |
string | yes for type=text |
Message text |
caption |
string | no | Used with media and file |
media |
file or object | yes for media and file |
Multipart file or JSON object with mimetype, filename, base64 |
idempotencyKey |
string | no | Optional deduplication key |
windowMs |
integer | no | Optional delivery window override in milliseconds |
Legacy aliases are still accepted:
phone maps to chatIdmessage maps to textidempotency_key maps to idempotencyKeywindow_ms maps to windowMs963912345678import crypto from "crypto";
const BASE_URL = "https://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({
chatId: "963912345678",
type: "text",
text: "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());
Media/file sends use POST /api/whatsapp/{token}/sendMedia.
JSON example:
{
"chatId": "123456789@g.us",
"type": "media",
"caption": "Launch poster",
"media": {
"mimetype": "image/png",
"filename": "poster.png",
"base64": "iVBORw0KGgoAAAANSUhEUgAA..."
}
}
Use these signed helper endpoints before sending to a newsletter/channel:
POST /api/whatsapp/{token}/invite-info with { "inviteCode": "AbCdEfGhIjK" }POST /api/whatsapp/{token}/channel-info with either { "inviteCode": "AbCdEfGhIjK" } or { "inviteLink": "https://whatsapp.com/channel/AbCdEfGhIjK" }| Code | Meaning |
|---|---|
200 |
Message accepted/sent |
401 |
Missing/invalid signature headers |
402 |
Insufficient wallet balance |
422 |
Validation error or unsupported message type for the target |
429 |
Rate limit or PAYG window limit |
503 |
Session/core server is not ready |