Sanity CLI dataset and CORS commands not found in Studio v3

13 replies
Last updated: Nov 29, 2025
Hello everyone, I’m wondering how to interact with the CLI and sanity studio v3. It seems that some commands no longer exists (like dataset and CORS)?
Here is the error message I get when I run
sanity help dataset
for example:
Error: Command "dataset" is not available outside of a Sanity project context.

Run the command again within a Sanity project directory, where "@sanity/core" is installed as a dependency.
AI Update

Good news - those commands still exist! The error message is actually telling you exactly what's happening: you need to run these commands from within a Sanity project directory, not just anywhere on your system.

The Context Issue

In Sanity CLI v3, many commands like dataset and cors require you to be inside a Sanity project folder (where @sanity/core is installed as a dependency). This is different from some global CLI operations that can run anywhere.

Here's how to fix this:

  1. Navigate to your Sanity project directory (where your sanity.config.ts or sanity.config.js file lives)
  2. Then run the commands:
cd /path/to/your-sanity-project
sanity dataset list
sanity cors list

Available Dataset & CORS Commands

Once you're in the correct directory, these commands should work:

Dataset commands:

  • sanity dataset list - List all datasets in your project
  • sanity dataset create <name> - Create a new dataset
  • sanity dataset export - Export dataset content
  • sanity dataset import - Import data into a dataset

CORS commands:

  • sanity cors list - List CORS origins
  • sanity cors add <origin> - Add a CORS origin
  • sanity cors delete <id> - Remove a CORS origin

CLI Configuration

Make sure your project has a CLI configuration file (sanity.cli.js or sanity.cli.ts) in the project root with your project ID:

import { defineCliConfig } from "sanity/cli";

export default defineCliConfig({
  api: {
    projectId: 'your-project-id',
    dataset: 'production'
  }
});

You can find more details in the official CLI documentation.

If you're trying to manage multiple projects, you'll need to cd into each project's directory before running these context-dependent commands, or use the --project flag where supported to specify which project you're working with.

Show original thread
13 replies

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?