Truncate Channel

Messages from a channel can be truncated. This will remove all of the messages but not affect the channel data or channel members. If you want to delete both channel and message data then use the Delete Channel method instead.

Truncate channel can be performed client-side or server-side. To use client-side, the user must have the TruncateChannel permission.

On server-side calls, user_id field can be used to identify channel truncator.

The default behaviour is to hide messages when channel is truncated. To permanently delete messages, set the hard_delete option to true. The following fields can be used to truncate a channel:

TypeDescriptionOptional
truncated_atDateTo truncate channel up to given time.
user_idstringUser who truncates the channel (server-side call only)
messageobjectA system message to be added via truncation.
skip_pushboolDon’t send a push notification for system message.
hard_deleteboolTrue if truncation should delete messages instead of hiding
await channelClient.TruncateAsync(channel.Type, channel.Id);

// Or with parameters:
await channelClient.TruncateAsync(channel.Type, channel.Id, new TruncateOptions
{
  SkipPush = true,
  HardDelete = true,
  Message = new MessageRequest
  {
    Text = "Dear Everyone. The channel has been truncated.",
    User = new UserRequest { Id = user.Id },
  },
});
© Getstream.io, Inc. All Rights Reserved.