Creating a dataset with public and private data in Sanity.io
Last updated: Sep 6, 2020
Is that possible to create a dataset that contains public & private documents, and the client can only access the public data while in the CMS can access both public and private data? Or I can only create different datasets individually?
Sep 5, 2020, 5:27 AM
I found Spaces may help, create two datasets for public and private use. Another question is, my public and private dataset have different schema, but Spaces seem share same schema even with different
Sep 5, 2020, 7:27 AM
A workaround is I can share the same schema in different datasets, but show a subset of documents that the current dataset needed in the navigation bar based on
So I can create private documents by providing a custom id like
(only through API ), then the client (without token) can’t access them. Am I right? 
The Sanity Studio automatically generates a random UUID for new documents (e.g.
), and does not allow you to specify an ID yourself, but you are free to use your own ID scheme for documents that you create using the HTTP API.
Sep 5, 2020, 8:21 AM
Sep 5, 2020, 8:49 AM
It works, thanks!
Sep 5, 2020, 8:52 AM
Or is it safest to keep it a private dataset and proxy the API requests using serverless functions?
Sep 5, 2020, 8:56 PM
You are right in thinking that. It’s the same way that drafts and the system documents (containing the permissions) work 🙂
Sep 6, 2020, 10:22 AM
– never clocked that this is why drafts only show up in authenticated requests. Amazing! Very excited to start making some lightweight shops in Sanity 🙂