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
Parameter | Type | Required | Description |
subscriberFilter | object | yes | The subscriber filter. |
subscriberFilter. | string | yes | The subscriber address. For example, phone number. |
subscriberFilter. | array of Enums | yes | The type of subscriber address: PHONE, EMAIL, UTM, COOKIE_ID, INSTAGRAM_ID, FACEBOOK_ID, TELEGRAM_ID, GOOGLE_ID, APPLE_ID, YANDEX_ID, EXT_USER_ID. |
dateFrom | datetime | no | The earliest date of messages that are to be returned by the server. The default value is one year. |
dateTo | datetime | no | The latest date of messages that are to be returned by the server. The default value is the current date. |
channelTypes | array of Enums | no | The 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. |
direction | string | no | The message direction: received from the client (IN) or sent to the client (OUT). |
trafficType | array of Enums | no | The traffic type: AD, SERVICE, HSM, CHAT. This parameter can have more than one value. |
subjectID | string | no | The subject ID filter. |
offset | integer | no | The number of messages to skip after sorting. The default value is 0. |
limit | integer | no | The maximum number of messages in the response. The default value is 15. The maximum value is 100. |
sort | string | no | The sorting parameters. |
sort.direction | array of Enums | no | The sorting direction: ASC or DESC. The default value is DESC. |
sort.property | string | no | The 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
Parameter | Description |
messageId | The internal message ID. |
tenantId | The user’s tenant ID. |
channelType | The channel type. |
direction | The message direction: incoming or outgoing. |
address | The sender’s address for incoming messages and the recipient’s address for outgoing messages. |
content | The message content. |
deliveryStatus | The message delivery status. |
deliveryStatusAt | The date and time of delivery status. |
deliveryStatusMessage | The delivery status message. |
sentOrReceivedAt | The date and time of sending for outgoing messages and delivery for incoming messages. |
subjectId | The subject ID. |
subjectName | The subject name. |
cascadeId | The cascade ID. |
cascadeName | The cascade name. |
cascadeStageUuid | The cascade step number. |
broadcastId | The broadcast ID. |
broadcastName | The broadcast name. |
trafficType | The traffic type. |
segments | The number of message segments. |
subscriberId | The subscriber ID in edna Pulse. |
comment | The comment parameter can be sent with a message. You can use it as a unique identifier of a message or broadcast. |
number | The page number. |
size | The number of items in the response. |
hasNext | The flag indicating the presence of the next page. |
replyInMessageId | The internal identifier of the user’s quoted message. The user quotes their message sent to the company. |
replyOutMessageId | The internal identifier of the company’s quoted message. The user quotes a message received from the company. |
replyOutMessageExternalRequestId | 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. |
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.