Your API token goes in the URL. Only the signed messaging endpoints currently require HMAC headers:
POST /api/whatsapp/{token}/sendMessagePOST /api/whatsapp/{token}/sendMediaPOST /api/whatsapp/{token}/invite-infoPOST /api/whatsapp/{token}/channel-infoX-API-Timestamp: milliseconds since epoch (example: Date.now())X-API-Signature: hex HMAC-SHA256You sign:
timestamp + token + rawBody
Where rawBody is the exact JSON string you send.
import crypto from "crypto";
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");
// headers:
// X-API-Timestamp: timestamp
// X-API-Signature: signature
$timestamp = (string) round(microtime(true) * 1000);
$token = env('DIGICHAT_API_TOKEN');
$secret = env('DIGICHAT_API_SECRET');
$body = json_encode([
'chatId' => '963912345678',
'type' => 'text',
'text' => 'Hello!'
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$signature = hash_hmac('sha256', $timestamp . $token . $body, $secret);
These endpoints use the token in the URL, but do not require signature headers:
GET /api/whatsapp/{token}/pingPOST /api/whatsapp/{token}/startGET /api/whatsapp/{token}/statusGET /api/whatsapp/{token}/qrGET /api/whatsapp/{token}/qr/imagePOST /api/whatsapp/{token}/refreshPOST /api/whatsapp/{token}/terminate