🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

How to retrieve a previous dataset in Sanity.io using the History API.

12 replies
Last updated: Jun 13, 2022
Hello,Does sanity keep dataset backups somewhere or is it something that needs to be done manually?
Is there a way to retrieve a dataset as of yesterday?

I have mistakenly overwritten the production dataset with the development one which is few months old, and I cannot find any option on the website to restore a previous dataset. (project is on team plan if that helps)

Jun 10, 2022, 9:07 AM
You’d have to do it manually with the export functionality I’m afraid. 😞
Jun 10, 2022, 9:16 AM
Maybe a support engineer can help you though.
Jun 10, 2022, 9:17 AM
Thanks User, how do I reach a support engineer?
Jun 10, 2022, 9:18 AM
Someone will reach out to you I guess.
Jun 10, 2022, 9:31 AM
Thanks 🙂 I'll wait
Jun 10, 2022, 9:32 AM
Hi User,This might be a case we cannot solve
😔. We generally recommend folks adopt their own backup routine; either by exporting their dataset or by making use of our cloud dataset cloning (for enterprise customers).However since you didn't delete the dataset in this case, it might be possible to rework it with information from the
History API if you feel comfortable writing a script. If you wish to explore that route, please let us know if we can assist in any way.
Jun 10, 2022, 5:46 PM
user J
, yep I've written sanity scripts before so I might get down to that route.
Does the history gets preserved even if I ran a restore with the
flag? From a quick check on the backend everything seem to be dated back to April, some documents even on February with the exception of new documents which have been preserved
Jun 10, 2022, 6:58 PM
Yes, history should be preserved via the transaction log.You can confirm this by running the command below, replacing these variables:

(obtained via
sanity debug --secrets
in the CLI)


of a document that was replaced)
curl -H "Authorization: Bearer <AUTH_TOKEN>" "https://<PROJECT_ID>.<http://api.sanity.io/v2021-06-07/data/history|api.sanity.io/v2021-06-07/data/history>/<DATASET_NAME>/transactions/<DOCUMENT_ID>?excludeContent=true"
Jun 13, 2022, 9:47 AM
omg, it works
Jun 13, 2022, 10:22 AM
Life saver! Thank you very much!!!
Jun 13, 2022, 10:22 AM
Jun 13, 2022, 10:45 AM
Wonderful we were able to help you out!
Jun 13, 2022, 10:46 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?