Truncate Channel

Truncating a channel removes all messages but preserves the channel data and members. To delete both the channel and its messages, use Delete Channel instead.

Truncation can be performed client-side or server-side. Client-side truncation requires the TruncateChannel permission.

On server-side calls, use the user_id field to identify who performed the truncation.

By default, truncation hides messages. To permanently delete messages, set hard_delete to true.

Truncate a Channel

using GetStream;
using GetStream.Models;

var client = new StreamClient("{{ api_key }}", "{{ api_secret }}");
var chat = new ChatClient(client);

var channelId = "channel-id";

// Truncate a channel
await chat.TruncateChannelAsync("messaging", channelId,
    new TruncateChannelRequest());

// Or with parameters:
await chat.TruncateChannelAsync("messaging", channelId,
    new TruncateChannelRequest
    {
        SkipPush = true,
        HardDelete = true,
        Message = new MessageRequest
        {
            Text = "Dear Everyone. The channel has been truncated.",
            UserID = "user-id"
        }
    });

Truncate Options

FieldTypeDescriptionOptional
truncated_atDateTruncate messages up to this time
user_idstringUser who performed the truncation (server-side only)
messageobjectA system message to add after truncation
skip_pushboolDo not send a push notification for the system message
hard_deleteboolPermanently delete messages instead of hiding them