Messenger API Documentation
Send Message
Initiate Messenger message sending service via API.
- URL:
https://api.nxcloud.com/v1/messenger/mt
- Method:
POST
- Content-Type:
application/json
- Requires authentication: Yes
Authentication Mechanism
Please refer to the following link for authentication rules: API Interface Calling Convention
Request Parameters
Parameter |
Type |
Required |
Description |
pageId |
String |
Yes |
Public page ID |
recipientId |
String |
Yes |
Recipient ID |
functionType |
String |
Yes |
Message type |
messageData |
Object |
Yes |
Message body parameters |
appkey |
String |
Yes |
Application unique identifier |
functionType Message Type Description
Type |
Description |
Required Parameters |
text |
Text |
messageData{rateType=Message, text cannot be empty} |
image |
Image |
messageData{rateType=Message, image cannot be empty} |
audio |
Audio |
messageData{rateType=Message, url cannot be empty} |
video |
Video |
messageData{rateType=Message, url cannot be empty} |
template |
Regular template |
messageData{rateType=Message, title cannot be empty} |
button_template |
Button template |
messageData{rateType=Message, text/elements cannot be empty} |
messageData Message Body Parameter Description
Parameter |
Type |
Required |
Description |
rateType |
String |
Yes |
Billing type (Message) |
text |
String |
No |
Text content |
url |
String |
No |
URL (image/audio/video URL depending on functionType) |
type |
String |
No |
Type (specific to functionType=template, generic/button) |
elements |
Array |
No |
Elements array |
rateType Billing Type Description
Type |
Description |
Message |
Message |
elements Element Parameter Description
Parameter |
Type |
Required |
Description |
title |
String |
No |
Title (required when type=generic) |
subtile |
String |
No |
Subtitle |
imageUrl |
String |
No |
Image URL |
buttons |
Array |
Yes |
Buttons array (required when type=button) |
buttons Button Parameter Description
Parameter |
Type |
Required |
Description |
type |
String |
Yes |
Type (web_url/postback) |
url |
String |
Yes |
Redirect URL |
title |
String |
Yes |
Button name |
Request Examples
Send Text Message
{
"appkey": "your_app_key",
"pageId": "your_page_id",
"recipientId": "recipient_id",
"functionType": "text",
"messageData": {
"text": "Hello World!",
"rateType": "Promotional"
}
}
Send Image Message
{
"appkey": "your_app_key",
"pageId": "your_page_id",
"recipientId": "recipient_id",
"functionType": "image",
"messageData": {
"url": "your_url",
"rateType": "Message"
}
}
Send Audio Message
{
"appkey": "your_app_key",
"pageId": "your_page_id",
"recipientId": "recipient_id",
"functionType": "audio",
"messageData": {
"url": "your_audio_url",
"rateType": "Message"
}
}
Send Video Message
{
"appkey": "your_app_key",
"pageId": "your_page_id",
"recipientId": "recipient_id",
"functionType": "video",
"messageData": {
"url": "your_video_url",
"rateType": "Message"
}
}
Send Regular Template Message
{
"appkey": "your_app_key",
"pageId": "your_page_id",
"recipientId": "recipient_id",
"functionType": "template",
"messageData": {
"elements": [
{
"title": "Welcome!",
"image_url": "https://example.com/image.jpg",
"subtitle": "We have the right hat for everyone.",
"action": {
"type": "web_url",
"url": "https://www.example.com"
},
"buttons": [
{
"type": "web_url",
"url": "https://www.example.com",
"title": "View Website"
}
]
}
],
"type": "generic",
"rateType": "Message"
}
}
Send Button Template Message
{
"appkey": "your_app_key",
"pageId": "your_page_id",
"recipientId": "recipient_id",
"functionType": "button_template",
"messageData": {
"text": "button template",
"elements": [
{
"buttons": [
{
"type": "web_url",
"url": "https://www.example.com",
"title": "Visit Website"
},
{
"type": "postback",
"payload": "POSTBACK_PAYLOAD",
"title": "Callback Button"
}
]
}
],
"type": "button",
"rateType": "Message"
}
}
Response Parameters
Parameter |
Type |
Description |
code |
Integer |
Response code |
message |
String |
Response description |
data |
Object |
Response data |
traceId |
Object |
traceId |
Response Example
{
"code": 0,
"message": "Success",
"data": {
"requestId": "metamid.xxxx"
},
"traceId": "xxxx"
}
Error Code Description
Error Code |
Description |
0 |
Success |
9000 |
Parameter error |