
Company News
Meet the Socket Team at RSAC and BSidesSF 2026
Join Socket for live demos, rooftop happy hours, and one-on-one meetings during BSidesSF and RSA 2026 in San Francisco.
@sanity/cli
Advanced tools
Code for sanity cli
sanity backup disable [DATASET]sanity backup download [DATASET]sanity backup enable [DATASET]sanity backup list [DATASET]sanity blueprints add TYPEsanity blueprints configsanity blueprints deploysanity blueprints destroysanity blueprints doctorsanity blueprints infosanity blueprints init [DIR]sanity blueprints logssanity blueprints plansanity blueprints stackssanity build [OUTPUTDIR]sanity codemod [CODEMODNAME]sanity cors add ORIGINsanity cors delete [ORIGIN]sanity cors listsanity dataset alias create [ALIASNAME] [TARGETDATASET]sanity dataset alias delete ALIASNAMEsanity dataset alias link [ALIASNAME] [TARGETDATASET]sanity dataset alias unlink [ALIASNAME]sanity dataset copy [SOURCE] [TARGET]sanity dataset create [NAME]sanity dataset delete DATASETNAMEsanity dataset embeddings disable [DATASET]sanity dataset embeddings enable [DATASET]sanity dataset embeddings status [DATASET]sanity dataset export [NAME] [DESTINATION]sanity dataset import SOURCEsanity dataset listsanity dataset visibility get DATASETsanity dataset visibility set DATASET MODEsanity debugsanity deploy [SOURCEDIR]sanity devsanity docs browsesanity docs read PATHsanity docs search QUERYsanity documents create [FILE]sanity documents delete ID [IDS]sanity documents get DOCUMENTIDsanity documents query QUERYsanity documents validatesanity exec SCRIPTsanity functions addsanity functions devsanity functions env add NAME KEY VALUEsanity functions env list NAMEsanity functions env remove NAME KEYsanity functions logs [NAME]sanity functions test [NAME]sanity graphql deploysanity graphql listsanity graphql undeploysanity help [COMMAND]sanity hook attempt ATTEMPTIDsanity hook createsanity hook delete [NAME]sanity hook listsanity hook logs [NAME]sanity initsanity install [PACKAGES]sanity learnsanity loginsanity logoutsanity managesanity manifest extractsanity mcp configuresanity media create-aspectsanity media delete-aspect ASPECTNAMEsanity media deploy-aspect [ASPECTNAME]sanity media export [DESTINATION]sanity media import SOURCEsanity migration create [TITLE]sanity migration listsanity migration run [ID]sanity openapi get SLUGsanity openapi listsanity preview [OUTPUTDIR]sanity projects create [PROJECTNAME]sanity projects listsanity schema deletesanity schema deploysanity schema extractsanity schema listsanity schema validatesanity start [OUTPUTDIR]sanity telemetry disablesanity telemetry enablesanity telemetry statussanity tokens add [LABEL]sanity tokens delete [TOKENID]sanity tokens listsanity typegen generatesanity undeploysanity users invite [EMAIL]sanity users listsanity versionssanity backup disable [DATASET]Disable backup for a dataset.
USAGE
$ pnpm exec sanity backup disable [DATASET]
ARGUMENTS
[DATASET] Dataset name to disable backup for
DESCRIPTION
Disable backup for a dataset.
EXAMPLES
Interactively disable backup for a dataset
$ pnpm exec sanity backup disable
Disable backup for the production dataset
$ pnpm exec sanity backup disable production
See code: src/commands/backup/disable.ts
sanity backup download [DATASET]Download a dataset backup to a local file.
USAGE
$ pnpm exec sanity backup download [DATASET] [--backup-id <value>] [--concurrency <value>] [--out <value>] [--overwrite]
ARGUMENTS
[DATASET] Dataset name to download backup from
FLAGS
--backup-id=<value> The backup ID to download
--concurrency=<value> [default: 10] Concurrent number of backup item downloads (max: 24)
--out=<value> The file or directory path the backup should download to
--overwrite Allows overwriting of existing backup file
DESCRIPTION
Download a dataset backup to a local file.
EXAMPLES
Interactively download a backup
$ pnpm exec sanity backup download
Download a specific backup for the production dataset
$ pnpm exec sanity backup download production --backup-id 2024-01-01-backup-1
Download backup to a specific file
$ pnpm exec sanity backup download production --backup-id 2024-01-01-backup-2 --out /path/to/file
Download backup and overwrite existing file
$ pnpm exec sanity backup download production --backup-id 2024-01-01-backup-3 --out /path/to/file --overwrite
See code: src/commands/backup/download.ts
sanity backup enable [DATASET]Enable backup for a dataset.
USAGE
$ pnpm exec sanity backup enable [DATASET]
ARGUMENTS
[DATASET] Dataset name to enable backup for
DESCRIPTION
Enable backup for a dataset.
EXAMPLES
Interactively enable backup for a dataset
$ pnpm exec sanity backup enable
Enable backup for the production dataset
$ pnpm exec sanity backup enable production
See code: src/commands/backup/enable.ts
sanity backup list [DATASET]List available backups for a dataset.
USAGE
$ pnpm exec sanity backup list [DATASET] [--after <value>] [--before <value>] [-l <value>]
ARGUMENTS
[DATASET] Dataset name to list backups for
FLAGS
-l, --limit=<value> [default: 30] Maximum number of backups returned
--after=<value> Only return backups after this date (inclusive, YYYY-MM-DD format)
--before=<value> Only return backups before this date (exclusive, YYYY-MM-DD format)
DESCRIPTION
List available backups for a dataset.
EXAMPLES
List backups for a dataset interactively
$ pnpm exec sanity backup list
List backups for the production dataset
$ pnpm exec sanity backup list production
List up to 50 backups for the production dataset
$ pnpm exec sanity backup list production --limit 50
List up to 10 backups created after 2024-01-31
$ pnpm exec sanity backup list production --after 2024-01-31 --limit 10
See code: src/commands/backup/list.ts
sanity blueprints add TYPEAdd a function resource to a Blueprint
USAGE
$ pnpm exec sanity blueprints add TYPE [--example <value> | -n <value> | --fn-type
document-create|document-delete|document-update|document-publish|media-library-asset-create|media-library-asset-upda
te|media-library-asset-delete... | --language ts|js | --javascript | --fn-helpers | --fn-installer
skip|npm|pnpm|yarn] [-i | ]
ARGUMENTS
TYPE (function) Type of resource to add (only "function" is supported)
FLAGS
-i, --install Shortcut for --fn-installer npm
-n, --name=<value> Name of the resource to add
--example=<value> Example to use for the function resource. Discover examples at
https://www.sanity.io/exchange/type=recipes/by=sanity
--[no-]fn-helpers Add helpers to the new function
--fn-installer=<option> Which package manager to use when installing the @sanity/functions helpers
<options: skip|npm|pnpm|yarn>
--fn-type=<option>... Document change event(s) that should trigger the function; you can specify multiple
events by specifying this flag multiple times
<options: document-create|document-delete|document-update|document-publish|media-library-
asset-create|media-library-asset-update|media-library-asset-delete>
--javascript Use JavaScript instead of TypeScript
--language=<option> [default: ts] Language of the new function
<options: ts|js>
DESCRIPTION
Add a function resource to a Blueprint
Scaffolds a new Sanity Function in your Blueprint. Functions are serverless handlers triggered by document events
(create, update, delete, publish) or media library events.
After adding a function, use 'functions dev' to test locally, then 'blueprints deploy' to publish it.
EXAMPLES
$ pnpm exec sanity blueprints add function
$ pnpm exec sanity blueprints add function --helpers
$ pnpm exec sanity blueprints add function --name my-function
$ pnpm exec sanity blueprints add function --name my-function --fn-type document-create
$ pnpm exec sanity blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
See code: @sanity/runtime-cli
sanity blueprints configView or edit the local Blueprint configuration
USAGE
$ pnpm exec sanity blueprints config [--project-id <value> -e] [--stack <value> ]
FLAGS
-e, --edit Modify the configuration interactively, or directly when combined with ID flags.
--project-id=<value> Directly set the project ID in the configuration. Requires --edit flag
--stack=<value> Stack name or ID to set in the configuration. Requires --edit flag
DESCRIPTION
View or edit the local Blueprint configuration
Manages the local Blueprint configuration, which links your Blueprint to a Sanity project and Stack.
Without flags, displays the current configuration. Use --edit to interactively modify settings, or combine --edit with
ID flags to update values directly (useful for scripting and automation).
If you need to switch your Blueprint to a different Stack, use --edit --stack.
EXAMPLES
$ pnpm exec sanity blueprints config
$ pnpm exec sanity blueprints config --edit
$ pnpm exec sanity blueprints config --edit --project-id <projectId>
$ pnpm exec sanity blueprints config --edit --project-id <projectId> --stack <name-or-id>
See code: @sanity/runtime-cli
sanity blueprints deployDeploy the local Blueprint to the remote Stack
USAGE
$ pnpm exec sanity blueprints deploy [--stack <value>] [--no-wait]
FLAGS
--no-wait Do not wait for Stack deployment to complete
--stack=<value> Stack name or ID to use instead of the locally configured Stack
DESCRIPTION
Deploy the local Blueprint to the remote Stack
Pushes your local Blueprint configuration to the remote Stack; provisioning, updating, or destroying resources as
needed. This is the primary command for applying infrastructure changes.
Before deploying, run 'blueprints plan' to preview changes. After deployment, use 'blueprints info' to verify Stack
status or 'blueprints logs' to monitor activity.
Use --no-wait to queue the deployment and return immediately without waiting for completion.
Set SANITY_ASSET_TIMEOUT (seconds) to override the 60-second timeout for processing resource assets.
EXAMPLES
$ pnpm exec sanity blueprints deploy
$ pnpm exec sanity blueprints deploy --no-wait
See code: @sanity/runtime-cli
sanity blueprints destroyDestroy the remote Stack deployment and its resources (will not delete local files)
USAGE
$ pnpm exec sanity blueprints destroy [--project-id <value> --stack <value> --force] [--no-wait]
FLAGS
--force Force Stack destruction (skip confirmation)
--no-wait Do not wait for Stack destruction to complete
--project-id=<value> Project associated with the Stack
--stack=<value> Stack name or ID to destroy (defaults to the locally configured Stack)
DESCRIPTION
Destroy the remote Stack deployment and its resources (will not delete local files)
Permanently removes the remote Stack and all its provisioned resources. Your local Blueprint files remain untouched,
allowing you to redeploy later with 'blueprints init' + 'blueprints deploy'.
This is a destructive operation. You will be prompted to confirm unless --force is specified.
Use this to clean up test environments or decommission a Stack you no longer need.
EXAMPLES
$ pnpm exec sanity blueprints destroy
$ pnpm exec sanity blueprints destroy --stack <name-or-id> --project-id <projectId> --force --no-wait
See code: @sanity/runtime-cli
sanity blueprints doctorDiagnose potential issues with local Blueprint and remote Stack configuration
USAGE
$ pnpm exec sanity blueprints doctor [--json] [-p <value>] [--verbose] [--fix]
FLAGS
-p, --path=<value> [env: SANITY_BLUEPRINT_PATH] Path to a Blueprint file or directory containing one
--fix Interactively fix configuration issues
--json Format output as json.
--[no-]verbose Verbose output; defaults to true
DESCRIPTION
Diagnose potential issues with local Blueprint and remote Stack configuration
Analyzes your local Blueprint and remote Stack configuration for common issues, such as missing authentication,
invalid project references, or misconfigured resources.
Run this command when encountering errors with other Blueprint commands. Use --fix to interactively resolve detected
issues.
See code: @sanity/runtime-cli
sanity blueprints infoShow information about the local Blueprint's remote Stack deployment
USAGE
$ pnpm exec sanity blueprints info [--stack <value>]
FLAGS
--stack=<value> Stack name or ID to use instead of the locally configured Stack
DESCRIPTION
Show information about the local Blueprint's remote Stack deployment
Displays the current state and metadata of your remote Stack deployment, including deployed resources, status, and
configuration.
Use this command to verify a deployment succeeded, check what resources are live, or confirm which Stack your local
Blueprint is connected to.
Run 'blueprints stacks' to see all available Stacks in your project or organization.
EXAMPLES
$ pnpm exec sanity blueprints info
$ pnpm exec sanity blueprints info --stack <name-or-id>
See code: @sanity/runtime-cli
sanity blueprints init [DIR]Initialize a local Blueprint and optionally provision a remote Stack deployment
USAGE
$ pnpm exec sanity blueprints init [DIR] [--verbose] [--dir <value>] [--example <value> | --blueprint-type json|js|ts |
--stack-id <value> | --stack-name <value>] [--project-id <value>]
ARGUMENTS
[DIR] Directory to create the local Blueprint in
FLAGS
--blueprint-type=<option> Blueprint manifest type to use for the local Blueprint
<options: json|js|ts>
--dir=<value> Directory to create the local Blueprint in
--example=<value> Example to use for the local Blueprint
--project-id=<value> Sanity project ID used to scope local Blueprint and remote Stack
--stack-id=<value> Existing Stack ID used to scope local Blueprint
--stack-name=<value> Name to use for a new Stack provisioned during initialization
--verbose Verbose output
DESCRIPTION
Initialize a local Blueprint and optionally provision a remote Stack deployment
A Blueprint is your local infrastructure-as-code configuration that defines Sanity resources (datasets, functions,
etc.). A Stack is the remote deployment target where your Blueprint is applied.
[NOTE: Currently, accounts are limited to three (3) Stacks per project scope.]
This is typically the first command you run in a new project. It creates a local Blueprint manifest file
(sanity.blueprint.ts, .js, or .json) and provisions a new remote Stack.
Additionally, a Blueprint configuration file is created in .sanity/ containing the scope and Stack IDs. This is
.gitignored by default.
After initialization, use 'blueprints plan' to preview changes, then 'blueprints deploy' to apply them.
EXAMPLES
$ pnpm exec sanity blueprints init
$ pnpm exec sanity blueprints init [directory]
$ pnpm exec sanity blueprints init --blueprint-type <json|js|ts>
$ pnpm exec sanity blueprints init --blueprint-type <json|js|ts> --project-id <projectId> --stack-id <stackId>
$ pnpm exec sanity blueprints init --blueprint-type <json|js|ts> --stack-name <stackName>
See code: @sanity/runtime-cli
sanity blueprints logsDisplay logs for the current Blueprint's Stack deployment
USAGE
$ pnpm exec sanity blueprints logs [--stack <value>] [-w]
FLAGS
-w, --watch Watch for new Stack logs (streaming mode)
--stack=<value> Stack name or ID to use instead of the locally configured Stack
DESCRIPTION
Display logs for the current Blueprint's Stack deployment
Retrieves Stack deployment logs, useful for debugging and monitoring deployment activity.
Use --watch (-w) to stream logs in real-time.
If you're not seeing expected logs, verify your Stack is deployed with 'blueprints info'.
EXAMPLES
$ pnpm exec sanity blueprints logs
$ pnpm exec sanity blueprints logs --watch
See code: @sanity/runtime-cli
sanity blueprints planEnumerate resources to be deployed to the remote Stack - will not modify any resources
USAGE
$ pnpm exec sanity blueprints plan [--stack <value>]
FLAGS
--stack=<value> Stack name or ID to use instead of the locally configured Stack
DESCRIPTION
Enumerate resources to be deployed to the remote Stack - will not modify any resources
Use this command to preview what changes will be applied to your remote Stack before deploying. This is a safe,
read-only operation—no resources are created, modified, or deleted.
Run 'blueprints plan' after making local changes to your Blueprint manifest to verify the expected diff. When ready,
run 'blueprints deploy' to apply changes.
EXAMPLES
$ pnpm exec sanity blueprints plan
See code: @sanity/runtime-cli
sanity blueprints stacksList all remote Stack deployments (defaults to the current Blueprint's project scope)
USAGE
$ pnpm exec sanity blueprints stacks [--project-id <value> | ]
FLAGS
--project-id=<value> Project ID to show Stack deployments for
DESCRIPTION
List all remote Stack deployments (defaults to the current Blueprint's project scope)
Shows all Stacks associated with a project or organization. By default, lists Stacks scoped to the local Blueprint.
Use this to discover existing Stacks you can scope a local Blueprint to (using 'blueprints config --edit'), or to
audit what's deployed across your project.
EXAMPLES
$ pnpm exec sanity blueprints stacks
$ pnpm exec sanity blueprints stacks --project-id <projectId>
$ pnpm exec sanity blueprints stacks --organization-id <organizationId>
See code: @sanity/runtime-cli
sanity build [OUTPUTDIR]Builds the Sanity Studio configuration into a static bundle
USAGE
$ pnpm exec sanity build [OUTPUTDIR] [--auto-updates] [--minify] [--source-maps] [--stats] [-y]
ARGUMENTS
[OUTPUTDIR] Output directory
FLAGS
-y, --yes Unattended mode, answers "yes" to any "yes/no" prompt and otherwise uses defaults
--[no-]auto-updates Enable/disable auto updates of studio versions
--[no-]minify Enable/disable minifying of built bundles
--[no-]source-maps Enable source maps for built bundles (increases size of bundle)
--stats Show stats about the built bundles
DESCRIPTION
Builds the Sanity Studio configuration into a static bundle
EXAMPLES
$ pnpm exec sanity build
$ pnpm exec sanity build --no-minify --source-maps
See code: src/commands/build.ts
sanity codemod [CODEMODNAME]Updates Sanity Studio codebase with a code modification script
USAGE
$ pnpm exec sanity codemod [CODEMODNAME] [--dry] [--extensions <value>] [--no-verify]
ARGUMENTS
[CODEMODNAME] Name of the codemod to run
FLAGS
--dry Dry run (no changes are made to files)
--extensions=<value> [default: js,ts,tsx] Transform files with these file extensions (comma separated)
--no-verify Skip verification steps before running codemod
DESCRIPTION
Updates Sanity Studio codebase with a code modification script
EXAMPLES
Show available code mods
$ pnpm exec sanity codemod
Run codemod to transform react-icons imports (dry run)
$ pnpm exec sanity codemod reactIconsV3 --dry
See code: src/commands/codemod.ts
sanity cors add ORIGINAllow a new origin to use your project API through CORS
USAGE
$ pnpm exec sanity cors add ORIGIN [--credentials]
ARGUMENTS
ORIGIN Origin to allow (e.g., https://example.com)
FLAGS
--[no-]credentials Allow credentials (token/cookie) to be sent from this origin
DESCRIPTION
Allow a new origin to use your project API through CORS
EXAMPLES
Interactively add a CORS origin
$ pnpm exec sanity cors add
Add a localhost origin without credentials
$ pnpm exec sanity cors add http://localhost:3000 --no-credentials
Add a production origin with credentials allowed
$ pnpm exec sanity cors add https://myapp.com --credentials
See code: src/commands/cors/add.ts
sanity cors delete [ORIGIN]Delete an existing CORS origin from your project
USAGE
$ pnpm exec sanity cors delete [ORIGIN]
ARGUMENTS
[ORIGIN] Origin to delete (will prompt if not provided)
DESCRIPTION
Delete an existing CORS origin from your project
EXAMPLES
Interactively select and delete a CORS origin
$ pnpm exec sanity cors delete
Delete a specific CORS origin
$ pnpm exec sanity cors delete https://example.com
See code: src/commands/cors/delete.ts
sanity cors listList all origins allowed to access the API for this project
USAGE
$ pnpm exec sanity cors list
DESCRIPTION
List all origins allowed to access the API for this project
EXAMPLES
List CORS origins for the current project
$ pnpm exec sanity cors list
See code: src/commands/cors/list.ts
sanity dataset alias create [ALIASNAME] [TARGETDATASET]Create a dataset alias within your project
USAGE
$ pnpm exec sanity dataset alias create [ALIASNAME] [TARGETDATASET] [-p <value>]
ARGUMENTS
[ALIASNAME] Dataset alias name to create
[TARGETDATASET] Target dataset name to link the alias to
FLAGS
-p, --project-id=<value> Project ID to use. Overrides the project ID from the Sanity config.
DESCRIPTION
Create a dataset alias within your project
EXAMPLES
Create alias in a specific project
$ pnpm exec sanity dataset alias create --project-id abc123 conference conf-2025
Create an alias with interactive prompts
$ pnpm exec sanity dataset alias create
Create alias named "conference" with interactive dataset selection
$ pnpm exec sanity dataset alias create conference
Create alias "conference" linked to "conf-2025" dataset
$ pnpm exec sanity dataset alias create conference conf-2025
Create alias with explicit ~ prefix
$ pnpm exec sanity dataset alias create ~conference conf-2025
See code: src/commands/dataset/alias/create.ts
sanity dataset alias delete ALIASNAMEDelete a dataset alias within your project
USAGE
$ pnpm exec sanity dataset alias delete ALIASNAME [-p <value>] [--force]
ARGUMENTS
ALIASNAME Dataset alias name to delete
FLAGS
-p, --project-id=<value> Project ID to use. Overrides the project ID from the Sanity config.
--force Skip confirmation prompt and delete immediately
DESCRIPTION
Delete a dataset alias within your project
EXAMPLES
Delete alias named "conference" with confirmation prompt
$ pnpm exec sanity dataset alias delete conference
Delete alias with explicit ~ prefix
$ pnpm exec sanity dataset alias delete ~conference
Delete alias named "conference" without confirmation prompt
$ pnpm exec sanity dataset alias delete conference --force
See code: src/commands/dataset/alias/delete.ts
sanity dataset alias link [ALIASNAME] [TARGETDATASET]Link a dataset alias to a dataset within your project
USAGE
$ pnpm exec sanity dataset alias link [ALIASNAME] [TARGETDATASET] [-p <value>] [--force]
ARGUMENTS
[ALIASNAME] Dataset alias name to link
[TARGETDATASET] Target dataset name to link the alias to
FLAGS
-p, --project-id=<value> Project ID to use. Overrides the project ID from the Sanity config.
--force Skip confirmation prompt when relinking existing alias
DESCRIPTION
Link a dataset alias to a dataset within your project
EXAMPLES
Link an alias with interactive prompts
$ pnpm exec sanity dataset alias link
Link alias named "conference" with interactive dataset selection
$ pnpm exec sanity dataset alias link conference
Link alias "conference" to "conf-2025" dataset
$ pnpm exec sanity dataset alias link conference conf-2025
Link alias with explicit ~ prefix
$ pnpm exec sanity dataset alias link ~conference conf-2025
Force link without confirmation (skip relink prompt)
$ pnpm exec sanity dataset alias link conference conf-2025 --force
See code: src/commands/dataset/alias/link.ts
sanity dataset alias unlink [ALIASNAME]Unlink a dataset alias from its dataset within your project
USAGE
$ pnpm exec sanity dataset alias unlink [ALIASNAME] [-p <value>] [--force]
ARGUMENTS
[ALIASNAME] Dataset alias name to unlink
FLAGS
-p, --project-id=<value> Project ID to use. Overrides the project ID from the Sanity config.
--force Skip confirmation prompt and unlink immediately
DESCRIPTION
Unlink a dataset alias from its dataset within your project
EXAMPLES
Unlink an alias with interactive selection
$ pnpm exec sanity dataset alias unlink
Unlink alias "conference" with confirmation prompt
$ pnpm exec sanity dataset alias unlink conference
Unlink alias with explicit ~ prefix
$ pnpm exec sanity dataset alias unlink ~conference
Unlink alias "conference" without confirmation prompt
$ pnpm exec sanity dataset alias unlink conference --force
See code: src/commands/dataset/alias/unlink.ts
sanity dataset copy [SOURCE] [TARGET]Manages dataset copying, including starting a new copy job, listing copy jobs and following the progress of a running copy job
USAGE
$ pnpm exec sanity dataset copy [SOURCE] [TARGET] [-p <value>] [--attach <value> | --list | --detach | --skip-history]
[--limit <value> ] [--offset <value> ]
ARGUMENTS
[SOURCE] Name of the dataset to copy from
[TARGET] Name of the dataset to copy to
FLAGS
-p, --project-id=<value> Project ID to use. Overrides the project ID from the Sanity config.
--attach=<value> Attach to the running copy process to show progress
--detach Start the copy without waiting for it to finish
--limit=<value> Maximum number of jobs returned (default 10, max 1000)
--list Lists all dataset copy jobs
--offset=<value> Start position in the list of jobs (default 0)
--skip-history Don't preserve document history on copy
DESCRIPTION
Manages dataset copying, including starting a new copy job, listing copy jobs and following the progress of a running
copy job
EXAMPLES
Interactively copy a dataset
$ pnpm exec sanity dataset copy
Copy from source-dataset (prompts for target)
$ pnpm exec sanity dataset copy source-dataset
Copy from source-dataset to target-dataset
$ pnpm exec sanity dataset copy source-dataset target-dataset
Copy without preserving document history (faster for large datasets)
$ pnpm exec sanity dataset copy --skip-history source target
Start copy job without waiting for completion
$ pnpm exec sanity dataset copy --detach source target
Attach to a running copy job to follow progress
$ pnpm exec sanity dataset copy --attach <job-id>
List all dataset copy jobs
$ pnpm exec sanity dataset copy --list
List copy jobs with pagination
$ pnpm exec sanity dataset copy --list --offset 2 --limit 10
See code: src/commands/dataset/copy.ts
sanity dataset create [NAME]Create a new dataset within your project
USAGE
$ pnpm exec sanity dataset create [NAME] [-p <value>] [--embeddings-projection <value> --embeddings] [--visibility
custom|private|public]
ARGUMENTS
[NAME] Name of the dataset to create
FLAGS
-p, --project-id=<value> Project ID to use. Overrides the project ID from the Sanity config.
--embeddings Enable embeddings for this dataset
--embeddings-projection=<value> GROQ projection for embeddings indexing (e.g. "{ title, body }")
--visibility=<option> Set visibility for this dataset (custom/private/public)
<options: custom|private|public>
DESCRIPTION
Create a new dataset within your project
EXAMPLES
Interactively create a dataset
$ pnpm exec sanity dataset create
Create a dataset named "my-dataset"
$ pnpm exec sanity dataset create my-dataset
Create a private dataset named "my-dataset"
$ pnpm exec sanity dataset create my-dataset --visibility private
See code: src/commands/dataset/create.ts
sanity dataset delete DATASETNAMEDelete a dataset within your project
USAGE
$ pnpm exec sanity dataset delete DATASETNAME [-p <value>] [--force]
ARGUMENTS
DATASETNAME Dataset name to delete
FLAGS
-p, --project-id=<value> Project ID to use. Overrides the project ID from the Sanity config.
--force Do not prompt for delete confirmation - forcefully delete
DESCRIPTION
Delete a dataset within your project
EXAMPLES
Delete a specific dataset
$ pnpm exec sanity dataset delete my-dataset
Delete a specific dataset without confirmation
$ pnpm exec sanity dataset delete my-dataset --force
See code: src/commands/dataset/delete.ts
sanity dataset embeddings disable [DATASET]Disable embeddings for a dataset
USAGE
$ pnpm exec sanity dataset embeddings disable [DATASET] [-p <value>]
ARGUMENTS
[DATASET] Dataset name to disable embeddings for
FLAGS
-p, --project-id=<value> Project ID to use. Overrides the project ID from the Sanity config.
DESCRIPTION
Disable embeddings for a dataset
EXAMPLES
Disable embeddings for the production dataset
$ pnpm exec sanity dataset embeddings disable production
See code: src/commands/dataset/embeddings/disable.ts
sanity dataset embeddings enable [DATASET]Enable embeddings for a dataset
USAGE
$ pnpm exec sanity dataset embeddings enable [DATASET] [-p <value>] [--projection <value>] [--wait]
ARGUMENTS
[DATASET] Dataset name to enable embeddings for
FLAGS
-p, --project-id=<value> Project ID to use. Overrides the project ID from the Sanity config.
--projection=<value> GROQ projection defining which fields to embed (e.g. "{ title, body }")
--wait Wait for embeddings processing to complete before returning
DESCRIPTION
Enable embeddings for a dataset
EXAMPLES
Enable embeddings for the production dataset
$ pnpm exec sanity dataset embeddings enable production
Enable embeddings with a specific projection
$ pnpm exec sanity dataset embeddings enable production --projection "{ title, body }"
Enable embeddings and wait for processing to complete
$ pnpm exec sanity dataset embeddings enable production --wait
See code: src/commands/dataset/embeddings/enable.ts
sanity dataset embeddings status [DATASET]Show embeddings settings and status for a dataset
USAGE
$ pnpm exec sanity dataset embeddings status [DATASET] [-p <value>]
ARGUMENTS
[DATASET] The name of the dataset to check embeddings status for
FLAGS
-p, --project-id=<value> Project ID to use. Overrides the project ID from the Sanity config.
DESCRIPTION
Show embeddings settings and status for a dataset
EXAMPLES
Show embeddings status for the production dataset
$ pnpm exec sanity dataset embeddings status production
See code: src/commands/dataset/embeddings/status.ts
sanity dataset export [NAME] [DESTINATION]Export dataset to local filesystem as a gzipped tarball. Assets failing with HTTP status codes 401, 403 and 404 upon download are ignored and excluded from export.
USAGE
$ pnpm exec sanity dataset export [NAME] [DESTINATION] [-p <value>] [--asset-concurrency <value>] [--mode stream|cursor]
[--no-assets] [--no-compress] [--no-drafts] [--overwrite] [--raw] [--types <value>]
ARGUMENTS
[NAME] Name of the dataset to export
[DESTINATION] Output destination file path
FLAGS
-p, --project-id=<value> Project ID to use. Overrides the project ID from the Sanity config.
--asset-concurrency=<value> [default: 8] Concurrent number of asset downloads
--mode=<option> [default: stream] Mode to export documents with `cursor` might be more performant for
larger datasets, but might not be as accurate if the dataset is being modified during
export
<options: stream|cursor>
--no-assets Export only non-asset documents and remove references to image assets
--no-compress Skips compressing tarball entries (still generates a gzip file)
--no-drafts Export only published versions of documents
--overwrite Overwrite any file with the same name
--raw Extract only documents, without rewriting asset references
--types=<value> Defines which document types to export (comma-separated)
DESCRIPTION
Export dataset to local filesystem as a gzipped tarball. Assets failing with HTTP status codes 401, 403 and 404 upon
download are ignored and excluded from export.
EXAMPLES
Export dataset "moviedb" to localPath.tar.gz
$ pnpm exec sanity dataset export moviedb localPath.tar.gz
Export dataset without assets
$ pnpm exec sanity dataset export moviedb assetless.tar.gz --no-assets
Export raw documents without asset reference rewriting
$ pnpm exec sanity dataset export staging staging.tar.gz --raw
Export specific document types
$ pnpm exec sanity dataset export staging staging.tar.gz --types products,shops
See code: src/commands/dataset/export.ts
sanity dataset import SOURCEImport documents to a Sanity dataset
USAGE
$ pnpm exec sanity dataset import SOURCE -p <value> -d <value> [-t <value>] [--replace | --missing] [--allow-failing-assets]
[--allow-assets-in-different-dataset] [--replace-assets] [--skip-cross-dataset-references]
[--allow-replacement-characters] [--allow-system-documents] [--asset-concurrency <value>]
ARGUMENTS
SOURCE Source file (use "-" for stdin)
FLAGS
-d, --dataset=<value> (required) Dataset to import to
-p, --project=<value> (required) Project ID to import to
-t, --token=<value> [env: SANITY_IMPORT_TOKEN] Token to authenticate with
--allow-assets-in-different-dataset Allow asset documents to reference different project/dataset
--allow-failing-assets Skip assets that cannot be fetched/uploaded
--allow-replacement-characters Allow unicode replacement characters in imported documents
--allow-system-documents Imports system documents
--asset-concurrency=<value> Number of parallel asset imports
--missing Skip documents that already exist
--replace Replace documents with the same IDs
--replace-assets Skip reuse of existing assets
--skip-cross-dataset-references Skips references to other datasets
DESCRIPTION
Import documents to a Sanity dataset
EXAMPLES
Import "./my-dataset.ndjson" into dataset "staging"
$ pnpm exec sanity dataset import -p myPrOj -d staging -t someSecretToken my-dataset.ndjson
Import into dataset "test" from stdin, read token from env var
cat my-dataset.ndjson | sanity dataset import -p myPrOj -d test -
See code: src/commands/dataset/import.ts
sanity dataset listList datasets of your project
USAGE
$ pnpm exec sanity dataset list [-p <value>]
FLAGS
-p, --project-id=<value> Project ID to use. Overrides the project ID from the Sanity config.
DESCRIPTION
List datasets of your project
EXAMPLES
List datasets of your project
$ pnpm exec sanity dataset list
List datasets for a specific project
$ pnpm exec sanity dataset list --project-id abc123
See code: src/commands/dataset/list.ts
sanity dataset visibility get DATASETGet the visibility of a dataset
USAGE
$ pnpm exec sanity dataset visibility get DATASET [-p <value>]
ARGUMENTS
DATASET The name of the dataset to get visibility for
FLAGS
-p, --project-id=<value> Project ID to use. Overrides the project ID from the Sanity config.
DESCRIPTION
Get the visibility of a dataset
EXAMPLES
Check the visibility of a dataset
$ pnpm exec sanity dataset visibility get my-dataset
See code: src/commands/dataset/visibility/get.ts
sanity dataset visibility set DATASET MODESet the visibility of a dataset
USAGE
$ pnpm exec sanity dataset visibility set DATASET MODE [-p <value>]
ARGUMENTS
DATASET The name of the dataset to set visibility for
MODE (public|private) The visibility mode to set
FLAGS
-p, --project-id=<value> Project ID to use. Overrides the project ID from the Sanity config.
DESCRIPTION
Set the visibility of a dataset
EXAMPLES
Make a dataset private
$ pnpm exec sanity dataset visibility set my-dataset private
Make a dataset public
$ pnpm exec sanity dataset visibility set my-dataset public
See code: src/commands/dataset/visibility/set.ts
sanity debugProvides diagnostic info for Sanity Studio troubleshooting
USAGE
$ pnpm exec sanity debug [--secrets]
FLAGS
--secrets Include API keys in output
DESCRIPTION
Provides diagnostic info for Sanity Studio troubleshooting
EXAMPLES
$ pnpm exec sanity debug
$ pnpm exec sanity debug --secrets
See code: src/commands/debug.ts
sanity deploy [SOURCEDIR]Builds and deploys Sanity Studio or application to Sanity hosting
USAGE
$ pnpm exec sanity deploy [SOURCEDIR] [--auto-updates] [--build] [--minify] [--schema-required] [--source-maps]
[--verbose] [-y]
ARGUMENTS
[SOURCEDIR] Source directory
FLAGS
-y, --yes Unattended mode, answers "yes" to any "yes/no" prompt and otherwise uses defaults
--[no-]auto-updates Automatically update the studio to the latest version
--[no-]build Don't build the studio prior to deploy, instead deploying the version currently in `dist/`
--[no-]minify Skip minifying built JavaScript (speeds up build, increases size of bundle)
--schema-required Fail-fast deployment if schema store fails
--source-maps Enable source maps for built bundles (increases size of bundle)
--verbose Enable verbose logging
DESCRIPTION
Builds and deploys Sanity Studio or application to Sanity hosting
EXAMPLES
Build and deploy the studio to Sanity hosting
$ pnpm exec sanity deploy
Deploys non-minified build with source maps
$ pnpm exec sanity deploy --no-minify --source-maps
Fail fast on schema store fails - for when other services rely on the stored schema
$ pnpm exec sanity deploy --schema-required
See code: src/commands/deploy.ts
sanity devStarts a local development server for Sanity Studio with live reloading
USAGE
$ pnpm exec sanity dev [--auto-updates] [--host <value>] [--load-in-dashboard] [--port <value>]
FLAGS
--[no-]auto-updates Automatically update Sanity Studio dependencies.
--host=<value> [default: localhost] The local network interface at which to listen.
--[no-]load-in-dashboard Load the app/studio in the Sanity dashboard.
--port=<value> [default: 3333] TCP port to start server on.
DESCRIPTION
Starts a local development server for Sanity Studio with live reloading
EXAMPLES
$ pnpm exec sanity dev --host=0.0.0.0
$ pnpm exec sanity dev --port=1942
$ pnpm exec sanity dev --load-in-dashboard
See code: src/commands/dev.ts
sanity docs browseOpen Sanity docs in a web browser
USAGE
$ pnpm exec sanity docs browse
DESCRIPTION
Open Sanity docs in a web browser
See code: src/commands/docs/browse.ts
sanity docs read PATHRead an article in terminal
USAGE
$ pnpm exec sanity docs read PATH [--web]
ARGUMENTS
PATH Path or URL to article, found in search results and docs content as links
FLAGS
--web Open in a web browser
DESCRIPTION
Read an article in terminal
EXAMPLES
Read as markdown in terminal
$ pnpm exec sanity docs read /docs/studio/installation
Read using full URL
$ pnpm exec sanity docs read https://www.sanity.io/docs/studio/installation
Open in web browser
$ pnpm exec sanity docs read /docs/studio/installation --web
Open using full URL in web browser
$ pnpm exec sanity docs read https://www.sanity.io/docs/studio/installation -w
See code: src/commands/docs/read.ts
sanity docs search QUERYSearch Sanity docs
USAGE
$ pnpm exec sanity docs search QUERY [--limit <value>]
ARGUMENTS
QUERY Search query for documentation
FLAGS
--limit=<value> [default: 10] Maximum number of results to return
DESCRIPTION
Search Sanity docs
EXAMPLES
Search for documentation about schemas
$ pnpm exec sanity docs search schema
Search with phrase
$ pnpm exec sanity docs search "groq functions"
Limit search results
$ pnpm exec sanity docs search "deployment" --limit=5
See code: src/commands/docs/search.ts
sanity documents create [FILE]Create one or more documents
USAGE
$ pnpm exec sanity documents create [FILE] [-d <value>] [--id <value>] [--json5] [--missing] [--replace] [--watch]
ARGUMENTS
[FILE] JSON file to create document(s) from
FLAGS
-d, --dataset=<value> Dataset to create document(s) in (overrides config)
--id=<value> Specify a document ID to use. Will fetch remote document ID and populate editor.
--json5 Use JSON5 file type to allow a "simplified" version of JSON
--missing On duplicate document IDs, don't modify the target document(s)
--replace On duplicate document IDs, replace existing document with specified document(s)
--watch Write the documents whenever the target file or buffer changes
DESCRIPTION
Create one or more documents
EXAMPLES
Create the document specified in "myDocument.json"
$ pnpm exec sanity documents create myDocument.json
Open configured $EDITOR and create the specified document(s)
$ pnpm exec sanity documents create
Fetch document with the ID "myDocId" and open configured $EDITOR with the current document content (if any). Replace
document with the edited version when the editor closes
$ pnpm exec sanity documents create --id myDocId --replace
Open configured $EDITOR and replace the document with the given content on each save. Use JSON5 file extension and
parser for simplified syntax.
$ pnpm exec sanity documents create --id myDocId --watch --replace --json5
See code: src/commands/documents/create.ts
sanity documents delete ID [IDS]Delete one or more documents from the projects configured dataset
USAGE
$ pnpm exec sanity documents delete ID... [IDS...] [--dataset <value>]
ARGUMENTS
ID... Document ID to delete
[IDS...] Additional document IDs to delete
FLAGS
--dataset=<value> NAME to override dataset
DESCRIPTION
Delete one or more documents from the projects configured dataset
EXAMPLES
Delete the document with the ID "myDocId"
$ pnpm exec sanity documents delete myDocId
ID wrapped in double or single quote works equally well
$ pnpm exec sanity documents delete 'myDocId'
Delete document with ID "someDocId" from dataset "blog"
$ pnpm exec sanity documents delete --dataset=blog someDocId
Delete the document with ID "doc1" and "doc2"
$ pnpm exec sanity documents delete doc1 doc2
See code: src/commands/documents/delete.ts
sanity documents get DOCUMENTIDGet and print a document by ID
USAGE
$ pnpm exec sanity documents get DOCUMENTID [-d <value>] [--pretty]
ARGUMENTS
DOCUMENTID Document ID to retrieve
FLAGS
-d, --dataset=<value> Dataset to get document from (overrides config)
--pretty Colorize JSON output
DESCRIPTION
Get and print a document by ID
EXAMPLES
Get the document with ID "myDocId"
$ pnpm exec sanity documents get myDocId
Get document with colorized JSON output
$ pnpm exec sanity documents get myDocId --pretty
Get document from a specific dataset
$ pnpm exec sanity documents get myDocId --dataset production
See code: src/commands/documents/get.ts
sanity documents query QUERYQuery for documents
USAGE
$ pnpm exec sanity documents query QUERY [--anonymous] [--api-version <value>] [-d <value>] [--pretty] [-p <value>]
ARGUMENTS
QUERY GROQ query to run against the dataset
FLAGS
-d, --dataset=<value> Dataset to query (overrides config)
-p, --project=<value> Project ID to query (overrides config)
--anonymous Send the query without any authorization token
--api-version=<value> [env: SANITY_CLI_QUERY_API_VERSION] API version to use (defaults to 2025-08-15)
--pretty Colorize JSON output
DESCRIPTION
Query for documents
EXAMPLES
Fetch 5 documents of type "movie"
$ pnpm exec sanity documents query '*[_type == "movie"][0..4]'
Fetch title of the oldest movie in the dataset named "staging"
$ pnpm exec sanity documents query '*[_type == "movie"]|order(releaseDate asc)[0]{title}' --dataset staging
Use API version v2021-06-07 and do a query
$ pnpm exec sanity documents query '*[_id == "header"] { "headerText": pt::text(body) }' --api-version v2021-06-07
See code: src/commands/documents/query.ts
sanity documents validateValidate documents in a dataset against the studio schema
USAGE
$ pnpm exec sanity documents validate [-d <value>] [--file <value>] [--format <value>] [--level error|warning|info]
[--max-custom-validation-concurrency <value>] [--max-fetch-concurrency <value>] [--workspace <value>] [-y]
FLAGS
-d, --dataset=<value> Override the dataset used. By default, this is derived from the given
workspace
-y, --yes Skips the first confirmation prompt
--file=<value> Provide a path to either an .ndjson file or a tarball containing an
.ndjson file
--format=<value> The output format used to print the found validation markers and
report progress
--level=<option> [default: warning] The minimum level reported out. Defaults to
warning
<options: error|warning|info>
--max-custom-validation-concurrency=<value> [default: 5] Specify how many custom validators can run concurrently
--max-fetch-concurrency=<value> [default: 25] Specify how many `client.fetch` requests are allow
concurrency at once
--workspace=<value> The name of the workspace to use when downloading and validating all
documents
DESCRIPTION
Validate documents in a dataset against the studio schema
EXAMPLES
Validates all documents in a Sanity project with more than one workspace
$ pnpm exec sanity documents validate --workspace default
Override the dataset specified in the workspace
$ pnpm exec sanity documents validate --workspace default --dataset staging
Save the results of the report into a file
$ pnpm exec sanity documents validate --yes > report.txt
Report out info level validation markers too
$ pnpm exec sanity documents validate --level info
See code: src/commands/documents/validate.ts
sanity exec SCRIPTExecutes a script within the Sanity Studio context
USAGE
$ pnpm exec sanity exec SCRIPT... [--mock-browser-env] [--with-user-token]
ARGUMENTS
SCRIPT... Path to the script to execute
FLAGS
--mock-browser-env Mocks a browser-like environment using jsdom
--with-user-token Prime access token from CLI config into getCliClient()
DESCRIPTION
Executes a script within the Sanity Studio context
EXAMPLES
Run the script at some/script.js in Sanity context
$ pnpm exec sanity exec some/script.js
Run the script at migrations/fullname.ts and configure `getCliClient()` from `sanity/cli` to include the current
user's token
$ pnpm exec sanity exec migrations/fullname.ts --with-user-token
Run the script at scripts/browserScript.js in a mock browser environment
$ pnpm exec sanity exec scripts/browserScript.js --mock-browser-env
Pass arbitrary arguments to scripts by separating them with a `--`. Arguments are available in `process.argv` as
they would in regular node scripts (eg the following command would yield a `process.argv` of: `['/path/to/node',
'/path/to/myscript.js', '--dry-run', 'positional-argument']`)
$ pnpm exec sanity exec --mock-browser-env myscript.js -- --dry-run positional-argument
See code: src/commands/exec.ts
sanity functions addAdd a Function to your Blueprint
USAGE
$ pnpm exec sanity functions add [--example <value> | -n <value> | | --language ts|js | --javascript | | ] [--type
document-create|document-delete|document-update|document-publish|media-library-asset-create|media-library-asset-upda
te|media-library-asset-delete... ] [--helpers] [--installer skip|npm|pnpm|yarn] [-i | ]
FLAGS
-i, --install Shortcut for --fn-installer npm
-n, --name=<value> Name of the Function to add
--example=<value> Example to use for the Function
--[no-]helpers Add helpers to the new Function
--installer=<option> How to install the @sanity/functions helpers
<options: skip|npm|pnpm|yarn>
--javascript Use JavaScript instead of TypeScript
--language=<option> [default: ts] Language of the new Function
<options: ts|js>
--type=<option>... Document change event(s) that should trigger the function; you can specify multiple events
by specifying this flag multiple times
<options: document-create|document-delete|document-update|document-publish|media-library-ass
et-create|media-library-asset-update|media-library-asset-delete>
DESCRIPTION
Add a Function to your Blueprint
Scaffolds a new Function in the functions/ folder and templates a resource for your Blueprint manifest.
Functions are serverless handlers triggered by document events (create, update, delete, publish) or media library
events.
After adding, use 'functions dev' to test locally, then 'blueprints deploy' to publish.
EXAMPLES
$ pnpm exec sanity functions add
$ pnpm exec sanity functions add --helpers
$ pnpm exec sanity functions add --name my-function
$ pnpm exec sanity functions add --name my-function --type document-create
$ pnpm exec sanity functions add --name my-function --type document-create --type document-update --lang js
See code: @sanity/runtime-cli
sanity functions devStart the Sanity Function emulator
USAGE
$ pnpm exec sanity functions dev [-h <value>] [-p <value>] [-t <value>]
FLAGS
-h, --host=<value> The local network interface at which to listen. [default: "localhost"]
-p, --port=<value> TCP port to start emulator on. [default: 8080]
-t, --timeout=<value> Maximum execution time for all functions, in seconds. Takes precedence over function-specific
`timeout`
DESCRIPTION
Start the Sanity Function emulator
Runs a local, web-based development server to test your functions before deploying.
Open the emulator in your browser to interactively test your functions with the payload editor.
Optionally, set the host and port with the --host and --port flags. Function timeout can be configured with the
--timeout flag.
To invoke a function with the CLI, use 'functions test'.
EXAMPLES
$ pnpm exec sanity functions dev --host 127.0.0.1 --port 8974
$ pnpm exec sanity functions dev --timeout 60
See code: @sanity/runtime-cli
sanity functions env add NAME KEY VALUEAdd or set an environment variable for a deployed function
USAGE
$ pnpm exec sanity functions env add NAME KEY VALUE
ARGUMENTS
NAME The name of the Sanity Function
KEY The name of the environment variable
VALUE The value of the environment variable
DESCRIPTION
Add or set an environment variable for a deployed function
Sets an environment variable in a deployed Sanity Function. If the variable already exists, its value is updated.
Environment variables are useful for API keys, configuration values, and other secrets that shouldn't be hardcoded.
Changes take effect on the next function invocation.
EXAMPLES
$ pnpm exec sanity functions env add MyFunction API_URL https://api.example.com/
See code: @sanity/runtime-cli
sanity functions env list NAMEList environment variables for a deployed function
USAGE
$ pnpm exec sanity functions env list NAME
ARGUMENTS
NAME The name of the Sanity Function
DESCRIPTION
List environment variables for a deployed function
Displays all environment variables (keys only) configured in a deployed Sanity Function.
Use 'functions env add' to set variables or 'functions env remove' to delete them.
EXAMPLES
$ pnpm exec sanity functions env list MyFunction
See code: @sanity/runtime-cli
sanity functions env remove NAME KEYRemove an environment variable from a deployed function
USAGE
$ pnpm exec sanity functions env remove NAME KEY
ARGUMENTS
NAME The name of the Sanity Function
KEY The name of the environment variable
DESCRIPTION
Remove an environment variable from a deployed function
Deletes an environment variable from a deployed Sanity Function. The change takes effect on the next function
invocation.
Use 'functions env list' to see current variables before removing.
EXAMPLES
$ pnpm exec sanity functions env remove MyFunction API_URL
See code: @sanity/runtime-cli
sanity functions logs [NAME]Retrieve or delete logs for a Sanity Function
USAGE
$ pnpm exec sanity functions logs [NAME] [--stack <value>] [-u] [-f [-d | -l <value> | -j]] [-w]
ARGUMENTS
[NAME] The name of the Sanity Function
FLAGS
-d, --delete Delete all logs for the function
-f, --force Skip confirmation for deleting logs
-j, --json Return logs in JSON format
-l, --limit=<value> [default: 50] Total number of log entries to retrieve
-u, --utc Show dates in UTC time zone
-w, --watch Watch for new logs (streaming mode)
--stack=<value> Stack name or ID to use instead of the locally configured Stack
DESCRIPTION
Retrieve or delete logs for a Sanity Function
Fetches execution logs from a deployed function, useful for debugging production issues or monitoring activity.
Use --watch (-w) to stream logs in real-time. Use --delete to clear all logs for a function (requires confirmation
unless --force is specified).
EXAMPLES
$ pnpm exec sanity functions logs <name>
$ pnpm exec sanity functions logs <name> --json
$ pnpm exec sanity functions logs <name> --limit 100
$ pnpm exec sanity functions logs <name> --delete
See code: @sanity/runtime-cli
sanity functions test [NAME]Invoke a local Sanity Function
USAGE
$ pnpm exec sanity functions test [NAME] [--data-before <value> | [-d <value> | -f <value> | --document-id <value>] | | |
--file-before <value> | --file-after <value> | --document-id-before <value> | --document-id-after <value>]
[--data-after <value> | | | | | | | ] [-e create|update|delete] [-t <value>] [-a <value>] [--with-user-token]
[--media-library-id <value> | --project-id <value> | --dataset <value>]
ARGUMENTS
[NAME] The name of the Sanity Function
FLAGS
-a, --api=<value> Sanity API Version to use
-d, --data=<value> Data to send to the function
-e, --event=<option> Type of event (create, update, delete)
<options: create|update|delete>
-f, --file=<value> Read data from file and send to the function
-t, --timeout=<value> Execution timeout value in seconds
--data-after=<value> Current document
--data-before=<value> Original document
--dataset=<value> The Sanity dataset to use
--document-id=<value> Document to fetch and send to function
--document-id-after=<value> Current document
--document-id-before=<value> Original document
--file-after=<value> Current document
--file-before=<value> Original document
--media-library-id=<value> Sanity Media Library ID to use
--project-id=<value> Sanity Project ID to use
--with-user-token Prime access token from CLI config
DESCRIPTION
Invoke a local Sanity Function
Executes a function locally with the provided payload, simulating how it would run when deployed. Use this to test
your function logic before deploying.
Provide test data via --data (inline JSON), --file (JSON file), or --document-id (fetch from Sanity). For update
events, use the before/after flag pairs to simulate document changes.
EXAMPLES
$ pnpm exec sanity functions test <name> --data '{ "id": 1 }'
$ pnpm exec sanity functions test <name> --file 'payload.json'
$ pnpm exec sanity functions test <name> --data '{ "id": 1 }' --timeout 60
$ pnpm exec sanity functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
See code: @sanity/runtime-cli
sanity graphql deployDeploy a GraphQL API from the current Sanity schema
USAGE
$ pnpm exec sanity graphql deploy [--api <value>...] [--dataset <value>] [--dry-run] [--force] [--generation gen1|gen2|gen3]
[--non-null-document-fields] [--playground] [--tag <value>] [--with-union-cache]
FLAGS
--api=<value>... Only deploy API with this ID. Can be specified multiple times.
--dataset=<value> Deploy API for the given dataset
--dry-run Validate defined GraphQL APIs, check for breaking changes, skip deploy
--force Deploy API without confirming breaking changes
--generation=<option> API generation to deploy (defaults to "gen3")
<options: gen1|gen2|gen3>
--non-null-document-fields Use non-null document fields (_id, _type etc)
--[no-]playground Enable GraphQL playground for easier debugging
--tag=<value> Deploy API(s) to given tag (defaults to "default")
--with-union-cache Enable union cache that optimizes schema generation for schemas with many self referencing
types
DESCRIPTION
Deploy a GraphQL API from the current Sanity schema
EXAMPLES
Deploy all defined GraphQL APIs
$ pnpm exec sanity graphql deploy
Validate defined GraphQL APIs, check for breaking changes, skip deploy
$ pnpm exec sanity graphql deploy --dry-run
Deploy only the GraphQL APIs with the IDs "staging" and "ios"
$ pnpm exec sanity graphql deploy --api staging --api ios
Deploy all defined GraphQL APIs, overriding any playground setting
$ pnpm exec sanity graphql deploy --playground
See code: src/commands/graphql/deploy.ts
sanity graphql listList all GraphQL endpoints deployed for this project
USAGE
$ pnpm exec sanity graphql list
DESCRIPTION
List all GraphQL endpoints deployed for this project
EXAMPLES
List GraphQL endpoints for the current project
$ pnpm exec sanity graphql list
See code: src/commands/graphql/list.ts
sanity graphql undeployRemove a deployed GraphQL API
USAGE
$ pnpm exec sanity graphql undeploy [--api <value>] [--dataset <value>] [--force] [--project <value>] [--tag <value>]
FLAGS
--api=<value> Undeploy API with this ID (project, dataset and tag flags take precedence)
--dataset=<value> Dataset to undeploy GraphQL API from
--force Skip confirmation prompt
--project=<value> Project ID to delete GraphQL API for
--tag=<value> [default: default] Tag to undeploy GraphQL API from
DESCRIPTION
Remove a deployed GraphQL API
EXAMPLES
Undeploy GraphQL API for current project and dataset
$ pnpm exec sanity graphql undeploy
Undeploy API with ID "ios"
$ pnpm exec sanity graphql undeploy --api ios
Undeploy GraphQL API for staging dataset
$ pnpm exec sanity graphql undeploy --dataset staging
Undeploy GraphQL API for staging dataset with "next" tag
$ pnpm exec sanity graphql undeploy --dataset staging --tag next
Undeploy GraphQL API without confirmation prompt
$ pnpm exec sanity graphql undeploy --force
See code: src/commands/graphql/undeploy.ts
sanity help [COMMAND]Display help for sanity.
USAGE
$ pnpm exec sanity help [COMMAND...] [-n]
ARGUMENTS
[COMMAND...] Command to show help for.
FLAGS
-n, --nested-commands Include all nested commands in the output.
DESCRIPTION
Display help for sanity.
See code: @oclif/plugin-help
sanity hook attempt ATTEMPTIDPrint details of a given webhook delivery attempt
USAGE
$ pnpm exec sanity hook attempt ATTEMPTID
ARGUMENTS
ATTEMPTID The delivery attempt ID to get details for
DESCRIPTION
Print details of a given webhook delivery attempt
EXAMPLES
Print details of webhook delivery attempt with ID abc123
$ pnpm exec sanity hook attempt abc123
See code: src/commands/hook/attempt.ts
sanity hook createCreate a new webhook for the current project
USAGE
$ pnpm exec sanity hook create
DESCRIPTION
Create a new webhook for the current project
EXAMPLES
Create a new webhook for the current project
$ pnpm exec sanity hook create
See code: src/commands/hook/create.ts
sanity hook delete [NAME]Delete a hook within your project
USAGE
$ pnpm exec sanity hook delete [NAME]
ARGUMENTS
[NAME] Name of hook to delete (will prompt if not provided)
DESCRIPTION
Delete a hook within your project
EXAMPLES
Interactively select and delete a hook
$ pnpm exec sanity hook delete
Delete a specific hook by name
$ pnpm exec sanity hook delete my-hook
See code: src/commands/hook/delete.ts
sanity hook listList hooks for a given project
USAGE
$ pnpm exec sanity hook list
DESCRIPTION
List hooks for a given project
EXAMPLES
List hooks for a given project
$ pnpm exec sanity hook list
See code: src/commands/hook/list.ts
sanity hook logs [NAME]List latest log entries for a given hook
USAGE
$ pnpm exec sanity hook logs [NAME] [--detailed]
ARGUMENTS
[NAME] Name of the hook to show logs for
FLAGS
--detailed Include detailed payload and attempts
DESCRIPTION
List latest log entries for a given hook
EXAMPLES
List latest log entries for a given hook
$ pnpm exec sanity hook logs
List latest log entries for a specific hook by name
$ pnpm exec sanity hook logs [NAME]
See code: src/commands/hook/logs.ts
sanity initInitialize a new Sanity Studio, project and/or app
USAGE
$ pnpm exec sanity init [--json] [--auto-updates | --bare] [--coupon <code> | --project-plan <name>] [--dataset
<name> | --dataset-default] [--env <filename> | ] [--git <message> | ] [--mcp] [--nextjs-add-config-files]
[--nextjs-append-env] [--nextjs-embed-studio] [--organization <id>] [--output-path <path> | ] [--overwrite-files]
[--package-manager <manager> | ] [--project <id> | --create-project <name>] [--provider <provider>] [--template
<template> | ] [--typescript | ] [--visibility <mode>] [-y]
FLAGS
-y, --yes Unattended mode, answers "yes" to any "yes/no" prompt and otherwise uses defaults
--[no-]auto-updates Enable auto updates of studio versions
--bare Skip the Studio initialization and only print the selected project ID and dataset
name to stdout
--coupon=<code> Optionally select a coupon for a new project (cannot be used with --project-plan)
--create-project=<name> Create a new project with the given name
--dataset=<name> Dataset name for the studio
--dataset-default Set up a project with a public dataset named "production"
--env=<filename> Write environment variables to file
--[no-]git=<message> Specify a commit message for initial commit, or disable git init
--[no-]mcp Enable AI editor integration (MCP) setup
--organization=<id> Organization ID to use for the project
--output-path=<path> Path to write studio project to
--[no-]overwrite-files Overwrite existing files
--package-manager=<manager> Specify which package manager to use [allowed: npm, yarn, pnpm]
--project=<id> Project ID to use for the studio
--project-plan=<name> Optionally select a plan for a new project
--provider=<provider> Login provider to use
--template=<template> Project template to use [default: "clean"]
--[no-]typescript Enable TypeScript support
--visibility=<mode> Visibility mode for dataset
GLOBAL FLAGS
--json Format output as json.
NEXT.JS FLAGS
--[no-]nextjs-add-config-files Add config files to Next.js project
--[no-]nextjs-append-env Append project ID and dataset to .env file
--[no-]nextjs-embed-studio Embed the Studio in Next.js application
DESCRIPTION
Initialize a new Sanity Studio, project and/or app
EXAMPLES
$ pnpm exec sanity init
Initialize a new project with a public dataset named "production"
$ pnpm exec sanity init --dataset-default
Initialize a project with the given project ID and dataset to the given path
$ pnpm exec sanity init -y --project abc123 --dataset production --output-path ~/myproj
Initialize a project with the given project ID and dataset using the moviedb template to the given path
$ pnpm exec sanity init -y --project abc123 --dataset staging --template moviedb --output-path .
Create a brand new project with name "Movies Unlimited"
$ pnpm exec sanity init -y --create-project "Movies Unlimited" --dataset moviedb --visibility private --template moviedb \
--output-path /Users/espenh/movies-unlimited
See code: src/commands/init.ts
sanity install [PACKAGES]Installs dependencies for Sanity Studio project
USAGE
$ pnpm exec sanity install [PACKAGES...]
ARGUMENTS
[PACKAGES...] Packages to install
DESCRIPTION
Installs dependencies for Sanity Studio project
EXAMPLES
$ pnpm exec sanity install
$ pnpm exec sanity install @sanity/vision
$ pnpm exec sanity install some-package another-package
See code: src/commands/install.ts
sanity learnOpens Sanity Learn in your web browser
USAGE
$ pnpm exec sanity learn
DESCRIPTION
Opens Sanity Learn in your web browser
See code: src/commands/learn.ts
sanity loginAuthenticates the CLI for access to Sanity projects
USAGE
$ pnpm exec sanity login [--open] [--provider <providerId>] [--sso <slug>]
FLAGS
--[no-]open Open a browser window to log in (`--no-open` only prints URL)
--provider=<providerId> Log in using the given provider
--sso=<slug> Log in using Single Sign-On, using the given organization slug
DESCRIPTION
Authenticates the CLI for access to Sanity projects
EXAMPLES
Log in using default settings
$ pnpm exec sanity login
Log in using Single Sign-On with the "my-organization" slug
$ pnpm exec sanity login --sso my-organization
Login with GitHub provider, but do not open a browser window automatically
$ pnpm exec sanity login --provider github --no-open
See code: src/commands/login.ts
sanity logoutLogs out the CLI from the current user session
USAGE
$ pnpm exec sanity logout
DESCRIPTION
Logs out the CLI from the current user session
See code: src/commands/logout.ts
sanity manageOpens project management interface in your web browser
USAGE
$ pnpm exec sanity manage
DESCRIPTION
Opens project management interface in your web browser
See code: src/commands/manage.ts
sanity manifest extractExtracts the studio configuration as one or more JSON manifest files.
USAGE
$ pnpm exec sanity manifest extract [--path <value>]
FLAGS
--path=<value> [default: /dist/static] Optional path to specify destination directory of the manifest files
DESCRIPTION
Extracts the studio configuration as one or more JSON manifest files.
**Note**: This command is experimental and subject to change. It is currently intended for use with Create only.
EXAMPLES
Extracts manifests
$ pnpm exec sanity manifest extract
Extracts manifests into /public/static
$ pnpm exec sanity manifest extract --path /public/static
See code: src/commands/manifest/extract.ts
sanity mcp configureConfigure Sanity MCP server for AI editors (Claude Code, Codex CLI, Cursor, Gemini CLI, GitHub Copilot CLI, VS Code)
USAGE
$ pnpm exec sanity mcp configure
DESCRIPTION
Configure Sanity MCP server for AI editors (Claude Code, Codex CLI, Cursor, Gemini CLI, GitHub Copilot CLI, VS Code)
EXAMPLES
Configure Sanity MCP server for detected AI editors
$ pnpm exec sanity mcp configure
See code: src/commands/mcp/configure.ts
sanity media create-aspectCreate a new aspect definition file
USAGE
$ pnpm exec sanity media create-aspect
DESCRIPTION
Create a new aspect definition file
EXAMPLES
Create a new aspect definition file
$ pnpm exec sanity media create-aspect
See code: src/commands/media/create-aspect.ts
sanity media delete-aspect ASPECTNAMEUndeploy an aspect
USAGE
$ pnpm exec sanity media delete-aspect ASPECTNAME [--media-library-id <value>] [--yes]
ARGUMENTS
ASPECTNAME Name of the aspect to delete
FLAGS
--media-library-id=<value> The id of the target media library
--yes Skip confirmation prompt
DESCRIPTION
Undeploy an aspect
EXAMPLES
Delete the aspect named "someAspect"
$ pnpm exec sanity media delete-aspect someAspect
See code: src/commands/media/delete-aspect.ts
sanity media deploy-aspect [ASPECTNAME]Deploy an aspect
USAGE
$ pnpm exec sanity media deploy-aspect [ASPECTNAME] [--all] [--media-library-id <value>]
ARGUMENTS
[ASPECTNAME] Name of the aspect to deploy
FLAGS
--all Deploy all aspects
--media-library-id=<value> The id of the target media library
DESCRIPTION
Deploy an aspect
EXAMPLES
Deploy the aspect named "someAspect"
$ pnpm exec sanity media deploy-aspect someAspect
Deploy all aspects
$ pnpm exec sanity media deploy-aspect --all
See code: src/commands/media/deploy-aspect.ts
sanity media export [DESTINATION]Export an archive of all file and image assets including their aspect data from the target media library. Video assets are excluded from the export.
USAGE
$ pnpm exec sanity media export [DESTINATION] [--asset-concurrency <value>] [--media-library-id <value>] [--no-compress]
[--overwrite]
ARGUMENTS
[DESTINATION] Output destination file path
FLAGS
--asset-concurrency=<value> [default: 8] Concurrent number of asset downloads
--media-library-id=<value> The id of the target media library
--no-compress Skips compressing tarball entries (still generates a gzip file)
--overwrite Overwrite any file with the same name
DESCRIPTION
Export an archive of all file and image assets including their aspect data from the target media library. Video assets
are excluded from the export.
EXAMPLES
Export media library interactively
$ pnpm exec sanity media export
Export media library to output.tar.gz
$ pnpm exec sanity media export output.tar.gz
Export specific media library
$ pnpm exec sanity media export --media-library-id my-library-id
See code: src/commands/media/export.ts
sanity media import SOURCEImport a set of assets to the target media library.
USAGE
$ pnpm exec sanity media import SOURCE [--media-library-id <value>] [--replace-aspects]
ARGUMENTS
SOURCE Image file or folder to import from
FLAGS
--media-library-id=<value> The id of the target media library
--replace-aspects Replace existing aspect data. All versions will be replaced (e.g. published and draft
aspect data)
DESCRIPTION
Import a set of assets to the target media library.
EXAMPLES
Import all assets from the "products" directory
$ pnpm exec sanity media import products
Import all assets from "gallery" archive
$ pnpm exec sanity media import gallery.tar.gz
Import all assets from the "products" directory and replace aspects
$ pnpm exec sanity media import products --replace-aspects
See code: src/commands/media/import.ts
sanity migration create [TITLE]Create a new migration within your project
USAGE
$ pnpm exec sanity migration create [TITLE]
ARGUMENTS
[TITLE] Title of migration
DESCRIPTION
Create a new migration within your project
EXAMPLES
Create a new migration, prompting for title and options
$ pnpm exec sanity migration create
Create a new migration with the provided title, prompting for options
$ pnpm exec sanity migration create "Rename field from location to address"
See code: @sanity/migrate
sanity migration listList available migrations
USAGE
$ pnpm exec sanity migration list
DESCRIPTION
List available migrations
EXAMPLES
List all available migrations in the project
$ pnpm exec sanity migration list
See code: @sanity/migrate
sanity migration run [ID]Run a migration against a dataset
USAGE
$ pnpm exec sanity migration run [ID] [--api-version <value>] [--concurrency <value>] [--confirm] [--dataset <value>]
[--dry-run] [--from-export <value>] [--progress] [--project <value>]
ARGUMENTS
[ID] ID
FLAGS
--api-version=<value> API version to use when migrating. Defaults to v2024-01-29.
--concurrency=<value> [default: 6] How many mutation requests to run in parallel. Must be between 1 and 10. Default:
6.
--[no-]confirm Prompt for confirmation before running the migration (default: true). Use --no-confirm to skip.
--dataset=<value> Dataset to migrate. Defaults to the dataset configured in your Sanity CLI config.
--[no-]dry-run By default the migration runs in dry mode. Use --no-dry-run to migrate dataset.
--from-export=<value> Use a local dataset export as source for migration instead of calling the Sanity API. Note:
this is only supported for dry runs.
--[no-]progress Display progress during migration (default: true). Use --no-progress to hide output.
--project=<value> Project ID of the dataset to migrate. Defaults to the projectId configured in your Sanity CLI
config.
DESCRIPTION
Run a migration against a dataset
EXAMPLES
dry run the migration
$ pnpm exec sanity migration run <id>
execute the migration against a dataset
$ pnpm exec sanity migration run <id> --no-dry-run --project xyz --dataset staging
execute the migration using a dataset export as the source
$ pnpm exec sanity migration run <id> --from-export=production.tar.gz --no-dry-run --project xyz --dataset staging
See code: @sanity/migrate
sanity openapi get SLUGGet an OpenAPI specification by slug
USAGE
$ pnpm exec sanity openapi get SLUG [--format yaml|json] [-w]
ARGUMENTS
SLUG Slug of the OpenAPI specification to retrieve
FLAGS
-w, --web Open in web browser
--format=<option> [default: yaml] Output format: yaml (default), json
<options: yaml|json>
DESCRIPTION
Get an OpenAPI specification by slug
EXAMPLES
Get a specification (YAML format, default)
$ pnpm exec sanity openapi get query
Get specification in JSON format
$ pnpm exec sanity openapi get query --format=json
Open specification in browser
$ pnpm exec sanity openapi get query --web
Pipe to file
$ pnpm exec sanity openapi get query > query-api.yaml
See code: src/commands/openapi/get.ts
sanity openapi listList all available OpenAPI specifications
USAGE
$ pnpm exec sanity openapi list [--json] [-w]
FLAGS
-w, --web Open HTTP Reference in web browser
--json Output JSON
DESCRIPTION
List all available OpenAPI specifications
EXAMPLES
List all available OpenAPI specs
$ pnpm exec sanity openapi list
List with JSON output
$ pnpm exec sanity openapi list --json
Open HTTP Reference in browser
$ pnpm exec sanity openapi list --web
See code: src/commands/openapi/list.ts
sanity preview [OUTPUTDIR]Starts a server to preview a production build
USAGE
$ pnpm exec sanity preview [OUTPUTDIR] [--host <value>] [--port <value>]
ARGUMENTS
[OUTPUTDIR] Output directory
FLAGS
--host=<value> [default: localhost] The local network interface at which to listen.
--port=<value> [default: 3333] TCP port to start server on.
DESCRIPTION
Starts a server to preview a production build
ALIASES
$ pnpm exec sanity start
EXAMPLES
$ pnpm exec sanity preview --host=0.0.0.0
$ pnpm exec sanity preview --port=1942
$ pnpm exec sanity preview some/build-output-dir
See code: src/commands/preview.ts
sanity projects create [PROJECTNAME]Create a new Sanity project
USAGE
$ pnpm exec sanity projects create [PROJECTNAME] [--dataset <value>] [--dataset-visibility private|public] [--json]
[--organization <slug|id>] [-y]
ARGUMENTS
[PROJECTNAME] Name of the project to create
FLAGS
-y, --yes Skip prompts and use defaults (project: "My Sanity Project", dataset: production,
visibility: public)
--dataset=<value> Create a dataset. Prompts for visibility unless specified or --yes used
--dataset-visibility=<option> Dataset visibility: public or private
<options: private|public>
--json Output in JSON format
--organization=<slug|id> Organization to create the project in
DESCRIPTION
Create a new Sanity project
EXAMPLES
Interactively create a project
$ pnpm exec sanity projects create
Create a project named "My New Project"
$ pnpm exec sanity projects create "My New Project"
Create a project in a specific organization
$ pnpm exec sanity projects create "My Project" --organization=my-org
Create a project with a private dataset named "staging"
$ pnpm exec sanity projects create "My Project" --dataset=staging --dataset-visibility=private
Create a project non-interactively with JSON output
$ pnpm exec sanity projects create "CI Project" --yes --json
See code: src/commands/projects/create.ts
sanity projects listLists projects connected to your user
USAGE
$ pnpm exec sanity projects list [--order asc|desc] [--sort id|members|name|url|created]
FLAGS
--order=<option> [default: desc]
<options: asc|desc>
--sort=<option> [default: created]
<options: id|members|name|url|created>
DESCRIPTION
Lists projects connected to your user
EXAMPLES
List projects
$ pnpm exec sanity projects list
List all users of the project, but exclude pending invitations and robots
$ pnpm exec sanity projects list --sort=members --order=asc
See code: src/commands/projects/list.ts
sanity schema deleteDelete schema documents by id
USAGE
$ pnpm exec sanity schema delete --ids <value> [--dataset <value>] [--verbose]
FLAGS
--dataset=<value> Delete schemas from a specific dataset
--ids=<value> (required) Comma-separated list of schema ids to delete
--verbose Enable verbose logging
DESCRIPTION
Delete schema documents by id
EXAMPLES
Delete a single schema
$ pnpm exec sanity schema delete --ids sanity.workspace.schema.workspaceName
Delete multiple schemas
$ pnpm exec sanity schema delete --ids sanity.workspace.schema.workspaceName,prefix.sanity.workspace.schema.otherWorkspace
See code: src/commands/schema/delete.ts
sanity schema deployDeploy schema documents into workspace datasets.
USAGE
$ pnpm exec sanity schema deploy [--extract-manifest] [--manifest-dir <directory>] [--tag <tag>] [--verbose] [--workspace
<name>]
FLAGS
--[no-]extract-manifest Disables manifest generation - the command will fail if no manifest exists
--manifest-dir=<directory> [default: ./dist/static] Directory containing manifest file
--tag=<tag> Add a tag suffix to the schema id
--verbose Print detailed information during deployment
--workspace=<name> The name of the workspace to deploy a schema for
DESCRIPTION
Deploy schema documents into workspace datasets.
**Note**: This command is experimental and subject to change.
This operation (re-)generates a manifest file describing the sanity config workspace by default.
To re-use an existing manifest file, use --no-extract-manifest.
EXAMPLES
Deploy all workspace schemas
$ pnpm exec sanity schema deploy
Deploy the schema for only the workspace "default"
$ pnpm exec sanity schema deploy --workspace default
See code: src/commands/schema/deploy.ts
sanity schema extractExtracts a JSON representation of a Sanity schema within a Studio context.
USAGE
$ pnpm exec sanity schema extract [--enforce-required-fields] [--format <format>] [--path <value>] [--watch]
[--watch-patterns <glob>...] [--workspace <name>]
FLAGS
--enforce-required-fields Makes the schema generated treat fields marked as required as non-optional
--format=<format> [default: groq-type-nodes] Format the schema as GROQ type nodes. Only available format at
the moment.
--path=<value> Optional path to specify destination of the schema file
--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)
--workspace=<name> The name of the workspace to generate a schema for
DESCRIPTION
Extracts a JSON representation of a Sanity schema within a Studio context.
**Note**: This command is experimental and subject to change.
EXAMPLES
Extracts schema types in a Sanity project with more than one workspace
$ pnpm exec sanity schema extract --workspace default
Watch mode - re-extract on changes
$ pnpm exec sanity schema extract --watch
Watch with custom glob patterns
$ pnpm exec sanity schema extract --watch --watch-patterns "lib/**/*.ts"
See code: src/commands/schema/extract.ts
sanity schema listLists all schemas in the current dataset.
USAGE
$ pnpm exec sanity schema list [--id <schema_id>] [--json]
FLAGS
--id=<schema_id> Fetch a single schema by id
--json Get schema as json
DESCRIPTION
Lists all schemas in the current dataset.
**Note**: This command is experimental and subject to change.
This operation (re-)generates a manifest file describing the sanity config workspace by default.
To re-use an existing manifest file, use --no-extract-manifest.
EXAMPLES
List all schemas found in any workspace dataset in a table
$ pnpm exec sanity schema list
Get a schema for a given id
$ pnpm exec sanity schema list --id _.schemas.workspaceName
Get stored schemas as pretty-printed json-array
$ pnpm exec sanity schema list --json
Get singular stored schema as pretty-printed json-object
$ pnpm exec sanity schema list --json --id _.schemas.workspaceName
See code: src/commands/schema/list.ts
sanity schema validateValidates all schema types specified in a workspace
USAGE
$ pnpm exec sanity schema validate [--debug-metafile-path <value>] [--format pretty|ndjson|json] [--level error|warning]
[--workspace <value>]
FLAGS
--format=<option> [default: pretty] The output format used to print schema errors and warnings
<options: pretty|ndjson|json>
--level=<option> [default: warning] The minimum level reported out
<options: error|warning>
--workspace=<value> The name of the workspace to use when validating all schema types
DEBUG FLAGS
--debug-metafile-path=<value> Optional path where a metafile will be written for build analysis. Only written on
successful validation. Can be analyzed at https://esbuild.github.io/analyze/
DESCRIPTION
Validates all schema types specified in a workspace
EXAMPLES
Validates all schema types in a Sanity project with more than one workspace
$ pnpm exec sanity schema validate --workspace default
Save the results of the report into a file
$ pnpm exec sanity schema validate > report.txt
Report out only errors
$ pnpm exec sanity schema validate --level error
Generate a report which can be analyzed with https://esbuild.github.io/analyze/
$ pnpm exec sanity schema validate --debug-metafile-path metafile.json
See code: src/commands/schema/validate.ts
sanity start [OUTPUTDIR]Starts a server to preview a production build
USAGE
$ pnpm exec sanity start [OUTPUTDIR] [--host <value>] [--port <value>]
ARGUMENTS
[OUTPUTDIR] Output directory
FLAGS
--host=<value> [default: localhost] The local network interface at which to listen.
--port=<value> [default: 3333] TCP port to start server on.
DESCRIPTION
Starts a server to preview a production build
ALIASES
$ pnpm exec sanity start
EXAMPLES
$ pnpm exec sanity start --host=0.0.0.0
$ pnpm exec sanity start --port=1942
$ pnpm exec sanity start some/build-output-dir
sanity telemetry disableDisable telemetry for your logged in user
USAGE
$ pnpm exec sanity telemetry disable
DESCRIPTION
Disable telemetry for your logged in user
EXAMPLES
Disable telemetry for your logged in user
$ pnpm exec sanity telemetry telemetry disable
See code: src/commands/telemetry/disable.ts
sanity telemetry enableEnable telemetry for your logged in user
USAGE
$ pnpm exec sanity telemetry enable
DESCRIPTION
Enable telemetry for your logged in user
EXAMPLES
Enable telemetry for your logged in user
$ pnpm exec sanity telemetry telemetry enable
See code: src/commands/telemetry/enable.ts
sanity telemetry statusCheck telemetry consent status for your logged in user
USAGE
$ pnpm exec sanity telemetry status
DESCRIPTION
Check telemetry consent status for your logged in user
EXAMPLES
Check telemetry consent status for your logged in user
$ pnpm exec sanity telemetry telemetry status
See code: src/commands/telemetry/status.ts
sanity tokens add [LABEL]Create a new API token for this project
USAGE
$ pnpm exec sanity tokens add [LABEL] [--json] [--role viewer] [-y]
ARGUMENTS
[LABEL] Label for the new token
FLAGS
-y, --yes Skip prompts and use defaults (unattended mode)
--json Output as JSON
--role=viewer Role to assign to the token
DESCRIPTION
Create a new API token for this project
EXAMPLES
Create a token with a label
$ pnpm exec sanity tokens add "My API Token"
Create a token with editor role
$ pnpm exec sanity tokens add "My API Token" --role=editor
Create a token in unattended mode
$ pnpm exec sanity tokens add "CI Token" --role=editor --yes
Output token information as JSON
$ pnpm exec sanity tokens add "API Token" --json
See code: src/commands/tokens/add.ts
sanity tokens delete [TOKENID]Delete an API token from this project
USAGE
$ pnpm exec sanity tokens delete [TOKENID] [--yes]
ARGUMENTS
[TOKENID] Token ID to delete (will prompt if not provided)
FLAGS
--yes Skip confirmation prompt (unattended mode)
DESCRIPTION
Delete an API token from this project
EXAMPLES
Interactively select and delete a token
$ pnpm exec sanity tokens delete
Delete a specific token by ID
$ pnpm exec sanity tokens delete silJ2lFmK6dONB
Delete a specific token without confirmation prompt
$ pnpm exec sanity tokens delete silJ2lFmK6dONB --yes
See code: src/commands/tokens/delete.ts
sanity tokens listList API tokens for the current project
USAGE
$ pnpm exec sanity tokens list [--json]
FLAGS
--json Output tokens in JSON format
DESCRIPTION
List API tokens for the current project
EXAMPLES
List tokens for the current project
$ pnpm exec sanity tokens list
List tokens in JSON format
$ pnpm exec sanity tokens list --json
See code: src/commands/tokens/list.ts
sanity typegen generateSanity TypeGen
USAGE
$ pnpm exec sanity typegen generate [--config-path <value>] [--watch]
FLAGS
--config-path=<value> [Default: sanity-typegen.json] Specifies the path to the typegen configuration file. This file
should be a JSON file that contains settings for the type generation process.
--watch [Default: false] Run the typegen in watch mode
DESCRIPTION
Sanity TypeGen
Configuration:
This command can utilize configuration settings defined in a `sanity-typegen.json` file. These settings include:
- "path": Specifies a glob pattern to locate your TypeScript or JavaScript files.
Default: "./src/**/*.{ts,tsx,js,jsx}"
- "schema": Defines the path to your Sanity schema file. This file should be generated using the `sanity schema
extract` command.
Default: "schema.json"
- "generates": Indicates the path where the generated TypeScript type definitions will be saved.
Default: "./sanity.types.ts"
The default configuration values listed above are used if not overridden in your `sanity-typegen.json` configuration
file. To customize the behavior of the type generation, adjust these properties in the configuration file according to
your project's needs.
Note:
- The `sanity schema extract` command is a prerequisite for extracting your Sanity Studio schema into a `schema.json`
file, which is then used by the `sanity typegen generate` command to generate type definitions.
EXAMPLES
Generate TypeScript type definitions from a Sanity Studio schema extracted using the `sanity schema extract`
command.
$ pnpm exec sanity typegen generate
See code: @sanity/codegen
sanity undeployRemoves the deployed Sanity Studio/App from Sanity hosting
USAGE
$ pnpm exec sanity undeploy [-y]
FLAGS
-y, --yes Unattended mode, answers "yes" to any "yes/no" prompt and otherwise uses defaults
DESCRIPTION
Removes the deployed Sanity Studio/App from Sanity hosting
See code: src/commands/undeploy.ts
sanity users invite [EMAIL]Invite a new user to the project
USAGE
$ pnpm exec sanity users invite [EMAIL] [--role <value>]
ARGUMENTS
[EMAIL] Email address to invite
FLAGS
--role=<value> Role to invite the user as
DESCRIPTION
Invite a new user to the project
EXAMPLES
Invite a new user to the project (prompt for details)
$ pnpm exec sanity users invite
Send a new user invite to the email "pippi@sanity.io", prompt for role
$ pnpm exec sanity users invite pippi@sanity.io
Send a new user invite to the email "pippi@sanity.io", as administrator
$ pnpm exec sanity users invite pippi@sanity.io --role administrator
See code: src/commands/users/invite.ts
sanity users listList all users of the project
USAGE
$ pnpm exec sanity users list [--invitations] [--order asc|desc] [--robots] [--sort id|name|role|date]
FLAGS
--[no-]invitations Includes or excludes pending invitations
--order=<option> [default: asc] Sort output ascending/descending
<options: asc|desc>
--[no-]robots Includes or excludes robots (token users)
--sort=<option> [default: date] Sort users by specified column
<options: id|name|role|date>
DESCRIPTION
List all users of the project
EXAMPLES
List all users of the project
$ pnpm exec sanity users list
List all users of the project, but exclude pending invitations and robots
$ pnpm exec sanity users list --no-invitations --no-robots
List all users, sorted by role
$ pnpm exec sanity users list --sort role
See code: src/commands/users/list.ts
sanity versionsShows installed versions of Sanity Studio and components
USAGE
$ pnpm exec sanity versions
DESCRIPTION
Shows installed versions of Sanity Studio and components
EXAMPLES
$ pnpm exec sanity versions
See code: src/commands/versions.ts
The Contentful CLI is a command-line tool for managing Contentful spaces and environments. It offers similar functionalities to @sanity/cli, such as creating and managing spaces, importing and exporting data, and deploying content. However, it is specific to the Contentful content management system.
Strapi is an open-source headless CMS that provides a CLI for managing projects. The Strapi CLI allows you to create new projects, generate APIs, and manage content types. While it offers similar functionalities to @sanity/cli, Strapi is a self-hosted solution, whereas Sanity.io is a managed service.
Netlify CLI is a command-line tool for managing Netlify sites and deployments. It allows you to deploy sites, manage environment variables, and perform other tasks related to Netlify hosting. While it is not a CMS, it offers deployment functionalities similar to @sanity/cli.
FAQs
Sanity CLI tool for managing Sanity installations, managing plugins, schemas and datasets
The npm package @sanity/cli receives a total of 338,656 weekly downloads. As such, @sanity/cli popularity was classified as popular.
We found that @sanity/cli demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 113 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Join Socket for live demos, rooftop happy hours, and one-on-one meetings during BSidesSF and RSA 2026 in San Francisco.

Research
/Security News
Malicious Packagist packages disguised as Laravel utilities install an encrypted PHP RAT via Composer dependencies, enabling remote access and C2 callbacks.

Research
/Security News
OpenVSX releases of Aqua Trivy 1.8.12 and 1.8.13 contained injected natural-language prompts that abuse local AI coding agents for system inspection and potential data exfiltration.