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
If the phone number is missing the country code, WhatsApp cannot reliably route the message.
Send this body component:
For a document header, use
The media URL must be publicly accessible by WhatsApp.
Use
parameters component list.
Required access
| Authentication | Required headers |
|---|---|
| Legacy workspace API key | Authorization: Bearer <legacy_workspace_api_key> and X-SP-Workspace-Id: <workspace_id>. |
Headers
Bearer token using the legacy workspace API key.
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
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.
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.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.Map every template variable
For each
{{1}}, {{2}}, or media/button placeholder in the template, add the matching entry in parameters.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.Body
WhatsApp channel UUID from Settings > API Details > Channels. This decides which connected WhatsApp number sends the message.
Destination phone number with country code at the start. Use digits only. Do not include
+, spaces, brackets, or hyphens.Examples: 918888888888, 14155550123, 447700900123.Must be
template.Approved WhatsApp template name. Use the exact name from Sagepilot or Meta.
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.Must be
list. This tells Sagepilot that parameters is already in Meta’s positional component format.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.
| Customer location | Correct | Incorrect |
|---|---|---|
| India | 918888888888 | 8080365185, +91 8080365185 |
| United States | 14155550123 | 4155550123, +1 (415) 555-0123 |
| United Kingdom | 447700900123 | 07700900123, +44 7700 900123 |
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
| Error | What it means | How to fix it |
|---|---|---|
Template <name> not found | The template name does not exist for the selected channel or workspace. | Confirm the exact template_name, channel_id, and X-SP-Workspace-Id. |
| Missing workspace ID | The legacy route cannot resolve the workspace context. | Send X-SP-Workspace-Id as a request header, not as a body field. |
| Missing customer name | The legacy route creates or updates a customer profile before queueing the template. | Send customer_name in the request body. |
| Missing or invalid phone number | customer_phone is empty or not routable. | Pass digits only with country code at the start. |
| Template variable mismatch | The template has placeholders that are missing from parameters, or the order is wrong. | Match each Meta component and placeholder in order. |
| Media cannot be fetched | WhatsApp cannot access the header media URL. | Use a public HTTPS URL for image, video, or document media. |
| Marketing template not received during testing | The recipient may not have an open WhatsApp conversation with the business. | Ask the recipient to message your business number first, then retry. |
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: