Slack allows archiving channels. We currently have around 50 channels that are no longer active with 0 users.

How can I efficiently archive these channels without having to join and archive them one by one?


5 Answers 5


To actually "slack-archive" the channels, ie the equivalent of running "/archive" within each channel, you'll need some API magic.

First, set up an API token for your user in the relevant team on https://api.slack.com/custom-integrations/legacy-tokens, then go to https://api.slack.com/methods/channels.list/test to get a json-listing of your channels together with the channel ids.

Then use these channel ids to run https://api.slack.com/methods/channels.archive/test for the channels you want to archive.

Here is a quick and dirty bash script (which uses jq) I recently ran on my Mac in order to archive the hundreds of channels that contained "sk-" in the channel name:

curl "https://slack.com/api/channels.list?token=$TOKEN&exclude_archived=true&pretty=1" > /tmp/channels.list
IDS=$(cat /tmp/channels.list | jq '.channels[] | select(.name | contains("sk-")) | .id' | sed -e 's/"//g')
for ID in $IDS; do
    echo $URL
    curl "$URL"

It got the job done, archiving about 2-3 channels per second.

  • @pnuts Only briefly now since you linked to them, but I found none that were related to this post?
    – Motin
    Commented Oct 17, 2017 at 23:23
  • I wanted to archive private conversations, so I needed to switch from legacy channels.list to the newer conversations.list and used the param &types=private_channel. Ditto changing channels.archive to conversations.archive
    – Carl Walsh
    Commented Jun 12, 2019 at 23:59

You can use spri.me (shameless plug) for this. Login, select the channels and "Archive".


Here is my quick PHP script that i use to clear all sk channels

$json_url = "https://slack.com/api/channels.list?token=YOURTOKEN&pretty=1";
$json = file_get_contents($json_url);

$data = json_decode($json);
echo "total channels:".$m."<br>";


for($i=0; $i<$m; $i++) {

//echo $data->channels[$i]->name."<br>";

if (strpos($cn, 'sk-') !== false and $cn2==0) {
   echo $data->channels[$i]->name."(".$cn2.") (id=";
   echo $cid.');<br>';

$json_url2 = "https://slack.com/api/channels.archive?token=YOURTOKEN&channel=".$cid."&pretty=1";
$json2 = file_get_contents($json_url2);

echo "total sk channels archived:".$k."<br>";


Here is a kotlin script I wrote recently to archive all channels that hadn't had a new message in them in 3 months.

Note: If you hit the API limit in the logs, wait 2 minutes and run it again.

import com.squareup.moshi.Moshi
import khttp.get
import java.time.ZonedDateTime

data class JsonChannelsList(
        val channels: List<JsonChannel>

data class JsonChannel(
        val id: String,
        val name_normalized: String,
        val is_archived: Boolean,
        val is_private: Boolean

data class JsonMessages(
        val messages: List<JsonMessage>

data class JsonMessage(
        val username: String,
        val text: String,
        val ts: String

data class ArchiveableChannel(
        val id: String,
        val name: String

 * Arg 0 is your slack api token with user access (to be able to read channels)
fun main(args: Array<String>) {
    val moshi = Moshi.Builder().build()
    val jsonChannelsAdapter = moshi.adapter(JsonChannelsList::class.java)
    val jsonMessagesAdapter = moshi.adapter(JsonMessages::class.java)

    val slackToken = args[0]

    val list = get("https://slack.com/api/channels.list?token=$slackToken&exclude_archived=true&pretty=1")

    val jsonChannelsList: JsonChannelsList = jsonChannelsAdapter.fromJson(list.jsonObject.toString()) as JsonChannelsList;
    println("${list.statusCode} - ${list.jsonObject}")
    val channels = jsonChannelsList.channels
    val archivable = arrayListOf<ArchiveableChannel>()

    println("Finding Archiveable Channels")
    for (c in channels) {
        println("Channel ${c.name_normalized} ")
        if (c.is_private) {
            println("private, skipped.")
        if (c.is_archived) {
            println("archived already.")
        val channelId = c.id;
        val THREE_MONTHS_AGO = ZonedDateTime.now().minusMonths(3).toEpochSecond()
        val msgs = get("https://slack.com/api/channels.history?token=$slackToken&channel=$channelId&oldest=$THREE_MONTHS_AGO&count=1")
//        print("messages ")
//        println(msgs.jsonObject)

        val jsonMessages: JsonMessages = jsonMessagesAdapter.fromJson(msgs.jsonObject.toString()) as JsonMessages
        if (jsonMessages.messages.isEmpty()) {
            archivable.add(ArchiveableChannel(c.id, c.name_normalized))

    println("Archive Channels")
    for (archiveChannel in archivable) {
        val archivedResult = get("https://slack.com/api/channels.archive?token=$slackToken&channel=${archiveChannel.id}&pretty=1")
        print("${archivedResult.statusCode} ")
        print("${archiveChannel.name} ")
    println("Archived ${archivable.size} channels.")
    println("Archived $archivable")

Dependencies needed:

compile "org.jetbrains.kotlin:kotlin-stdlib:1.0.3"
compile 'khttp:khttp:0.1.0'

Source project here: https://github.com/novoda/spikes/tree/master/slackdeath


Go into Team Settings > Message Archives. Select the "Export" tab, then "start export." Per the information on this page, this will create a file that will consist of "a series of JSON files: one per channel per day with activity, plus a file containing information about all members of your team."

It will take Slack some time to prepare this export, especially if you have a lot of message traffic and media in the channels (it also exports images). After some time, it will e-mail you to let you know the export is ready for download.

  • 1
    Sounds like the question is about another kind of archiving (as in putting the channel away)?
    – user1686
    Commented Aug 23, 2016 at 22:28
  • In the context of Slack this is what I'd expect a person to mean by "archive." Storing the existing chatlog in that channel away and putting it into cold storage. If you delete the channel later, I suppose that'd be a different operation.
    – Bradley Evans
    Commented Aug 23, 2016 at 22:31
  • For reference, on individual channels this help page ( get.slack.help/hc/en-us/articles/213185307-Deleting-a-channel ) shows archiving and deleting to be seperate operations, not a single "save and close" operation.
    – Bradley Evans
    Commented Aug 23, 2016 at 22:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.