Deleting lost data in Sanity.io using the API

9 replies
Last updated: Oct 28, 2020
Another question: I deleted a content type named “Category” but it seems the data that was created with it is still there somewhere. I get a graphql warning that documents exists with this type that I cannot access anymore. Is there a way to clean up this “lost data”?
Oct 28, 2020, 10:48 AM
you can try to fetch documentIds and remove it through API
Oct 28, 2020, 11:47 AM
I have the documentIds. How can you remove them through the API?
Oct 28, 2020, 2:24 PM
client.delete('bike-123')
  .then(res => {
    console.log('Bike deleted')
  })
  .catch(err => {
    console.error('Delete failed: ', err.message)
  })
Oct 28, 2020, 2:25 PM
Thx again!
Oct 28, 2020, 2:26 PM
I have the documentIds. How can you remove them through the API?
Oct 28, 2020, 2:24 PM
client.delete('bike-123')
  .then(res => {
    console.log('Bike deleted')
  })
  .catch(err => {
    console.error('Delete failed: ', err.message)
  })
Oct 28, 2020, 2:25 PM
Thx again!
Oct 28, 2020, 2:26 PM

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?