Pinned Messages

Pinned messages highlight important content in a channel. Use them for announcements, key information, or temporarily promoted content. Each channel can have multiple pinned messages, with optional expiration times.

Pinning and Unpinning Messages

Pin an existing message using pinMessage, or create a pinned message by setting pinned: true when sending.

// There is no separate pin call. Pinning is a field on the message, so you set it and
// send the message, or set it on a message you already have and update that.

// Create a pinned message. Leave PinExpires zeroed to pin until unpinned.
FMessage Message{TEXT("Important announcement")};
Message.bPinned = true;
Channel->SendMessage(Message);

// Pin for 7 days
FMessage Expiring{TEXT("Pinned for a week")};
Expiring.bPinned = true;
Expiring.PinExpires = FDateTime::UtcNow() + FTimespan::FromDays(7);
Channel->SendMessage(Expiring);

// Pin an existing message
ExistingMessage.bPinned = true;
Channel->UpdateMessage(ExistingMessage);

// Unpin previously pinned message
ExistingMessage.bPinned = false;
Channel->UpdateMessage(ExistingMessage);

// Who pinned it and when are filled in by the API, on the message it sends back
const FUserRef PinnedBy = ExistingMessage.PinnedBy;
const FDateTime PinnedAt = ExistingMessage.PinnedAt;

Pin Parameters

NameTypeDescriptionDefaultOptional
pinnedbooleanWhether the message is pinnedfalse
pinned_atstringTimestamp when the message was pinned-
pin_expiresstringTimestamp when the pin expires. Null means the message does not expirenull
pinned_byobjectThe user who pinned the message-

Pinning a message requires the PinMessage permission. See Permission Resources and Default Permissions for details.

Retrieving Pinned Messages

Query a channel to retrieve the 10 most recent pinned messages from pinned_messages.

// The pinned message list is not yet read from the channel state in the Unreal SDK.
// Please let us know if you'd like this feature implemented: https://github.com/GetStream/stream-chat-unreal/issues
//
// Messages already loaded in the channel do carry their pin state, so you can pick them
// out of the list you have:
const FMessages& Messages = Channel->State.Messages.GetMessages();
const FMessages Pinned = Messages.FilterByPredicate([](const FMessageRef& M) { return M->bPinned; });

Paginating Pinned Messages

Use the dedicated pinned messages endpoint to retrieve all pinned messages with pagination.

// The dedicated pinned-messages endpoint is not yet available in the Unreal SDK.
// Please let us know if you'd like this feature implemented: https://github.com/GetStream/stream-chat-unreal/issues
// Filtering the messages already loaded in the channel by FMessage::bPinned is the
// available alternative, and it only sees the messages that are loaded.