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

ctx := context.Background()

// Get a channel
channel := client.Channel("messaging", "general")

// Archive the channel for user amy
userID := "amy"
channelMemberResp, err := channel.Archive(ctx, userID)

// Query for channels that are archived
resp, err := client.QueryChannels(ctx, &QueryOption{
	UserID: userID,
	Filter: map[string]interface{}{
		"archived": true,
	},
})

// Unarchive the channel
channelMemberResp, err = channel.Unarchive(ctx, userID)

Global Archiving

To archive a channel for all users, use filter_tags to tag the channel as archived. This allows you to query for globally archived channels across your application.

// Archive globally by adding an "archived" tag
channel.Update(ctx, map[string]interface{}{
    "filter_tags": []string{"archived"},
}, nil)

// Query globally archived channels
filter := map[string]interface{}{
    "filter_tags": map[string]interface{}{
        "$in": []string{"archived"},
    },
}
resp, err := client.QueryChannels(ctx, &QueryOption{Filter: filter})