Skip to main content
Sanity CLI provides various commands for managing projects, authentication, accessing documentation, and development utilities beyond the core build/deploy workflow.

Project Management

Open Management Interface

Open your project’s management interface in a web browser:
sanity manage
This opens:
  • https://www.sanity.io/manage/project/<project-id> (if in a project directory)
  • https://www.sanity.io/manage/ (if not in a project)
The management interface allows you to configure API settings, CORS origins, datasets, team members, and more.

List Projects

List all projects you have access to:
sanity projects list
Output:
Your projects:
  abc123 - My Awesome Project
  def456 - E-commerce Store
  ghi789 - Blog CMS

Create Project

Create a new Sanity project:
sanity projects create
You’ll be prompted for:
  • Project name
  • Organization (if you belong to multiple)
  • Project plan

Authentication

Login

Authenticate the CLI:
sanity login
Options:
  • --sso <slug> - Log in using Single Sign-On
  • --provider <providerId> - Authenticate against a specific provider
  • --no-open - Don’t open browser, only print URL
sanity login

Logout

Log out from the CLI:
sanity logout
This:
  • Revokes the current session
  • Clears stored authentication token
  • Clears cached telemetry consent

Documentation Access

Browse Documentation

Open Sanity documentation in your browser:
sanity docs browse
This opens sanity.io/docs.

Search Documentation

Search the documentation from the CLI:
sanity docs search <query>
Example:
sanity docs search "portable text"

Read Documentation

Read documentation in the terminal:
sanity docs read <topic>
Example:
sanity docs read "schema-types"

Development Tools

Debug Information

Gather debugging information:
sanity debug
Outputs:
  • Sanity CLI version
  • Node.js version
  • Package versions
  • Project configuration
  • System information
For sensitive information (auth tokens):
sanity debug --secrets
The --secrets flag exposes authentication tokens. Only use when troubleshooting and never share the output publicly.

Check Versions

Show installed versions of Sanity packages:
sanity versions
Output:
Installed Sanity modules:
  @sanity/cli: 3.42.0
  sanity: 5.13.0
  @sanity/vision: 3.42.0
  @sanity/ui: 2.0.0

Install Plugin

Install a Sanity plugin:
sanity install <plugin-name>
Example:
sanity install @sanity/vision
This:
  1. Installs the npm package
  2. Adds it to package.json
  3. Optionally adds it to sanity.config.ts
Modern Sanity projects use standard npm/pnpm/yarn commands. The install command is primarily for backward compatibility.

Type Generation

Generate TypeScript Types

Generate TypeScript types from your schema:
sanity typegen generate
This creates TypeScript definitions based on your schema files. Options:
  • --output <path> - Output file path (default: sanity.types.ts)
  • --watch - Watch for changes and regenerate
Example:
sanity typegen generate --output ./types/sanity-schema.ts

Telemetry

Manage CLI telemetry settings.

Check Status

sanity telemetry status

Enable Telemetry

sanity telemetry enable

Disable Telemetry

sanity telemetry disable
Telemetry helps improve Sanity by sharing anonymous usage data. It can be disabled at any time.

Sanity Functions

Manage Sanity Functions (serverless functions).

Development Server

Start local functions development server:
sanity functions dev

View Logs

View function execution logs:
sanity functions logs

Test Functions

Test functions locally:
sanity functions test

Manage Environment Variables

Manage function environment variables:
sanity functions env

Blueprints

Manage infrastructure blueprints (Infrastructure as Code).

Initialize Blueprint

sanity blueprints init

Plan Changes

Preview infrastructure changes:
sanity blueprints plan

Deploy Blueprint

Apply infrastructure changes:
sanity blueprints deploy

View Blueprint Info

sanity blueprints info

View Logs

sanity blueprints logs

Destroy Infrastructure

sanity blueprints destroy
The destroy command permanently removes infrastructure resources. Use with caution.

OpenAPI

Interact with Sanity OpenAPI specifications.

List Specifications

sanity openapi list

Get Specification

sanity openapi get <spec-id>

Code Transformation

Run Codemod

Run codemods to transform your code:
sanity codemod <codemod-name>
Codemods help with:
  • Migrating between major versions
  • Updating deprecated patterns
  • Transforming schema definitions

Learning Resources

Interactive Learning

Access interactive learning resources:
sanity learn
This opens Sanity’s learning platform in your browser.

AI Editor Integration (MCP)

Configure Model Context Protocol for AI editor integration:
sanity mcp configure
This sets up:
  • Cursor integration
  • Windsurf integration
  • Other MCP-compatible editors
MCP integration allows AI coding assistants to understand your Sanity schema and provide better suggestions.

Help

Get help for any command:
sanity help
sanity help <command>
Examples:
sanity help

Configuration Files

Management commands read from:

sanity.cli.ts

CLI-specific configuration:
sanity.cli.ts
import {defineCliConfig} from 'sanity/cli'

export default defineCliConfig({
  api: {
    projectId: 'abc123',
    dataset: 'production',
  },
  deployment: {
    appId: 'your-app-id',
  },
  autoUpdates: true,
})

sanity.config.ts

Studio configuration:
sanity.config.ts
import {defineConfig} from 'sanity'
import {structureTool} from 'sanity/structure'

export default defineConfig({
  name: 'default',
  title: 'My Studio',
  projectId: 'abc123',
  dataset: 'production',
  plugins: [structureTool()],
})

Environment Variables

Management commands respect:
  • SANITY_AUTH_TOKEN - Authentication token (for CI/CD)
  • SANITY_STUDIO_PROJECT_ID - Override project ID
  • SANITY_STUDIO_DATASET - Override dataset
Example CI usage:
SANITY_AUTH_TOKEN=${{ secrets.SANITY_TOKEN }} sanity deploy --yes

Common Workflows

Initial Project Setup

# Create and configure a new project
npm create sanity@latest
cd my-sanity-project
sanity login
sanity dev

Adding Team Members

# Open project management
sanity manage

# Navigate to "Team" and invite members

Debugging Issues

# Gather debug info
sanity debug

# Check versions
sanity versions

# Search documentation
sanity docs search "error message"

Type-Safe Development

# Generate TypeScript types from schema
sanity typegen generate

# Start development with type safety
sanity dev

Next Steps

CLI Overview

Return to CLI overview and command reference

Initialize Project

Learn about project initialization

Build docs developers (and LLMs) love