Unlock seamless workflows and faster delivery with our latest releases – get the details

Delete documents using sanity cli

This bash script can be used to delete documents using sanity cli.

deletedocs.sh

#!/bin/bash

type=$1
for id in $(sanity documents query "*[_type=='$type'] {_id}" | jq -r '.[] |$
    sanity documents delete "$id"
done

You can you this bash script to delete documents from Sanity.

Usage: ./deletedocs.sh <type>

Where <type> is the type of document you want to delete.

Contributor