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
Parameter | Data type | Character | Description |
subscriberFilter | object | Optional | The recipient’s filter. |
subscriberFilter. | string | Optional | The recipient’s address. For example, a phone number. |
subscriberFilter. | string | Optional | The 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 |
offset | integer | Optional | The number of messages to skip after sorting. The default value is 0. |
limit | integer | Optional | The number of messages in the response. The default value is 15. The maximum value is 1000. |
channelTypes | array of strings | Optional | The 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. |
direction | string | Optional | The direction of the message. Possible values: • IN : from the receiver;• OUT : to the recipient. |
dateFrom | string | Optional | The 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. |
dateTo | string | Optional | The 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. |
sort | object | Optional | The sorting parameters. |
sort.property | string | Optional | The parameter for sorting. You can use the value of any parameter from the response example to sort. |
sort.direction | string | Optional | The sorting direction. Possible values: • ASC : ascending sorting;• DESC : descending sorting.The default is DESC . It is only used with the sort.property parameter. |
trafficTypes | array of strings | Optional | The traffic type with the "direction":"OUT" parameter value.Possible values: • AD : marketing messages;• SERVICE : service messages;• HSM : template WhatsApp messages;• CHAT : free WhatsApp messages. |
subjectID | integer | Optional | The 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
Parameter | Data type | Description |
content | array of objects | The array of transmitted messages. |
content.messageId | integer | The internal ID of the message. |
content.tenantId | integer | The user’s personal account ID. |
content.channelType | string | The channel type. Possible values: • WHATSAPP : the WhatsApp channel;• SMS : the SMS channel;• VIBER : the Viber channel;• PUSH : the Push channel. |
content.direction | string | The message direction. Possible values: • IN : incoming message;• OUT : outgoing message.By default, all messages are returned. |
content.address | string | The sender’s address for incoming messages and the recipient’s address for outgoing messages. |
content.content | string | The text of the message. |
content.deliveryStatus | string | The 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.deliveryStatusAt | string | The date and time of delivery status in ISO 8601 format (for example, “2024-07-01T00:00:00Z”). |
content.deliveryStatusMessage | string | The delivery status message. |
content.sentOrReceivedAt | string | The 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.subjectId | integer | The subject ID. |
content.subjectName | string | The subject name. |
content.cascadeId | integer | The cascade ID. |
content.cascadeName | string | The cascade name. |
content.cascadeStageUuid | string | The cascade step number. |
content.broadcastId | integer | The broadcast ID. |
content.broadcastName | string | The broadcast name. |
content.trafficType | string | The 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.segments | integer | The number of message segments. |
content.subscriberId | integer | The recipient’s ID in edna Pulse. |
content.matcherId | integer | The ID of the template used to send messages with the "direction":"OUT" parameter value. |
content.matcherName | string | The name of the template used to send messages with the "direction":"OUT" parameter value. |
content.comment | string | The comment parameter can be passed when sending messages. It can be used to uniquely identify a message or broadcast. |
hasNext | boolean | The flag indicating the presence of the next page. |
content.replyInMessageId | integer | The internal identifier of the user’s quoted message. The user quotes their message sent to the company. |
content.replyOutMessageId | integer | The internal identifier of the company’s quoted message. The user quotes a message received from the company. |
content.replyOutMessage ExternalRequestId | integer | The 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:
Code | Error | Description |
401 | Api-key not found | An invalid API key is specified. |
400 | not-valid-request | An empty value is specified for the address parameter. |
400 | limit-not-valid | A value greater than 1000 is specified in the limit parameter. |
400 | date-range-not-valid | The range of values between the dateFrom and dateTo parameters exceeds 366 days. |
400 | message-matcher-subject-not-found | An invalid identifier is specified in the value of the subjectID parameter. |