Archiving Channels

Channel members can archive a channel for themselves. This is a per-user setting that does not affect other members.

Archived channels function identically to regular channels via the API, but your UI can display them separately. When a channel is archived, the timestamp is recorded and returned as archived_at in the response.

When querying channels, filter by archived: true to retrieve only archived channels, or archived: false to exclude them.

Archive a Channel

using GetStream;
using GetStream.Models;

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

var channelId = "channel-id";
var memberId = "user-id";

// Archive the channel for user
// user_id must be passed as a query param
await client.MakeRequestAsync<UpdateMemberPartialRequest, UpdateMemberPartialResponse>(
    "PATCH",
    "/api/v2/chat/channels/{type}/{id}/member",
    new Dictionary<string, string> { ["user_id"] = memberId },
    new UpdateMemberPartialRequest
    {
        Set = new Dictionary<string, object> { ["archived"] = true }
    },
    new Dictionary<string, string> { ["type"] = "messaging", ["id"] = channelId });

// Unarchive the channel for user
await client.MakeRequestAsync<UpdateMemberPartialRequest, UpdateMemberPartialResponse>(
    "PATCH",
    "/api/v2/chat/channels/{type}/{id}/member",
    new Dictionary<string, string> { ["user_id"] = memberId },
    new UpdateMemberPartialRequest
    {
        Set = new Dictionary<string, object> { ["archived"] = false }
    },
    new Dictionary<string, string> { ["type"] = "messaging", ["id"] = channelId });

Global Archiving

Channels are archived for a specific member. If the channel should instead be archived for all users, this can be stored as custom data in the channel itself. The value cannot collide with existing fields, so use a value such as globally_archived: true.