Delivery receipt

Delivery receipt is a feature that indicates whether a message has successfully been delivered to all the intended recipients by Sendbird server. With the implementation of delivery receipt, Sendbird not only provides the timestamp of when each user has last read the messages in each channel, but also the timestamp of when each user has the message last delivered to each user in each channel.

DeliveryReceipt

Note: Delivery receipt is only applicable to group channels.


Benefits

Delivery receipt provides the following benefits.

Highly in demand feature

Most popular messaging apps, such as WhatsApp and Facebook Messenger, provide this feature. Users who have experienced them expect to see if the message they sent has been successfully delivered when using a new chat service. Delivery receipt is a feature in high demand that today’s users are accustomed to using.

Improved user experience

Previously, a sender had no way of knowing whether their message was unread because the server is in the process of delivering or failed to deliver the message due to the unreliable internet connection, or simply because the recipients haven’t yet read the message. This feature enables users to become better-informed, thus improving the Sendbird user experience.


How it works

Delivery receipt works in a similar way to read receipt. The server stores the timestamp of the message last delivered as delivered_ts. The timestamp is recorded per user, per channel.

API endpoint

The Chat API provides the mark all messages as delivered action to receive a delivery event from the recipient client. This method updates the database with delivered_ts which indicates the delivery timestamp of the last message, if your Sendbird application has delivery receipt enabled.

Delivery event

If any of the following actions is called, they are all considered a delivery event to Sendbird server.

ActionHTTP request

Mark all messages as delivered in a group channel

PUT /group_channels/{channel_url}/messages/mark_as_delivered
Marks all messages in the group channel as delivered for a specific user.

Mark all messages as read in a group channel

PUT /group_channels/{channel_url}/messages/mark_as_read_all
Marks all messages in the group channel as read for a specific user.

Mark all messages as read in all the joined group channels

PUT /users/{user_id}/mark_as_read_all
Marks all of the user’s unread messages as read across all group channels.

When the server receives a delivery event from a user, it updates the database with the user’s delivery receipt and stores the current server time as delivered_ts to the database.

Note: The Chat API's send a message to a group channel action is also considered a delivery event for Sendbird server when it is called to send a message to a group channel.


Mark all messages as delivered

Marks all messages in a group channel as delivered for a given user. This action is only applicable for users in a group channel.

HTTP request

Light Color Skin
Copy
PUT https://api-{application_id}.sendbird.com/v3/group_channels/{channel_url}/messages/mark_as_delivered

Parameters

The following table lists the parameters that this action supports.

Parameters
RequiredTypeDescription

application_id

string

Specifies the unique ID of your application.

channel_url

string

Specifies the URL of the target channel.

Request body

The following table lists the properties of an HTTP request that this action supports.

Properties
RequiredTypeDescription

user_id

string

Specifies the ID of the recipient to mark messages as delivered.

Light Color Skin
Copy
{
    "user_id": "debbie" 
}

Response

If delivered_ts of the user is updated, the key ts, which indicates the updated value of the user’s delivered_ts, is included in the response in Unix milliseconds format.

Light Color Skin
Copy
{
    "ts": 1542756099266 
}

Any GET API call that returns a group channel resource contains the delivery_receipt property inside the resource. A user who has never made a delivery event isn’t included in the property. The property consists of the user ID and the timestamp of when the user last received the message in Unix milliseconds as shown below.

Light Color Skin
Copy
{
    "channels": [
        {
            ...

            "delivery_receipt": {
                "benjamin": 1542756099266,
                "charles": 1542756098734,
                "debbie": 1542756099266
            },
            ...

        },
        ...
    
    ],
    "next": "ansYQFFRQ1AIEUBXX1RcE2d0FUZSUlkJFVQRHB86AkAgNn8eABABBBNFX..." 
}