OpenTV ENTera & OpenTV Platform Documentation
26.26_Q2 25.52_Q4 25.26_Q2 25.12_Q1 24.50_Q4 24.38_Q3 24.26_Q2 23.50_Q4 23.24_Q2 23.12_Q1 22.50_Q4 22.38_Q3 22.24_Q2
26.26_Q2 25.52_Q4 25.26_Q2 25.12_Q1 24.50_Q4 24.38_Q3 24.26_Q2 23.50_Q4 23.24_Q2 23.12_Q1 22.50_Q4 22.38_Q3 22.24_Q2

Sending a message to an account or user profile

Request

You can send a message to a specific account or to a specific user profile. DMM sends the message to each of the account's active devices.

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:

Bash
https://<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

Mandatory arguments

  • accountId (in URL) – the ID of the account

  • envelope object 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 in data must be strings. See Message format – general notifications and the rules in Managing messaging.
    Within message, data must 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 in text and any of the additional fields listed below

Other arguments

The envelope object can also contain:

  • id – a UUID that identifies the message. If you don't provide one, DMM generates it. All the account's devices get the same ID.

  • expiration – the message time to live, in seconds

  • event – an event type for tracking. It isn't delivered to the client application.

Within message:

  • notification block:

    • Include a notification block if the notification is meant to be presented immediately to the user.

    • Omit the notification block if the client should store the notification so that the user can view it when they choose to (for example, in an inbox).

  • data can 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 of OPEN_CONTENT, OPEN_PRODUCT, OPEN_APP, or OPEN_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 action is OPEN_CONTENT: channelId specifies the channel to be switched to, contentId the VOD content to be played, or eventId the live event to be played

      • If action is OPEN_PRODUCT, productId specifies the product to be displayed

      • If action is OPEN_APP, appUrl specifies the URL of the app to be opened

      • If action is OPEN_PACK, packId specifies 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:

JSON
{
  "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:

JSON
{
  "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

A successful request returns an HTTP 200 status. The response body says how many devices the message was sent to, for example:

JSON
{
  "message": "Published to 3 device(s) successfully"
}

If sending fails for one or more of the account's devices, the request returns an HTTP 207 status. This includes the case where sending fails for every device. The response body gives the number of active devices, how many succeeded and failed, and the IDs of the devices in each group, for example:

JSON
{
  "message": "Published to 2 device(s) successfully, 1 failed",
  "totalDevices": 3,
  "successCount": 2,
  "failureCount": 1,
  "successDeviceIds": [
    "6981a0c296645ee8f00ed301",
    "6981a0d996645ee8f00ed303"
  ],
  "failureDeviceIds": [
    "6981a0e496645ee8f00ed305"
  ]
}

An unauthorised request returns an HTTP 401 status – for example, if the access token is invalid or has expired.

A forbidden request returns an HTTP 403 status – for example, if there is no access token or the user does not have the operatorRole role.

If DMM has no active devices for the account, the request returns an HTTP 404 status. This is also the case if the account does not exist.

A request that is not valid returns an HTTP 500 status – for example, if message contains a line break, envelope.id is not a UUID, or envelope.from contains characters other than printable ASCII. An HTTP 500 status is also returned if DMM cannot send the message for any other reason.

See also

For full details of this API, see the Device Messaging Manager (DMM) API documentation v1.

To send a message to an account from OpCon, see Send a message to an account in the OpCon documentation.