Send WhatsApp template
Send WhatsApp template
Send an approved WhatsApp template message through the legacy template-send API.
POST
Send WhatsApp template
Use this endpoint to send an approved WhatsApp template from one of your connected WhatsApp channels to a customer.
This endpoint uses the legacy template-send contract. You pass the template name and a Meta-style
Send this body component:
For a document header, use
The media URL must be publicly accessible by WhatsApp.
Use
parameters component list.
Required access
Headers
string
required
Bearer token using the legacy workspace API key.
string
required
Workspace ID for the request. This header is required so Sagepilot can resolve the workspace, channel, template, and customer record before sending the WhatsApp template.
Send the workspace ID in the
X-SP-Workspace-Id header. Do not send it as workspace_id inside the JSON body.Before you send
1
Get your workspace API details
In Sagepilot, go to Settings > API Details. Copy your workspace ID and generate or copy a legacy workspace API key.
2
Choose the WhatsApp channel
Use the
channel_id for the WhatsApp number you want to send from. Each connected number has its own channel ID.3
Confirm the approved template name
Use the template name exactly as it appears in Sagepilot or Meta, for example
checkout_1. Template names are case-sensitive.4
Map every template variable
For each
{{1}}, {{2}}, or media/button placeholder in the template, add the matching entry in parameters.5
Send to a phone number with country code
Send
customer_phone as digits only with the country code first, such as 918888888888 for India or 14155550123 for the United States.6
Validate required fields before testing
Confirm that
X-SP-Workspace-Id, customer_name, customer_phone, channel_id, template_name, parameter_type, and parameters are present before sending the request.Body
string
required
WhatsApp channel UUID from Settings > API Details > Channels. This decides which connected WhatsApp number sends the message.
string
required
Destination phone number with country code at the start. Use digits only. Do not include
+, spaces, brackets, or hyphens.Examples: 918888888888, 14155550123, 447700900123.string
default:"template"
required
Must be
template.string
required
Approved WhatsApp template name. Use the exact name from Sagepilot or Meta.
string
required
Customer name to associate with the recipient. This is required for the legacy send flow because Sagepilot creates or updates the customer record before queueing the WhatsApp template.This does not automatically fill a template variable unless you also pass the same value in
parameters.string
default:"list"
required
Must be
list. This tells Sagepilot that parameters is already in Meta’s positional component format.object
required
Meta-style template component payload. Supported component types include For an image header and one body variable, pass:
body, header, and button.For a body template such as Hi {{1}}, pass:Phone number format
Always include the country code at the start ofcustomer_phone.
If the phone number is missing the country code, WhatsApp cannot reliably route the message.
How template variables map
WhatsApp templates use positional placeholders such as{{1}}, {{2}}, and {{3}}. The API does not use the placeholder names from your internal systems. It uses component order.
Body text variables
For this template body:Ankita fills {{1}}. #1001 fills {{2}}.
Header media variables
If the template has an image header, send:document instead:
Dynamic URL buttons
If the template has a URL button with a dynamic placeholder, add abutton component.
index: 0 for the first button, index: 1 for the second button, and so on.
For Sagepilot CTA buttons such as https://app.sagepilot.ai/cta?redirect={{1}}, pass only the encoded destination URL as the button text. Do not pass the full Sagepilot CTA wrapper URL.
Complete example
This example sends an abandoned checkout template with:- An image header.
- One body variable for the customer name.
- One dynamic URL button for the checkout link.
OTP / authentication template example
Use this shape for authentication templates that send a one-time password and include a Copy Code button. For example, the approved authentication templateotp_authentication expects the OTP in the body and in the OTP button parameter. Use the same code in both places.
Body-only example
Use this shape when the template has only body text placeholders and no header media or buttons.Successful response
Common errors
Meta template component reference
Theparameters array follows Meta’s WhatsApp template component structure. Refer to Meta’s WhatsApp template documentation when mapping body placeholders, media headers, and URL buttons: