Skip to main content
POST
/
api
/
v1
/
whatsapp
/
template
Send WhatsApp template message
curl --request POST \
  --url https://{subdomain}.mihu.ai/api/v1/whatsapp/template \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "agentId": "32d8fc98-be1e-4d32-a12e-146f397fb1cb",
  "templateId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "phoneNumber": "+12345678900",
  "parameters": {
    "field1": "John Doe",
    "field2": "Order #12345",
    "field3": "2024-01-15"
  },
  "header": {
    "type": "image",
    "url": "https://example.com/image.jpg",
    "filename": "invoice.pdf"
  }
}
'
import requests

url = "https://{subdomain}.mihu.ai/api/v1/whatsapp/template"

payload = {
"agentId": "32d8fc98-be1e-4d32-a12e-146f397fb1cb",
"templateId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"phoneNumber": "+12345678900",
"parameters": {
"field1": "John Doe",
"field2": "Order #12345",
"field3": "2024-01-15"
},
"header": {
"type": "image",
"url": "https://example.com/image.jpg",
"filename": "invoice.pdf"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
agentId: '32d8fc98-be1e-4d32-a12e-146f397fb1cb',
templateId: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
phoneNumber: '+12345678900',
parameters: {field1: 'John Doe', field2: 'Order #12345', field3: '2024-01-15'},
header: {type: 'image', url: 'https://example.com/image.jpg', filename: 'invoice.pdf'}
})
};

fetch('https://{subdomain}.mihu.ai/api/v1/whatsapp/template', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://{subdomain}.mihu.ai/api/v1/whatsapp/template",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'agentId' => '32d8fc98-be1e-4d32-a12e-146f397fb1cb',
'templateId' => 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
'phoneNumber' => '+12345678900',
'parameters' => [
'field1' => 'John Doe',
'field2' => 'Order #12345',
'field3' => '2024-01-15'
],
'header' => [
'type' => 'image',
'url' => 'https://example.com/image.jpg',
'filename' => 'invoice.pdf'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://{subdomain}.mihu.ai/api/v1/whatsapp/template"

payload := strings.NewReader("{\n \"agentId\": \"32d8fc98-be1e-4d32-a12e-146f397fb1cb\",\n \"templateId\": \"a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n \"phoneNumber\": \"+12345678900\",\n \"parameters\": {\n \"field1\": \"John Doe\",\n \"field2\": \"Order #12345\",\n \"field3\": \"2024-01-15\"\n },\n \"header\": {\n \"type\": \"image\",\n \"url\": \"https://example.com/image.jpg\",\n \"filename\": \"invoice.pdf\"\n }\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://{subdomain}.mihu.ai/api/v1/whatsapp/template")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"agentId\": \"32d8fc98-be1e-4d32-a12e-146f397fb1cb\",\n \"templateId\": \"a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n \"phoneNumber\": \"+12345678900\",\n \"parameters\": {\n \"field1\": \"John Doe\",\n \"field2\": \"Order #12345\",\n \"field3\": \"2024-01-15\"\n },\n \"header\": {\n \"type\": \"image\",\n \"url\": \"https://example.com/image.jpg\",\n \"filename\": \"invoice.pdf\"\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://{subdomain}.mihu.ai/api/v1/whatsapp/template")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"agentId\": \"32d8fc98-be1e-4d32-a12e-146f397fb1cb\",\n \"templateId\": \"a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n \"phoneNumber\": \"+12345678900\",\n \"parameters\": {\n \"field1\": \"John Doe\",\n \"field2\": \"Order #12345\",\n \"field3\": \"2024-01-15\"\n },\n \"header\": {\n \"type\": \"image\",\n \"url\": \"https://example.com/image.jpg\",\n \"filename\": \"invoice.pdf\"\n }\n}"

response = http.request(request)
puts response.read_body
{
  "success": true,
  "message": "WhatsApp template message sent successfully",
  "data": {
    "messageId": "wamid.HBgMOTA1NDM1NTA2Njc3FQIAEhggRDdBQjlFM0Q2Q0E4OEJBMDE5NkMyNEZBNjVCNzE2MzYA",
    "templateName": "order_confirmation",
    "recipientPhone": "+12345678900",
    "conversationId": 456
  }
}
{
"success": false,
"message": "Template parameter mismatch: provided 3 parameters but template expects 0 parameters",
"data": [
"<unknown>"
]
}
{
"success": false,
"message": "Agent not found | Template not found | WhatsApp not configured for this agent",
"data": [
"<unknown>"
]
}
{
"success": false,
"message": "The agentId field is required. | The phoneNumber field is required.",
"data": [
"<unknown>"
]
}
{
"success": false,
"message": "Failed to send WhatsApp message",
"data": [
"<unknown>"
]
}

Authorizations

Authorization
string
header
required

Use a Bearer token to access these API endpoints. Example: "Bearer {your-token}"

Body

application/json
agentId
string<uuid>
required

UUID of the Agent. Must exist and have WhatsApp configured.

Example:

"32d8fc98-be1e-4d32-a12e-146f397fb1cb"

templateId
string<uuid>
required

UUID of the approved WhatsApp template to send. You can get the templateId from the templates section.

Example:

"a1b2c3d4-e5f6-7890-abcd-ef1234567890"

phoneNumber
string
required

Phone number of the recipient in E.164 format (e.g., +1234567890).

Example:

"+12345678900"

parameters
object

Optional object containing parameters to fill template placeholders. Keys should be field1, field2, etc. corresponding to {{1}}, {{2}}, etc. in the template. Omit this field if template has no placeholders.

Example:
{
"field1": "John Doe",
"field2": "Order #12345",
"field3": "2024-01-15"
}
header
object

Optional header media definition. Supports image, video, or document with a publicly accessible URL.

Response

Success

success
boolean

Indicates whether the request completed successfully. True for successful responses; false for documented error responses.

Example:

true

message
string

Human-readable response message. Safe to display in logs or simple client notifications; use structured fields for program logic.

Example:

"WhatsApp template message sent successfully"

data
object