val channelClient = client.channel("messaging", "general")
channelClient.updatePartial(set = mapOf("frozen" to true)).enqueue { result ->
if (result is Result.Success) {
val channel = result.value
} else {
// Handle Result.Failure
}
}Freezing Channels
Freezing a channel prevents users from sending new messages and adding or deleting reactions.
Sending a message to a frozen channel returns an error message. Attempting to add or delete reactions returns a 403 Not Allowed error.
User roles with the UseFrozenChannel permission can still use frozen channels normally. By default, no user role has this permission.
Freeze a Channel
using GetStream;
using GetStream.Models;
var client = new StreamClient("{{ api_key }}", "{{ api_secret }}");
var chat = new ChatClient(client);
var channelId = "channel-id";
// Freeze a channel
await chat.UpdateChannelPartialAsync("messaging", channelId,
new UpdateChannelPartialRequest
{
Set = new Dictionary<string, object> { ["frozen"] = true }
});Unfreeze a Channel
using GetStream;
using GetStream.Models;
var client = new StreamClient("{{ api_key }}", "{{ api_secret }}");
var chat = new ChatClient(client);
var channelId = "channel-id";
// Unfreeze a channel
await chat.UpdateChannelPartialAsync("messaging", channelId,
new UpdateChannelPartialRequest
{
Set = new Dictionary<string, object> { ["frozen"] = false }
});Granting the Frozen Channel Permission
Permissions are typically managed in the Stream Dashboard under your app's Roles & Permissions settings. This is the recommended approach for most use cases.
To grant permissions programmatically, update the channel type using a server-side API call. See user permissions for more details.
// For security reasons, granting channel permissions is only possible via a server-side SDK