API Management

Send WhatsApp Message – Mercuri API

Endpoint

POST https://api.mercuri.cx/v1/send_message
  • The API endpoint to send WhatsApp messages.


Headers

{
 'Content-Type': 'application/json',
 'Authorization': `Bearer ${bearerToken}`
}
  • Content-Type → JSON format for the request body.

  • Authorization → Use your Mercuri API token .


Request (Payload)

Request (Payload)
{
   "phoneNumberId":"635894262943892",
    "channel":"whatsapp",
    "recipient":"+918971476855",
    "message":{
        "type":"template",
        "template":{
            // "templateId":"1777667316490397",
            "templateId":"2020796801660936",
            "parameters":[
                {
                    "otpCode":"112233",
                    "businessPhoneNumber":"+919986347648"
                    // "firstName" : "JJ",
                    // "lastName" : "Thomson",
                    // "businessName" : "Mercuri",
                    // "orderNumber" : "100ABCD45",
                    // "orderTotal" : "1000",
                    // "productImageUL" : "https://static.wixstatic.com/media/34f0c8_101765cede714e4b8fe3291be9e5acbb~mv2.png/v1/fill/w_290,h_290,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/34f0c8_101765cede714e4b8fe3291be9e5acbb~mv2.png",
                    // "expirationTime":"2025-07-24T09:55:28.613Z",
                    // "couponCode":"ABCD35"
                }
            ]
        }
    },
    "country":"US",
    "saveToInbox":true
}
}

Field Descriptions:

Field
Description

phoneNumberId

WhatsApp Business/ SMS number ID (sender). Follow these steps to get your phone number ID.

channel

"whatsapp"or"sms"

recipient

Customer’s phone number (receiver)

message.type

"template" – type of message

message.template.templateId

Approved WhatsApp/SMS template ID. Follow these steps to get your template ID.

message.template.parameters

array of object fields (OTP, names, order info, etc.)

country

Customer’s country code. If the recipient phone number does not include a country code, Mercuri will default to this country code (e.g., "US").

saveToInbox

true to save message in Mercuri inbox


Response

Status: 422
 { 
    "messageId": null, 
    "status": "failed", 
    "errorCode": "VALIDATION_FAILED", 
    "errors": [ 
        { 
            "code": "INVALID_RECIPIENT_PHONE_NUMBER", 
            "message": "Invalid recipient phone number: 9901758738 (country: US)." 
        } 
    ] 
}
Status: 422
{ 
    "messageId": null, 
    "status": "failed", 
    "errorCode": "VALIDATION_FAILED", 
    "errors": [ 
        { 
            "code": "INVALID_REQUEST_PAYLOAD", 
            "message": "message.template.parameters: Invalid input: expected array, received 
object" 
        } 
    ] 
} 
 
{ 
    "messageId": null, 
    "status": "FAILED", 
    "errorCode": "VALIDATION_FAILED", 
    "errors": [ 
        { 
            "code": "INVALID_REQUEST_PAYLOAD", 
            "message": "message.template.templateId: Invalid input: expected string, received 
undefined" 
        } 
    ] 
} 
Status: 400
{ 
    "messageId": null, 
    "status": "failed", 
    "errorCode": "API_TRIGGER_FAILED", 
    "errors": [ 
        { 
            "code": "WHATSAPP_TEMPLATE_NOT_FOUND", 
            "message": "WhatsApp template not found." 
        } 
    ] 
} 
// Some code

Flow Overview

  1. Your system prepares the payload with dynamic customer/order info.

  2. Sends a POST request to the Mercuri API.

  3. Mercuri processes the payload and delivers the message.

  4. API returns a response to your system for tracking success/error.



Last updated