Requesting Recipient’s Message History

Use this method to request the recipient’s message history.

Message History Request Method

Using this method, the user’s software requests the recipient’s message history. The request is executed through the public API interface with API key authorization.

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 is unsuccessful, the method returns a message with an error code.

Connection URL

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

Request Format

The request body passes the recipient ID and the required filters.

{
  "offset": 0,
  "limit": 0,
  "sort": [
    {
      "direction": "ASC",
      "property": "SMS"
    }
  ],
  "subscriberFilter": {
    "address": "10000000000",
    "type": "EDNA_ID"
  },
  "dateFrom": "2023-07-20T11:57:02.074Z",
  "dateTo": "2023-07-20T11:57:02.074Z",
  "channelTypes": [
    "SMS"
  ],
  "direction": "OUT",
  "trafficTypes": [
    "AD"
  ],
  "subjectId": 0
}

Request Example

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

{
  "subscriberFilter": {
    "address": "00000000000",
    "type": "PHONE"
  },
  "channelTypes": ["WHATSAPP"],
  "direction": "IN",
  "subjectId": 20526,
  "dateFrom": "2023-06-01T00:00:00Z",
  "dateTo": "2023-06-12T00:00:00Z",
  "limit": 12,
  "offset": 1,
  "sort": [{"property": "messageId", "direction":  "ASC"}]
}

Request Parameters

ParameterTypeRequiredDescription
subscriberFilterobject yesThe subscriber filter.
subscriberFilter.
address
stringyesThe subscriber address. For example, phone number.
subscriberFilter.
type
array of EnumsyesThe type of subscriber address: PHONE, EMAIL, UTM, COOKIE_ID, INSTAGRAM_ID, FACEBOOK_ID, TELEGRAM_ID, GOOGLE_ID, APPLE_ID, YANDEX_ID, EXT_USER_ID.
dateFromdatetimenoThe earliest date of messages that are to be returned by the server. The default value is one year.
dateTodatetimenoThe latest date of messages that are to be returned by the server. The default value is the current date.
channelTypesarray of EnumsnoThe channel type filter: WHATSAPP, SMS, VIBER, PUSH. For example, enter PUSH to retrieve only messages sent through the push channel. This parameter can have more than one value.
directionstringnoThe message direction: received from the client (IN) or sent to the client (OUT).
trafficTypearray of EnumsnoThe traffic type: AD, SERVICE, HSM, CHAT. This parameter can have more than one value.
subjectIDstringnoThe subject ID filter.
offsetintegernoThe number of messages to skip after sorting. The default value is 0.
limitintegernoThe maximum number of messages in the response. The default value is 15. The maximum value is 100.
sortstringnoThe sorting parameters.
sort.directionarray of EnumsnoThe sorting direction: ASC or DESC. The default value is DESC.
sort.propertystringnoThe parameter for sorting. You can use the value of any parameter from the response example for sorting.

Response Format

This method returns a JSON object containing all messages sent to or received from the user that meet the specified criteria, and additional information about these messages.

Response Example

{
    "content": [
        {
            "messageId": 2945744,
            "tenantId": 549,
            "channelType": "SMS",
            "direction": "OUT",
            "address": "15050000000",
            "content": "{\"text\": \"Hello. Glad o see\", \"type\": \"TEXT\"}",
            "deliveryStatus": "UNDELIVERED",
            "deliveryStatusAt": "2022-10-18T21:12:37Z",
            "deliveryStatusMessage": "unrouted",
            "sentOrReceivedAt": "2022-10-18T21:12:34.223452Z",
            "subjectId": 284,
            "subjectName": "subject_sms",
            "cascadeId": 427,
            "cascadeName": "New channel",
            "cascadeStageUuid": "37549bb8-b343-4a3b-99a5-a23ce83ec66a",
            "trafficType": "AD",
            "segments": 1,
            "subscriberId": 2399569,
            "replyInMessageId": 537701
        },
        {
            "messageId": 2946294,
            "tenantId": 549,
            "channelType": "SMS",
            "direction": "OUT",
            "address": "79000000000",
            "content": "{\"text\": \"Hello. Glad o see\", \"type\": \"TEXT\"}",
            "deliveryStatus": "SENT",
            "deliveryStatusAt": "2022-10-18T21:14:18Z",
            "sentOrReceivedAt": "2022-10-18T21:14:15.358104Z",
            "subjectId": 284,
            "subjectName": "subject_sms",
            "cascadeId": 427,
            "cascadeName": "New channel",
            "cascadeStageUuid": "37549bb8-b343-4a3b-99a5-a23ce83ec66a",
            "trafficType": "AD",
            "segments": 1,
            "subscriberId": 2399569,
            "replyOutMessageId": 5043874,
            "replyOutMessageExternalRequestId": "2c2dd5f1-5ad8-449d-9c38-b6bdf288f1e5"
        }
    ],
    "number": 0,
    "size": 15,
    "hasNext": false
}

Response Parameters

ParameterDescription
messageIdThe internal message ID.
tenantIdThe user’s tenant ID.
channelTypeThe channel type.
directionThe message direction: incoming or outgoing.
addressThe sender’s address for incoming messages and the recipient’s address for outgoing messages.
contentThe message content.
deliveryStatusThe message delivery status.
deliveryStatusAtThe date and time of delivery status.
deliveryStatusMessageThe delivery status message.
sentOrReceivedAtThe date and time of sending for outgoing messages and delivery for incoming messages.
subjectIdThe subject ID.
subjectNameThe subject name.
cascadeIdThe cascade ID.
cascadeNameThe cascade name.
cascadeStageUuidThe cascade step number.
broadcastIdThe broadcast ID.
broadcastNameThe broadcast name.
trafficTypeThe traffic type.
segmentsThe number of message segments.
subscriberIdThe subscriber ID in edna Pulse.
commentThe comment parameter can be sent with a message. You can use it as a unique identifier of a message or broadcast.
numberThe page number.
sizeThe number of items in the response.
hasNextThe flag indicating the presence of the next page.
replyInMessageIdThe internal identifier of the user’s quoted message. The user quotes their message sent to the company.
replyOutMessageIdThe internal identifier of the company’s quoted message. The user quotes a message received from the company.
replyOutMessageExternalRequestIdThe 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.

List of Errors

The method returns the 400 Bad Request error message and a JSON object with a description in the following cases.

  • invalid API key specified;
  • the required address parameter is not specified;
  • the specified limit value is greater than 100;
  • the specified dateFrom date is more than 1 year before the current one.