Structured Content 2022: Join our conference to explore fresh perspectives on content and digital experiences →

Can I import some utility for generate keys in same format used by sanity studio?

2 replies
Last updated: Nov 16, 2020

Hello, I'm migrating some data through sanity client using sanity exec. For collections I got this warning after importing new data:

This usually happens when items are created through the API client from outside the Content Studio and someone forgets to set the _key-property of list items.
The value of the _key can be any string as long as it is unique for each element within the array.
The message is clear, I would just like to know if I can import some utility for generate keys in same format used by sanity studio, to maintain uniformity. Thanks

Nov 16, 2020, 3:44 PM

In the Sanity JavaScript client library documentation they use an npm package called

to generate the keys

Nov 16, 2020, 3:51 PM

Now I see! Perfect, thank you

Nov 16, 2020, 3:53 PM Get the most out of your content is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Free to get started, pay-as-you-go on all plans.