home / http-apis / sanity

Sanity CLI

Official · Sanity

Official Sanity CLI for Studio setup, datasets, documents, schema tooling, deployments, and content platform operations.

$npm install --global sanity@latest
Language
TypeScript
Stars
6,023
Category
HTTP & APIs
Agent
Ready
Agent Compatibility
JSON Output
Agent Skill
MCP Support
AI Analysis

Sanity CLI is the official command surface for creating, developing, and operating Sanity Studio projects and the underlying content platform. It covers local studio workflows, content and dataset operations, schema and API tooling, and deployment tasks.

What It Enables
  • Initialize studios or apps, run local dev and deploy flows, and manage project settings, datasets, CORS, tokens, users, and project creation from the shell.
  • Query, fetch, create, delete, import, export, validate, and migrate content and datasets without going through the Studio UI.
  • Extract schemas, generate types, deploy GraphQL APIs, inspect OpenAPI specs, and operate newer platform surfaces such as functions and blueprints.
Agent Fit
  • Several high-value commands return structured JSON, including document queries and gets, token and project flows, OpenAPI output, function logs, and blueprint diagnostics.
  • The CLI exposes real inspect/change/verify loops across content, schema, datasets, and deployments, so it fits scripted maintenance, migrations, and CI workflows well.
  • It can also configure Sanity MCP server entries for supported AI editors, though the direct shell commands are the more important automation surface here.
Caveats
  • A lot of the value depends on an existing sanity.cli.ts project context and Sanity credentials; sanity login opens a browser by default.
  • JSON support is command-specific rather than universal, and init or deploy flows still lean on prompts unless you pass unattended flags.