Skip to main content

SendWhatsappMessage

To send message through a business phone.

Request Parameters

NameTypeDescriptionRequired
ActionstringActionNameYES
AccountIdintAccount IdYES
TostringTarget phone numberYES
TypestringMessage TypeYES
ContentstringMessage Content varies with Type (json in text)YES
BusinessPhonestringBusiness PhoneYES

Request Example

{
"Action": "SendWhatsappMessage",
"AccountId": 8899,
"BusinessPhone": "8615000579987",
"To": "447731688264",
"Type": "text",
"Content": "{\"body\":\"text-message-content\",\"preview_url\":false}"
}

Parameters of Text Messages

NameTypeDescriptionRequired
bodystringThe body of a text message can contain a URL or formatting elements. The formatting elements are described as follows. Bold: Bold text, for example, Your total is $10.50. Italics: Text that requires italics, such as Your total is $10.50. Underline: Text that requires strikethrough , for example, Your total is $10.50.YES
preview_urlbooleanWhether to enable URL preview. If true is set to enable URL preview, and false is set to disable URL preview. The URL must start with http:// or https:// and be followed by the link address information expressed in the domain name (the link address expressed in the IP address is not identified). URL preview is a message rendering feature supported by WhatsApp client side.NO

Types of Text Messages, Example JSON

{
"body": "text-message-content",
"preview_url": false
}

Parameters of Image Messages

NameTypeDescriptionRequired
linkstring(Either id or link) URL link of the image. It must be HTTP/HTTPS URLs.NO
idstring(Either id or link) Image storage ID, obtained after uploading the file through the Media interface.NO
captionstringDescription of imageNO

Types of Image Messages, Example JSON

{
"id": "5867096a-a9be-4a56-94d6-89377623b4ac",
"caption": "image test"
}

Parameters of Video Messages

NameTypeDescriptionRequired
linkstring(Either id or link) URL link of the video. It must be HTTP/HTTPS URLs.NO
idstring(Either id or link) Video storage ID, obtained after uploading the file through the Media interface.NO
captionstringDescription of videoNO

Types of Video Messages, Example JSON

{
"id": "5867096a-a9be-4a56-94d6-89377623b4ac",
"caption": "video test"
}

Parameters of Audio Messages

NameTypeDescriptionRequired
linkstring(Either id or link) URL link of the audio. It must be HTTP/HTTPS URLs.NO
idstring(Either id or link) Audio storage ID, obtained after uploading the file through the Media interface.NO

Types of Audio Messages, Example JSON

{
"id": "5867096a-a9be-4a56-94d6-89377623b4ac"
}

Parameters of Document Messages

NameTypeDescriptionRequired
linkstring(Either id or link) URL link of the document. It must be HTTP/HTTPS URLs.NO
idstring(Either id or link) Document storage ID, obtained after uploading the file through the Media interface.NO
filenamestringThe name of documentNO

Types of Document Messages, Example JSON

{
"id": "5867096a-a9be-4a56-94d6-89377623b4ac",
"filename": "document"
}

Parameters of Location Messages

NameTypeDescriptionRequired
latitudefloat64information of latitudeYES
longitudefloat64information of longtitudeYES
namestringname of fileNO
addressstringname of fileNO

Types of Location Messages, Example JSON

{
"latitude": 22.550802897696343,
"longitude": 113.93844723701477,
"name": "Los Angeles, CA",
"address": "Westwood Blvd"
}

Parameters of sticker Messages

NameTypeDescriptionRequired
linkstring(Either id or link) URL link of sticker. It must be HTTP/HTTPS URLs.NO
idstring(Either id or link) sticker storage ID, obtained after uploading the file through the Media interface.NO

Types of sticker, Example JSON

{
"id": "5867096a-a9be-4a56-94d6-89377623b4ac"
}

Parameters of Template Messages

NameTypeDescriptionRequired
namestringname of templateYES
languageLanguagesettings of template languageYES
components[]ComponentSequences of variable setting for components within templatesNO

Parameters of Language

NameTypeDescriptionRequired
codestringcode of languageYES
policystringThe fixed value is deterministicYES

Parameters of Component

NameTypeDescriptionRequired
typestringtype of component. It can be header,body,button
1)When type = header, set the variable information in the template header;
2)When type = body, set the variable information in the template content;
3)When type = button, set the variable information in the template button.
YES
sub_typestringThe type of button created. It is required only when type = button, and it can be url, quick_reply. If type is of other types, this parameter is unavailable.NO
indexstringThe position index of the button. It is required only when type = button. The serial number of the button is 0 to 2.NO
parameters[]Parameterlist of component parametersNO
Parameters
NameTypeDescriptionRequired
typestring1)When the type of component object = header, it can be text,image,video,document;
2)When the type of component object = body, the value is text;
3)When the type of component object = button and sub_type = url, the value is text;
4)When the type of component object = button and sub_type = quick_reply, the value is payload.
YES
textstringSet the text content of the corresponding parameter. It is required only when type = text. If type is of other types, this parameter is unavailable.NO
payloadstringSet the payload content of the corresponding parameter. The payload object is defined with reference to the video message. It is required only when type = payload. If type is of other types, this parameter is unavailable.NO
imageImageSet the image content of the corresponding parameter. The image object is defined with reference to the image message. It is required only when type = image. If type is of other types, this parameter is unavailable.NO
videoVideoSet the video content of the corresponding parameter. The video object is defined with reference to the video message. It is required only when type = video. If type is of other types, this parameter is unavailable.NO
documentDocumentSet the document content of the corresponding parameter. The ducument object is defined with reference to the document message. It is required only when type = document. If type is of other types, this parameter is unavailable.NO

Types of Verification Code Messages, Example JSON

{
"name": "otp_test_02",
"language": {
"policy": "deterministic",
"code": "zh_CN"
},
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "123456"
}
]
},
{
"type": "button",
"sub_type": "url",
"index": "0",
"parameters": [
{
"type": "text",
"text": "123456"
}
]
}
]
}

Types of Variable Template Messages, Example JSON

{
"name": "text_template",
"language": {
"code": "en_US",
"policy": "deterministic"
},
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "David"
},
{
"type": "text",
"text": "B520"
}
]
}
]
}

Types of Quick Reply Template Messages,Example JSON

{
"name": "xy_button_tempalte",
"language": {
"code": "en_US",
"policy": "deterministic"
},
"components": [
{
"type": "header",
"parameters": [
{
"type": "text",
"text": "header"
}
]
},
{
"type": "button",
"sub_type": "quick_reply",
"index": "0",
"parameters": [
{
"type": "payload",
"payload": "text1"
}
]
},
{
"type": "button",
"sub_type": "quick_reply",
"index": "1",
"parameters": [
{
"type": "payload",
"payload": "text2"
}
]
},
{
"type": "button",
"sub_type": "quick_reply",
"index": "2",
"parameters": [
{
"type": "payload",
"payload": "text3"
}
]
}
]
}

Response Parameters

NameTypeDescription
ActionstringSendWhatsappMessageResponse
RetCodeint0 for success Error Codes
MessagestringMessage
RequestIdstringRequest Id
DataobjectReturn data

Data Parameters

NameTypeDescription
MessageIdstringMessage Id

Response Example

{
"Action": "SendWhatsappMessageResponse",
"Data": {
"MessageId": "xxx"
},
"Message": "",
"RequestId": "8ea6c8f2-e23f-4816-9a48-243a40d66bfb",
"RetCode": 0
}