Was this page helpful?
Deploy your schema into your dataset to enable deep integration between your content model and Sanity apps.
With the launch of version 3.88.0, Sanity Studio gains support for deploying a representation of your content model, in the form of a schema, to your dataset. This allows for robust integration between your finely tuned studios and apps like Dashboard and Canvas.
Working with AI? The Sanity MCP Server can also deploy your schema.
The schema commands belong to the sanity schema group. They allow you to deploy your schemas at the workspace level to your corresponding combination of dataset and projectId, making them accessible to various Sanity apps and APIs.
For commands requiring a deploy token (when not logged in with proper privileges), use:
SANITY_AUTH_TOKEN=<your-deploy-token> sanity schema <command>
sanity schema deployDeploys schema documents to workspace datasets. If you've already run sanity login, you typically have deploy permission by default. In CI environments where sanity login hasn't been executed, you'll need to provide a deploy token.
Options:
--workspace <workspace_name> - Deploy for a specific workspace. Essential for studios with multiple projectIds.--tag <tag> - Add a tag suffix to the schema id for testing without overwriting existing schemas.--manifest-dir <directory> - Directory with manifest file (default: ./dist/static). Crucial for embedded studios.--no-extract-manifest - Skip manifest generation when nothing has changed.--verbose - Show detailed deployment information, including the schemaId.Examples:
# Deploy all workspace schemas sanity schema deploy # Deploy schema for specific workspace sanity schema deploy --workspace default # Use existing manifest file sanity schema deploy --no-extract-manifest
sanity schema listLists all schemas in the current dataset. This is important for identifying the schema id needed for agent actions.
Options:
--json - Get schema as JSON--id <schema_id> - Fetch a single schema by id--manifest-dir <directory> - Directory containing manifest file (default: ./dist/static)--no-extract-manifest - Skip manifest generationExamples:
# List all schemas sanity schema list # Get specific schema sanity schema list --id _.schemas.workspaceName # Get schemas as JSON sanity schema list --json
sanity schema deleteRemoves schema documents by id. Useful when you need to remove schemas from Canvas or Agent Actions.
Options:
--ids <schema_id_1,schema_id_2,...> - Comma-separated list of schema ids to delete--dataset <dataset_name> - Delete schemas from a specific dataset--manifest-dir <directory> - Directory containing manifest file (default: ./dist/static)--no-extract-manifest - Skip manifest generationExamples:
# Delete single schema sanity schema delete --ids _.schemas.workspaceName # Delete multiple schemas sanity schema delete --ids _.schemas.workspaceName,_.schemas.otherWorkspace.tag.taggedSchema
sanity schema extractExtracts studio configuration as JSON files, which are used by other Sanity tools to understand your studio setup.
Options:
--path <directory>: Custom destination directory for manifest files (default: /dist/static)—-watch: Run watch mode to run extract as changes to the schema occur.--workspace <name>: The name of the workspace to generate a schema for.--path: Optional path to specify destination of the schema file.--format=[groq-type-nodes]: Format the schema as GROQ type nodes. Only available format at the moment.--watch: Enable watch mode to re-extract schema on file changes.--watch-patterns <glob>: Additional glob pattern(s) to watch (can be specified multiple times).Examples:
# Extract schema to default location sanity schema extract # Extract to custom directory sanity schema extract --path /public/static # Extract to a directory with watch sanity schema extract --path /public/static --watch
The extracted manifest follows this structure:
interface CreateManifest {
version: number // Current version: 2
createdAt: string // ISO timestamp
workspaces: ManifestWorkspaceFile[]
}
interface ManifestWorkspaceFile {
name: string
title?: string
subtitle?: string
basePath: string
dataset: string
projectId: string
schema: string // filename with serialized schema
tools: string // filename
icon: string | null
}The manifest system works with several Sanity CLI commands:
deploy, list, and delete use the manifest to identify schemasThe following commands are only relevant for Typegen and don't impact server-side schema functionality or compatibility with Dashboard, Canvas, or Agent Actions:
sanity schema validateValidates schema types in a workspace.
Options:
--workspace <name> - Workspace to validate--format <pretty|ndjson|json> - Output format--level <error|warning> - Minimum reporting level (default: warning)sanity manifest extractExtracts the studio configuration as one or more JSON manifest files.
Options:
--path: Optional path to specify destination directory of the manifest files. Default: /dist/staticsanity deploy - Includes schema deployment in the processsanity typegen generate - Creates TypeScript types from schema types and GROQ queries<studio-url>/static/create-manifest.json. You can specify this using the --path option.--no-extract-manifest to use existing files.SANITY_AUTH_TOKEN=<your-deploy-token> sanity schema <command># Deploy all workspace schemas
sanity schema deploy
# Deploy schema for specific workspace
sanity schema deploy --workspace default
# Use existing manifest file
sanity schema deploy --no-extract-manifest# List all schemas
sanity schema list
# Get specific schema
sanity schema list --id _.schemas.workspaceName
# Get schemas as JSON
sanity schema list --json# Delete single schema
sanity schema delete --ids _.schemas.workspaceName
# Delete multiple schemas
sanity schema delete --ids _.schemas.workspaceName,_.schemas.otherWorkspace.tag.taggedSchema# Extract schema to default location
sanity schema extract
# Extract to custom directory
sanity schema extract --path /public/static
# Extract to a directory with watch
sanity schema extract --path /public/static --watchinterface CreateManifest {
version: number // Current version: 2
createdAt: string // ISO timestamp
workspaces: ManifestWorkspaceFile[]
}
interface ManifestWorkspaceFile {
name: string
title?: string
subtitle?: string
basePath: string
dataset: string
projectId: string
schema: string // filename with serialized schema
tools: string // filename
icon: string | null
}