Send a WhatsApp template message from Emarsys

Prev Next
Post
/emarsys/sendwhatsapptemplate/{ENCRYPTED_STREAM_ID}

API that enables Emarsys automation workflows to send pre-approved WhatsApp templates to recipients. This specialized endpoint processes webhook data from Emarsys using a simplified flat key-value format, allowing seamless integration between Emarsys marketing automations and WhatsApp business messaging via CommBox.

Security
HTTP
Type bearer

JWT token for authentication. The token should be generated using the Secret Key provided in the CommBox Emarsys Module settings.

Path parameters
ENCRYPTED_STREAM_ID
stringRequired

The encrypted stream identifier for your WhatsApp channel in CommBox

Body parameters
basicTemplate

Basic text-only template

{
  "to": "9725551234",
  "templateName": "simple_notification",
  "template.language.code": "en"
}
templateWithBodyParams

Template with body parameters

{
  "to": "9725551234",
  "templateName": "multiple_params_in_body",
  "template.language.code": "en_GB",
  "body.1.value": "https://www.commbox.io",
  "body.2.value": "Product Launch",
  "body.3.value": "March 15th"
}
templateWithHeaderParam

Template with text header and body parameter

{
  "to": "9725551234",
  "templateName": "text_header_body",
  "template.language.code": "en",
  "header.type": "text",
  "header.value": "Important Update",
  "body.1.value": "Your order has shipped"
}
documentAttachment

Template with document attachment

{
  "to": "9725551234",
  "templateName": "document_template",
  "template.language.code": "en_US",
  "header.type": "document",
  "header.value": "https://www.example.com/resources/document.pdf",
  "header.filename": "product-catalog.pdf",
  "body.1.value": "Our latest catalog"
}
imageAttachment

Template with image attachment

{
  "to": "9725551234",
  "templateName": "image_template",
  "template.language.code": "en",
  "header.type": "image",
  "header.value": "https://www.example.com/images/product.jpg",
  "body.1.value": "Check out our new product!"
}
imageAttachmentWithMediaId

Template with image attachment using Media ID

{
  "to": "9725551234",
  "templateName": "image_template",
  "template.language.code": "en",
  "header.type": "image",
  "header.value": "913225593849516",
  "body.1.value": "Check out our new product!"
}
videoAttachment

Template with video attachment

{
  "to": "9725551234",
  "templateName": "video_template",
  "template.language.code": "en",
  "header.type": "video",
  "header.value": "https://www.example.com/videos/product-demo.mp4",
  "body.1.value": "Product demonstration"
}
videoAttachmentWithMediaId

Template with video attachment using Media ID

{
  "to": "9725551234",
  "templateName": "video_template",
  "template.language.code": "en",
  "header.type": "video",
  "header.value": "27f8b007-7750-418e-9852-b4f8b7f95b9f",
  "body.1.value": "Product demonstration"
}
documentAttachmentWithMediaId

Template with document attachment using Media ID

{
  "to": "9725551234",
  "templateName": "document_template",
  "template.language.code": "en",
  "header.type": "document",
  "header.value": "550197337025434",
  "header.filename": "file-sample_150kB.pdf",
  "body.1.value": "PDF document"
}
dynamicButton

Template with dynamic URL button

{
  "to": "9725551234",
  "templateName": "dynamic_url",
  "template.language.code": "en",
  "button.value": "https://www.commbox.io/support?user=12345",
  "body.1.value": "Click for support"
}
callButton

Template with Call a Phone Number button

{
  "to": "9725551234",
  "templateName": "Call_a_phone_num_btn",
  "template.language.code": "en"
}
multipleButtons

Template with Call and Visit Website buttons

{
  "to": "9725551234",
  "templateName": "Call_and_Visit_a_Website_btns",
  "template.language.code": "en"
}
staticUrlButton

Template with Static URL button

{
  "to": "9725551234",
  "templateName": "static_url",
  "template.language.code": "en",
  "body.1.value": "Your Name"
}
quickReplyButtons

Template with Quick Reply buttons

{
  "to": "9725551234",
  "templateName": "3 buttons",
  "template.language.code": "en",
  "body.1.value": "Your Name"
}
authTemplate

Authentication template with copy button

{
  "to": "9725551234",
  "templateName": "auth_template",
  "template.language.code": "en",
  "button.value": "COPY",
  "body.1.value": "455455"
}
createConversationObject

Template with conversation object creation

{
  "to": "9725551234",
  "templateName": "customer_support",
  "template.language.code": "en",
  "body.1.value": "Order #12345",
  "object.substreamid": 0,
  "object.statusid": 1,
  "object.content": "{\"orderId\":\"12345\"}",
  "object.user.uniqueid": "67890",
  "object.user.lastname": "Doe",
  "object.user.firstname": "John",
  "object.user.phone1": "9725551234",
  "object.user.email": "john.doe@example.com",
  "object.user.remarks": "Returning customer"
}
documentWithObjectData

Document template with conversation object creation

{
  "to": "9725551234",
  "templateName": "doc1",
  "template.language.code": "en",
  "header.type": "document",
  "header.value": "https://denverzoo.org/wp-content/uploads/2018/09/African-lion.pdf",
  "header.filename": "African-lion.pdf",
  "body.1.value": "hello",
  "object.substreamid": 0,
  "object.statusid": 1,
  "object.content": "{}",
  "object.user.uniqueid": "01234567",
  "object.user.lastname": "Doe",
  "object.user.firstname": "John",
  "object.user.phone1": "9725551234",
  "object.user.email": "john.doe@example.com",
  "object.user.remarks": "some remark for user"
}
scheduledMessage

Scheduled template message

{
  "to": "9725551234",
  "templateName": "reminder",
  "template.language.code": "en",
  "body.1.value": "appointment tomorrow",
  "schedule": 1739365010
}
object

Request schema for sending WhatsApp template messages. The minimal required parameters are to, templateName, and template.language.code. Additional parameters depend on the template structure and whether conversation objects should be created in CommBox.

to
string Required

The recipient's phone number with country code (no + symbol)

Example9725551234
templateName
string Required

The name of the approved WhatsApp template

Examplewelcome_message
template.language.code
string Required

The language code for the template

Exampleen
schedule
integer

Unix timestamp for scheduled message delivery (optional)

Example1739365010
header.type
string

Type of header content (if template has a header)

Valid values[ "text", "image", "document", "video" ]
Exampleimage
header.value
string

Content for the header (URL or Media ID)

Examplehttps://example.com/image.jpg
header.filename
string

Filename for document attachments (required for document headers)

Exampleproduct-catalog.pdf
body.1.value
string

Content for the first body placeholder

ExampleJohn
body.2.value
string

Content for the second body placeholder

ExamplePremium Plan
body.3.value
string

Content for the third body placeholder

ExampleMarch 15, 2025
button.value
string

Dynamic value for button (if template has dynamic buttons)

Examplehttps://example.com/support
object.substreamid
integer

The substream ID in CommBox (for conversation object creation)

Example0
object.statusid
integer

The status ID in CommBox (for conversation object creation)

Example1
object.content
string

Additional content for the conversation object (JSON string)

Example{"subject":"Welcome Message"}
object.user.uniqueid
string

Unique identifier for the user

Example12345678
object.user.lastname
string

User's last name

ExampleDoe
object.user.firstname
string

User's first name

ExampleJohn
object.user.phone1
string

User's phone number

Example9725551234
object.user.email
string

User's email address

Examplejohn.doe@example.com
object.user.remarks
string

Additional notes about the user

ExampleReturning customer
object

Request schema for sending WhatsApp template messages. The minimal required parameters are to, templateName, and template.language.code. Additional parameters depend on the template structure and whether conversation objects should be created in CommBox.

to
string Required

The recipient's phone number with country code (no + symbol)

Example9725551234
templateName
string Required

The name of the approved WhatsApp template

Examplewelcome_message
template.language.code
string Required

The language code for the template

Exampleen
schedule
integer

Unix timestamp for scheduled message delivery (optional)

Example1739365010
header.type
string

Type of header content (if template has a header)

Valid values[ "text", "image", "document", "video" ]
Exampleimage
header.value
string

Content for the header (URL or Media ID)

Examplehttps://example.com/image.jpg
header.filename
string

Filename for document attachments (required for document headers)

Exampleproduct-catalog.pdf
body.1.value
string

Content for the first body placeholder

ExampleJohn
body.2.value
string

Content for the second body placeholder

ExamplePremium Plan
body.3.value
string

Content for the third body placeholder

ExampleMarch 15, 2025
button.value
string

Dynamic value for button (if template has dynamic buttons)

Examplehttps://example.com/support
object.substreamid
integer

The substream ID in CommBox (for conversation object creation)

Example0
object.statusid
integer

The status ID in CommBox (for conversation object creation)

Example1
object.content
string

Additional content for the conversation object (JSON string)

Example{"subject":"Welcome Message"}
object.user.uniqueid
string

Unique identifier for the user

Example12345678
object.user.lastname
string

User's last name

ExampleDoe
object.user.firstname
string

User's first name

ExampleJohn
object.user.phone1
string

User's phone number

Example9725551234
object.user.email
string

User's email address

Examplejohn.doe@example.com
object.user.remarks
string

Additional notes about the user

ExampleReturning customer
Responses
200

Operation successful

{
  "status": "200",
  "description": "Operation successful",
  "response_time": "2024-08-06T07:51:52.258Z",
  "data": [
    {
      "recipient": "9725551234",
      "id": "gBEGlyVGZjUpAgmyuqAHfxbHmnQ",
      "status": 200,
      "object_id": 38383744
    }
  ]
}
Expand All
object
status
string

Status code as string

Example200
description
string

Human-readable description of the response

ExampleOperation successful
response_time
string

Timestamp of the response

Example2024-08-06T07:51:52.2581942Z
data
Array of object

Array of recipient results

object
recipient
string

Recipient's phone number

Example9725551234
id
string

Message ID from WhatsApp

ExamplegBEGlyVGZjUpAgmyuqAHfxbHmnQ
status
integer

Status code for this recipient

Example200
object_id
integer

CommBox conversation object ID (if created)

Example38383744
206

Partial success (some messages succeeded, some failed)

{
  "status": "206",
  "description": "Some messages failed",
  "response_time": "2024-08-06T07:51:52.258Z",
  "data": [
    {
      "recipient": "9725551234",
      "id": "gBEGlyVGZjUpAgmyuqAHfxbHmnQ",
      "status": 200,
      "object_id": 38383744
    },
    {
      "recipient": "9725559876",
      "status": 400,
      "failed": "invalid — Not a valid WhatsApp user"
    }
  ]
}
object
status
string

Status code as string

Example206
description
string

Human-readable description of the response

ExampleSome messages failed
response_time
string

Timestamp of the response

Example2024-08-06T07:51:52.2581942Z
data
Array

Array of recipient results (mix of success and failure)

OneOf
object
object
recipient
string
Example9725551234
id
string
ExamplegBEGlyVGZjUpAgmyuqAHfxbHmnQ
status
integer
Example200
object_id
integer
Example38383744
object
object
recipient
string
Example9725559876
status
integer
Example400
failed
string
Exampleinvalid — Not a valid WhatsApp user
400

Bad request, could not process the input data

{
  "status": "400",
  "description": "Missing parameter templateName",
  "response_time": "2024-08-06T07:51:52.258Z",
  "data": [
    {
      "recipient": "9725551234",
      "status": 400,
      "failed": "Missing required parameter"
    }
  ]
}
Expand All
object
status
string

Error status code as string

Example400
description
string

Human-readable description of the error

ExampleMissing parameter templateName
response_time
string

Timestamp of the response

Example2024-08-06T07:51:52.2581942Z
data
Array of object

Array of recipient error details

object
recipient
string

Recipient's phone number

Example9725551234
status
integer

Error status code

Example400
failed
string

Failure reason

ExampleMissing required parameter
401

Unauthorized - The supplied JWT credentials are not sufficient to access the resource

404

Not found - The requested resource is not found

429

Too Many Requests - Too many requests have been made in a short period of time (Throttling)

500

Server Error - The server could not return the representation due to an internal server error

501

Not Implemented - The requested operation is not supported