Request
You can send a message to a specific account or to a specific user profile. This sends the message to all the devices that belong to the account.
If the message is targeted to a specific user profile, it is up to the client application to deliver it only to the specified user profile.
If you use ION as your client application, note that it does not yet support user-profile-specific messages.
-
You may need to target a specific account for account-specific reasons, for example, an issue with a payment method or an upcoming subscription renewal.
-
You may want to target a specific user profile, for example, if you want to send a targeted promotion based on a profile's known viewing habits.
To do this, send a POST request to:
http://<host>:<port>/messaging/v1/accounts/{accountId}/inbox
If the message includes a notification section, the device may display it without passing the message to the client application – see “Client processing of messages” in Managing messaging.
Headers
-
Content-Type: application/json
Mandatory fields
-
accountId(in URL) – the ID of the account -
envelopeobject containing at least:-
from– who the notification is from (printable ASCII characters only)
-
-
message– the message, as a string that contains JSON: on a single line, with special characters escaped. All values indatamust be strings. See Message format – general notifications and the rules in Managing messaging.
Withinmessage,datamust contain:-
referenceType– one of:-
NOTIFICATION– a general notification -
ALERT– an alert -
PROMOTION– a promotion
-
-
title– the title of the message displayed to the user -
body– the body of the message: a string that contains a JSON object, with the message text intextand any of the additional fields listed below
-
Optional fields
The envelope object can also contain:
-
id– a UUID that identifies the message. If you don't provide one, DMM generates it. -
expiration– the message time to live, in seconds -
event– an event type for tracking. It isn't delivered to the client application.
Within message:
-
notificationblock:-
Include a
notificationblock if the notification is meant to be presented immediately to the user. -
Omit the
notificationblock if the client should store the notification so that the user can view it when they choose to (for example, in an inbox).
-
-
datacan also contain:-
userProfile– if the message is targeted to a specific user profile, the ID of the user profile -
action– the action to be performed when the user interacts with the message. One ofOPEN_CONTENT,OPEN_PRODUCT,OPEN_APP, orOPEN_PACK. -
priority– the priority of the message. The value and how it is used are determined by the operator. For example, the client could use this to decide when to show the message (for example, immediately or only once the user finishes watching the current content). -
displayTime– the amount of time that the message should be displayed on the screen, in seconds, as a string (for example,"10")
-
-
Within the JSON object in
data.body:-
Depending on
data.action:-
If
actionisOPEN_CONTENT:channelIdspecifies the channel to be switched to,contentIdthe VOD content to be played, oreventIdthe live event to be played -
If
actionisOPEN_PRODUCT,productIdspecifies the product to be displayed -
If
actionisOPEN_APP,appUrlspecifies the URL of the app to be opened -
If
actionisOPEN_PACK,packIdspecifies the pack to be displayed
-
-
imageUrl– the URL of an image to be displayed in the message -
videoUrl– the URL of a video to be displayed in the message
-
Example
A request with this payload sends a promotion to the specified user profile. Here, message and data.body are shown as JSON objects for clarity:
{
"envelope": {
"from": "Operator"
},
"message": {
"notification": {
"title": "Movies We Know You'll Love",
"body": "Based on the movies you have watched, we think you will love this movie bundle!"
},
"data": {
"referenceType": "PROMOTION",
"userProfile": "Dave",
"title": "Movies We Know You'll Love",
"action": "OPEN_PRODUCT",
"body": {
"text": "Based on the movies you have watched, we think you will love this movie bundle! Click below to get it.",
"productId": "ACTION_MOVIE_BUNDLE",
"imageUrl": "https://imageservice.sales.opentv.com/images/v1/image/Movie/GLOBAL_MV000336630000/Poster?width=300&aspect=2x3"
}
}
}
}
In the actual request, message is a string, and data.body is a string inside it. This is the JSON that you would actually use as the body of the request:
{
"envelope": {
"from": "Operator"
},
"message": "{\"notification\":{\"title\":\"Movies We Know You'll Love\",\"body\":\"Based on the movies you have watched, we think you will love this movie bundle!\"},\"data\":{\"referenceType\":\"PROMOTION\",\"userProfile\":\"Dave\",\"title\":\"Movies We Know You'll Love\",\"action\":\"OPEN_PRODUCT\",\"body\":\"{\\\"text\\\":\\\"Based on the movies you have watched, we think you will love this movie bundle! Click below to get it.\\\",\\\"productId\\\":\\\"ACTION_MOVIE_BUNDLE\\\",\\\"imageUrl\\\":\\\"https://imageservice.sales.opentv.com/images/v1/image/Movie/GLOBAL_MV000336630000/Poster?width=300&aspect=2x3\\\"}\"}}"
}
Response
-
HTTP 200 – the message was sent to all the account's devices.
-
HTTP 207 – the message was sent to some of the account's devices but not others. The response gives the number of devices and the IDs of the devices that succeeded and failed.
-
HTTP 404 – no devices were found for the account.
-
HTTP 500 – the request was not valid (for example, the message contains a line break) or the message could not be sent.
See also
For full details of this API, see the Device Messaging Manager (DMM) API documentation v1.