In-App UI
JavaScript
SDK
MessageClient

MessageClient reference

Complete reference for the MessageClient in the Knock JavaScript SDK.

Client for interacting with message operations in the Knock API.

Constructor

#

Initializes a new message client instance.

Parameters:

knockKnock

The Knock client instance to use for API requests.

Returns: MessageClient

Methods

#

get

#

Retrieves a specific message by its ID.

Parameters:

messageIdstring

The unique identifier of the message to retrieve.

Returns: Promise<Message>

Example:

updateStatus

#

Updates the engagement status of a message. For the "interacted" status, additional metadata can be provided.

Parameters:

messageIdstring

The unique identifier of the message to update.

statusMessageEngagementStatus

The engagement status to set (e.g., 'read', 'seen', 'archived', 'interacted').

optionsUpdateMessageStatusOptions

Optional parameters. Required when status is 'interacted' to provide metadata.

Returns: Promise<Message>

Example:

removeStatus

#

Removes an engagement status from a message. Note: Cannot remove "interacted" status.

Parameters:

messageIdstring

The unique identifier of the message to update.

statusExclude<MessageEngagementStatus, 'interacted'>

The engagement status to remove (e.g., 'read', 'seen', 'archived'). Cannot be 'interacted'.

Returns: Promise<Message>

Example:

batchUpdateStatuses

#

Updates the engagement status of multiple messages in a single request.

Parameters:

messageIdsstring[]

Array of message IDs to update.

statusMessageEngagementStatus | 'unseen' | 'unread' | 'unarchived'

The engagement status to set on all messages. Can include removal statuses like 'unseen', 'unread', 'unarchived'.

optionsUpdateMessageStatusOptions

Optional parameters. Required when status is 'interacted' to provide metadata.

Returns: Promise<Message[]>

Example:

bulkUpdateAllStatusesInChannel

#

Updates the engagement status of all messages in a specific channel.

Parameters:

channelIdstring

The ID of the channel containing the messages to update.

statusMessageEngagementStatus

The engagement status to set on all messages in the channel.

optionsobject

Additional options for the bulk update operation.

Returns: Promise<BulkOperation>

Example: