Home Documentation Rental FAQ Contact details
Sign in

Messages receiving

Description

GET /messages

The resource allows to get all incoming (including new unread) and outgoing messages.

Messages are stored for 10 days on our servers.

URL resource:

https://app.api-messenger.com/messages

Input data

Parameter Required Value
new No Get new (unread) messages only
page No The results page number to show in the response.

If the page number specified exceeds the total pages found number, there is displayed an error.

Default value: 1.

Output data

The output structure is shown below.

{ 
    "status": "{enum}",
    "pager":
        {
            "currentPage": {int32},
            "pagesCount": {int32},
            "pageSize": {int32},
            "totalsMessage": {int32}
        },
    "messages":
        [
            {
                "body": "{string}",
                "chatId": "{string}",
                "formattedTitle": "{string}",
                "fromMe": {boolean},
                "sender": "{string}",
                "timestamp": {int64},
                "type": "{enum}"
            },
            ...
        ]
}

Parameters description:

Parameter Value
status Response status.

Possible values:

  • ERROR — an error has occurred.

  • OK — the request has been completed successfully.
pager Search results brief.
messages Messages list which meet the search criteria.
Parameters nested in pager
currentPage Output results page number.

In case if the messages satisfying the search conditions specified in the query haven’t been found or use the following parameter new, parameter is not displayed.
pagesCount Pages number with the results.

In case if the messages satisfying the search conditions specified in the query haven’t been found or use the following parameter new, parameter is not displayed.
pageSize The messages number displayed on the page.

In case if the messages satisfying the search conditions specified in the query haven’t been found or use the following parameternew, parameter is not displayed.
totalsMessage Total number of messages found.

In case if the messages satisfying the search conditions specified in the query haven’t been found, parameter value: 0.
Parameters nested in messages
body If the parameter value type— chat, the message text is displayed, otherwise a link to download the file is displayed.
chatId Individual chat ID
formattedTitle Sender name
fromMe Possible values:

  • true — outgoing message.

  • false — incoming message.
sender Message author ID
timestamp UNIX timestamp in seconds
type Message type.

Possible values:

  • document — document.

  • video — video.

  • image — image.

  • ptt — voice message.

  • audio — audio recording.

  • chat — text message.

Errors description

The server returns an HTTP response code and a brief error description in the event of error.

Examples

Query example:

curl -i -H 'Content-Type: application/json' -X GET 'https://app.api-messenger.com/messages?page=1'

Response example:

HTTP/1.1 200 OK
Content-Type: application/json;charset=utf-8
...

{ "status": "OK", "pager": { "currentPage": 1, "pagesCount": 1, "pageSize": 50, "totalsMessage": 2 }, "messages": [ { "body": "All wings, report in! The next animated", "chatId": "1456353397@c.us", "formattedTitle": "Jon", "fromMe": true, "sender": "19763593251@c.us", "timestamp": 1534522998, "type": "chat" }, { "body": "https://app.api-messenger.com/file/2c2b15ds6d8d/", "chatId": "1456353397@c.us", "formattedTitle": "Jon", "fromMe": false, "sender": "1456353397@c.us", "timestamp": 1534523969, "type": "document" } ] }