GetMessage#
The method returns the chat message.
Settings
To receive incoming messages you need to enable the Receive webhooks on incoming messages and files setting using the SetSettings method or through the console.
To receive messages sent prom phone you need to enable the Receive webhooks on messages sent from phone setting using the SetSettings method or through the console.
To receive the statuses of sent messages you need to enable the Receive notifications about the statuses of sent messages setting using the SetSettings method or through console
Messages sent and received before enabling these settings will not be included in the journal.
It may take up to 5 minutes for the settings to take effect.
The GetChatHistory method only returns the history that WhatsApp provides to the system.
The appearance of messages in the journal may take up to 2 minutes. Journal methods should only be used for retrieving chat history. For quicker message retrieval, use the notification system.
Request#
To get chat message, you have to execute a request at:
POST {{apiUrl}}/waInstance{{idInstance}}/getMessage/{{apiTokenInstance}}
For idInstance, apiTokenInstance and apiUrl request parameters, please refer to Before you start section.
Request parameters#
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
chatId | string | Yes | Personal or chat Id the message of which you need to get |
idMessage | string | Yes | Message ID |
Request body example#
message request:
{
"chatId": "79123456789@c.us",
"idMessage": "BAE5F4886F6F2D05"
}
Response#
The response contains a received or sent message in the chat.
Response parameters#
Object with parameters:
| Parameter | Type | Description |
|---|---|---|
type | string | Message type: outgoing - outgoing message; incoming - incoming message |
idMessage | string | Incoming message Id |
timestamp | integer | Message acceptance time in UNIX format |
statusMessage | string | Outgoing message status. Present only for type = outgoing. Possible variants: |
noAccount - no WhatsApp account on phone number | ||
pending - is sent | ||
sent - sent | ||
delivered - delivered | ||
read - read/seen/heard | ||
failed - An error occurred while sending the message to the WhatsApp server. Limits for sending template messages have been reached | ||
noActiveSession - 24-hour service window for sending service messages is not open | ||
sendByApi | boolean | Is the message sent through API. Present only for type = outgoing |
typeMessage | string | Message type, possible variants: |
textMessage - text message | ||
imageMessage - image message | ||
videoMessage - video message | ||
documentMessage - document message | ||
audioMessage - audio message | ||
reactionMessage - reaction message. Depreceted | ||
locationMessage - location message | ||
contactMessage - contact message | ||
contactsArrayMessage - message with contacts array | ||
chatId | string | Chat Id, where the message has been received |
senderId | string | Message sender Id. Present only for type = incoming |
senderName | string | Message sender name. Present only for type = incoming |
senderContactName | string | Obsolete |
textMessage | string | Text message, if typeMessage=textMessage |
downloadUrl | string | Link to download a file, if if typeMessage = imageMessage/videoMessage /documentMessage/audioMessage |
Response body example#
Examples of incoming message response bodies#
Text message#
{
"type": "incoming",
"idMessage": "9DB14F14A253D33F4A9CD84123456789",
"timestamp": 1706522263,
"typeMessage": "textMessage",
"chatId": "79123456789@c.us",
"textMessage": "Hi",
"senderId": "70000000012@c.us",
"senderName": "Rachel",
"senderContactName": "Rachel 2"
}
Document or media message#
{
"type": "incoming",
"idMessage": "EAAE5A5CD000000000",
"timestamp": 1706601620,
"typeMessage": "imageMessage", //"videoMessage"/`documentMessage`/`audioMessage`
"chatId": "79123456789@c.us",
"downloadUrl": "https://api.green-api.com/waInstance1234/downloadFile/EA1BD1AE042DC4F3609867126309D67C.jpg",
"caption": "What do you think?",
"fileName": "03963bac-6020-423c-80df-1aa123456789.jpg",
"jpegThumbnail": "/9j/4AAQSkZJ/aAAgBAwEBPwCVYw//xAApEAACAx/2kOVh/VKAoAH/leFhX//+AAMA/9k=",
"mimeType": "image/jpeg",
"isAnimated": false,
"isForwarded": true,
"forwardingScore": 1,
"senderId": "70000000012@c.us",
"senderName": "Rachel",
"senderContactName": "Rachel 2"
}
Location message#
{
"type": "incoming",
"idMessage": "3A8427EF85F000000000",
"timestamp": 1706674611,
"typeMessage": "locationMessage",
"chatId": "70000000012@c.us",
"location": {
"nameLocation": "Cafe",
"address": "Astana",
"jpegThumbnail": "/9j/4AAQSkZJRgABAQAASABIAAD/4QBYRX",
"latitude": 51.1280000000000,
"longitude": 71.4307620000000,
"forwardingScore": 0,
"isForwarded": false
},
"senderId": "70000000012@c.us",
"senderName": "Rachel",
"senderContactName": "Rachel 2"
}
Contact message#
{
"type": "incoming",
"idMessage": "3AA2C1D83560000000000",
"timestamp": 1706675513,
"typeMessage": "contactMessage",
"chatId": "70000000012@c.us",
"contact": {
"displayName": "Anastasia",
"vcard": "BEGIN:VCARD\nVERSION:3.0\nN:;Anastasia;;;\nFN:Anastasia\nTEL;type=CELL;type=VOICE;waid=70000000013:+7 000 000-00-13\nEND:VCARD",
"forwardingScore": 0,
"isForwarded": false
},
"senderId": "70000000012@c.us",
"senderName": "Rachel",
"senderContactName": "Rachel 2"
}
Contacts array message#
{
"type": "incoming",
"idMessage": "3AA2C1D83560000000000",
"timestamp": 1706675513,
"typeMessage": "contactsArrayMessage",
"chatId": "70000000012@c.us",
"messageData": {
"contacts": [
{
"displayName": "John Doe",
"vcard": "BEGIN:VCARD\nVERSION:3.0\nN:;John Doe;;;\nFN:John Doe\nORG:John Doe\nTITLE:\nTEL;type=Mobile:+7 912 345-56-78\nEND:VCARD",
"contextInfo": null
},
{
"displayName": "Jane Doe",
"vcard": "BEGIN:VCARD\nVERSION:3.0\nN:;Jane Doe;;;\nFN:Jane Doe\nTEL;type=Mobile;waid=79123456799:+7 912 345-67-99\nEND:VCARD",
"contextInfo": null
}
],
"forwardingScore": 0,
"isForwarded": false
},
"senderId": "70000000012@c.us",
"senderName": "Rachel",
"senderContactName": "Rachel 2"
}
Examples of outgoing message response bodies#
Text message#
{
"type": "outgoing",
"idMessage": "BAE5143000000000",
"timestamp": 1706761225,
"typeMessage": "textMessage",
"chatId": "70000000012@c.us",
"textMessage": "Hi",
"statusMessage": "read",
"sendByApi": true
}
Document or media message#
{
"type": "outgoing",
"idMessage": "BAE5F94000000000",
"timestamp": 1706765613,
"typeMessage": "imageMessage", //"videoMessage"/`documentMessage`/`audioMessage`
"chatId": "70000000012@c.us",
"downloadUrl": "https://api.green-api.com/waInstance1234/downloadFile/3EB0BDDC94BFDFB3D4FA.jpg",
"caption": "What do you think?",
"fileName": "b89ded5e-1a3b-4168-895a-540123456789.jpg",
"jpegThumbnail": "/9j/4AAQSkZJRgABAQAAAQABAAD/FFFCF//Z",
"mimeType": "image/jpeg",
"isAnimated": false,
"isForwarded": true,
"forwardingScore": 2,
"statusMessage": "read",
"sendByApi": false
}
Location message#
{
"type": "outgoing",
"idMessage": "BAE5870000000000",
"timestamp": 1706761414,
"typeMessage": "locationMessage",
"chatId": "70000000012@c.us",
"location": {
"nameLocation": "Cafe",
"address": "Astana",
"jpegThumbnail": "/9j/4AAQSkZJRgABAQAASABIAAD/4QBYRX",
"latitude": 51.1280000000000,
"longitude": 71.4307620000000,
"forwardingScore": 0,
"isForwarded": false
},
"statusMessage": "read",
"sendByApi": true
}
Contact message#
{
"type": "outgoing",
"idMessage": "F39F2DCE000000000",
"timestamp": 1706762400,
"typeMessage": "contactMessage",
"chatId": "70000000012@c.us",
"contact": {
"displayName": "Anastasia",
"vcard": "BEGIN:VCARD\nVERSION:3.0\nN:;Anastasia;;;\nFN:Anastasia\nTEL;type=CELL;type=VOICE;waid=70000000013:+7 000 000-00-13\nEND:VCARD",
"forwardingScore": 0,
"isForwarded": false
},
"statusMessage": "read",
"sendByApi": false
}
Contacts array message#
{
"type": "outgoing",
"idMessage": "3AA2C1D83560000000000",
"timestamp": 1706675513,
"typeMessage": "contactsArrayMessage",
"chatId": "70000000012@c.us",
"messageData": {
"contacts": [
{
"displayName": "John Doe",
"vcard": "BEGIN:VCARD\nVERSION:3.0\nN:;John Doe;;;\nFN:John Doe\nORG:John Doe\nTITLE:\nTEL;type=Mobile:+7 912 345-56-78\nEND:VCARD",
"contextInfo": null
},
{
"displayName": "Jane Doe",
"vcard": "BEGIN:VCARD\nVERSION:3.0\nN:;Jane Doe;;;\nFN:Jane Doe\nTEL;type=Mobile;waid=79123456799:+7 912 345-67-99\nEND:VCARD",
"contextInfo": null
}
],
"forwardingScore": 0,
"isForwarded": false
},
"statusMessage": "read",
"sendByApi": true
}
GetMessage errors#
For a list of errors common to all methods, refer to Common errors section
| HTTP code | Error identifier | Description |
|---|---|---|
| 400 | chatId not found | chatID is not found |
| 400 | ID message notfound | IDMessage is not found |
Request examples#
import requests
url = "{{apiUrl}}/waInstance{{idInstance}}/getMessage/{{apiTokenInstance}}"
payload = "{\r\n\"chatId\": \"79123456789@c.us\, \"idMessage\": \"BAE5F4886F6F2D05\" \"r\n}"
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data = payload)
print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/getMessage/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"chatId": "11001234567@c.us",
"idMessage": "BAE5F4886F6F2D05"
}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
.append({{apiUrl}})
.append("/waInstance").append({{idInstance}})
.append("/getMessage/")
.append({{apiTokenInstance}});
var headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
var jsonBody = "{\"chatId\": \"11001234567@c.us\",\"idMessage\": \"BAE5F4886F6F2D05\"}";
var requestEntity = new HttpEntity<>(jsonBody, headers);
var response = restTemplate.exchange(requestUrl.toString(), HttpMethod.POST, requestEntity, String.class);
System.out.println(response);
var requestUrl = new StringBuilder();
requestUrl
.append({{apiUrl}})
.append("/waInstance").append({{idInstance}})
.append("/getMessage/")
.append({{apiTokenInstance}});
var response = Unirest.post(requestUrl.toString())
.header("Content-Type", "application/json")
.body("{\"chatId\": \"11001234567@c.us\",\"idMessage\": \"BAE5F4886F6F2D05\"}")
.asString();
System.out.println(response);
Sub GetMessage()
Dim url As String
Dim RequestBody As String
Dim http As Object
Dim response As String
' The idInstance and apiTokenInstance values are available in your account, double brackets must be removed
url = "{{apiUrl}}/waInstance{{idInstance}}/getMessage/{{apiTokenInstance}}"
' chatId - identifier of the personal chat whose message you want to receive, idMessage - message ID
RequestBody = "{""chatId"":""71234567890@c.us"",""idMessage"":""BAE123EEF6BD09C7""}"
Set http = CreateObject("MSXML2.XMLHTTP")
With http
.Open "POST", url, False
.setRequestHeader "Content-Type", "application/json"
.send RequestBody
End With
response = http.responseText
Debug.Print response
' Outputting the answer to the desired cell
Range("A1").Value = response
Set http = Nothing
End Sub