✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

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