DigiChat Documentation
Send a message

Signed request and common mistakes.

Send a message

Endpoint:

POST /api/whatsapp/{token}/sendMessage

Before calling this, make sure the session status is ONLINE.

Request body

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 chatId
  • message maps to text
  • idempotency_key maps to idempotencyKey
  • window_ms maps to windowMs
Phone format
Use international digits only for direct contact sends. Example: 963912345678

Signed request (Node.js fetch)

import 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 send examples

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..."
  }
}

Channel and invite resolution

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" }

Common responses

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