# 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

<codetabs>

<codetabs-item value="kotlin" label="Kotlin">

```kotlin
// Retrieve ChannelClient
val channelClient = client.channel("messaging", "example")

// Archive the channel
channelClient.archive().enqueue { /* ... */ }

// Query for channels that are archived
val query = QueryChannelsRequest(
  filter = Filters.eq("archived", true),
  offset = 0,
  limit = 10,
)
client.queryChannels(query).enqueue { /* ... */ }

// Unarchive the channel
channelClient.unarchive().enqueue { /* ... */ }
```

</codetabs-item>

<codetabs-item value="javascript" label="JavaScript">

```js
// Get a channel
const channel = client.channel("messaging", "example");

// Archive the channel
await channel.archive();

// Query for channels that are not archived
const resp = await client.queryChannels({ archived: false });

// Unarchive the channel
await channel.unarchive();
```

</codetabs-item>

<codetabs-item value="dart" label="Dart">

```dart
// Archive the channel
await channel.archive();

// Query for channels that are not archived
final channels = await client.queryChannelsOnline(filter: Filter.equal('archived', false));

// Unarchive the channel
await channel.unarchive();
```

</codetabs-item>

<codetabs-item value="go" label="Go">

```go
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)
```

</codetabs-item>

<codetabs-item value="php" label="Php">

```php
// Get a channel
$channel = $client->channel("messaging", "general");

// Archive the channel for user amy
$userId = "amy";
$response = $channel->archive($userId);

// Query for channels that are archived
$response = $client->queryChannels([
    "archived" => true,
], null, [
    "user_id" => $userId
]);

// Unarchive the channel
$response = $channel->unarchive($userId);
```

</codetabs-item>

<codetabs-item value="python" label="Python">

```python
# Get a channel
channel = client.channel("messaging", "general")

# Archive the channel for user amy
user_id = "amy"
response = channel.archive(user_id)

# Query for channels that are archived
response = client.query_channels({"archived": True}, user_id=user_id)

# Unarchive the channel
response = channel.unarchive(user_id)
```

</codetabs-item>

<codetabs-item value="ruby" label="Ruby">

```ruby
# Get a channel
channel = client.channel("messaging", "general")

# Archive the channel for user amy
user_id = "amy"
response = channel.archive(user_id)

# Query for channels that are archived
response = client.query_channels({ 'archived': true }, sort: nil, user_id: user_id)

# Unarchive the channel
response = channel.unarchive(user_id)
```

</codetabs-item>

<codetabs-item value="java" label="Java">

```java
// Archive the channel for user amy.
Channel.archive(channel.getType(), channel.getId(), "amy").request();

// Query for amy's channels that are archived.
Channel.list()
    .userId("amy")
    .filterCondition(FilterCondition.in("members", "amy"))
    .filterCondition("archived", true)
    .request();

// Unarchive
Channel.unarchive(channel.getType(), channel.getId(), "amy").request();
```

</codetabs-item>

<codetabs-item value="swift" label="Swift">

```swift
// Controllers

// Archive the channel for the current user.
channelController.archive { error in
    if let error {
        // handle error
    }
}

// Query all the archived channels.
let channelListController = chatClient.channelListController(
    query: ChannelListQuery(
        filter: .and([
            .containMembers(userIds: [currentUserId]),
            .equal(.archived, to: true)
        ])
    )
)
channelListController.synchronize { error in
    if let error {
        // handle error
    } else {
        let archivedChannels = channelListController.channels
    }
}

// Unarchive the channel for the current user.
channelController.unarchive { error in
    if let error {
        // handle error
    }
}

// State layer (async-await)

// Archive the channel for the current user.
try await chat.archive()

// Query all the archived channels.
let channelList = chatClient.makeChannelList(
    with: ChannelListQuery(
        filter: .and([
            .containMembers(userIds: [currentUserId]),
            .equal(.archived, to: true)
        ])
    )
)
try await channelList.get()
let archivedChannels = channelList.state.channels

// Unarchive the channel for the current user.
try await chat.unarchive()
```

</codetabs-item>

<codetabs-item value="csharp" label="C#">

```csharp
// Archive
var archiveResponse = await _channelClient.ArchiveAsync("messaging", "channel-id", "user-id");

// Get the date when the channel got archived by the user
var archivedAt = archiveResponse.ChannelMember.ArchivedAt;

// Get channels that are NOT archived
var unarchivedChannels = await _channelClient.QueryChannelsAsync(new QueryChannelsOptions
{
    Filter = new Dictionary<string, object>
    {
        { "archived", false },
    },
    UserId = "user-id",
});

// Unarchive
var unarchiveResponse = await _channelClient.UnarchiveAsync("messaging", "channel-id", "user-id");
```

</codetabs-item>

</codetabs>

## 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`.


---

This page was last updated at 2026-03-05T19:05:17.469Z.

For the most recent version of this documentation, visit [https://getstream.io/chat/docs/flutter-dart/archiving_channels/](https://getstream.io/chat/docs/flutter-dart/archiving_channels/).