GetMessage#
The method returns a chat message.
The method uses limits on the request rate per second.
Request#
To get a message, you need to execute a request at:
POST
{{apiUrl}}/waInstance{{idInstance}}/getMessage/{{apiTokenInstance}}
To get the apiUrl, idInstance and apiTokenInstance request parameters, refer to the Before you start section.
Request parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
chatId | string | Yes | Identifier of the personal or group chat whose message you need to get |
idMessage | string | Yes | Message ID |
Request body example#
A message request:
{
"chatId": "10000000",
"idMessage": "1769676078000"
}
Response#
Response fields#
| Field | Type | Description |
|---|---|---|
type | string | Message kind: - outgoing - an outgoing message; - incoming - an incoming message |
idMessage | string | Identifier of the incoming message |
timestamp | integer | Time the message was received in UNIX format |
statusMessage | string | Status of the outgoing message. Only for type = outgoing. Possible values: - delivered - delivered- read - read/viewed/listened to |
sendByApi | boolean | Flag indicating sending through the API. Only for type = outgoing |
typeMessage | string | Message type, possible values: textMessage/imageMessage/videoMessage /documentMessage/ audioMessage/pollMessage/locationMessage |
chatId | string | Chat identifier the message was received in. |
chatType | string | Chat type. Possible values: "user", "group", "supergroup", "channel", "bot" |
senderName | string | Name of the message sender. Only for type = incoming |
senderType | string | Sender type. Possible values: "user", "group", "supergroup", "channel", "bot". Only for type = incoming |
senderContactName | string | Sender name from the phone book contact list. Only for type = incoming |
isForwarded | boolean | Flag of a forwarded message, true/false |
forwardingScore | integer | Number of times the message has been forwarded |
textMessage | string | Message text, if typeMessage=textMessage |
downloadUrl | string | Link to download the file, if typeMessage = imageMessage /videoMessage/documentMessage/audioMessage |
caption | string | File caption, if typeMessage = imageMessage/videoMessage /documentMessage/ audioMessage |
fileName | string | File name, if typeMessage = imageMessage/videoMessage /documentMessage / audioMessage |
jpegThumbnail | string | Image preview in base64 encoding, if typeMessage = imageMessage/videoMessage/documentMessage , audioMessage |
mimeType | string | File type, according to the Media Types classification, if typeMessage = imageMessage/videoMessage/documentMessage/ audioMessage |
isAnimated | boolean | Flag of an animated file, true/false.Present if typeMessage = imageMessage/videoMessage/documentMessage/audioMessage |
Response body example#
Response body examples for an incoming message#
Text message#
{
"type": "incoming",
"idMessage": "1769676078000",
"timestamp": 1769676078,
"typeMessage": "textMessage",
"chatId": "10000000",
"chatType": "user",
"textMessage": "I use GREEN-API to send this message!",
"senderId": "10000000",
"senderName": "Vasilisa the Wise",
"senderType": "user",
"senderContactName": "Vasilisa the Wise",
"deletedMessageId": "",
"editedMessageId": "",
"isEdited": false,
"isDeleted": false
}
Message with a document or media#
{
"type": "incoming",
"idMessage": "1769676078000",
"timestamp": 1706601620,
"typeMessage": "imageMessage", //"videoMessage"/`documentMessage`/`audioMessage`/`stickerMessage`
"chatId": "-10000000000000",
"chatType": "supergroup",
"downloadUrl": "https://4100.api.green-api.com/download/4100/609867126309D67C.jpg",
"caption": "How do you like it?",
"fileName": "1706601620.jpg",
"jpegThumbnail": "/9j/4AAQSkZJ/aAAgBAwEBPwCVYw//xAApEAACAx/2kOVh/VKAoAH/leFhX//+AAMA/9k=",
"mimeType": "image/jpeg",
"isAnimated": false,
"isForwarded": true,
"forwardingScore": 1,
"senderId": "100000000",
"senderName": "Vasilisa the Wise",
"senderType": "user",
"senderContactName": "Vasilisa",
"videoNote": true,
"isEdited": false,
"isDeleted": false
}
Message with a video#
The
videoNotefield takes the valuetruefor an instant video message andfalsefor a regular video message
{
"type": "incoming",
"idMessage": "1769676078000",
"timestamp": 1741243696,
"typeMessage": "videoMessage",
"chatId": "100000000",
"chatType": "bot",
"downloadUrl": "https://4100.api.green-api.com/download/4100/609867126309D67C.92c70.mp4",
"caption": "",
"fileName": "1741243696.mp4",
"jpegThumbnail": "",
"mimeType": "video/mp4",
"isAnimated": false,
"isForwarded": false,
"forwardingScore": 0,
"senderId": "100000000",
"senderName": "Ivan Tsarevich",
"senderType": "bot",
"senderContactName": "Ivan",
"videoNote": true,
"editedMessageId": "",
"deletedMessageId": "",
"videoNote": true,
"isEdited": false,
"isDeleted": false
},
Message with a reaction#
{
"type": "incoming",
"idMessage": "1769676078000",
"timestamp": 1706601621,
"typeMessage": "reactionMessage",
"chatId": "100000000",
"chatType": "user",
"extendedTextMessageData": {
"text": "😄"
},
"quotedMessage": {
"stanzaId": "1769680453000",
"participant": "100000000"
},
"senderId": "70000000013@c.us",
"senderName": "Vasilisa the Wise",
"senderType": "user",
"senderContactName": "Vasilisa"
}
Message with a location#
{
"type": "incoming",
"idMessage": "1769676078000",
"timestamp": 1706674611,
"typeMessage": "locationMessage",
"chatId": "100000000",
"chatType": "user",
"location": {
"latitude": 51.128,
"longitude": 71.430762,
"forwardingScore": 0,
"isForwarded": false
},
"senderId": "100000000",
"senderName": "Vasilisa the Wise",
"senderType": "user",
"senderContactName": "Vasilisa"
}
Message with a contact#
{
"type": "incoming",
"idMessage": "1769676078000",
"timestamp": 1706675513,
"typeMessage": "contactMessage",
"chatId": "100000000",
"chatType": "user",
"contact": {
"chatId": "",
"displayName": "Ivan Tsarevich",
"vcard": "BEGIN:VCARD\nVERSION:3.0\nN:;Ivan Tsarevich;;;\nFN:Ivan Tsarevich\nTEL;type=CELL;type=VOICE;waid=70000000013:+7 000 000-00-13\nEND:VCARD",
"forwardingScore": 0,
"isForwarded": false
},
"senderId": "100000000",
"senderName": "Vasilisa the Wise",
"senderType": "user",
"senderContactName": "Vasilisa"
}
Response body examples for an outgoing message#
Text message#
{
"type": "outgoing",
"idMessage": "1769676078000",
"timestamp": 1755178760,
"typeMessage": "textMessage",
"chatId": "10000000",
"chatType": "user",
"textMessage": "I use GREEN-API to send this message!",
"statusMessage": "delivered",
"sendByApi": true,
"deletedMessageId": "",
"editedMessageId": "",
"isEdited": false,
"isDeleted": false
}
Media and file messages#
{
"type": "outgoing",
"idMessage": "1769676078000",
"timestamp": 1706765613,
"typeMessage": "imageMessage", //"videoMessage"/`documentMessage`/`audioMessage`/`stickerMessage`
"chatId": "100000000",
"chatType": "user",
"downloadUrl": "https://4100.api.green-api.com/download/4100/3EB0BDDC94BFDFB3D4FA.jpg",
"caption": "How do you like it?",
"fileName": "1706765613.jpg",
"jpegThumbnail": "/9j/4AAQSkZJRgABAQAAAQABAAD/FFFCF//Z",
"mimeType": "image/jpeg",
"isAnimated": false,
"isForwarded": true,
"forwardingScore": 2,
"statusMessage": "read",
"sendByApi": false,
"deletedMessageId": "",
"editedMessageId": "",
"isEdited": false,
"isDeleted": false
}
Message with a reaction#
{
"type": "outgoing",
"idMessage": "1769676078000",
"timestamp": 1706601621,
"typeMessage": "reactionMessage",
"chatId": "100000000",
"chatType": "user",
"extendedTextMessageData": {
"text": "😄"
},
"quotedMessage": {
"stanzaId": "1769680453000",
"participant": "100000000"
},
"statusMessage": "read",
"sendByApi": false
}
Message with a location#
{
"type": "outgoing",
"idMessage": "1769676078000",
"timestamp": 1706761414,
"typeMessage": "locationMessage",
"chatId": "100000000",
"chatType": "user",
"location": {
"latitude": 51.128,
"longitude": 71.430762,
"forwardingScore": 0,
"isForwarded": false
},
"statusMessage": "read",
"sendByApi": true,
"deletedMessageId": "",
"editedMessageId": "",
"isEdited": false,
"isDeleted": false
}
Message with a contact#
{
"type": "outgoing",
"idMessage": "1769676078000",
"timestamp": 1706762400,
"typeMessage": "contactMessage",
"chatId": "100000000",
"chatType": "user",
"contact": {
"chatId": "",
"displayName": "Ivan Tsarevich",
"urlAvatar": "",
"phoneNumber": 79876543210,
"vcard": "BEGIN:VCARD\nVERSION:3.0\nN:;Ivan Tsarevich;;;\nFN:Ivan Tsarevich\nTEL;type=CELL;type=VOICE;waid=70000000013:+7 000 000-00-13\nEND:VCARD",
"forwardingScore": 0,
"isForwarded": false
},
"statusMessage": "read",
"sendByApi": false,
"deletedMessageId": "",
"editedMessageId": "",
"isEdited": false,
"isDeleted": false
}
Errors#
For the list of errors common to all methods, see the Common errors section
| HTTP code | Error identifier | Description |
|---|---|---|
| 400 | Bad RequestValidation failed | Validation error |
| 400 | Validation failed.Details: 'idMessage' is not allowed to be empty | The idMessage field must not be empty |
| 400 | Validation failed.Details: 'message id' must be at least 16 symbols | The idMessage field must contain at least 16 characters |
| 400 | chatId not found | The chat was not found. Possible reasons: 1. The message is still in the message queue and the system has not managed to process it. You can request the ShowMessagesQueue method to check the messages. |
| 400 | Message not found by id '{{idMessage}}' | The message was not found. Possible reasons: 1. The message is still in the message queue and the system has not managed to process it. You can request the ShowMessagesQueue method to check the messages. 2. The chat, message number or the instance the message is requested on is specified incorrectly. |
Code examples#
import requests
url = "{{apiUrl}}/waInstance{{idInstance}}/getMessage/{{apiTokenInstance}}"
payload = {
"chatId": "10000000",
"idMessage": "1769676078000"
}
headers = {'Content-Type': 'application/json'}
response = requests.post(url, json=payload)
print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/getMessage/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"chatId": "10000000",
"idMessage": "1769676078000"
}'
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\": \"10000000\",\"idMessage\": \"1769676078000\"}";
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\": \"10000000\",\"idMessage\": \"1769676078000\"}")
.asString();
System.out.println(response);
Sub GetMessage()
Dim url As String
Dim RequestBody As String
Dim http As Object
Dim response As String
' The apiUrl, idInstance and apiTokenInstance values are available in console, double brackets must be removed
url = "{{apiUrl}}/waInstance{{idInstance}}/getMessage/{{apiTokenInstance}}"
' chatId - identifier of the personal or group chat whose message you want to receive, idMessage - message ID
RequestBody = "{""chatId"":""10000000"",""idMessage"":""1769676078000""}"
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