How to retrieve a previous dataset in Sanity.io using the History API.
I'm really sorry to hear about this situation - accidentally overwriting production data is incredibly stressful. Let me clarify what options are available to you.
Understanding Backups vs. Document History
First, it's important to distinguish between two different Sanity features:
Document History/Revisions: This is automatically enabled for all plans and tracks individual document changes over time. However, the retention period is limited based on your plan:
- Free plan: 3 days
- Growth plan: 90 days
- Enterprise plan: 365 days
Backups: This is a separate enterprise-only feature that provides managed dataset snapshots with longer retention policies. This feature must be manually enabled via the CLI and is not available on the Team plan.
Your Situation on the Team Plan
Unfortunately, the Team plan (which has been deprecated in favor of the current Free/Growth/Enterprise tiers) does not have access to the managed Backups feature. This means Sanity doesn't automatically create full dataset backups that you can restore.
However, you may still be able to recover your data depending on your plan's document history retention:
If Your Team Plan Has Document History Retention
The document revision system keeps track of individual document changes. If your Team plan includes revision history similar to the Growth plan (90 days), your documents from "yesterday" should still exist in the revision history.
Important limitation: The History API is designed for restoring individual documents, not bulk dataset restoration. You would need to:
- Know which documents were overwritten
- Access each document's history individually
- Restore them one by one
This is technically possible but extremely time-consuming for an entire dataset.
Immediate Action Required: Contact Support
Given that you've overwritten your entire production dataset, you need to contact Sanity support immediately. Reach them through your Sanity dashboard or at support@sanity.io.
Explain:
- You're on a Team plan
- You accidentally overwrote production with an old development dataset
- You need urgent help with recovery options
Support may be able to:
- Clarify your specific plan's retention policies
- Provide guidance on bulk recovery tools not publicly documented
- Potentially assist with special recovery procedures for this emergency situation
Time is critical - the sooner you contact them, the better your chances of recovery.
What Sanity Does NOT Provide
Sanity does not automatically create or store full dataset backups for you unless you're on an Enterprise plan with the Backups feature enabled. This is a common misconception - document history is not the same as dataset backups.
Prevention for the Future
Once you've resolved this situation, you should implement your own backup strategy using the dataset export CLI command:
# Manual backup
sanity dataset export production backup-$(date +%Y%m%d).tar.gzYou can automate this with:
- GitHub Actions to create scheduled backups
- Cron jobs that run exports and store them in cloud storage (S3, Google Cloud Storage, etc.)
- CI/CD pipelines
Also consider:
- Using separate projects (not just datasets) for production and development to prevent this type of accident
- Implementing stricter access controls for production
Bottom Line
Contact Sanity support immediately - they're your best hope for recovery. Don't make any more changes to your production dataset until you've spoken with them or begun a recovery process. While document history may preserve individual document versions from yesterday, recovering an entire overwritten dataset is not something you can easily do yourself with the available tools.
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.