Send Message via Viber API
- URL:
https://api.nxcloud.com/saas/viber/send
- Method:
POST
- Content-Type:
application/json
- Requires Authentication:
Yes
Authentication Mechanism
Refer to the following URL for authentication rules: API Call Guidelines
Request Parameters
Header Parameters:
Parameter |
Type |
Required |
Example |
Description |
accessKey |
String |
Yes |
fme2na3kdi3ki |
User identity key |
ts |
String |
Yes |
1655710885431 |
Current request timestamp (in milliseconds), with a maximum allowed difference of 60 seconds from the server time |
bizType |
String |
Yes |
7 |
Viber business type, fixed value “7” |
action |
String |
Yes |
mt |
Viber business operation, fixed value “mt” |
sign |
String |
Yes |
6e9506557d1f289501d333ee2c361111 |
API request signature, as per the general guidelines |
Body Parameters:
Parameter |
Type |
Required |
Example |
Description |
tenant_id |
Long |
Yes |
1 |
Tenant ID |
appkey |
String |
Yes |
pem28kje |
Application appkey |
to |
String |
Yes |
86158xxxx1795 |
Recipient's Viber number, must include country code, e.g., 86158xxxx1795 |
type |
String |
Yes |
1 |
Type of message being sent: Text Image Text + Image Text + Button Text + Image + Button |
filename |
String |
No |
- |
Required when the message includes an image. |
fileUrl |
String |
No |
- |
Media file URL, required when the message includes an image. |
content |
String |
No |
- |
Required when the message includes text. |
viber_video_button_info |
Object |
No |
- |
Required when the message includes a button. |
Message Types:
- 1: Text
- 3: Image
- 10: Text + Image
- 12: Text + Button
- 11: Text + Image + Button
viber_video_button_info
parameters:
Parameter |
Type |
Required |
Example |
Description |
button_text |
String |
No |
- |
Button text, required when type is 11/12 |
button_link |
String |
No |
- |
Button link, required when type is 11/12 |
Request Examples
Text Message
{
"tenant_id": 123,
"appkey": "Exxx",
"to": "86137xxxx",
"type": 1,
"content": "Sample text message"
}
Image Message
{
"tenant_id": 123,
"appkey": "Exxx",
"to": "86137xxxx",
"type": 3,
"filename": "7PSg8pGsIuWfHJZ.jpg",
"fileUrl": "https://nxtele-hk.oss-cn-hongkong.aliyuncs.com/6.5M.jpeg?Expires=1706089776&OSSAccessKeyId=TMP.3KhCyAyQVWhZt6N1prT69KjWMhXRDFQ5Ad5bj4BNkAx8TC3RuvXofqDdgunV9gQtDJk91X8n7kuypNJRBTJPhtqTcViaa5&Signature=%2FHvdJziTm2eaeqvTW7Y5VVxA5ZA%3D"
}
Text + Image
{
"tenant_id": 123,
"appkey": "Exxx",
"to": "86137xxxx",
"type": 10,
"filename": "7PSg8pGsIuWfHJZ.jpg",
"fileUrl": "https://s2.loli.net/2024/01/24/7PSg8pGsIuWfHJZ.jpg",
"content": "Text with image"
}
Text + Button
{
"tenant_id": 123,
"appkey": "Exxx",
"to": "86137xxxx",
"type": 12,
"content": "Text with a button",
"viber_video_button_info": {
"button_text": "Button text",
"button_link": "https://www.example.com"
}
}
Text + Image + Button
{
"tenant_id": 123,
"appkey": "Exxx",
"to": "86137xxxx",
"type": 11,
"filename": "7PSg8pGsIuWfHJZ.jpg",
"fileUrl": "https://s2.loli.net/2024/01/24/7PSg8pGsIuWfHJZ.jpg",
"content": "Text with image and button",
"viber_video_button_info": {
"button_text": "Button text 1",
"button_link": "https://www.example.com"
}
}
Response Parameters
Parameter |
Type |
Description |
code |
Integer |
Response code |
data |
JsonObject |
Result data |
message |
String |
Response message |
traceId |
String |
Trace ID |
Parameter |
Type |
Description |
message_id |
String |
Message ID |
Response Examples
Success Response
{
"code": 0,
"message": "",
"data": {
"message_id": "gBGGhSNXV1dfAglVQ0RRuE3YWhc"
},
"traceId": "56bf81643292cd6a89ecde64ae00db13"
}
Failure Response
{
"code": -1,
"message": "Failure",
"traceId": "77f8709b545f4fee93fd7f098be9df04"
}
Response Code Explanations
Code |
Message |
Solution |
0 |
Success |
- |
-1 |
Failure |
Contact technical support |
1000~100X |
Authentication failed |
Refer to the API authentication section |
1100 |
Customer does not exist / Status is unavailable |
Account issue, contact support |
1102 |
Insufficient balance |
Insufficient balance, contact support |
9000 |
Request parameter error |
Check for missing parameters |
9001 |
System business error |
Contact technical support |
9002 |
Phone number error |
Invalid number, check the number |
9003 |
Customer APP does not exist / Status is unavailable |
Application issue, contact support |
9004 |
Customer APP does not have quotation |
Application quotation missing, contact support |
9005 |
Missing customer APP routes |
Routing issue, contact technical support |
9011 |
Customer APP quotation currency error |
Quotation currency issue, contact technical support |
9999 |
Unknown error |
Contact technical support |