Channel token is required to access this API resource. Tokens can be generated by using the key icon, next to the desired channel in Settings.
Requests
The Messages API is composed of several type of requests:
This request sends a text message directly to the Contact as per defined in the Endpoint.
Copy POST /v1/message/sendContent/{contactId}
Sample POST Text Request
Copy curl -X POST \
https://app.heyx.io/api/v1/message/sendContent/{contactId} \
-H 'Authorization: Bearer {channel_token}' \
-H 'Content-Type: application/json' \
-d '{
"body": [
{
"type" : "text",
"text" : "Hi there"
}
]
}'
Response - Success (HTTP status → 200)
Copy {
"status": "Success",
"message": "Message Sent",
"data": []
}
Please note that in case of Viber Channel - due to a certain limitation - the Contact ID needs to be provided in a Base64 encoded format.
Send Attachment Request
This request sends attachment in form of URL directly to the Contact as per defined in the Endpoint. The file can either be image, video, audio or file.
Copy POST /v1/message/sendContent/{contactId}
Sample POST Send Image Request
Copy curl -X POST \
https://app.heyx.io/api/v1/message/sendContent/{contactId} \
-H 'Authorization: Bearer {channel_token}' \
-H 'Content-Type: application/json' \
-d '{
"body": [
{
"type" : "image",
"url" : "http://abc.com"
}
]
}'
Response - Success (HTTP status → 200)
Copy {
"status": "Success",
"message": "Message Sent",
"data": []
}
Sample POST Send Video Request
Copy curl -X POST \
https://app.heyx.io/api/v1/message/sendContent/{contactId} \
-H 'Authorization: Bearer {channel_token}' \
-H 'Content-Type: application/json' \
-d '{
"body": [
{
"type" : "video",
"url" : "http://abc.com"
}
]
}'
Response - Success (HTTP status → 200)
Copy {
"status": "Success",
"message": "Message Sent",
"data": []
}
Sample POST Send Audio Request
Copy curl -X POST \
https://app.heyx.io/api/v1/message/sendContent/{contactId} \
-H 'Authorization: Bearer {channel_token}' \
-H 'Content-Type: application/json' \
-d '{
"body": [
{
"type" : "audio",
"url" : "http://abc.com"
}
]
}'
Response - Success (HTTP status → 200)
Copy {
"status": "Success",
"message": "Message Sent",
"data": []
}
Sample POST Send File Request
Copy curl -X POST \
https://app.heyx.io/api/v1/message/sendContent/{contactId} \
-H 'Authorization: Bearer {channel_token}' \
-H 'Content-Type: application/json' \
-d '{
"body": [
{
"type" : "file",
"url" : "http://abc.com"
}
]
}'
Response - Success (HTTP status → 200)
Copy {
"status": "Success",
"message": "Message Sent",
"data": []
}
Send Text with Quick Replies Request
This request send text message with quick replies for the receivers.
Copy curl -X POST \
https://app.heyx.io/api/v1/message/sendContent/{contactId} \
-H 'Authorization: Bearer {channel_token}' \
-H 'Content-Type: application/json' \
-d '{
"body": [
{
"type":"quick_reply",
"title" : "What is you favorite color?",
"replies" : ["Black","Blue","Grey","Red"]
}
]
}'
Response - Success (HTTP status → 200)
Copy {
"status": "Success",
"message": "Message Sent",
"data": []
}
Error Codes
Unauthorized (HTTP Status → 401)
Copy {
"status": "error",
"message": "API Token is invalid.",
"data": []
}
Too Many Requests (HTTP Status → 429)
Copy {
"status": "error",
"message": "Too many requests",
"data": []
}
Method Not Allowed (HTTP Status → 405)
Copy {
"status": "error",
"message": "405 Method Not Allowed.",
"data": []
}
General (HTTP Status → 403)
Copy {
"status": "error",
"message": "Message String",
"data": []
}
Unmatched File Type (HTTP Status → 403)
Copy {
"status": "error",
"message": "Sorry, Url provided is not an image/audio/video file",
"data": []
}
Limitations
Only one message can be sent in 1 API call.
API has rate limit of 25 RPS.
10 Quick replies with 20 characters each are allowed.
Survey is not cancelled by default. forceCancelSurvey : true
must explicitly be sent in the payload.
Contact status will not be changed on API call.