Skip to content

LastOutgoingMessages#

The method returns the last outgoing messages of the account. In the default mode the last messages for 24 hours are returned.

Settings

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 method returns the last 10000 messages. The LastOutgoingMessages 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 outgoing messages, you have to execute a request at:

GET {{apiUrl}}/waInstance{{idInstance}}/lastOutgoingMessages/{{apiTokenInstance}}

For idInstance, apiTokenInstance and apiUrl request parameters, refer to Before you start section.

URL request parameters#

Parameter Type Mandatory Description
minutes integer No time in minutes for which the messages should be displayed (default is 1440 minutes)

Response#

Response parameters#

Array of objects with parameters:

Parameter Type Description
type string Message type, outgoing - outgoing message
idMessage string Outgoing message Id
timestamp integer Time of the last action on a message in UNIX format
statusMessage string Outgoing message status, 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
typeMessage string Message type, possible variants:
textMessage - text message
imageMessage - image message
videoMessage - video message
documentMessage - document file message
audioMessage - audio message
locationMessage - location message
contactMessage - contact message
contactsArrayMessage - array of contacts
chatId string Chat Id, where message has been sent to
isForwarded boolean The flag indicates whether the message is forwarded
forwardingScore integer Number of message forwards
textMessage string Text message, if typeMessage = textMessage
downloadUrl string Link to download a file, if 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. The field is filled in correctly only for typeMessage = documentMessage, in other cases the file name is generated automatically
jpegThumbnail string base64-coded image preview, if typeMessage = imageMessage /videoMessage/documentMessage/audioMessage
mimeType string File type according to the Media Types, if typeMessage = imageMessage /videoMessage/documentMessage/audioMessage
isAnimated boolean The flag indicates whether the file is animated, if typeMessage = imageMessage/videoMessage/documentMessage/audioMessage
location object Location structure object, if typeMessage = locationMessage
contact object Contact structure object, if typeMessage = contactMessage
contacts object Contact structure object, if typeMessage = contactsArrayMessage

Response body example#

[
    {
        "type": "outgoing",
        "idMessage": "BAE5143000000000",
        "timestamp": 1706761225,
        "typeMessage": "textMessage",
        "chatId": "70000000012@c.us",
        "textMessage": "Hi",
        "statusMessage": "read",
        "sendByApi": true
    },
    {
        "type": "outgoing",
        "idMessage": "BAE5F94000000000",
        "timestamp": 1706765613,
        "typeMessage": "imageMessage", //"videoMessage"/`documentMessage`/`audioMessage`
        "chatId": "70000000012@c.us",
        "downloadUrl": "https://api.greenwaba.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
    },
    {
        "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
    },
    {
        "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
    },
    {
        "type": "outgoing",
        "idMessage": "AC3C8F45EA99087477B34C8964AEB8D8",
        "timestamp": 1764056445,
        "typeMessage": "contactsArrayMessage",
        "chatId": "79123456789@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",
            "vcard": "BEGIN:VCARD\nVERSION:3.0\nN:;Jane;;;\nFN:Jane\nTEL;type=Mobile;waid=79123456799:+7 912 345-67-99\nEND:VCARD",
            "contextInfo": null
        }
        ],
        "forwardingScore": 0,
        "isForwarded": false
        },
        "statusMessage": "delivered",
        "sendByApi": false,
        "deletedMessageId": "",
        "editedMessageId": "",
        "isEdited": false,
        "isDeleted": false
    }
]

LastOutgoingMessages errors#

For a list of errors common to all methods, refer to Common errors section

Request examples#

import requests

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

payload = {}
headers= {}

response = requests.request("GET", url, headers=headers, data = payload)

print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/lastOutgoingMessages/{{apiTokenInstance}}?minutes=3240'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/lastOutgoingMessages/")
    .append({{apiTokenInstance}});

var response = restTemplate.exchange(requestUrl.toString(), HttpMethod.GET, null, String.class);
System.out.println(response);
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/lastOutgoingMessages/")
    .append({{apiTokenInstance}});

var response = Unirest.get(requestUrl.toString())
    .header("Content-Type", "application/json")
    .asString();

System.out.println(response);
Sub LastOutgoingMessages()
    Dim url 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}}/lastOutgoingMessages/{{apiTokenInstance}}"

    Set http = CreateObject("MSXML2.XMLHTTP")

    http.Open "GET", url, False
    http.send

    response = http.responseText

    Debug.Print response

    ' Outputting the answer to the desired cell
    Range("A1").Value = response

    Set http = Nothing
End Sub