Sending Messages (imOutMessage)

The method described in this article is only intended for SME.

The request body contains a JSON with parameters of the message to be sent to clients of messengers WhatsApp or Viber. The server returns a response code 200 in case of a sucessful request. The response body contains a JSON with message ID and its delivery code. You can find all available codes and their details in the Available Status Codes article.

Request Endpoint

To send a message, make a POST request to this URL: https://im.edna.io/api/imOutMessage

Request Format

The request body contains a JSON object with the message parameters. The exact set of parameters depends on the message type and its content that can be one of the following: text, image, document, video.

{
    "id": "dtest-001",
    "subject": "test",
    "address": "+79000000000",
    "priority": "high",
    "startTime": "2020-06-12T15:30:10.000Z",
    "validityPeriodSeconds": 86400,
    "contentType": "image",
    "attachmentName": "Puppy image",
    "attachmentUrl": "https://picsum.photos/id/1006/200/300"
}

Request Parameters

ParameterTypeDescription
idstringMessage identifier. It is generated by your system, after which the value must be transferred to the request. Any length of the string up to 36 characters is allowed.
subjectstringText of the message subject. 

Important! All signatures must first be registered on the platform. Otherwise, the message will not be delivered.
addressstringPhone number to which the message will be sent in the 79ХХХХХХХХХ format.
prioritystring (optional)Message priority that determines the delivery time. The available values are:

realtime – The message must be delivered immediately.
high – This is a message with high priority.
normal – This is a message with normal priority.
low – This is a message with low priority.
startTimestring (optional)Start time, i.e. the time when the message will be sent (it won’t be sent until the specified time). This parameter is used for delayed sending in the following format:

• YYYY-MM-DDTHH:mm:ss.SSSXXX (2021-01-21T08:00:00Z)
• YYYY-MM-DDTHH:mm:ss.SSS+TZ (2021-01-21T08:00:00Z+03:00)
validityPeriodSecondsint (optional)Message validity period specified in seconds. The message must be delivered until the end of the period. If it can’t be delivered during this period, for example, if the recipient is unavailable, it won’t be delivered at all. The default value is 86400 seconds (it equals 1 day). The minimum value is 30. The maximum is 86400. We recommended that you use 86400 because messengers round the value up to the full day.
imTypestring (optional)Defines a channel used to deliver the message.

whatsapp – WhatsApp
viber – Viber Service Messages
vk – Vkontakte Community Messages
contentTypestringType of the message content. The available options are:

text – For a text message
image – For a message with an image included
document – For a message with a document attached
video – For a message that contains a video file
audio – For a message that contains an audio file
location – For a message with coordinates, an address and a description of a place. The coordinates are converted into a Google Maps snapshot.
textstringMessage text. It is required only if contentType is text.
attachmentNamestring (optional)Name of the attached image/document/video. 

Important! attachmentName must not exceed 25 characters for a Viber message. For all other messengers, the limit is 75 characters.
attachmentUrlstringURL of the attached image/document/video. It is required if contentType is specified as one of the non-text values.

Important! The URL must start with https.
latitudestring (optional)Latitude of the geolocation. It is required if contentType='location'.
longitudestring (optional)Longitude of the geolocation. It is required if contentType='location'.
locationAddressstring (optional)Geolocation address. It is optional and is only used when contentType='location'.
captionstring (optional)Geolocation name. It is optional and is only used when contentType='location'
commentstring (optional)Text comment in a message. This parameter is displayed in the detailed report.

Requirements for Text Formatting

Pay attention to how you put words in quotation marks. If you use the single () or double quote () symbols in the message text, make sure to put the backslash (\) symbol before the opening and after the closing quotation mark. See the following example:

Correct:

“text”: “Maria! We are inviting you to our workshop \“Cooking with Tefal\” 11/25/2021 at 1 p.m. Don\’t miss this event! Give us a call: +7 (495) 100-00-00”

Incorrect:

“text”: “Maria! We are inviting you to our workshop “Cooking with Tefal” on 11/25/2021 at 1 p.m. Do not miss this event! Give us a call: +7 (495) 100-80-00”

Response Format

The response contains a JSON object with the ID of the sent message and one of the available response codes.

{
  "id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
  "code": "ok"
}

Response Parameters

ParameterTypeDescription
idstringMessage identifier. It is generated by your system.
codestringResponse code for this message. See the possible values in the Available status codes article.

Content Types

All attachments that you send must comply with the following requirements. Otherwise, the message will not be delivered.

Content typeSupported formatSize, MB
documentAny valid MIME type100
imageimage/jpeg, image/png5
audioaudio/aac, audio/mp4, audio/amr, audio/mpeg, audio/ogg
codec: opus (NWB) and ACC
16
videovideo/mp4, video/3gpp

Note: Only H.264 video codec and AAC audio codec are supported.
16
For Viber, the name of the attached file (attachmentName) cannot exceed 25 characters. For all other messengers, it can be up to 75 characters.

SMS Fallback Scenario

If for some reason the message is not delivered to the recipient, there is a function of fallback delivery via an SMS message. For this, you need to include some additional parameters in the imOutMessage request body. Please note that the subject of the SMS message is registered on the platform separately from the subject of imOutMessage.

{
  "id": "6ba0c4dc-8671-4e2f-afac-9b516415a082",
  "subject": "test",
  "address": "+79000000000",
  "priority": "high",
  "startTime": "2020-06-12T15:30:10.000Z",
  "validityPeriodSeconds": 86400,
  "contentType": "image",
  "attachmentName": "Puppy image", 
  "attachmentUrl": "https://picsum.photos/id/237/200/300"
  "reserveSms": 
    {
    "subject": "subject for sms",
    "priority": "normal",
    "contentType": "text",
    "content": "Sms content",
    "sendTimeoutSeconds": 600,
    "validityPeriodMinutes": 120,
    "comment": "some comment"
    }
}

Request Parameters

ParameterTypeDescription
subjectstringText of SMS message subject
prioritystring (optional)Message priority that determines the delivery time. The available values are:

realtime – The message must be delivered immediately.
high – This is a message with high priority.
normal – This is a message with normal priority.
low – This is a message with low priority.
contentTypestringType of the message content. The available options are:

text – For a text message
image – For a message with an image included
document – For a message with a document attached
video – For a message that contains a video file
contentstringSMS message content
sendTimeoutSecondsint (optional)The time after which an SMS message will be sent if the message is not delivered to messenger.
validityPeriodSecondsint (optional)Time (in seconds) during which an SMS message should be delivered. If the message cannot be delivered during this time (for example, the recipient is not available), it will not be delivered at all.
commentstring (optional)Text comment in a message. This parameter is displayed in the detailed report.