Skip to content

GetMessage#

Test

השיטה מחזירה את הודעת הצ'אט.

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 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

It may take up to 5 minutes for the settings to take effect.

To receive messages that were sent and received by your phone before connecting the instance, after saving the settings on the instance, you need to do logout and authorize again.

The GetMessage 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.

בַּקָשָׁה#

כדי לקבל הודעת צ'אט, עליך לבצע בקשה בכתובת

POST
{{apiUrl}}/waInstance{{idInstance}}/getMessage/{{apiTokenInstance}}
TEST

לפרמטרים של בקשת apiUrl, idInstance ו-apiTokenInstance, עיין ב לפני שמתחילים סָעִיף.

בקש פרמטרים#

פָּרָמֶטֶר סוּג הֶכְרֵחִי תֵאוּר
chatId string כֵּן זיהוי אישי או צ'אט את המסר שאתה צריך לקבל
idMessage string כֵּן מזהה הודעה

דוגמה לגוף תגובה#

בקשה להודעה:

{
  "chatId": "120363043968066561@g.us",
  "idMessage": "BAE5F4886F6F2D05"
}

תְגוּבָה#

התגובה מכילה הודעה שהתקבלה או נשלחה בצ'אט.

פרמטרי תגובה#

אובייקט עם פרמטרים::

פָּרָמֶטֶר סוּג הֶכְרֵחִי
type string סוג הודעה: יוצא - הודעה יוצאת; נכנסת - הודעה נכנסת
idMessage string מזהה הודעה נכנסת
timestamp integer זמן קבלת הודעה בפורמט UNIX
statusMessage string מצב הודעה יוצאת. הצג רק עבור 'סוג' = 'יוצא'. גרסאות אפשריות:
noAccount - אין חשבון WhatsApp במספר הטלפון
notInGroup - לא בקבוצה הזו
pending - נשלח
sent - נשלח
delivered - נמסר
read - קרא/ראה/שמע
yellowCard - השעיית שליחת הודעות עקב פעילות ספאם. הודעות שנשלחות לאחר קבלת הסטטוס נשמרות בתור לשליחה למשך 24 שעות. כדי להמשיך להפעיל את המופע, עליך לבצע א לְאַתחֵל של המקרה
sendByApi boolean האם ההודעה נשלחה דרך API. הצג רק עבור type = outgoing
typeMessage string סוג הודעה, גרסאות אפשריות:
textMessage - הודעת טקסט
imageMessage - הודעת תמונה
videoMessage - הודעת וידאו
documentMessage - הודעת קובץ מסמך
audioMessage - הודעת שמע
stickerMessage - הודעת מדבקה
reactionMessage - הודעת תגובה
locationMessage - הודעת מיקום
contactMessage - הודעת קשר
extendedTextMessage - קישור והודעה מקדימה
pollMessage - הודעת סקר
pollUpdateMessage - עדכון הודעת סקר. הצג רק עבור type = incoming
quotedMessage - הודעה מצוטטת
chatId string זיהוי צ'אט, היכן התקבלה ההודעה
senderId string שולח הודעה Id. הצג רק עבור type = incoming
senderName string שם שולח ההודעה. הצג רק עבור type = incoming
senderContactName string שם שולח ההודעה בהתאם לרשימת אנשי הקשר של החשבון הנוכחי. הצג רק עבור type = incoming
isForwarded boolean הדגל מציין אם ההודעה מועברת
forwardingScore integer מספר העברות ההודעות
textMessage string הודעת טקסט, אם typeMessage=textMessage/extendedTextMessage
downloadUrl string קישור להורדת קובץ, אם typeMessage = imageMessage/videoMessage /documentMessage/audioMessage/stickerMessage
caption string כיתוב קובץ, אם typeMessage = imageMessage/videoMessage /documentMessage/audioMessage/stickerMessage
fileName string שם הקובץ, אםtypeMessage = imageMessage/videoMessage /documentMessage/audioMessage/stickerMessage.השדה מולא נכון רק עבור typeMessage = documentMessage, במקרים אחרים שם הקובץ נוצר באופן אוטומטי
jpegThumbnail string base64-תצוגה מקדימה של תמונה מקודדת, אם typeMessage = imageMessage /videoMessage/documentMessage/audioMessage/stickerMessage
mimeType string סוג הקובץ לפי סוגי מדיה, if typeMessage = imageMessage /videoMessage/documentMessage/audioMessage/stickerMessage
isAnimated boolean הדגל מציין אם הקובץ מונפש, אם typeMessage = imageMessage/videoMessage/documentMessage/audioMessage/stickerMessage
location object אובייקט מבנה מיקום, אם typeMessage = locationMessage
contact object אובייקט מבנה קשר, אם typeMessage = contactMessage
extendedTextMessage object אובייקט הודעת טקסט (מתקדם), אם typeMessage = extendedTextMessage/quotedMessage
extendedTextMessageData object אובייקט נתוני הודעת תגובה, אם typeMessage = reactionMessage
pollMessageData object אובייקט מבנה נתונים של סקר, אם typeMessage = pollMessage/pollUpdateMessage
quotedMessage object אובייקט נתוני הודעה מצוטט, אם typeMessage = quotedMessage/reactionMessage

Parameters of location object:

Parameter Type Description
nameLocation string Location name
address string Location address
latitude double Location latitude
longitude double Location longitude
jpegThumbnail string base64-coded image preview
isForwarded boolean The flag indicates whether the message is forwarded
forwardingScore integer Number of message forwards

Parameters of contact object:

Parameter Type Description
displayName string Contact display name
vcard string VCard structure (contact visit card)
isForwarded boolean The flag indicates whether the message is forwarded
forwardingScore integer Number of message forwards

Parameters of extendedTextMessage object:

Parameter Type Description
text string Link text
description string Link description
title string Link title
previewType string Link preview type. previewType:None value is deprecated
jpegThumbnail string base64-coded image preview
stanzaId string Quoted message ID. Present only for typeMessage= quotedMessage
participant string Recipient/sender chat ID. Present only for typeMessage= quotedMessage
isForwarded boolean The flag indicates whether the message is forwarded
forwardingScore integer Number of message forwards

Parameters of extendedTextMessageData object:

Parameter Type Description
text string Reaction (emoji) to a message

Parameters of pollMessageData object:

Parameter Type Description
stanzaId string Outgoing poll message id. Present only for typeMessage=pollUpdateMessage
name string Poll text
options array Array of poll options. Present only for typeMessage= pollMessage
votes array Array of poll vote. Present only for typeMessage=pollUpdateMessage
multipleAnswers boolean Flag to allow multiple answers

Parameters of options array:

Parameter Type Description
optionName string Poll choice option text

Parameters of votes array:

Parameter Type Description
optionName string Poll choice option text
optionVoters array Array poll vote account id

Parameters of quotedMessage object:

Parameter Type Description
stanzaId string Quoted message ID
participant string Recipient chat ID
typeMessage string Quoted message type

The remaining fields of the quotedMessage object are filled in depending on the type of the quoted message and are identical to the fields described above

Response body example#

Examples of incoming message response bodies#

Text message#
    {
        "type": "incoming",
        "idMessage": "9DB14F14A253D33F4A9CD84123456789",
        "timestamp": 1706522263,
        "typeMessage": "textMessage",
        "chatId": "120363153000000000@g.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`/`stickerMessage`
        "chatId": "120363153000000000@g.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"
    }
Reaction message#
    {
        "type": "incoming",
        "idMessage": "3A1EBA0F23004BD415BB",
        "timestamp": 1706601621,
        "typeMessage": "reactionMessage",
        "chatId": "70000000012@c.us",
        "extendedTextMessageData": {
            "text": "😄"
        },
        "quotedMessage": {
            "stanzaId": "B4D7D8A1A7D887D5580F000000000000",
            "participant": "70000000012@c.us",
        },
        "senderId": "70000000013@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"
    }
Extended text message#
    {
        "type": "incoming",
        "idMessage": "3A66D7F0B50000000000",
        "timestamp": 1706675928,
        "typeMessage": "extendedTextMessage",
        "chatId": "70000000012@c.us",
        "textMessage": "Hqhqhhqh\nhttps://greenapi.com",
        "extendedTextMessage": {
            "text": "Hqhqhhqh\nhttps://greenapi.com",
            "description": "GREEN API: WhatsApp API on any language PHP, JavaScript, 1C, Python, Java, C#, VBA etc.",
            "title": "GREEN API: send and receive WhatsApp messages",
            "previewType": "None",
            "jpegThumbnail": "/9j/4AAQSkZJRgABAQAAAQABZ",
            "forwardingScore": 0,
            "isForwarded": false
        },
        "senderId": "70000000012@c.us",
        "senderName": "Rachel",
        "senderContactName": "Rachel 2"
    }
Poll message#
    {
        "type": "incoming",
        "idMessage": "3A71511C3A0000000000",
        "timestamp": 1706676278,
        "typeMessage": "pollMessage",
        "chatId": "70000000012@c.us",
        "pollMessageData": {
            "name": "Choose your favorite color",
            "options": [
                {
                    "optionName": "Red"
                },
                {
                    "optionName": "Green"
                }
            ],
            "multipleAnswers": true
        },
        "senderId": "70000000012@c.us",
        "senderName": "Rachel",
        "senderContactName": "Rachel 2"
    }
Poll update message#
    {
        "type": "incoming",
        "idMessage": "3A0493ED90000000000000",
        "timestamp": 1706676447,
        "typeMessage": "pollUpdateMessage",
        "chatId": "70000000012@c.us",
        "pollMessageData": {
            "name": "Where will we go?",
            "stanzaId": "46618B98B3B9DF50F123456789123456",
            "votes": [
                {
                    "optionName": "Beach",
                    "optionVoters": [
                        "70000000012@c.us"
                    ]
                },
                {
                    "optionName": "Mountains",
                    "optionVoters": []
                }
            ],
            "multipleAnswers": true
        },
        "senderId": "70000000012@c.us",
        "senderName": "Rachel",
        "senderContactName": "Rachel 2"
    }
Quoted message#

    {
        "type": "incoming",
        "idMessage": "3AB0EB938BA0000000000",
        "timestamp": 1706677013,
        "typeMessage": "quotedMessage",
        "chatId": "70000000012@c.us",
        "extendedTextMessage": {
            "text": "For the beach",
            "stanzaId": "46618B98B3B9DF50F123456789123456",
            "participant": "70000000012@c.us"
        },
        "quotedMessage": {
            "stanzaId": "46618B98B3B9DF50F123456789123456",
            "participant": "70000000012@c.us",
            "typeMessage": "pollMessage",
            "pollMessageData": {
                "name": "Where will we go?",
                "options": [],
                "multipleAnswers": true
            }
        },
        "senderId": "70000000012@c.us",
        "senderName": "Rachel",
        "senderContactName": "Rachel 2"
    }
    {
        "type": "incoming",
        "idMessage": "3A70B27A6020000000000",
        "timestamp": 1706677254,
        "typeMessage": "quotedMessage",
        "chatId": "70000000012@c.us",
        "extendedTextMessage": {
            "text": "Great!",
            "stanzaId": "EAAE5A5CD000000000",
            "participant": "70000000012@c.us"
        },
        "quotedMessage": {
            "stanzaId": "EAAE5A5CD000000000",
            "participant": "70000000012@c.us",
            "typeMessage": "imageMessage", //"videoMessage"/`documentMessage`/`audioMessage`/`stickerMessage`
            "downloadUrl": "",
            "caption": "",
            "fileName": "",
            "jpegThumbnail": "/9j/4AAQSkZJRgABAQAAA=",
            "mimeType": "image/jpeg",
            "isAnimated": false,
            "isForwarded": false,
            "forwardingScore": 0
        },
        "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`/`stickerMessage`
        "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
    }
Reaction message#
    {
        "type": "outgoing",
        "idMessage": "3A1EBA0F23004BD415BB",
        "timestamp": 1706601621,
        "typeMessage": "reactionMessage",
        "chatId": "70000000012@c.us",
        "extendedTextMessageData": {
            "text": "😄"
        },
        "quotedMessage": {
            "stanzaId": "B4D7D8A1A7D887D5580F000000000000",
            "participant": "70000000012@c.us",
        },
        "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
    }
Extended text message#
    {
        "type": "outgoing",
        "idMessage": "BAE56E0000000000",
        "timestamp": 1706849285,
        "typeMessage": "extendedTextMessage",
        "chatId": "70000000012@c.us",
        "textMessage": "https://greenapi.com",
        "extendedTextMessage": {
            "text": "https://greenapi.com",
            "description": "GREEN API: WhatsApp API on any language PHP, JavaScript, 1C, Python, Java, C#, VBA etc.",
            "title": "GREEN API: send and receive WhatsApp messages",
            "previewType": "None",
            "jpegThumbnail": "/9j/4AAQSkZJRgABAQAAAQABZ",
            "forwardingScore": 0,
            "isForwarded": false
        },
        "statusMessage": "sent",
        "sendByApi": true
    }
Poll message#
    {
        "type": "outgoing",
        "idMessage": "460D84E00000000000",
        "timestamp": 1706762412,
        "typeMessage": "pollMessage",
        "chatId": "70000000012@c.us",
        "pollMessageData": {
            "name": "Choose your favorite color",
            "options": [
                {
                    "optionName": "Red"
                },
                {
                    "optionName": "Green"
                }
            ],
            "multipleAnswers": true
        },
        "statusMessage": "delivered",
        "sendByApi": true
    }
Quoted message#

    {
        "type": "outgoing",
        "idMessage": "B1494991277FD000000000000000000000",
        "timestamp": 1706849516,
        "typeMessage": "quotedMessage",
        "chatId": "70000000012@c.us",
        "extendedTextMessage": {
            "text": "Black",
            "stanzaId": "460D84E00000000000",
            "participant": "70000000012@c.us"
        },
        "quotedMessage": {
            "stanzaId": "460D84E00000000000",
            "participant": "70000000012@c.us",
            "typeMessage": "pollMessage",
            "pollMessageData": {
                "name": "Choose your favorite color",
                "options": [],
                "multipleAnswers": true
            }
        },
        "statusMessage": "delivered",
        "sendByApi": false
    }
    {
        "type": "outgoing",
        "idMessage": "21D6C50B400DBCEC30000000000000",
        "timestamp": 1706852882,
        "typeMessage": "quotedMessage",
        "chatId": "70000000012@c.us",
        "extendedTextMessage": {
            "text": "Cool",
            "stanzaId": "79DC2458992097F00000000000000000",
            "participant": "70000000012@c.us"
        },
        "quotedMessage": {
            "stanzaId": "79DC2458992097F00000000000000000",
            "participant": "70000000012@c.us",
            "typeMessage": "imageMessage", //"videoMessage"/`documentMessage`/`audioMessage`/`stickerMessage`
            "downloadUrl": "",
            "caption": "",
            "fileName": "",
            "jpegThumbnail": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAgq7O/wD/2Q==",
            "mimeType": "image/jpeg",
            "isAnimated": false,
            "isForwarded": false,
            "forwardingScore": 0
        },
        "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. The message is still in the message queue and the system has not had time to process it. You can request the ShowMessagesQueue method to check messages.
400 ID message notfound IDMessage is not found. The message is still in the message queue and the system has not had time to process it. You can request the ShowMessagesQueue method to check messages. The chat, message number, or instance on which the message request occurs is probably incorrectly specified.

Request examples#

import requests

url = "{{apiUrl}}/waInstance{{idInstance}}/getMessage/{{apiTokenInstance}}"

payload = "{\r\n\"chatId\": \"120363043968066561@g.us\, \"idMessage\": \"BAE5F4886F6F2D05\" \"r\n}"
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": "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 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"":""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