How AI is powering better personalization in e-commerce [with Vercel]. Sign up now

Where to find Sanity environment variable details in .env file?

3 repliesLast updated: Nov 29, 2025

Hello, i have sanity .env questions. - where can we find below details
AI Update

I can help you find the details you need for your Sanity .env file! Here's where to locate each piece of information:

Finding Your Project ID and Dataset

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).

Creating API Tokens

To create an API token:

Important: Never commit tokens to version control. Add your .env files to .gitignore.

API Version

The API version is a date string in the format YYYY-MM-DD. Common versions include:

You should always specify an API version to avoid unexpected behavior. The API versioning docs have details on what changed in each version.

Example .env File

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.

Show original thread
3 replies

Was this answer helpful?

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.

Related contributions