Skip to main content
Skip table of contents

Sending a message to all devices subscribed to a topic

Request

To send a notification to all the devices that are subscribed to a particular topic, send a POST request to:

http://<host>:<port>/messaging/v1/topics/{topic_name}/inbox

Headers

  • Content-Type: application/json

Mandatory fields

  • topic_name (in URL) – the name of the topic
  • envelope object containing at least:
    • from – who the notification is from
  • message – the message – base64-encoded opaque data or UTF-8-encoded data with no CR/LFs
    Note that this is client-specific. For ION clients, the message must be in this format (but with CR/LFs removed):

    CODE
    {
        "data" :
            "{
                "title":"Titles promotions message",
                "message":"Content promotions messages"
            }"
            "notification" :
            "{
                  "title":"Titles promotions message",
                  "message":"Content promotions messages"
            }"
    }


    The contents of data and notification must be the same.

Example

A request with this payload sends a message to all the devices that are subscribed to the topic specified in the URL:

CODE
{
    "envelope": {
        "event": "subscription-changed",
        "id": "e7ebbd43-62d3-4962-b71d-0e9f98555d9b",
        "app_id": 1234,
        "from": "account-management-service",
        "expiration": 60000
    },
    "message": "eyAiZnJvbSIgOiAicmVtb3RlcHZyIiwgInRvIiA6ICIxMjM0NTYiLCAidGltZXN0YW1wIiA6ICIxNDgzNzY4OTg3IiwgInByaW9yaXR5IiA6ICIxMCIsICJyZXBseS10byIgOiAiaHR0cHM6Ly9hZGRyZXNzLnRvLnJlcGx5IG9yIG5vZGVAbWFjaGluZTpxdWV1ZSIsICJkYXRhIiA6ICJwcml2YXRlIGRhdGEgdXNlZCBieSB0aGUgZGV2aWNlIHJlbW90ZSBib29raW5nIGFwcGxpY2F0aW9uIn0="
}
The device must already be registered with DMM.

Response

The request returns an HTTP 200 status if the message was sent successfully.

An unsuccessful request returns an HTTP 404 status if the topic is not recognised.

See also

For full details of this API, see the DMM API documentation.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.