How to find API tokens and create a preview secret in Sanity.io.

3 replies
Last updated: Mar 15, 2024
Hello, i have sanity .env questions. - where can we find below details
Mar 15, 2024, 11:22 AM
On your project dashboard. If you go to sanity.io and log in you'll find your projects there and on the page for that project you'll find those tokens.
Mar 15, 2024, 11:32 AM
Hello
user G
Thanks for your response. It is really helpful
I created API token as "Website preview" from here for SANITY_API_TOKEN - now how can do for the SANITY_PREVIEW_SECRET
Mar 15, 2024, 12:04 PM
The
SANITY_PREVIEW_SECRET
can be anything - it's just there to hash things with (I think). You need to create (ideally) 2 tokens: 1 with read access and 1 with read and write access. You do that in the API panel in the
tokens
section at the bottom.
Mar 15, 2024, 2:49 PM

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.

Was this answer helpful?