Notifications Guide v1
Notifications
Version 1

User logs

Copy link

Logs contain the holistic data on notifications and notification messages a target user receives. As for notifications, a Notification overview resource and Notification details resource contain information on how many notification messages have been sent out, when the notification arrived at the target user's channel, and how many users have clicked the message. Meanwhile, you can also retrieve all the Notification messages that a single target user has received from a specified time point.

These figures also can be monitors in the Logs page on Sendbird Dashboard.


Resource representation

Copy link

Depending on the call, a response may contain different resources as follows.

Notification message

Copy link

A Notification message is an actual message that an end user receives as a result of a notification you've sent. Thus, the Notification message resource contains more data on the message and message event that each target user received. This is returned when requesting user logs.

NameTypeDescription

notification_id

string

The unique ID of the notification.

template_key

string

The template key of the notification.

channel

nested object

The channel of the notification.

channel.key

string

The key of the channel.

channel.type

string

The type of the channel.

mode

string

The delivery mode of the notification. Options: real-time, batch.

title

string

The title of the notification. If not specified, the value is null.

tag

string

The tag of the notification. If not specified, the value is null.

priority

string

The priority of the batch notification. Options: high, normal, low.

message_data

nested object

The data for the notification.

message_data.message_status

string

The status of the notification message. Valid values are SENT and READ.

message_data.channel_url

string

The unique URL of the channel where the message is sent to.

message_data.label

string

The label of the notification.

message_data.template_variables

nested object

The template variables used to send the notification.

message_data.event_logs

nested object

The event logs for the notification message.

message_data.event_logs.sent_at

long

Timestamp in milliseconds when the notification message was sent.

message_data.event_logs.impression_at

long

Timestamp in milliseconds when the notification message was marked as impression. (Default: 0)

message_data.event_logs.clicked_at

long

Timestamp in milliseconds when the notification message was marked as clicked. (Default: 0)

message_data.custom_event_logs

nested object

The custom event logs for the notification message.

message_data.custom_event_logs.{topic}

long

Timestamp in milliseconds when the notification message was marked by custom event topic.


List notification messages a user received

Copy link

This API retrieves all the logs on notification messages that a user has received since the specified message_ts.

HTTP Request

Copy link
GET https://api-{application_id}.notifications.sendbird.com/v1/users/{user_id}/channels/{channel_key}/messages/

Request body

Copy link
RequiredTypeDescription

user_id

string

Specifies the user ID to retrieve notification messages.

channel_key

string

Specifies the channel key to retrieve notification messages.

message_ts

long

Specifies the timestamp to be the reference point of the query in Unix milliseconds.

include_event_logs

bool

Specifies whether to include event logs in the response or not.

OptionalTypeDescription

prev_limit

string

Specifies the number of previously sent messages to retrieve before. For example, if message_ts is set to 1484202848298 and prev_limit to 50, it returns 50 messages sent by 1484202848297 which is the specified message_ts value minus 1. Acceptable values range from 0 to 100. (Default: 10)

next_limit

long

Specifies the number of sent messages to retrieve after message_ts. For example, if message_ts is set to 1484202848298 and next_limit to 50, it returns returns 50 messages sent from 1484202848299 which is the specified message_ts value plus 1. Acceptable values range from 0 to 100. (Default: 10)

reverse

boolean

Determines whether to sort the results in reverse chronological order. If set to true, messages appear in reverse chronological order where the newest comes first and the oldest last. (Default: false)

include_only_removed

boolean

Determines whether to include only messages removed from the channel in the results. (Default: false)

Response

Copy link

If successful, this action returns a list of Notification message resources in the response body.

{
    "messages": [
        {
            "notification_id": "7148658397991144705",
            "template_key": "random-1358",
            "channel": {
                "key": "shipt-demo-01",
                "type": "feed"
            },
            "mode": "realtime",
            "title": "Random Test 02",
            "tag": "",
            "priority": null,
            "message_data": {
                "message_status": "READ",
                "channel_url": "notification_99_shipt-demo-01",
                "template_variables": {},
                "label": null,
                "custom_type": "Update",
                "event_logs": null,
                "custom_event_logs": null,
                "updated_at": 0
            }
        },
        {
            "notification_id": "7150383783817091713",
            "template_key": "template-03",
            "channel": {
                "key": "shipt-demo-01",
                "type": "feed"
            },
            "mode": "realtime",
            "title": "NotificationsReview#2Demo",
            "tag": "test",
            "priority": null,
            "message_data": {
                "message_status": "READ",
                "channel_url": "notification_99_shipt-demo-01",
                "template_variables": {
                    "image_url.url": "https://www.shutterstock.com/shutterstock/photos/2274412231/display_1500/stock-vector-many-rainbow-gradient-random-bright-soft-balls-background-colorful-balls-background-for-kids-zone-2274412231.jpg",
                    "image_url.width": 1500,
                    "image_url.height": 700,
                    "header": "Notifications Review",
                    "content": "This is a test body",
                    "left_button_text": "Left B",
                    "left_button_action.type": "web",
                    "left_button_action.data": "https://google.com",
                    "right_button_text": "Right B ",
                    "right_button_action.type": "web",
                    "right_button_action.data": "https://apple.com"
                },
                "label": "Travel Tips",
                "custom_type": "Travel Tips",
                "event_logs": null,
                "custom_event_logs": null,
                "updated_at": 0
            }
        }
    ]
}