capabilities.work

Bulk Delete by Query

A 2-step recipe with Sanity. We can help you get access.

Recipe · 2 steps

Bulk Delete by Query

with Sanity

Delete all documents matching a GROQ filter after counting them.

  1. Count how many documents match the filter so the deletion blast radius is known before any write.
  2. Issue a delete mutation that targets every document selected by the GROQ query.
What you'll need to have ready
  • projectId: The Sanity project id that scopes the API endpoint.
  • apiToken: Sanity project API token used as a Bearer credential.
  • dataset: Dataset name to delete documents from.
  • filter: GROQ filter expression selecting documents to delete (e.g. _type == "tempImport").
For your developer

Arazzo workflow sanity:bulk-delete-by-query, 2 operations: queryDocumentsPost → mutateDocuments. Specs on APIs.io.