Introducing History API & Experience
Written by Even Westvang
We’re thrilled to announce that we have released a new document history experience in Sanity Studio, as well as a new API for querying document revisions. Upgrade your Studio (sanity upgrade
) to get the new features, and visit our documentation.
Now you can browse revisions for documents, as well as restore earlier versions. Both via an API and in Sanity Studio. You can now also see who made the edits which is a significant improvement to collaborative workflows.
The History API and Experience
To make a History Experience for people working with content in the Studio, we had to build APIs that it could query. Obviously, since the Studio is open source and can be hosted anywhere, we had to make these APIs are available for you to use however you see fit outside of the Studio as well. To learn more about the different endpoints and how they work, check out the API documentation.
What we call “History Experience” is the user interface for browsing through revisions, and restoring them within the Studio. This includes some new labels for document status, which we hope will make it easier to spot if a document is a draft, and if it has been published.
This UI is only the first public iteration. Features like diffing between revisions will come at a later point. It's a non-trivial design challenge, since Sanity allows you to have deeply nested structured content. We really want to get diffing right, so it's both intuitive and useful for people who work with content.
How long do we remember?
History retention is the amount of time you have access to these revisions before they are automatically deleted. The latest version of your published and drafted document will always be available.
The retention period on your documents are defined by the plan you are on. We count retention time backward from the current day.
The retention time for the different plans are:
- Standard (free, pay-as-you-go): 3 days
- Advanced: 90 days, can be upgraded to 365 days
- Enterprise: 365 days, or contact us for custom retention
Revisions that are older than the cutoff will be truncated into one revision item, older transactions will be permanently deleted. The document history is truncated regularly every day.
GDPR and the ability to forget
In order to make Sanity Studio real-time we made it send debounced keystrokes as patches to the backend. From when we launched publicly in fall 2017, to spring 2018, we kept a complete history of these patches. But in order to be compliant with the European General Data Protection Regulation (GDPR), we had to build the mechanisms to be able to also forget all these patches. Forgetting is actually a feature.
According to the GDPR, you need to be able to guarantee your data is actually scrubbed within a given time limit. This absolutely also goes for personally sensitive data in your content. This means that staying GDPR compliant will be a breeze with Sanity, compared to other content platforms where you would have to build mechanisms to clean your history in Git or in your database.
Obviously, if you choose export your documents or patch events outside of Sanity, it will be on you to take care of in terms of GPDR compliance. Fortunately, that shouldn't be too difficult with structured content.