Send Message
This API is used to send messages from the client system to the end user through various supported channels ( WhatsApp, Telegram, LINE, and Facebook Messenger )
Endpoint
URL : {base url}/{channel}/send/{clientID}
Method : POST
Headers : Auth-username: {username} and Auth-password: {password}
Request
This section describes the request parameters and provides examples of JSON requests used to send a message.
Description Parameter Request
FIELD | TYPE ALLOWED | DESCRIPTION | REQUIRED |
---|---|---|---|
id | String | Unique code from Message ID | Mandatory |
reply_id | String | Unique code from ID of the message being replied | Optional |
times | Integer | Format = Unix Timestamp from sending message | Mandatory |
timestamp | Timestamp | Format = Date Time from sending messages | Mandatory |
reply_token | String | Token for Telegram replies only | Optional |
recipient | String | Recipient's phone number | Mandatory |
type | String | Message type: text, image, video, audio, button, list, location | Mandatory |
body | JSON Object | For the message contained in the body | Optional |
text | String | Text message content ( for type text) | Mandatory |
media | JSON Object | For message type Media ( image, video, audio, voice, document) | Optional |
url | String | URL of the media file ( for type image/video/audio/voice/document) | Mandatory |
name | String | Display name of the media file ( for type image/video/audio/voice/document) | Optional |
location | JSON Object | For message type Location | Optional |
latitude | Float | Latitude coordinate (for type location) | Mandatory |
longitude | Float | Longitude coordinate (for type location) | Mandatory |
button | JSON Object | For the message contained in the button | |
key | String | Button ID received from the client and returned back when a postback is triggered by the client (for type button) | Mandatory |
title | String | Button label (for type button) | Mandatory |
list | JSON Object | For the message contained in the list | Optional |
title | String | Title of the list (for type list) | Mandatory |
sections | Array | selectable section | Mandatory |
title | String | Title of the list section | Mandatory |
description | String | Description of the list section | Mandatory |
actions | Array | selectable actions | Mandatory |
key | String | list ID received from the client and returned if there is a post back from the client. | Mandatory |
title | String | Name of the selected list action | Mandatory |
description | String | Description of the selected list action | Mandatory |
header | JSON Object | custom message in header for type button/list) | Optional |
type | String | Message type: text, image, video, document, | Mandatory |
text | String | Text header content ( for type text) | Mandatory |
media_url | String | URL of the media file for header ( for type image/video/document) | Mandatory |
footer | JSON Object | custom message in footer for type button/list) | Optional |
title | String | Title of the footer | Mandatory |
text | String | Text footer content | Mandatory |
Sample JSON Request
{
"id": "3c0b1912-xxxx-xxxx-xxxx-xxxxxxxxxx",
"reply_id": "",
"times": 0,
"timestampt": "2023-11-10T12:38:08.153726382+07:00",
"reply_token": "",
"recipient": "628xxxxxxxx",
//Type: text/image/video/audio/button/list/location
"type": "text",
"body": {
"text": "xxx xxxx xxxxx.",
// Type image/video/audio/voice/document
"media": {
"url": "",
"name": ""
},
// Type location
"location": {
"latitude": 0,
"longitude": 0
},
// Type button
"button": [{
"key": "btn1",
"title": "Button 1"
},
{
"key": "btn2",
"title": "Button 2"
},
{
"key": "btn3",
"title": "Button 3"
}
],
// Type list
"list": {
"title": "",
"sections": [{
"title": "Section 1",
"description": "Description section 1",
"actions": [{
"key": "sec1act1",
"title": "Action 1",
"description": "Description action 1"
},
{
"key": "sec1act2",
"title": "Action 2",
"description": "Description action 2"
},
{
"key": "sec1act3",
"title": "Action 3",
"description": "Description action 3"
}
]
}]
}
},
// special type button/list
"header": {
//Type: text/image/video/document
"type": "",
"text": "",
"media_url": ""
},
// special type button/list
"footer": {
"title": "",
"text": ""
}
}
Response
This section describes the response parameters and provides JSON response examples returned by the Konnek platform after a message is sent.
Description Parameter Response
FIELD | TYPE ALLOWED | DESCRIPTION |
---|---|---|
meta | JSON Object | Details information from meta |
status | Boolean | true = success,false = failed |
code | String | HTTP response status code |
message | String | Description of the result from the statusCode |
errors | String | Error message (if any) |
data | JSON Object | Detailed Information from the Message Sent |
message_id | String | ID of the message sent |
status | Integer | Message status: -3 Failed, -2 Undelivered, -1 Unsent, 0 Pending, 1 Sent, 2 Delivered, 3 Read |
tid | String | Transaction ID for message tracking |
Sample JSON Response
{
"meta": {
"status": true,
"code": 200,
"message": "OK",
"errors": null
},
"data": {
"message_id": "3c0b1912-xxx-xxxx-xxxx-xxxxxxxx",
"status": 0,
"tid": "b3d31d85-xxxx-xxxx-xxxx-xxxxxxxxx"
}
}