Requesting Message History

The api/messages/history method is used to request the recipient’s message history.

Calling api/messages/history Method

To call the api/messages/history method, send a POST request to the URL https://app.edna.io/api/messages/history.

If the request is successful, the method returns a response with a code of 200 and a JSON object with text and information about the message. If the request fails, the method returns an error code. More about errors.

Request Body Format

{
    "subscriberFilter": {
        "address": "35000000000",
        "type": "EDNA_ID"
    },
    "offset": 0,
    "limit": 0,
    "channelTypes": [
        "SMS"
    ],
    "direction": "OUT",
    "dateFrom": "2024-07-01T00:00:00Z",
    "dateTo": "2024-07-22T00:00:00Z",
    "sort": [
        {
            "property": "messageId",
            "direction": "DESC"
        }
    ],
    "trafficTypes": [
        "AD"
    ],
    "subjectId": 0
}

Request Example

Request header:

POST https://app.edna.io/api/messages/history 
x-api-key: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Content-Type: application/json

Request body with the subscriberFilter parameter:

{
    "subscriberFilter": {
        "address": "35000000000",
        "type": "PHONE"
    },
    "offset": 0,
    "limit": 1000,
    "channelTypes": [
        "SMS"
    ],
    "direction": "OUT",
    "dateFrom": "2024-07-01T00:00:00Z",
    "dateTo": "2024-07-22T00:00:00Z",
    "sort": [
        {
            "property": "messageId",
            "direction": "DESC"
        }
    ],
    "trafficTypes": [
        "AD"
    ],
    "subjectId": 50192
}

Request body without the subscriberFilter parameter:

{
    "offset": 0,
    "limit": 1000,
    "channelTypes": [
        "SMS"
    ],
    "direction": "OUT",
    "dateFrom": "2024-07-01T00:00:00Z",
    "dateTo": "2024-07-22T00:00:00Z",
    "sort": [
        {
            "property": "messageId",
            "direction": "DESC"
        }
    ],
    "trafficTypes": [
        "AD"
    ],
    "subjectId": 50192
}

Request Parameters

ParameterData typeCharacterDescription
subscriberFilterobject OptionalThe recipient’s filter.
subscriberFilter.
address
string OptionalThe recipient’s address. For example, a phone number.
subscriberFilter.
type
stringOptionalThe recipient’s address type.

Possible values:
PHONE
EMAIL
UTM
COOKIE_ID
INSTAGRAM_ID
FACEBOOK_ID
TELEGRAM_ID
GOOGLE_ID
APPLE_ID
YANDEX_ID
EXT_USER_ID
offsetintegerOptionalThe number of messages to skip after sorting.

The default value is 0.
limitintegerOptionalThe number of messages in the response.

The default value is 15. The maximum value is 1000.
channelTypesarray of stringsOptionalThe channel type.

Possible values:
WHATSAPP: the WhatsApp channel;
SMS: the SMS channel;
VIBER: the Viber channel;
PUSH: the Push channel.

For example, if the PUSH value is passed, the message content will only be returned for the Push channel. You can pass multiple values.
directionstringOptionalThe direction of the message.

Possible values:
IN: from the receiver;
OUT: to the recipient.
dateFromstringOptionalThe time in ISO 8601 format (for example, “2024-07-01T00:00:00Z”) from which messages are requested. By default, messages from the last 30 days are requested.

To receive all messages from a specific date in the past to the present, specify only the required date in the dateFrom parameter and leave the dateTo parameter empty.

In the limit parameter, specify the number of messages you want to get.
dateTostringOptionalThe time in ISO 8601 format (for example, “2024-07-01T00:00:00Z”) at which messages are requested. By default, messages from the last 30 days are requested.

The maximum range of values between the dateFrom and dateTo parameters is 366 days.

To receive all messages for the last 30 days, specify a date in the last 30 days in the dateTo parameter and leave the dateFrom parameter empty. If you specify a date later than 30 days ago in the dateTo parameter and leave the dateFrom parameter empty, the response will contain an empty list.

In the limit parameter, specify the number of messages you want to get.
sortobjectOptionalThe sorting parameters.
sort.propertystringOptionalThe parameter for sorting. You can use the value of any parameter from the response example to sort.
sort.directionstringOptionalThe sorting direction.

Possible values:
ASC: ascending sorting;
DESC: descending sorting.

The default is DESC. It is only used with the sort.property parameter.
trafficTypesarray of stringsOptionalThe traffic type with the "direction":"OUT" parameter value.

Possible values:
AD: marketing messages;
SERVICE: service messages;
HSM: template WhatsApp messages;
CHAT: free WhatsApp messages.
subjectIDintegerOptionalThe subject ID.

Response Format

A JSON object is returned in response to the request. The JSON object contains messages sent to or received from the user according to the specified conditions.

Response Example

{
    "content": [
        {
            "messageId": 8270556,
            "tenantId": 3193,
            "channelType": "SMS",
            "direction": "OUT",
            "address": "35000000000",
            "content": "{\"text\": \"Hello. Glad to see\", \"type\": \"TEXT\"}",
            "deliveryStatus": "DELIVERED",
            "deliveryStatusAt": "2024-07-23T08:08:20.000+0000",
            "sentOrReceivedAt": "2024-07-23T08:08:20.201+0000",
            "subjectId": 50192,
            "subjectName": "subject_sms",
            "cascadeId": 32522,
            "cascadeName": "cascade_sms",
            "cascadeStageUuid": "b75c5b32-d185-4784-aac0-ec3adc468a71",
            "broadcastId": 318463,
            "broadcastName": "cxzxzcxzcxz",
            "trafficType": "AD",
            "segments": 1,
            "subscriberId": 11354769
        },
        {
            "messageId": 8270515,
            "tenantId": 3193,
            "channelType": "SMS",
            "direction": "OUT",
            "address": "35000000001",
            "content": "{\"text\": \"Hello. Glad to see\", \"type\": \"TEXT\"}",
            "deliveryStatus": "DELIVERED",
            "deliveryStatusAt": "2024-07-23T08:02:11.000+0000",
            "sentOrReceivedAt": "2024-07-23T08:02:11.223+0000",
            "subjectId": 50192,
            "subjectName": "subject_sms",
            "cascadeId": 32522,
            "cascadeName": "cascade_sms",
            "matcherId": 6199,
            "matcherName": "serv_1",
            "cascadeStageUuid": "b75c5b32-d185-4784-aac0-ec3adc468a71",
            "broadcastId": 318462,
            "broadcastName": "cxvzxc",
            "trafficType": "SERVICE",
            "segments": 1,
            "subscriberId": 11354769
        }
    ],
    "hasNext": false
}

Response Parameters

ParameterData typeDescription
contentarray of objectsThe array of transmitted messages.
content.messageIdintegerThe internal ID of the message.
content.tenantIdintegerThe user’s personal account ID.
content.channelTypestringThe channel type.

Possible values:
WHATSAPP: the WhatsApp channel;
SMS: the SMS channel;
VIBER: the Viber channel;
PUSH: the Push channel.
content.directionstringThe message direction.

Possible values:
IN: incoming message;
OUT: outgoing message.

By default, all messages are returned.
content.addressstringThe sender’s address for incoming messages and the recipient’s address for outgoing messages.
content.contentstringThe text of the message.
content.deliveryStatusstringThe message delivery status.

Possible values:
ACCEPTED: message accepted to edna Pulse;
INVALID: outgoing message didn’t pass validation on the edna Pulse side;
ENQUEUED: outgoing message was successfully sent on the edna Pulse side;
SENT: outgoing message was successfully sent to the recipient;
UNDELIVERED: outgoing message wasn’t delivered to the recipient or was sent unsuccessfully;
DELIVERED: outgoing message was delivered to the recipient;
READ: outgoing message was read by the recipient.
content.deliveryStatusAtstringThe date and time of delivery status in ISO 8601 format (for example, “2024-07-01T00:00:00Z”).
content.deliveryStatusMessagestringThe delivery status message.
content.sentOrReceivedAtstringThe date and time of sending for outgoing messages and delivery for incoming messages in ISO 8601 format (for example, “2024-07-01T00:00:00Z”).
content.subjectIdintegerThe subject ID.
content.subjectNamestringThe subject name.
content.cascadeIdintegerThe cascade ID.
content.cascadeNamestringThe cascade name.
content.cascadeStageUuidstringThe cascade step number.
content.broadcastIdintegerThe broadcast ID.
content.broadcastNamestringThe broadcast name.
content.trafficTypestringThe traffic type with the "direction":"OUT" parameter value.

Possible values:
AD: marketing messages;
SERVICE: service messages;
HSM: template WhatsApp messages;
CHAT: free WhatsApp messages.
content.segmentsintegerThe number of message segments.
content.subscriberIdintegerThe recipient’s ID in edna Pulse.
content.matcherIdintegerThe ID of the template used to send messages with the "direction":"OUT" parameter value.
content.matcherNamestringThe name of the template used to send messages with the "direction":"OUT" parameter value.
content.commentstringThe comment parameter can be passed when sending messages. It can be used to uniquely identify a message or broadcast.
hasNextbooleanThe flag indicating the presence of the next page.
content.replyInMessageIdintegerThe internal identifier of the user’s quoted message. The user quotes their message sent to the company.
content.replyOutMessageIdintegerThe internal identifier of the company’s quoted message. The user quotes a message received from the company.
content.replyOutMessage
ExternalRequestId
integerThe external identifier of the company’s quoted message, which it specifies when sending an outgoing message via the API if the user has quoted a message received from the company.

Errors

Possible errors after calling the hiapi/messages/historystory method:

CodeErrorDescription
401Api-key not foundAn invalid API key is specified.
400not-valid-requestAn empty value is specified for the address parameter.
400limit-not-validA value greater than 1000 is specified in the limit parameter.
400date-range-not-validThe range of values between the dateFrom and dateTo parameters exceeds 366 days.
400message-matcher-subject-not-foundAn invalid identifier is specified in the value of the subjectID parameter.