Deleting & Hiding a Channel

Last Edit: Feb 02 2020

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


const destroy = await channel.delete();
                    

$channel->delete();
                    

curl -i -X DELETE
  -H "Content-Type: application/json" \
  -H "Stream-Auth-Type: jwt" \
  -H "Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidGhpZXJyeSJ9.eoUjRuyJ1aUtTdZlZO9eX1lHkLXbUPWhdAb6Nr9GPNw" \
  "https://chat-us-east-c1.stream-io-api.com/channels/messaging/thiery-tommaso?api_key=c38bmrz86x8y"
                    
If you recreate this channel, it will show up empty. Recovering old messages is not currently supported via the Stream Chat API.

Hiding a Channel

Hiding a channel will remove it from query channel requests for that user until a new message is added. Please keep in mind that hiding a channel is only available to members of that channel.

Optionally you can also clear the entire message history of that channel for the user. This way, when a new message is received, it will be the only one present in the channel.


// hides the channel until a new message is added there
await channel.hide();

// shows a previously hidden channel
await channel.show();
                    

// hides the channel until a new message is added there
$channel->hide('elon');

// shows a previously hidden channel
$channel->show('elon');
                    

// hides the channel until a new message is added there
await channel.hide();

// shows a previously hidden channel
await channel.show();

// hide the channel and clear the message history
await channel.hide(clearHistory: true);
                    
You can still retrieve the list of hidden channels using the { "hidden" : true } query parameter.