Skip to main content

UC-008 — Bulk WhatsApp Template Campaign

Goal
Create and send a bulk WhatsApp campaign with approved templates
Channel
WhatsApp
Estimated time
25 minutes

Real-world scenarios​

  • ShopItalia — WhatsApp promotional notification: ShopItalia sends a "Summer sales -50%" promotion to 15,000 customers via a WhatsApp template with a "Go to shop" button and header image.
  • BeautyBox — Personalized coupons: Bulk send of personalized discount coupons with customer name and unique code, tracking opens and link clicks.
  • AssicuraSemplice — Policy expiry reminder: Automatic notification to customers with policies expiring in the next 30 days, with a button for online renewal.

WhatsApp campaign lifecycle​

The diagram illustrates the cycle from draft to configuration with Meta-approved WhatsApp template, cost estimation, confirmation and monitoring of delivery and read metrics. The API reports the READY_TO_SEND state as "status": "DRAFT" with "readyToSend": true.

Prerequisites​

  • Active API Key with campaign and WhatsApp channel permissions
  • WhatsApp template approved by Meta (see UC-006)
  • Verified and active WhatsApp Business number: its id, the whatsappPhoneNumberId of the campaign, is listed by GET /whatsapp/phone-numbers (see also UC-005)
  • Contact list created and populated (see UC-011)

Step 1 — Create the campaign as a draft​

Create a new campaign specifying the WhatsApp channel (sendingMode) and recipients taken from contact lists (destinationType: 0).

curl -X POST https://api.qlara.ai/api/partner-gateway/campaigns \
-H "Content-Type: application/json" \
-H "X-Api-Key: YOUR_API_KEY" \
-d '{
"name": "Saldi Estivi 2027",
"description": "Promozione saldi estivi -50% con coupon personalizzato",
"sendingMode": "WHATSAPP",
"destinationType": 0
}'

Response — Campaign created​

{
"id": 3907,
"name": "Saldi Estivi 2027",
"description": "Promozione saldi estivi -50% con coupon personalizzato",
"status": "DRAFT",
"sendingMode": "WHATSAPP",
"destinationType": 0,
"readyToSend": false,
"creationDate": "2027-04-09 08:00:00.000+0000"
}

Step 2 — Configure the template and recipient list​

Associate the WhatsApp Business number, the approved WhatsApp template and the contact list with the campaign, then mark it as ready with readyToSend: true. Send whatsappPhoneNumberId and whatsappTemplateId in the same request. Every update must also carry sendingMode and destinationType, the latter with the value set at creation (0).

curl -X PUT https://api.qlara.ai/api/partner-gateway/campaigns/3907 \
-H "Content-Type: application/json" \
-H "X-Api-Key: YOUR_API_KEY" \
-d '{
"sendingMode": "WHATSAPP",
"destinationType": 0,
"whatsappPhoneNumberId": 5,
"whatsappTemplateId": 188,
"contactListIds": [415],
"scheduledDate": "2027-06-01 08:00:00.000+0200",
"readyToSend": true
}'

Response — Campaign configured​

{
"id": 3907,
"name": "Saldi Estivi 2027",
"status": "DRAFT",
"sendingMode": "WHATSAPP",
"whatsappPhoneNumberId": 5,
"whatsappTemplateId": 188,
"contactListIds": [415],
"scheduledDate": "2027-06-01 06:00:00.000+0000",
"readyToSend": true
}
Template variables

The campaign carries no template parameters: each variable of the approved template (for example {firstName}) is filled in for every recipient from the matching field of the contact in the list. Make sure contacts have those fields populated.

Behind the scenes — Bulk WhatsApp sending and rate limiting
  1. Template loading: The template is loaded from your account when whatsappPhoneNumberId and whatsappTemplateId arrive together. An ID that is not one of your templates gets 404, while an AUTHENTICATION template, or a template with a media header but no uploaded media, gets 400. The approval status is not checked: use a template in APPROVED status on Meta.
  2. Variable resolution: The variables defined in the template are resolved per recipient from the contact record, so the campaign request never lists them.
  3. Messaging limit: Meta limits how many recipients a number can message in 24 hours, by its tier (messagingLimitTier, see UC-005): check it against the size of the list before confirming.
  4. Conversation window: A template reaches contacts who have not written to you. When a recipient replies, a 24-hour window opens in which you can answer with free-form messages from the inbox (see UC-015).
  5. Quality rating: Meta monitors the template's quality rating. High block rates can lead to template suspension. Monitor post-campaign metrics.

Step 3 — Estimate the cost and confirm​

Check the recipients and the price of the campaign.

# Get the cost estimate
curl -X GET https://api.qlara.ai/api/partner-gateway/campaigns/3907/price \
-H "X-Api-Key: YOUR_API_KEY"

Response — Cost estimate​

{
"id": 3907,
"name": "Saldi Estivi 2027",
"status": "DRAFT",
"sendingMode": "WHATSAPP",
"whatsappTemplateId": 188,
"contactListIds": [415],
"totalPrice": 105000000000,
"walletKind": "EURO",
"numOfDistinctContact": 15000,
"readyToSend": true
}

numOfDistinctContact is the number of distinct recipients and totalPrice the total price of the campaign, in the unit of the wallet named by walletKind: for EURO, hundred-millionths of a euro, so 105000000000 is €1,050.

# Confirm and schedule the campaign (202 Accepted, no body)
curl -X PUT https://api.qlara.ai/api/partner-gateway/campaigns/3907/confirm \
-H "X-Api-Key: YOUR_API_KEY"

Expected result​

StepActionResult
1POST /campaignsCampaign created with status DRAFT
2PUT /campaigns/{id}Status DRAFT with readyToSend: true, number, template and list
3GET /price15,000 distinct recipients (numOfDistinctContact) and totalPrice
4PUT /confirm202 Accepted: campaign confirmed, delivery scheduled

Complete end-to-end example​

# 1. Create WhatsApp campaign
CAMP_ID=$(curl -s -X POST https://api.qlara.ai/api/partner-gateway/campaigns \
-H "Content-Type: application/json" \
-H "X-Api-Key: YOUR_API_KEY" \
-d '{
"name": "Saldi Estivi 2027",
"description": "Promozione saldi con coupon personalizzato",
"sendingMode": "WHATSAPP",
"destinationType": 0
}' | jq -r '.id')

echo "Campaign ID: $CAMP_ID"

# 2. Configure number, template and list
curl -s -X PUT "https://api.qlara.ai/api/partner-gateway/campaigns/${CAMP_ID}" \
-H "Content-Type: application/json" \
-H "X-Api-Key: YOUR_API_KEY" \
-d '{
"sendingMode": "WHATSAPP",
"destinationType": 0,
"whatsappPhoneNumberId": 5,
"whatsappTemplateId": 188,
"contactListIds": [415],
"readyToSend": true
}'

# 3. Check the price
curl -s -X GET "https://api.qlara.ai/api/partner-gateway/campaigns/${CAMP_ID}/price" \
-H "X-Api-Key: YOUR_API_KEY" | jq .

# 4. Confirm
curl -s -X PUT "https://api.qlara.ai/api/partner-gateway/campaigns/${CAMP_ID}/confirm" \
-H "X-Api-Key: YOUR_API_KEY"

Variants​

Campaign with a personalized coupon code​

The campaign cannot pass a different value to each recipient: a unique coupon code has to come from the contact record. Save each customer's code on the contact (see UC-011), use an approved template whose text shows it through a variable, and point the campaign at that template:

curl -X PUT "https://api.qlara.ai/api/partner-gateway/campaigns/${CAMP_ID}" \
-H "Content-Type: application/json" \
-H "X-Api-Key: YOUR_API_KEY" \
-d '{
"sendingMode": "WHATSAPP",
"destinationType": 0,
"whatsappPhoneNumberId": 5,
"whatsappTemplateId": 192,
"contactListIds": [416],
"readyToSend": true
}'

Common errors​

The two campaign errors below carry only a generic message in data, which does not name the field that failed: look for the cause here.

404 Not Found — WhatsApp template not found​

{
"status": "fail",
"data": "Resource not found."
}

Solution: POST /campaigns and PUT /campaigns/{id} answer this way when whatsappTemplateId is not a template of your account. Check the template ID as shown in UC-006. A whatsappPhoneNumberId that is not a number of your account gets 404 too, with "data": "WhatsApp phone number not found": take its id from the list of your numbers (UC-005). The approval status is not checked here: make sure the template is APPROVED on Meta before you confirm the campaign.

400 Bad Request — WhatsApp fields missing​

{
"status": "fail",
"data": "Bad request."
}

Solution: Every sending mode that includes WhatsApp needs both whatsappPhoneNumberId and whatsappTemplateId: without them, GET /campaigns/{id}/price and PUT /campaigns/{id}/confirm answer with this generic error. Send both in the same POST /campaigns or PUT /campaigns/{id} request before confirming: whatsappTemplateId alone is refused with 400 and "data": "'whatsappPhoneNumberId' is required together with 'whatsappTemplateId': the template is loaded only when both are sent".

401 Unauthorized — Missing or invalid API Key​

{
"error": "Invalid API Key"
}

Solution: Verify that the X-Api-Key header is present and that the key is active in the platform dashboard.

Next steps​

References​