@sanity/cli
v7.4.0
Published
Sanity CLI tool for managing Sanity projects and organizations
Readme
@sanity/cli
Code for sanity cli
Commands
sanity backups disable [DATASET]sanity backups download [DATASET]sanity backups enable [DATASET]sanity backups list [DATASET]sanity blueprints add TYPEsanity blueprints configsanity blueprints deploysanity blueprints destroysanity blueprints doctorsanity blueprints infosanity blueprints init [DIR]sanity blueprints logssanity blueprints mint-deploy-tokensanity blueprints plansanity blueprints promotesanity blueprints stackssanity build [OUTPUTDIR]sanity codemod [CODEMODNAME]sanity cors add ORIGINsanity cors delete [ORIGIN]sanity cors listsanity datasets alias create [ALIASNAME] [TARGETDATASET]sanity datasets alias delete ALIASNAMEsanity datasets alias link [ALIASNAME] [TARGETDATASET]sanity datasets alias unlink [ALIASNAME]sanity datasets copy [SOURCE] [TARGET]sanity datasets create [NAME]sanity datasets delete DATASETNAMEsanity datasets embeddings disable [DATASET]sanity datasets embeddings enable [DATASET]sanity datasets embeddings status [DATASET]sanity datasets export [NAME] [DESTINATION]sanity datasets import SOURCE [TARGETDATASET]sanity datasets listsanity datasets visibility get DATASETsanity datasets visibility set DATASET MODEsanity debugsanity deploy [SOURCEDIR]sanity devsanity docs browsesanity docs read PATHsanity docs search QUERYsanity doctor [CHECKS]sanity 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 hooks attempt ATTEMPTIDsanity hooks createsanity hooks delete [NAME]sanity hooks listsanity hooks 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 migrations create [TITLE]sanity migrations listsanity migrations run [ID]sanity openapi get SLUGsanity openapi listsanity preview [OUTPUTDIR]sanity projects create [PROJECTNAME]sanity projects listsanity schemas deletesanity schemas deploysanity schemas extractsanity schemas listsanity schemas validatesanity 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 versions
sanity backups disable [DATASET]
Disable backup for a dataset
USAGE
$ sanity backups disable [DATASET] [-p <id>]
ARGUMENTS
[DATASET] Dataset name to disable backup for
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to disable backups for (overrides CLI configuration)
DESCRIPTION
Disable backup for a dataset
EXAMPLES
Interactively disable backup for a dataset
$ sanity backups disable
Disable backup for the production dataset
$ sanity backups disable productionsanity backups download [DATASET]
Download a dataset backup to a local file
USAGE
$ sanity backups download [DATASET] [-p <id>] [--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
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to download backup from (overrides CLI configuration)
DESCRIPTION
Download a dataset backup to a local file
EXAMPLES
Interactively download a backup
$ sanity backups download
Download a specific backup for the production dataset
$ sanity backups download production --backup-id 2024-01-01-backup-1
Download backup to a specific file
$ sanity backups download production --backup-id 2024-01-01-backup-2 --out /path/to/file
Download backup and overwrite existing file
$ sanity backups download production --backup-id 2024-01-01-backup-3 --out /path/to/file --overwritesanity backups enable [DATASET]
Enable backup for a dataset
USAGE
$ sanity backups enable [DATASET] [-p <id>]
ARGUMENTS
[DATASET] Dataset name to enable backup for
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to enable backups for (overrides CLI configuration)
DESCRIPTION
Enable backup for a dataset
EXAMPLES
Interactively enable backup for a dataset
$ sanity backups enable
Enable backup for the production dataset
$ sanity backups enable productionsanity backups list [DATASET]
List available backups for a dataset
USAGE
$ sanity backups list [DATASET] [-p <id>] [--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)
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to list backups for (overrides CLI configuration)
DESCRIPTION
List available backups for a dataset
EXAMPLES
List backups for a dataset interactively
$ sanity backups list
List backups for the production dataset
$ sanity backups list production
List up to 50 backups for the production dataset
$ sanity backups list production --limit 50
List up to 10 backups created after 2024-01-31
$ sanity backups list production --after 2024-01-31 --limit 10sanity blueprints add TYPE
[deprecated] Use "functions add" instead
USAGE
$ sanity blueprints add TYPE [--json] [--example <value> | -n <value> | --fn-type
document-publish|document-create|document-delete|document-update|media-library-asset-create|media-library-asset-dele
te|media-library-asset-update|scheduled-function|sync-tag-invalidate... | --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-publish|document-create|document-delete|document-update|media-library-
asset-create|media-library-asset-delete|media-library-asset-update|scheduled-function|syn
c-tag-invalidate>
--javascript Use JavaScript instead of TypeScript
--json Format output as json
--language=<option> [default: ts] Language of the new function
<options: ts|js>
DESCRIPTION
[deprecated] Use "functions add" instead
This command is deprecated. Use "functions add" instead.
Equivalent usage:
$ sanity functions add
$ sanity functions add --name my-function --type document-create
EXAMPLES
$ sanity blueprints add function
$ sanity blueprints add function --helpers
$ sanity blueprints add function --name my-function
$ sanity blueprints add function --name my-function --fn-type document-create
$ sanity blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang jssanity blueprints config
View or edit the local Blueprint configuration
USAGE
$ sanity blueprints config [--json] [--stack <value> -e] [--project-id <value> ] [--organization-id <value> ]
FLAGS
-e, --edit Modify the configuration interactively, or directly when combined with ID flags.
--json Format output as json
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
--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
$ sanity blueprints config
$ sanity blueprints config --edit
$ sanity blueprints config --edit --project-id <projectId>
$ sanity blueprints config --edit --project-id <projectId> --stack <name-or-id>sanity blueprints deploy
Deploy the local Blueprint to the remote Stack
USAGE
$ sanity blueprints deploy [--json] [--stack <value>] [--project-id <value> | --organization-id <value>] [-m <value>]
[--no-wait] [--new-stack-name <value>]
FLAGS
-m, --message=<value> Message describing the deployment (e.g. reason for change)
--json Format output as json
--new-stack-name=<value> Set a new name for the Stack
--no-wait Do not wait for Stack deployment to complete
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
--stack=<value> Stack name or ID to use instead of the locally configured Stack
DESCRIPTION
Deploy the local Blueprint to the remote Stack
Applies your local Blueprint to the remote Stack, creating, updating, or removing 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.
Use --fn-installer to force which package manager to use when deploying functions.
Set SANITY_ASSET_TIMEOUT (seconds) to override the 60-second timeout for processing resource assets.
Exit codes: 0 deployed, 2 deployment failed, 75 deployment accepted but completion could not be confirmed (rerun
'blueprints info' to check).
EXAMPLES
$ sanity blueprints deploy
$ sanity blueprints deploy --message "Enable staging dataset"
$ sanity blueprints deploy --no-wait
$ sanity blueprints deploy --fn-installer npm
$ sanity blueprints deploy --stack <name-or-id>
$ sanity blueprints deploy --organization-id <orgId> --stack <name-or-id>
$ sanity blueprints deploy --new-stack-name <new-name>sanity blueprints destroy
Destroy a remote Stack deployment and its resources
USAGE
$ sanity blueprints destroy [--json] [--project-id <value> --stack <value> --force] [--organization-id <value> ]
[--no-wait]
FLAGS
--force Force Stack destruction (skip confirmation)
--json Format output as json
--no-wait Do not wait for Stack destruction to complete
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
--stack=<value> Stack name or ID to destroy (defaults to the locally configured Stack)
DESCRIPTION
Destroy a remote Stack deployment and its resources
Permanently removes the remote Stack and all its provisioned resources. Your Blueprint manifest and resource files
remain intact; "stackId" is unset in your local config.
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.
Exit codes: 0 destroyed, 2 destruction failed, 75 destruction accepted but completion could not be confirmed (rerun
'blueprints info' to check).
EXAMPLES
$ sanity blueprints destroy
$ sanity blueprints destroy --stack <name-or-id> --project-id <projectId> --force --no-waitsanity blueprints doctor
Diagnose potential issues with local Blueprint and remote Stack configuration
USAGE
$ 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.
EXAMPLES
$ sanity blueprints doctor
$ sanity blueprints doctor --fixsanity blueprints info
Display the status and resources of the remote Stack deployment
USAGE
$ sanity blueprints info [--json] [--stack <value>] [--project-id <value> | --organization-id <value>]
FLAGS
--json Format output as json
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
--stack=<value> Stack name or ID
DESCRIPTION
Display the status and resources of the 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
$ sanity blueprints info
$ sanity blueprints info --stack <name-or-id>
$ sanity blueprints info --project-id <id> --stack <name-or-id>
$ sanity blueprints info --organization-id <orgId> --stack <name-or-id>sanity blueprints init [DIR]
Initialize a Blueprint and create a remote Stack
USAGE
$ sanity blueprints init [DIR] [--json] [--dir <value>] [--example <value> | --blueprint-type json|js|ts |
--stack-id <value> | --stack-name <value>] [--project-id <value> | --organization-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
--json Format output as json
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
--project-id=<value> Sanity project ID used to scope Blueprint and 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
DESCRIPTION
Initialize a Blueprint and create a remote Stack
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
$ sanity blueprints init
$ sanity blueprints init [directory]
$ sanity blueprints init --blueprint-type <json|js|ts>
$ sanity blueprints init --organization-id <organizationId>
$ sanity blueprints init --project-id <projectId>
$ sanity blueprints init --stack-name <newStackName>
$ sanity blueprints init --stack-id <existingStackId>
$ sanity blueprints init new-stack --type <json|js|ts> --org <organizationId> --name <newStackName>
$ sanity blueprints init old-stack --type <json|js|ts> --project-id <projectId> --stack-id <existingStackId>sanity blueprints logs
Display logs for the current Blueprint's Stack deployment
USAGE
$ sanity blueprints logs [--json] [--stack <value>] [--project-id <value> | --organization-id <value>] [-l <value>
| -w] [--since <value> | ] [--before <value> | ]
FLAGS
-l, --limit=<value> Maximum number of log entries to retrieve (1-500)
-w, --watch Watch for new Stack logs
--before=<value> Only show logs before this ISO 8601 timestamp
--json Format output as json
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
--since=<value> Only show logs after this ISO 8601 timestamp
--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 tail logs in real-time.
Use --limit, --since, or --before to narrow the result set when not watching.
If you're not seeing expected logs, verify your Stack is deployed with 'blueprints info'.
EXAMPLES
$ sanity blueprints logs
$ sanity blueprints logs --watch
$ sanity blueprints logs --stack <name-or-id>
$ sanity blueprints logs --limit 500
$ sanity blueprints logs --since 2026-05-01T00:00:00Z
$ sanity blueprints logs --before 2026-05-01T00:00:00Zsanity blueprints mint-deploy-token
Create a robot API token for deploying Blueprints from CI/CD
USAGE
$ sanity blueprints mint-deploy-token [--project-id <value> | --organization-id <value>] [--label <value>] [-P |
--json]
FLAGS
-P, --print Print only the raw token to stdout (suitable for shell substitution)
--json Format output as json
--label=<value> Human-readable label for the robot. Defaults to a generated value.
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
DESCRIPTION
Create a robot API token for deploying Blueprints from CI/CD
Mints a long-lived robot token with the role required to plan, deploy, and destroy Blueprints in this project or
organization.
By default the command runs interactively and asks how you want to receive the token (clipboard, print, or exit). Use
--print to emit only the raw token for shell pipelines, or --json for full API output.
The minted token is also visible in your Sanity Manage UI under Robots, where it can be revoked.
EXAMPLES
$ sanity blueprints mint-deploy-token
$ sanity blueprints mint-deploy-token --label "ci-deploy"
$ sanity blueprints mint-deploy-token --print
export SANITY_AUTH_TOKEN=$(sanity blueprints mint-deploy-token --print)
$ sanity blueprints mint-deploy-token --json
$ sanity blueprints mint-deploy-token --project-id <projectId>
$ sanity blueprints mint-deploy-token --organization-id <orgId>sanity blueprints plan
Preview changes that will be applied to the remote Stack
USAGE
$ sanity blueprints plan [--json] [--stack <value>] [--project-id <value> | --organization-id <value>]
FLAGS
--json Format output as json
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
--stack=<value> Stack name or ID to use instead of the locally configured Stack
DESCRIPTION
Preview changes that will be applied to the remote Stack
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
$ sanity blueprints plan
$ sanity blueprints plan --stack <name-or-id>
$ sanity blueprints plan --organization-id <orgId> --stack <name-or-id>sanity blueprints promote
Promote a Stack from project scope to organization scope
USAGE
$ sanity blueprints promote [--json] [--stack <value>] [--project-id <value> | ] [--force] [--new-stack-name <value>]
FLAGS
--force Skip confirmation prompt
--json Format output as json
--new-stack-name=<value> Set a new name for the Stack while promoting
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
--stack=<value> Stack name or ID to promote
DESCRIPTION
Promote a Stack from project scope to organization scope
Promotes a deployed Stack to organization scope, enabling management of org-level resources. Promotion cannot be
reversed.
Your local Blueprint configuration will be updated to reflect the new scope.
EXAMPLES
$ sanity blueprints promote
$ sanity blueprints promote --stack <name-or-id>
$ sanity blueprints promote --project-id <projectId> --stack <name-or-id>
$ sanity blueprints promote --new-stack-name <new-name>sanity blueprints stacks
List remote Stack deployments for your project or organization
USAGE
$ sanity blueprints stacks [--json] [--project-id <value> | --organization-id <value> | --include-projects]
FLAGS
--include-projects Include Stacks from all projects within the organization. Requires --organization-id.
--json Format output as json
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
DESCRIPTION
List remote Stack deployments for your project or organization
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.
Use --include-projects with --organization-id to also list Stacks from all projects within the organization.
EXAMPLES
$ sanity blueprints stacks
$ sanity blueprints stacks --project-id <projectId>
$ sanity blueprints stacks --organization-id <organizationId>
$ sanity blueprints stacks --organization-id <organizationId> --include-projectssanity build [OUTPUTDIR]
Build Sanity Studio into a static bundle
USAGE
$ 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
Build Sanity Studio into a static bundle
EXAMPLES
$ sanity build
$ sanity build --no-minify --source-mapssanity codemod [CODEMODNAME]
Updates Sanity Studio codebase with a code modification script
USAGE
$ 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
$ sanity codemod
Run codemod to transform react-icons imports (dry run)
$ sanity codemod reactIconsV3 --drysanity cors add ORIGIN
Add a CORS origin to the project
USAGE
$ sanity cors add ORIGIN [-p <id>] [--credentials]
ARGUMENTS
ORIGIN Origin to allow (e.g., https://example.com)
FLAGS
--[no-]credentials Allow credentials (token/cookie) to be sent from this origin
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to add CORS origin to (overrides CLI configuration)
DESCRIPTION
Add a CORS origin to the project
EXAMPLES
Interactively add a CORS origin
$ sanity cors add
Add a localhost origin without credentials
$ sanity cors add http://localhost:3000 --no-credentials
Add a production origin with credentials allowed
$ sanity cors add https://myapp.com --credentials
Add a CORS origin for a specific project
$ sanity cors add https://myapp.com --project-id abc123sanity cors delete [ORIGIN]
Delete a CORS origin from the project
USAGE
$ sanity cors delete [ORIGIN] [-p <id>]
ARGUMENTS
[ORIGIN] Origin to delete (will prompt if not provided)
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to delete CORS origin from (overrides CLI configuration)
DESCRIPTION
Delete a CORS origin from the project
EXAMPLES
Interactively select and delete a CORS origin
$ sanity cors delete
Delete a specific CORS origin
$ sanity cors delete https://example.com
Delete a CORS origin from a specific project
$ sanity cors delete --project-id abc123sanity cors list
List CORS origins for the project
USAGE
$ sanity cors list [-p <id>]
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to list CORS origins for (overrides CLI configuration)
DESCRIPTION
List CORS origins for the project
EXAMPLES
List CORS origins for the project
$ sanity cors list
List CORS origins for a specific project
$ sanity cors list --project-id abc123sanity datasets alias create [ALIASNAME] [TARGETDATASET]
Create a dataset alias for the project
USAGE
$ sanity datasets alias create [ALIASNAME] [TARGETDATASET] [-p <id>]
ARGUMENTS
[ALIASNAME] Dataset alias name to create
[TARGETDATASET] Target dataset name to link the alias to
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to create dataset alias in (overrides CLI configuration)
DESCRIPTION
Create a dataset alias for the project
EXAMPLES
Create alias in a specific project
$ sanity datasets alias create --project-id abc123 conference conf-2025
Create an alias with interactive prompts
$ sanity datasets alias create
Create alias named "conference" with interactive dataset selection
$ sanity datasets alias create conference
Create alias "conference" linked to "conf-2025" dataset
$ sanity datasets alias create conference conf-2025sanity datasets alias delete ALIASNAME
Delete a dataset alias from the project
USAGE
$ sanity datasets alias delete ALIASNAME [-p <id>] [--force]
ARGUMENTS
ALIASNAME Dataset alias name to delete
FLAGS
--force Skip confirmation prompt and delete immediately
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to delete dataset alias from (overrides CLI configuration)
DESCRIPTION
Delete a dataset alias from the project
EXAMPLES
Delete alias named "conference" with confirmation prompt
$ sanity datasets alias delete conference
Delete alias named "conference" without confirmation prompt
$ sanity datasets alias delete conference --forcesanity datasets alias link [ALIASNAME] [TARGETDATASET]
Link a dataset alias to a dataset in the project
USAGE
$ sanity datasets alias link [ALIASNAME] [TARGETDATASET] [-p <id>] [--force]
ARGUMENTS
[ALIASNAME] Dataset alias name to link
[TARGETDATASET] Target dataset name to link the alias to
FLAGS
--force Skip confirmation prompt when relinking existing alias
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to link dataset alias in (overrides CLI configuration)
DESCRIPTION
Link a dataset alias to a dataset in the project
EXAMPLES
Link an alias with interactive prompts
$ sanity datasets alias link
Link alias named "conference" with interactive dataset selection
$ sanity datasets alias link conference
Link alias "conference" to "conf-2025" dataset
$ sanity datasets alias link conference conf-2025
Force link without confirmation (skip relink prompt)
$ sanity datasets alias link conference conf-2025 --forcesanity datasets alias unlink [ALIASNAME]
Unlink a dataset alias from its dataset in the project
USAGE
$ sanity datasets alias unlink [ALIASNAME] [-p <id>] [--force]
ARGUMENTS
[ALIASNAME] Dataset alias name to unlink
FLAGS
--force Skip confirmation prompt and unlink immediately
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to unlink dataset alias in (overrides CLI configuration)
DESCRIPTION
Unlink a dataset alias from its dataset in the project
EXAMPLES
Unlink an alias with interactive selection
$ sanity datasets alias unlink
Unlink alias "conference" with confirmation prompt
$ sanity datasets alias unlink conference
Unlink alias "conference" without confirmation prompt
$ sanity datasets alias unlink conference --forcesanity datasets copy [SOURCE] [TARGET]
Copy a dataset or manage copy jobs
USAGE
$ sanity datasets copy [SOURCE] [TARGET] [-p <id>] [--limit <value> ] [--offset <value> ]
[--skip-content-releases | | [--attach <value> | --list | --detach | --skip-history]]
ARGUMENTS
[SOURCE] Name of the dataset to copy from
[TARGET] Name of the dataset to copy to
FLAGS
--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-content-releases Don't copy content release documents to the target dataset
--skip-history Don't preserve document history on copy
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to copy dataset in (overrides CLI configuration)
DESCRIPTION
Copy a dataset or manage copy jobs
EXAMPLES
Interactively copy a dataset
$ sanity datasets copy
Copy from source-dataset (prompts for target)
$ sanity datasets copy source-dataset
Copy from source-dataset to target-dataset
$ sanity datasets copy source-dataset target-dataset
Copy without preserving document history (faster for large datasets)
$ sanity datasets copy --skip-history source target
Copy without content release documents
$ sanity datasets copy --skip-content-releases source target
Start copy job without waiting for completion
$ sanity datasets copy --detach source target
Attach to a running copy job to follow progress
$ sanity datasets copy --attach <job-id>
List all dataset copy jobs
$ sanity datasets copy --list
List copy jobs with pagination
$ sanity datasets copy --list --offset 2 --limit 10sanity datasets create [NAME]
Create a new dataset for the project
USAGE
$ sanity datasets create [NAME] [-p <id>] [--embeddings-projection <value> --embeddings] [--visibility
custom|private|public]
ARGUMENTS
[NAME] Name of the dataset to create
FLAGS
--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>
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to create dataset in (overrides CLI configuration)
DESCRIPTION
Create a new dataset for the project
EXAMPLES
Interactively create a dataset
$ sanity datasets create
Create a dataset named "my-dataset"
$ sanity datasets create my-dataset
Create a private dataset named "my-dataset"
$ sanity datasets create my-dataset --visibility privatesanity datasets delete DATASETNAME
Delete a dataset from the project
USAGE
$ sanity datasets delete DATASETNAME [-p <id>] [--force]
ARGUMENTS
DATASETNAME Dataset name to delete
FLAGS
--force Do not prompt for delete confirmation - forcefully delete
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to delete dataset from (overrides CLI configuration)
DESCRIPTION
Delete a dataset from the project
EXAMPLES
Delete a specific dataset
$ sanity datasets delete my-dataset
Delete a specific dataset without confirmation
$ sanity datasets delete my-dataset --forcesanity datasets embeddings disable [DATASET]
Disable embeddings for a dataset
USAGE
$ sanity datasets embeddings disable [DATASET] [-p <id>]
ARGUMENTS
[DATASET] Dataset name to disable embeddings for
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to disable embeddings for (overrides CLI configuration)
DESCRIPTION
Disable embeddings for a dataset
EXAMPLES
Disable embeddings for the production dataset
$ sanity datasets embeddings disable productionsanity datasets embeddings enable [DATASET]
Enable embeddings for a dataset
USAGE
$ sanity datasets embeddings enable [DATASET] [-p <id>] [--projection <value>] [--wait]
ARGUMENTS
[DATASET] Dataset name to enable embeddings for
FLAGS
--projection=<value> GROQ projection defining which fields to embed (e.g. "{ title, body }")
--wait Wait for embeddings processing to complete before returning
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to enable embeddings for (overrides CLI configuration)
DESCRIPTION
Enable embeddings for a dataset
EXAMPLES
Enable embeddings for the production dataset
$ sanity datasets embeddings enable production
Enable embeddings with a specific projection
$ sanity datasets embeddings enable production --projection "{ title, body }"
Enable embeddings and wait for processing to complete
$ sanity datasets embeddings enable production --waitsanity datasets embeddings status [DATASET]
Show embeddings settings and status for a dataset
USAGE
$ sanity datasets embeddings status [DATASET] [-p <id>]
ARGUMENTS
[DATASET] The name of the dataset to check embeddings status for
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to check embeddings status for (overrides CLI configuration)
DESCRIPTION
Show embeddings settings and status for a dataset
EXAMPLES
Show embeddings status for the production dataset
$ sanity datasets embeddings status productionsanity datasets export [NAME] [DESTINATION]
Export a dataset to a local gzipped tarball. Assets returning 401, 403, or 404 are excluded from the export.
USAGE
$ sanity datasets export [NAME] [DESTINATION] [-p <id>] [--asset-concurrency <value>] [--mode stream|cursor]
[--no-assets] [--no-compress] [--no-drafts] [--no-strict-asset-verification] [--overwrite] [--raw] [--types <value>]
ARGUMENTS
[NAME] Name of the dataset to export
[DESTINATION] Output destination file path
FLAGS
--asset-concurrency=<value> [default: 8] Concurrent number of asset downloads
--mode=<option> [default: stream] Export mode ('cursor' is faster for large datasets but may miss
concurrent changes)
<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
--no-strict-asset-verification Do not abort the export when an asset fails hash or content-length verification
--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)
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to export dataset from (overrides CLI configuration)
DESCRIPTION
Export a dataset to a local gzipped tarball. Assets returning 401, 403, or 404 are excluded from the export.
EXAMPLES
Export dataset "moviedb" to localPath.tar.gz
$ sanity datasets export moviedb localPath.tar.gz
Export dataset without assets
$ sanity datasets export moviedb assetless.tar.gz --no-assets
Export raw documents without asset reference rewriting
$ sanity datasets export staging staging.tar.gz --raw
Export specific document types
$ sanity datasets export staging staging.tar.gz --types products,shops
Export dataset without aborting on asset verification failures
$ sanity datasets export moviedb moviedb.tar.gz --no-strict-asset-verificationsanity datasets import SOURCE [TARGETDATASET]
Import documents to a Sanity dataset
USAGE
$ sanity datasets import SOURCE [TARGETDATASET] [--allow-assets-in-different-dataset] [--allow-failing-assets]
[--allow-replacement-characters] [--allow-system-documents] [--asset-concurrency <value>] [-d <name>] [--missing |
--replace] [-p <id>] [--replace-assets] [--skip-cross-dataset-references] [-t <value>]
ARGUMENTS
SOURCE Source file (use "-" for stdin)
[TARGETDATASET] Target dataset (prefer --dataset flag instead)
FLAGS
-d, --dataset=<name> Dataset 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
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to import to (overrides CLI configuration)
DESCRIPTION
Import documents to a Sanity dataset
EXAMPLES
Import "./my-dataset.ndjson" into dataset "staging"
$ sanity datasets import -d staging my-dataset.ndjson
Import into dataset "test" from stdin
cat my-dataset.ndjson | sanity datasets import -d test -
Import with explicit project ID (overrides CLI configuration)
$ sanity datasets import -p projectId -d staging my-dataset.ndjson
Import with an explicit token (e.g. for CI/CD)
$ sanity datasets import -d staging -t someSecretToken my-dataset.ndjsonsanity datasets list
List datasets for the project
USAGE
$ sanity datasets list [-p <id>]
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to list datasets for (overrides CLI configuration)
DESCRIPTION
List datasets for the project
EXAMPLES
List datasets for the project
$ sanity datasets list
List datasets for a specific project
$ sanity datasets list --project-id abc123sanity datasets visibility get DATASET
Get the visibility of a dataset
USAGE
$ sanity datasets visibility get DATASET [-p <id>]
ARGUMENTS
DATASET The name of the dataset to get visibility for
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to get dataset visibility for (overrides CLI configuration)
DESCRIPTION
Get the visibility of a dataset
EXAMPLES
Check the visibility of a dataset
$ sanity datasets visibility get my-datasetsanity datasets visibility set DATASET MODE
Set the visibility of a dataset
USAGE
$ sanity datasets visibility set DATASET MODE [-p <id>]
ARGUMENTS
DATASET The name of the dataset to set visibility for
MODE (public|private) The visibility mode to set
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to set dataset visibility for (overrides CLI configuration)
DESCRIPTION
Set the visibility of a dataset
EXAMPLES
Make a dataset private
$ sanity datasets visibility set my-dataset private
Make a dataset public
$ sanity datasets visibility set my-dataset publicsanity debug
Print diagnostic info for troubleshooting
USAGE
$ sanity debug [--secrets] [--verbose]
FLAGS
--secrets Include API keys in output
--verbose Show full error details including stack traces
DESCRIPTION
Print diagnostic info for troubleshooting
EXAMPLES
$ sanity debug
$ sanity debug --secretssanity deploy [SOURCEDIR]
Builds and deploys Sanity Studio or application to Sanity hosting
USAGE
$ sanity deploy [SOURCEDIR] [--auto-updates] [--external | --source-maps | --minify | --build]
[--schema-required] [--url <value>] [--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 Build the studio before deploying (use --no-build to deploy existing `dist/` output)
--external Register an externally hosted studio
--[no-]minify Minify built JavaScript (use --no-minify to skip for faster builds)
--schema-required Fail if schema deployment fails
--source-maps Enable source maps for built bundles (increases size of bundle)
--url=<value> Studio URL for deployment. For external studios, the full URL. For hosted studios, the
hostname (e.g. "my-studio" or "my-studio.sanity.studio")
--verbose Enable verbose logging
DESCRIPTION
Builds and deploys Sanity Studio or application to Sanity hosting
EXAMPLES
Build and deploy the studio to Sanity hosting
$ sanity deploy
Deploys non-minified build with source maps
$ sanity deploy --no-minify --source-maps
Fail fast on schema store fails - for when other services rely on the stored schema
$ sanity deploy --schema-required
Register an externally hosted studio (studioHost contains full URL)
$ sanity deploy --externalsanity dev
Start a local development server with live reloading
USAGE
$ sanity dev [--auto-updates] [--host <value>] [--load-in-dashboard] [--port <value>]
FLAGS
--[no-]auto-updates Automatically update Sanity Studio dependencies
--host=<value> Local network interface to listen on (default: localhost)
--[no-]load-in-dashboard Load the app/studio in the Sanity dashboard
--port=<value> TCP port to start server on (default: 3333)
DESCRIPTION
Start a local development server with live reloading
EXAMPLES
$ sanity dev --host=0.0.0.0
$ sanity dev --port=1942
$ sanity dev --load-in-dashboardsanity docs browse
Open Sanity docs in your browser
USAGE
$ sanity docs browse
DESCRIPTION
Open Sanity docs in your browsersanity docs read PATH
Read an article in terminal
USAGE
$ 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
$ sanity docs read /docs/studio/installation
Read using full URL
$ sanity docs read https://www.sanity.io/docs/studio/installation
Open in web browser
$ sanity docs read /docs/studio/installation --web
Open using full URL in web browser
$ sanity docs read https://www.sanity.io/docs/studio/installation -wsanity docs search QUERY
Search Sanity docs
USAGE
$ 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
$ sanity docs search schema
Search with phrase
$ sanity docs search "groq functions"
Limit search results
$ sanity docs search "deployment" --limit=5sanity doctor [CHECKS]
Run diagnostics on your Sanity project
USAGE
$ sanity doctor [CHECKS...] [-j]
ARGUMENTS
[CHECKS...] Checks to enable (defaults to all). Valid: cli
FLAGS
-j, --json Output results as JSON
DESCRIPTION
Run diagnostics on your Sanity project
EXAMPLES
$ sanity doctor
Output results as JSON
$ sanity doctor --json
Only run CLI-related diagnostics
$ sanity doctor clisanity documents create [FILE]
Create one or more documents
USAGE
$ sanity documents create [FILE] [-p <id>] [-d <name>] [--id <value>] [--json5] [--missing] [--replace] [--watch]
ARGUMENTS
[FILE] JSON file to create document(s) from
FLAGS
--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
OVERRIDE FLAGS
-d, --dataset=<name> Dataset to create document(s) in (overrides CLI configuration)
-p, --project-id=<id> Project ID to create document(s) in (overrides CLI configuration)
DESCRIPTION
Create one or more documents
EXAMPLES
Create the document specified in "myDocument.json"
$ sanity documents create myDocument.json
Open configured $EDITOR and create the specified document(s)
$ 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
$ 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.
$ sanity documents create --id myDocId --watch --replace --json5
Create documents in a specific project
$ sanity documents create myDocument.json --project-id abc123sanity documents delete ID [IDS]
Delete one or more documents from the project's configured dataset
USAGE
$ sanity documents delete ID... [IDS...] [-p <id>] [-d <name>]
ARGUMENTS
ID... Document ID to delete
[IDS...] Additional document IDs to delete
OVERRIDE FLAGS
-d, --dataset=<name> Dataset to delete from (overrides CLI configuration)
-p, --project-id=<id> Project ID to delete from (overrides CLI configuration)
DESCRIPTION
Delete one or more documents from the project's configured dataset
EXAMPLES
Delete the document with the ID "myDocId"
$ sanity documents delete myDocId
ID wrapped in double or single quote works equally well
$ sanity documents delete 'myDocId'
Delete document with ID "someDocId" from dataset "blog"
$ sanity documents delete --dataset=blog someDocId
Delete the document with ID "doc1" and "doc2"
$ sanity documents delete doc1 doc2
Delete a document from a specific project
$ sanity documents delete myDocId --project-id abc123sanity documents get DOCUMENTID
Get and print a document by ID
USAGE
$ sanity documents get DOCUMENTID [-p <id>] [-d <name>] [--pretty]
ARGUMENTS
DOCUMENTID Document ID to retrieve
FLAGS
--pretty Colorize JSON output
OVERRIDE FLAGS
-d, --dataset=<name> Dataset to get document from (overrides CLI configuration)
-p, --project-id=<id> Project ID to get document from (overrides CLI configuration)
DESCRIPTION
Get and print a document by ID
EXAMPLES
Get the document with ID "myDocId"
$ sanity documents get myDocId
Get document with colorized JSON output
$ sanity documents get myDocId --pretty
Get document from a specific dataset
$ sanity documents get myDocId --dataset production
Get a document from a specific project
$ sanity documents get myDocId --project-id abc123sanity documents query QUERY
Query for documents
USAGE
$ sanity documents query QUERY [-p <id>] [-d <name>] [--anonymous] [--api-version <value>] [--pretty]
ARGUMENTS
QUERY GROQ query to run against the dataset
FLAGS
--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
OVERRIDE FLAGS
-d, --dataset=<name> Dataset to query (overrides CLI configuration)
-p, --project-id=<id> Project ID to query (overrides CLI configuration)
DESCRIPTION
Query for documents
EXAMPLES
Fetch 5 documents of type "movie"
$ sanity documents query '*[_type == "movie"][0..4]'
Fetch title of the oldest movie in the dataset named "staging"
$ sanity documents query '*[_type == "movie"]|order(releaseDate asc)[0]{title}' --dataset staging
Use API version v2021-06-07 and do a query
$ sanity documents query '*[_id == "header"] { "headerText": pt::text(body) }' --api-version v2021-06-07
Query documents in a specific project and dataset
$ sanity documents query '*[_type == "post"]' --project-id abc123 --dataset productionsanity documents validate
Validate documents in a dataset against the studio schema
USAGE
$ sanity documents validate [-p <id>] [-d <name>] [--file <value>] [--format <value>] [--level error|warning|info]
[--max-custom-validation-concurrency <value>] [--max-fetch-concurrency <value>] [--workspace <value>] [-y]
FLAGS
-d, --dataset=<name> Override the dataset used. By default, this is derived from the given
workspace
-p, --project-id=<id> Override the project ID 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. 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 allowed to
run concurrently
--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
$ sanity documents validate --workspace default
Override the dataset specified in the workspace
$ sanity documents validate --workspace default --dataset staging
Save the results of the report into a file
$ sanity documents validate --yes > report.txt
Report out info level validation markers too
$ sanity documents validate --level info
Validate documents in a specific project and dataset
$ sanity documents validate --project-id abc123 --dataset productionsanity exec SCRIPT
Executes a script within the Sanity Studio context
USAGE
$ sanity exec SCRIPT... [--mock-browser-env] [--with-user-token]
ARGUMENTS
SCRIPT... Path to the script to execute
FLAGS
--mock-browser-env Mock a browser environment with jsdom
--with-user-token Include your auth token in getCliClient()
DESCRIPTION
Executes a script within the Sanity Studio context
EXAMPLES
Run the script at some/script.js in Sanity context
$ 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
$ sanity exec migrations/fullname.ts --with-user-token
Run the script at scripts/browserScript.js in a mock browser environment
$ 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']`)
$ sanity exec --mock-browser-env myscript.js -- --dry-run positional-argumentsanity functions add
Add a Function to your Blueprint
USAGE
$ sanity functions add [--json] [--example <value> | -n <value> | | --language ts|js | --javascript | | ]
[--type document-publish|document-create|document-delete|document-update|media-library-asset-create|media-library-as
set-delete|media-library-asset-update|scheduled-function|sync-tag-invalidate... ] [--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
--json Format output as json
--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-publish|document-create|document-delete|document-update|media-library-ass
et-create|media-library-asset-delete|media-library-asset-update|scheduled-function|sync-tag-
invalidate>
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, live content or media-library events (create, update, delete,
publish).
After adding, use 'functions dev' to test locally, then 'blueprints deploy' to publish.
EXAMPLES
$ sanity functions add
$ sanity functions add --helpers
$ sanity functions add --name my-function
$ sanity functions add --name my-function --type document-create
$ sanity functions add --name my-function --type document-create --type document-update --lang jssanity functions dev
Start the Sanity Function emulator
USAGE
$ sanity functions dev [--json] [-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`
--json Format output as json
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
$ sanity functions dev --host 127.0.0.1 --port 8974
$ sanity functions dev --timeout 60sanity functions env add NAME KEY VALUE
Add or set an environment variable for a deployed function
USAGE
$ sanity functions env add NAME KEY VALUE [--json]
ARGUMENTS
NAME The name of the Sanity Function
KEY The name of the environment variable
VALUE The value of the environment variable
FLAGS
--json Format output as json
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
$ sanity functions env add MyFunction API_URL https://api.example.com/sanity functions env list NAME
List environment variables for a deployed function
USAGE
$ sanity functions env list NAME [--json]
ARGUMENTS
NAME The name of the Sanity Function
FLAGS
--json Format output as json
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
$ sanity functions env list MyFunctionsanity functions env remove NAME KEY
Remove an environment variable from a deployed function
USAGE
$ sanity functions env remove NAME KEY [--json]
ARGUMENTS
NAME The name of the Sanity Function
KEY The name of the environment variable
FLAGS
--json Format output as json
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
$ sanity functions env remove MyFunction API_URLsanity functions logs [NAME]
Retrieve or delete logs for a Sanity Function
USAGE
$ sanity functions logs [NAME] [--stack <value>] [-u] [-f [-d | -l <value> | --json]] [-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
-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)
--json Format output as json
--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
$ sanity functions logs <name>
$ sanity functions logs <name> --json
$ sanity functions logs <name> --limit 100
$ sanity functions logs <name> --deletesanity functions test [NAME]
Invoke a local
