
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThis error means your sanity.cli.js file is missing the required projectId configuration that the CLI needs to communicate with Sanity's API. Here's how to fix it:
Create or update your sanity.cli.js file in the root of your project with this minimal configuration:
import { defineCliConfig } from 'sanity/cli'
export default defineCliConfig({
api: {
projectId: 'your-project-id',
dataset: 'production'
}
})Replace 'your-project-id' with your actual Sanity project ID (you can find this in your Sanity manage dashboard).
It's better practice to use environment variables:
import { defineCliConfig } from 'sanity/cli'
export default defineCliConfig({
api: {
projectId: process.env.SANITY_STUDIO_PROJECT_ID,
dataset: process.env.SANITY_STUDIO_DATASET
}
})Then add these to your .env file:
SANITY_STUDIO_PROJECT_ID=your-project-id SANITY_STUDIO_DATASET=production
If you're using TypeScript, create sanity.cli.ts instead:
import { defineCliConfig } from 'sanity/cli'
export default defineCliConfig({
api: {
projectId: process.env.SANITY_STUDIO_PROJECT_ID!,
dataset: process.env.SANITY_STUDIO_DATASET!,
}
})The sanity.cli.js configuration file is specifically for CLI operations. If this file is missing or incomplete, the CLI will try to fall back to your sanity.config.ts file, but it's best practice to have both properly configured. The CLI config is what allows commands like sanity deploy, sanity dataset, and other CLI operations to know which project they're working with.
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