
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI can help you find the details you need for your Sanity .env file! Here's where to locate each piece of information:
You can find both your project ID and dataset name at manage.sanity.io:
Your dataset name is typically something like production, development, or whatever you named it when creating your project. You can see all available datasets in your project settings under the "Datasets" section.
Alternatively, if you already have a Studio set up locally, you can find these in your sanity.config.js or sanity.json file (for older Studio v2 projects).
To create an API token:
Important: Never commit tokens to version control. Add your .env files to .gitignore.
The API version is a date string in the format YYYY-MM-DD. Common versions include:
2021-03-25 (introduced GROQ spec compliance)2021-10-212025-02-19 (latest, changed default perspective to published)You should always specify an API version to avoid unexpected behavior. The API versioning docs have details on what changed in each version.
Here's what your .env file should look like:
SANITY_STUDIO_API_PROJECT_ID=your-project-id SANITY_STUDIO_API_DATASET=production SANITY_AUTH_TOKEN=your-token-here
Note: Environment variables for Sanity Studio must be prefixed with SANITY_STUDIO_. If you're using Next.js, you'll need NEXT_PUBLIC_ prefix instead for client-side variables. More details in the environment variables documentation.
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store