WhatsApp Business API for partner delivery confirmation
The scenario sends a partner or distributor contact a personalized WhatsApp template when an order is delivered to their location.

Use case overview
The scenario sends a partner or distributor contact a personalized WhatsApp template when an order is delivered to their location. The message includes the partner company name, order number, product name, and delivery receipt note. A static URL button opens order or transfer details.
Template example
Hello, {{1}}! Order #{{2}} for "{{3}}" has been delivered to your partner pickup point. {{4}}.
[Handoff details]
The details URL button is fixed in the Meta template — only body variables are sent via the API. Recipient is the partner phone (MANAGER_PHONE), not the end customer.
Variables and purpose
{{1}}— partner or distributor company name{{2}}— order number{{3}}— product name{{4}}— delivery receipt note (time, location, or next step)
Filled-in example
Hello, North Distributor LLC! Order #10482 for "Wireless headphones" has been delivered to your partner pickup point. Accepted today at 11:20 AM at the partner warehouse..
[Handoff details]
When to use it
- b2b distribution
- franchise and partner networks
- integrators
Business value
- TMS or OMS emits a partner-delivery event
- System resolves the partner contact phone and shipment details
- Template message is built with four body variables and a static URL button
- Partner contact receives WhatsApp confirmation at their phone
- Delivery status is logged for B2B fulfilment or inventory reconciliation
Workflow
- Logistics marks delivery to the partner location and fires an event.
- The system resolves the partner contact phone and shipment fields.
- A personalized template message is built with four body variables and a static URL button.
- The partner contact receives the WhatsApp confirmation and can open details via the button.
- Delivery result is logged; errors are handled according to platform rules.
- Delivery progress is reported asynchronously — typically
sent, thendelivered(or failed/undelivered). - Your system receives status via webhook (
hooks[]) or pollsGET …/hookInfo?messageId=<id>and handles failures if needed.

Technical implementation
Prerequisites
- A 1MSG account with WhatsApp Business API connected and an approved message template.
- Partner contact phone in international format (without
+and spaces). - Shipment data: partner name, order number, product name, delivery note.
Code examples
#!/usr/bin/env node
// === Configuration (replace "___" placeholders) ===
const API_BASE_URL = "https://api.1msg.io"; // production 1MSG API base URL
const CHANNEL_ID = "___"; // channel ID from 1MSG dashboard
const API_TOKEN = "___"; // channel JWT token (Bearer)
const TEMPLATE_NAME = "___"; // approved template name
const TEMPLATE_NAMESPACE = "___"; // template namespace (422 without it)
const TEMPLATE_LANGUAGE = "___"; // template language code, e.g. "en"
// === Test data ===
const MANAGER_PHONE = "___"; // manager phone in international format
const TEST_COMPANYORSPECIALISTNAME = "___"; // {{1}} company or specialist name
const TEST_TICKETNUMBER = "___"; // {{2}} ticket number
const TEST_PRODUCTNAME = "___"; // {{3}} product name
const TEST_NEXTSTEP = "___"; // {{4}} next step
function normalizePhone(phone) {
return String(phone).replace(/\D/g, "");
}
function assertConfigured(values) {
for (const [key, value] of Object.entries(values)) {
if (value === "___" || value === "" || value === undefined || value === null) {
throw new Error(`Missing configuration value: ${key}`);
}
}
}
async function sendTemplateMessage({ phone, companyOrSpecialistName, ticketNumber, productName, nextStep }) {
assertConfigured({
CHANNEL_ID,
API_TOKEN,
TEMPLATE_NAME,
TEMPLATE_NAMESPACE,
TEMPLATE_LANGUAGE,
phone,
companyOrSpecialistName,
ticketNumber,
productName,
nextStep,
});
const url = `${API_BASE_URL}/${CHANNEL_ID}/sendTemplate`;
// params carries body ONLY. Button text is fixed in the Meta template — no button param.
const requestBody = {
phone: normalizePhone(phone),
template: TEMPLATE_NAME,
namespace: TEMPLATE_NAMESPACE,
language: {
policy: "deterministic",
code: TEMPLATE_LANGUAGE,
},
params: [
{
type: "body",
parameters: [
{ type: "text", text: String(companyOrSpecialistName) }, // {{1}} company or specialist name
{ type: "text", text: String(ticketNumber) }, // {{2}} ticket number
{ type: "text", text: String(productName) }, // {{3}} product name
{ type: "text", text: String(nextStep) }, // {{4}} next step
],
},
],
};
const res = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${API_TOKEN}`,
},
body: JSON.stringify(requestBody),
});
const raw = await res.text();
let data;
try {
data = JSON.parse(raw);
} catch {
data = null;
}
if (!res.ok || !data || data.sent !== true) {
console.error("Send failed. API response:");
console.error(raw);
process.exit(1);
}
console.log("Message sent to manager.");
console.log("API response:", raw);
return data;
}
if (require.main === module) {
sendTemplateMessage({
phone: MANAGER_PHONE,
companyOrSpecialistName: TEST_COMPANYORSPECIALISTNAME,
ticketNumber: TEST_TICKETNUMBER,
productName: TEST_PRODUCTNAME,
nextStep: TEST_NEXTSTEP,
}).catch((err) => {
console.error("Execution failed:", err.message);
process.exit(1);
});
}
module.exports = { sendTemplateMessage };
Immediate API response (synchronous)
- HTTP 2xx and JSON
"sent": truemean 1MSG accepted the message for sending — not that it already reached the customer's phone. - Save the `id` field from the response (value looks like
wamid.…). Use it to correlate delivery callbacks or polling. - The response may also include
messageanddescription— informational only.
Delivery status (asynchronous)
- Register a webhook (
POST …/webhook) so 1MSG POSTs delivery updates to your HTTPS endpoint in a separate `hooks[]` payload (sent,delivered,read, or failed/undelivered when applicable). - Optionally poll:
GET {base}/{channel}/hookInfo?messageId=<id from sendTemplate>. - In practice, delivery often completes within a few seconds — but that is not guaranteed by the API contract.
Common errors
- Invalid or non-normalized phone number
- Unapproved or missing template name / namespace
- No customer opt-in for WhatsApp business messages
- Template variable count mismatch (422 from API)
- Delivery failure — check status webhook and retry policy
FAQ
- Do I need an approved template? Yes — cold-start WhatsApp messages require a Meta-approved template.
- Can I customize the message text? Body variables are dynamic; fixed text and button labels are set in the Meta template.
- How do I check delivery?
sent: trueonly confirms acceptance. Track delivery via webhookhooks[]orGET …/hookInfo?messageId=<id>. - What if the message is not delivered? Log the failed/undelivered hook, verify opt-in and template status, then retry or fall back to another channel.
- Can I connect this to my CRM or backend? Yes — trigger the API call from your platform webhook or event handler.
Related
Build WhatsApp automation in minutes
Use 1MSG to automate this workflow and try it with our free demo.
