Send a WhatsApp Template Message
    • Dark
      Light
    • PDF

    Send a WhatsApp Template Message

    • Dark
      Light
    • PDF

    Article summary

    Post
    /api/apps/public/{appId}/templateMessage

    Send template messages via WhatsApp to targeted contacts directly from your workspace using this endpoint. It supports only WhatsApp Cloud App and WhatsApp Sandbox App. To get the valid endpoint URL for sending template messages in your workspace,

    • Go to Administration > Apps > Marketplace
    • Search for WhatsApp Cloud app
    • Navigate to App Info > Details > POST templateMessage.
    • Copy the endpoint URL for sending template messages in your workspace. The URL also includes the appId.
    Path parameters
    appId
    stringRequired



    Body parameters

    We strongly recommend including the + prefix for all phone numbers in the payload. While you can submit numbers without the leading + sign, we have encountered cases where WhatsApp will return an invalid response despite the number being in use.

    Expand All
    object
    Example{ "phoneNumbers": [ "2368106035555" ], "connectedWhatsAppNo": "104920685899299", "template": { "name": "ship", "language": { "code": "en", "policy": "deterministic" }, "components": [ { "type": "body", "parameters": [ { "type": "text", "text": "20" } ] } ] } }
    phoneNumbers
    Array of string Required

    Recipient WhatsApp IDs where you want to send the template message. You can validate a WhatsApp id from here.

    string 
    connectedWhatsAppNo
    string Required

    The WhatsApp Number from which you want to send this template message. The WhatsApp number connected to your workspace via the app.

    targetAgent
    string 

    Username of the agent you want to transfer the chat to when the WhatsApp user replies.

    targetDepartment
    string 

    Department name or ID where you want to transfer the chat to when the WhatsApp user replies.

    template
    objectRequired

    Provide information about the template message you wish to send. Refer to Message Templates and Sending WhatsApp template messages from your workspace for template examples.

    namespace
    string 
    name
    string 
    language
    object
    code
    string 
    policy
    string 
    components
    Array of object 
    object
    type
    string 
    parameters
    Array of object 
    object
    type
    string 
    text
    string 
    Responses
    200

    OK

    Success
    {
      "success": true
    }
    object
    success
    boolean 
    400

    Bad Request

    Too many phone numbers
    {
      "success": false,
      "error": "Too many phone numbers! Please make sure that phoneNumbers are <= 250"
    }
    Agent Not Found
    {
      "success": false,
      "error": "No Agent found with username abc98"
    }
    Department Not Found
    {
      "success": false,
      "error": "No Department found with id/Name SalesDepartment"
    }
    Invalid WhatsApp Contact
    {
      "success": false,
      "error": "Connected WhatsApp Number (connectedWhatsAppNo) i.e. 565412001234 is not a valid WhatsApp contact. Contact Status is invalid"
    }
    Invalid Connected WhatsApp Number
    {
      "success": false,
      "error": "Error! Connected WhatsApp Number (connectedWhatsAppNo) i.e. 565412001234 has not been registered yet on Rocket.Chat. Please goto #omnichannel-whatsapp-setup channel and connect this WhatsApp number first there before sending this request again."
    }
    object
    success
    boolean 
    error
    string 
    401

    Unauthorized

    Authorization Error
    {
      "status": "error",
      "message": "You must be logged in to do this."
    }
    object
    status
    string 
    message
    string 
    403

    Forbidden

    Permission Error
    {
      "success": false,
      "error": "User does not have the permissions required for this action [error-unauthorized]"
    }
    object
    success
    boolean 
    error
    string 

    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.