# Deleting Channels

You can delete or truncate a channel to remove its contents. To remove only messages while preserving the channel, see [Truncate Channel](https://getstream.io/chat/docs/php/truncate-channel/).

## Deleting a Channel

You can delete a single Channel using the  `delete`  method. This marks the channel as deleted and hides all the messages.

```php label="PHP"
use GetStream\ChatClient;
use GetStream\GeneratedModels as Models;

$client = new ChatClient("{{ api_key }}", "{{ api_secret }}");

$client->deleteChannel("messaging", "general", false);
```

>
> **Info:** If you recreate this channel, it will show up empty. Recovering old messages is not supported, unless the channel was deleted with `skip_truncate` (see [Preserving message history](#preserving-message-history) below). Use the [disable method](https://getstream.io/chat/docs/php/disabling-channels/) if you want a fully reversible change.
>

## Preserving Message History

By default, deleting a channel hides its messages, so a channel later recreated with the same ID starts out empty. Set `skip_truncate` to `true` to preserve message history through the delete instead, so a channel later recreated with the same ID (for example with `GetOrCreateChannel`) restores the full message history.

This is useful for apps where the same pair of users can end up back in the same channel, for example a dating app where two users unmatch and later re-match.

>
> **Warning:** `skip_truncate` is server-side only and only supported on [distinct channels](https://getstream.io/chat/docs/php/creating-channels/#distinct-channels). It cannot be combined with `hard_delete`, and it cannot be used if the channel's messages were already hidden by an earlier delete or truncate.
>

```php label="PHP"
use GetStream\ChatClient;

$client = new ChatClient("{{ api_key }}", "{{ api_secret }}");

// Preserve history through the soft delete (hardDelete, skipTruncate)
$client->deleteChannel("messaging", "general", false, true);
```

## Deleting Many Channels

You can delete up to 100 channels and optionally all of their messages using this method. This can be a large amount of data to delete, so this endpoint processes asynchronously, meaning responses contain a `task ID` which can be polled using the [getTask endpoint](https://getstream.io/docs/platform/async-operations/) to check status of the deletions. Channels will be soft-deleted immediately so that channels no longer return from queries, but permanently deleting the channel and deleting messages takes longer to process.

By default, messages are soft deleted, which means they are removed from client but are still available via server-side export functions. You can also hard delete messages, which deletes them from everywhere, by setting `"hard_delete": true` in the request. Messages that have been soft or hard deleted cannot be recovered.

You can also set `skip_truncate` to `true` to preserve message history for every channel in the request, the same as for a [single channel delete](#preserving-message-history). If any of the given CIDs is not eligible (it isn't a distinct channel, or its messages were already hidden by an earlier delete or truncate), the entire request is rejected and none of the channels are deleted.

This is currently supported on the following SDK versions (or higher):

- Javascript 4.3.0, Python 3.14.0, Ruby 2.12.0, PHP 2.6.0, Go 3.13.0, Java 1.4.0, Unity 2.0.0 and .NET 0.22.0

```php label="PHP"
// soft deletion
$response = $client->deleteChannels(new Models\DeleteChannelsRequest(
    cids: ["messaging:channel-1", "messaging:channel-2"],
));

// hard deletion
$response = $client->deleteChannels(new Models\DeleteChannelsRequest(
    cids: ["messaging:channel-1", "messaging:channel-2"],
    hardDelete: true,
));

$taskResponse = $client->getTask($response->getData()->taskID);

// preserve history (distinct channels only)
$response = $client->deleteChannels(new Models\DeleteChannelsRequest(
    cids: ["messaging:channel-1", "messaging:channel-2"],
    skipTruncate: true,
));
```

The  `deleteChannels`  response contain a taskID which can be polled using the [getTask endpoint](https://getstream.io/docs/platform/async-operations/) to check the status of the deletions.

---

For the most recent version of this documentation, visit [https://getstream.io/chat/docs/php/channel-delete/](https://getstream.io/chat/docs/php/channel-delete/).