# @sanity/cli

Code for sanity cli

<!-- toc -->

- [@sanity/cli](#sanitycli)
- [Commands](#commands)

<!-- tocstop -->

# Commands

  <!-- commands -->

- [`sanity api ENDPOINT`](#sanity-api-endpoint)
- [`sanity assets upload`](#sanity-assets-upload)
- [`sanity backups disable [DATASET]`](#sanity-backups-disable-dataset)
- [`sanity backups download [DATASET]`](#sanity-backups-download-dataset)
- [`sanity backups enable [DATASET]`](#sanity-backups-enable-dataset)
- [`sanity backups list [DATASET]`](#sanity-backups-list-dataset)
- [`sanity blueprints add TYPE`](#sanity-blueprints-add-type)
- [`sanity blueprints config`](#sanity-blueprints-config)
- [`sanity blueprints deploy`](#sanity-blueprints-deploy)
- [`sanity blueprints destroy`](#sanity-blueprints-destroy)
- [`sanity blueprints doctor`](#sanity-blueprints-doctor)
- [`sanity blueprints info`](#sanity-blueprints-info)
- [`sanity blueprints init [DIR]`](#sanity-blueprints-init-dir)
- [`sanity blueprints logs`](#sanity-blueprints-logs)
- [`sanity blueprints mint-deploy-token`](#sanity-blueprints-mint-deploy-token)
- [`sanity blueprints plan`](#sanity-blueprints-plan)
- [`sanity blueprints promote`](#sanity-blueprints-promote)
- [`sanity blueprints stacks`](#sanity-blueprints-stacks)
- [`sanity build [OUTPUTDIR]`](#sanity-build-outputdir)
- [`sanity codemod [CODEMODNAME]`](#sanity-codemod-codemodname)
- [`sanity context build KNOWLEDGEBASEID`](#sanity-context-build-knowledgebaseid)
- [`sanity context create`](#sanity-context-create)
- [`sanity context delete KNOWLEDGEBASEID`](#sanity-context-delete-knowledgebaseid)
- [`sanity context get KNOWLEDGEBASEID`](#sanity-context-get-knowledgebaseid)
- [`sanity context imports create KNOWLEDGEBASEID`](#sanity-context-imports-create-knowledgebaseid)
- [`sanity context imports delete KNOWLEDGEBASEID IMPORTID`](#sanity-context-imports-delete-knowledgebaseid-importid)
- [`sanity context imports download KNOWLEDGEBASEID IMPORTID`](#sanity-context-imports-download-knowledgebaseid-importid)
- [`sanity context imports get KNOWLEDGEBASEID IMPORTID`](#sanity-context-imports-get-knowledgebaseid-importid)
- [`sanity context imports list KNOWLEDGEBASEID`](#sanity-context-imports-list-knowledgebaseid)
- [`sanity context jobs get KNOWLEDGEBASEID JOBID`](#sanity-context-jobs-get-knowledgebaseid-jobid)
- [`sanity context list`](#sanity-context-list)
- [`sanity context refresh KNOWLEDGEBASEID`](#sanity-context-refresh-knowledgebaseid)
- [`sanity context update KNOWLEDGEBASEID`](#sanity-context-update-knowledgebaseid)
- [`sanity cors add ORIGIN`](#sanity-cors-add-origin)
- [`sanity cors delete [ORIGIN]`](#sanity-cors-delete-origin)
- [`sanity cors list`](#sanity-cors-list)
- [`sanity datasets alias create [ALIASNAME] [TARGETDATASET]`](#sanity-datasets-alias-create-aliasname-targetdataset)
- [`sanity datasets alias delete ALIASNAME`](#sanity-datasets-alias-delete-aliasname)
- [`sanity datasets alias link [ALIASNAME] [TARGETDATASET]`](#sanity-datasets-alias-link-aliasname-targetdataset)
- [`sanity datasets alias unlink [ALIASNAME]`](#sanity-datasets-alias-unlink-aliasname)
- [`sanity datasets copy [SOURCE] [TARGET]`](#sanity-datasets-copy-source-target)
- [`sanity datasets create [NAME]`](#sanity-datasets-create-name)
- [`sanity datasets delete DATASETNAME`](#sanity-datasets-delete-datasetname)
- [`sanity datasets embeddings disable [DATASET]`](#sanity-datasets-embeddings-disable-dataset)
- [`sanity datasets embeddings enable [DATASET]`](#sanity-datasets-embeddings-enable-dataset)
- [`sanity datasets embeddings status [DATASET]`](#sanity-datasets-embeddings-status-dataset)
- [`sanity datasets export [NAME] [DESTINATION]`](#sanity-datasets-export-name-destination)
- [`sanity datasets import SOURCE [TARGETDATASET]`](#sanity-datasets-import-source-targetdataset)
- [`sanity datasets list`](#sanity-datasets-list)
- [`sanity datasets visibility get DATASET`](#sanity-datasets-visibility-get-dataset)
- [`sanity datasets visibility set DATASET MODE`](#sanity-datasets-visibility-set-dataset-mode)
- [`sanity debug`](#sanity-debug)
- [`sanity deploy [SOURCEDIR]`](#sanity-deploy-sourcedir)
- [`sanity dev`](#sanity-dev)
- [`sanity docs browse`](#sanity-docs-browse)
- [`sanity docs read PATH`](#sanity-docs-read-path)
- [`sanity docs search QUERY`](#sanity-docs-search-query)
- [`sanity doctor [CHECKS]`](#sanity-doctor-checks)
- [`sanity documents create [FILE]`](#sanity-documents-create-file)
- [`sanity documents delete ID [IDS]`](#sanity-documents-delete-id-ids)
- [`sanity documents get DOCUMENTID`](#sanity-documents-get-documentid)
- [`sanity documents query QUERY`](#sanity-documents-query-query)
- [`sanity documents validate`](#sanity-documents-validate)
- [`sanity exec SCRIPT`](#sanity-exec-script)
- [`sanity functions add`](#sanity-functions-add)
- [`sanity functions dev`](#sanity-functions-dev)
- [`sanity functions env add NAME KEY VALUE`](#sanity-functions-env-add-name-key-value)
- [`sanity functions env list NAME`](#sanity-functions-env-list-name)
- [`sanity functions env remove NAME KEY`](#sanity-functions-env-remove-name-key)
- [`sanity functions logs [NAME]`](#sanity-functions-logs-name)
- [`sanity functions test [NAME]`](#sanity-functions-test-name)
- [`sanity graphql deploy`](#sanity-graphql-deploy)
- [`sanity graphql list`](#sanity-graphql-list)
- [`sanity graphql undeploy`](#sanity-graphql-undeploy)
- [`sanity help [COMMAND]`](#sanity-help-command)
- [`sanity hooks attempt ATTEMPTID`](#sanity-hooks-attempt-attemptid)
- [`sanity hooks create`](#sanity-hooks-create)
- [`sanity hooks delete [NAME]`](#sanity-hooks-delete-name)
- [`sanity hooks list`](#sanity-hooks-list)
- [`sanity hooks logs [NAME]`](#sanity-hooks-logs-name)
- [`sanity init`](#sanity-init)
- [`sanity install [PACKAGES]`](#sanity-install-packages)
- [`sanity learn`](#sanity-learn)
- [`sanity login`](#sanity-login)
- [`sanity logout`](#sanity-logout)
- [`sanity manage`](#sanity-manage)
- [`sanity manifest extract`](#sanity-manifest-extract)
- [`sanity mcp configure`](#sanity-mcp-configure)
- [`sanity media create-aspect`](#sanity-media-create-aspect)
- [`sanity media delete-aspect ASPECTNAME`](#sanity-media-delete-aspect-aspectname)
- [`sanity media deploy-aspect [ASPECTNAME]`](#sanity-media-deploy-aspect-aspectname)
- [`sanity media export [DESTINATION]`](#sanity-media-export-destination)
- [`sanity media import SOURCE`](#sanity-media-import-source)
- [`sanity migrations create [TITLE]`](#sanity-migrations-create-title)
- [`sanity migrations list`](#sanity-migrations-list)
- [`sanity migrations run [ID]`](#sanity-migrations-run-id)
- [`sanity new [PROJECTNAME]`](#sanity-new-projectname)
- [`sanity openapi get SLUG`](#sanity-openapi-get-slug)
- [`sanity openapi list`](#sanity-openapi-list)
- [`sanity organizations create`](#sanity-organizations-create)
- [`sanity organizations delete ORGANIZATIONID`](#sanity-organizations-delete-organizationid)
- [`sanity organizations get ORGANIZATIONID`](#sanity-organizations-get-organizationid)
- [`sanity organizations list`](#sanity-organizations-list)
- [`sanity organizations update ORGANIZATIONID`](#sanity-organizations-update-organizationid)
- [`sanity preview [OUTPUTDIR]`](#sanity-preview-outputdir)
- [`sanity projects create [PROJECTNAME]`](#sanity-projects-create-projectname)
- [`sanity projects list`](#sanity-projects-list)
- [`sanity projects unclaimed`](#sanity-projects-unclaimed)
- [`sanity schemas delete`](#sanity-schemas-delete)
- [`sanity schemas deploy`](#sanity-schemas-deploy)
- [`sanity schemas extract`](#sanity-schemas-extract)
- [`sanity schemas list`](#sanity-schemas-list)
- [`sanity schemas validate`](#sanity-schemas-validate)
- [`sanity skills install`](#sanity-skills-install)
- [`sanity telemetry disable`](#sanity-telemetry-disable)
- [`sanity telemetry enable`](#sanity-telemetry-enable)
- [`sanity telemetry status`](#sanity-telemetry-status)
- [`sanity tokens create [LABEL]`](#sanity-tokens-create-label)
- [`sanity tokens delete [TOKENID]`](#sanity-tokens-delete-tokenid)
- [`sanity tokens list`](#sanity-tokens-list)
- [`sanity tokens rotate`](#sanity-tokens-rotate)
- [`sanity typegen generate`](#sanity-typegen-generate)
- [`sanity undeploy [APPID]`](#sanity-undeploy-appid)
- [`sanity users invite [EMAIL]`](#sanity-users-invite-email)
- [`sanity users list`](#sanity-users-list)
- [`sanity versions`](#sanity-versions)
- [`sanity workflows abort INSTANCEID`](#sanity-workflows-abort-instanceid)
- [`sanity workflows definition delete NAME`](#sanity-workflows-definition-delete-name)
- [`sanity workflows definition diff NAME`](#sanity-workflows-definition-diff-name)
- [`sanity workflows definition list`](#sanity-workflows-definition-list)
- [`sanity workflows definition show NAME`](#sanity-workflows-definition-show-name)
- [`sanity workflows deploy`](#sanity-workflows-deploy)
- [`sanity workflows diagnose INSTANCEID`](#sanity-workflows-diagnose-instanceid)
- [`sanity workflows fire-action INSTANCEID`](#sanity-workflows-fire-action-instanceid)
- [`sanity workflows list`](#sanity-workflows-list)
- [`sanity workflows nuke`](#sanity-workflows-nuke)
- [`sanity workflows reset-activity INSTANCEID ACTIVITY`](#sanity-workflows-reset-activity-instanceid-activity)
- [`sanity workflows set-stage INSTANCEID`](#sanity-workflows-set-stage-instanceid)
- [`sanity workflows show INSTANCEID`](#sanity-workflows-show-instanceid)
- [`sanity workflows start NAME`](#sanity-workflows-start-name)
- [`sanity workflows tail INSTANCEID`](#sanity-workflows-tail-instanceid)

## `sanity api ENDPOINT`

Make an authenticated HTTP request to a Sanity API

```
USAGE
  $ sanity api ENDPOINT [-p <id>] [-d <name>] [--api-version <version>] [--global | --project-hosted] [-H
    <key:value>...] [-i] [--input <file> | -F <key=value>... | -f <key=value>...] [-X <method>] [--pretty] [-t <token> |
    --anonymous]

ARGUMENTS
  ENDPOINT  API path (eg "projects" or "data/query/{dataset}"), optionally with placeholders, or a full
            https://*.api.sanity.io URL

FLAGS
  -F, --field=<key=value>...      Add a typed parameter (key=value): true/false/null and numbers are converted, @file
                                  reads the value from a file, @- from stdin
  -H, --header=<key:value>...     Add an HTTP request header (key: value)
  -X, --method=<method>           HTTP method to use (default GET, or POST when fields or --input are provided)
  -f, --raw-field=<key=value>...  Add a string parameter (key=value)
  -i, --include                   Include the HTTP response status and headers in the output
  -t, --token=<token>             API token to authenticate with, instead of the logged-in user token
      --anonymous                 Send the request without an authorization token
      --api-version=<version>     API version to use (eg v2025-02-19). Defaults to a version embedded in the endpoint
                                  path, or the version from the matching OpenAPI spec
      --global                    Force the request to the global API host (api.sanity.io)
      --input=<file>              Read the raw request body from a file (use "-" for stdin). Sent without a default
                                  Content-Type - provide one with -H when the API requires it
      --pretty                    Colorize JSON output
      --project-hosted            Force the request to the project API host (<projectId>.api.sanity.io)

OVERRIDE FLAGS
  -d, --dataset=<name>   Dataset for {dataset} placeholders (overrides CLI configuration)
  -p, --project-id=<id>  Project ID for {projectId} placeholders and project-hosted APIs (overrides CLI configuration)

DESCRIPTION
  Make an authenticated HTTP request to a Sanity API

  The endpoint argument is an API path as documented in the published OpenAPI
  specifications - list them with "sanity openapi list" and inspect one with
  "sanity openapi get <slug>". Paths can be copied verbatim from the specs:
  {projectId} and {dataset} placeholders are filled in from flags or the CLI
  configuration, and the API host (api.sanity.io or <projectId>.api.sanity.io)
  is chosen based on the specs' routing information.

  The default request method is GET, or POST when fields or --input are
  provided. For GET/HEAD requests, fields are sent as query parameters;
  otherwise they are combined into a JSON request body sent with
  "Content-Type: application/json". Raw --input bodies are sent without a
  default Content-Type - provide one with -H when the API requires it. The
  response body is written to stdout.

  Requests are authenticated with the token from "sanity login". To use a
  specific token instead - for example in CI or when the CLI is not logged in
  - pass --token or set the SANITY_AUTH_TOKEN environment variable. Pass
  --anonymous to send no token at all.

EXAMPLES
  Get the current user

    $ sanity api users/me

  Get the current project (placeholder filled from CLI config)

    $ sanity api projects/{projectId}

  Run a GROQ query against the project host

    $ sanity api 'data/query/{dataset}' -f query='*[_type == "movie"][0..2]'

  Send a JSON body built from typed fields

    $ sanity api projects/{projectId} -X PATCH -F displayName="My project"

  Send a raw request body from stdin

    echo '{"mutations": []}' | sanity api 'data/mutate/{dataset}' --input - -H 'Content-Type: application/json'

  Include the response status and headers, pinning the API version

    $ sanity api jobs/123 --include --api-version v2025-02-19

  Authenticate with a specific token instead of the logged-in session

    SANITY_AUTH_TOKEN=<token> sanity api users/me
```

## `sanity assets upload`

Upload one image or file to a Sanity dataset, from a local path or a URL, and print the asset document as JSON

```
USAGE
  $ sanity assets upload [-p <id>] [-d <name>] [--content-type <mime-type>] [--file <path>] [--filename <filename>]
    [--from-url <url>] [--type image|file]

FLAGS
  --content-type=<mime-type>  MIME type of the asset, such as image/png or application/pdf. Only applies to --file
  --file=<path>               Path to the local file to upload
  --filename=<filename>       Original filename stored on the asset document. Defaults to the local filename when using
                              --file
  --from-url=<url>            https URL for Sanity to fetch the asset from, instead of uploading a local file. Must be
                              reachable from the public internet without authentication
  --type=<option>             [default: image] Asset type to create
                              <options: image|file>

OVERRIDE FLAGS
  -d, --dataset=<name>   Dataset to upload the asset to (overrides CLI configuration)
  -p, --project-id=<id>  Project ID to upload the asset to (overrides CLI configuration)

DESCRIPTION
  Upload one image or file to a Sanity dataset, from a local path or a URL, and print the asset document as JSON

EXAMPLES
  Upload an image using the configured project

    $ sanity assets upload --file ./hero.png --type image --dataset production

  Upload a file with explicit project, dataset, and MIME type

    $ sanity assets upload --file ./brief.pdf --type file --content-type application/pdf --project-id abc123 \
      --dataset production

  Have Sanity fetch an image from a public URL

    $ sanity assets upload --from-url 'https://example.com/hero.png' --type image --dataset production
```

## `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 production
```

## `sanity 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 --overwrite
```

## `sanity 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 production
```

## `sanity 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 10
```

## `sanity 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|pub-sub|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|pub-sub|scheduled-func
                               tion|sync-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 js
```

## `sanity 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 180-second timeout for processing resource assets.

  Set SANITY_ASSET_CONCURRENCY to override how many resource assets are processed at once (default 4).

  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> -f] [--organization-id <value>  ]
    [--no-wait]

FLAGS
  -f, --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-wait
```

## `sanity blueprints doctor`

Diagnose potential issues with local Blueprint and remote Stack configuration

```
USAGE
  $ sanity blueprints doctor [--json] [-p <value>] [--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

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.

  Supports --json for programmatic consumption of diagnostic results.

EXAMPLES
  $ sanity blueprints doctor

  $ sanity blueprints doctor --fix
```

## `sanity blueprints info`

Display the status and resources of the remote Stack deployment

```
USAGE
  $ sanity blueprints info [--json] [-v] [--stack <value>] [--project-id <value> | --organization-id <value>]

FLAGS
  -v, --verbose                  Show resource and external IDs
      --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 (defaults to the current directory)

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.

  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. A .gitignore
  covering node_modules, .env, and Function build output is created or updated; the .sanity/ config itself is not
  ignored.

  After initialization, use 'blueprints plan' to preview changes, then 'blueprints deploy' to apply them.

  Running without a directory prompts to confirm the current directory. Run 'blueprints init .' to initialize in the
  current directory without a prompt.

EXAMPLES
  $ sanity blueprints init

  $ 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 [--stack <value>] [--project-id <value> | --organization-id <value>] [-l <value> | [-w |
    --json]] [--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:00Z
```

## `sanity 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 | --all]

FLAGS
  --all                      List Stacks from every organization and project you have access to
  --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.

  Without a scope, prompts for an organization or project. Use --all to list Stacks across every organization and
  project you can access, or --include-projects with --organization-id for one organization and its projects.

EXAMPLES
  $ sanity blueprints stacks

  $ sanity blueprints stacks --all

  $ sanity blueprints stacks --project-id <projectId>

  $ sanity blueprints stacks --organization-id <organizationId>

  $ sanity blueprints stacks --organization-id <organizationId> --include-projects
```

## `sanity 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-maps
```

## `sanity 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 --dry
```

## `sanity context build KNOWLEDGEBASEID`

Build a knowledge base from its imported content

```
USAGE
  $ sanity context build KNOWLEDGEBASEID [--cancel | --watch]

ARGUMENTS
  KNOWLEDGEBASEID  Knowledge base ID

FLAGS
  --cancel  Cancel the running build instead of starting one
  --watch   Wait for the build to finish, exiting non-zero if it fails

DESCRIPTION
  Build a knowledge base from its imported content

EXAMPLES
  Start a build and return the job ID

    $ sanity context build kb-abc123

  Start a build and wait for it to finish (non-zero exit on failure)

    $ sanity context build kb-abc123 --watch

  Cancel the running build, if any

    $ sanity context build kb-abc123 --cancel
```

## `sanity context create`

Create a knowledge base

```
USAGE
  $ sanity context create [--organization <id>] [--description <value>] [--title <value>]

FLAGS
  --description=<value>  Knowledge base description
  --title=<value>        Knowledge base title

OVERRIDE FLAGS
  --organization=<id>  Organization to create the knowledge base in (overrides CLI configuration)

DESCRIPTION
  Create a knowledge base

EXAMPLES
  Interactively create a knowledge base

    $ sanity context create

  Create a knowledge base in a specific organization

    $ sanity context create --organization org-abc123 --title "Support docs" --description "Product docs and \
      troubleshooting guides"
```

## `sanity context delete KNOWLEDGEBASEID`

Delete a knowledge base and its generated content

```
USAGE
  $ sanity context delete KNOWLEDGEBASEID [-y]

ARGUMENTS
  KNOWLEDGEBASEID  Knowledge base ID

FLAGS
  -y, --yes  Skip confirmation prompt (unattended mode)

DESCRIPTION
  Delete a knowledge base and its generated content

EXAMPLES
  Delete a knowledge base after confirmation

    $ sanity context delete kb-abc123

  Delete a knowledge base without confirmation prompt

    $ sanity context delete kb-abc123 --yes
```

## `sanity context get KNOWLEDGEBASEID`

Get details of a knowledge base

```
USAGE
  $ sanity context get KNOWLEDGEBASEID [--json]

ARGUMENTS
  KNOWLEDGEBASEID  Knowledge base ID

FLAGS
  --json  Output the knowledge base in JSON format

DESCRIPTION
  Get details of a knowledge base

EXAMPLES
  Get details of a specific knowledge base

    $ sanity context get kb-abc123

  Output the knowledge base as JSON

    $ sanity context get kb-abc123 --json
```

## `sanity context imports create KNOWLEDGEBASEID`

Import content into a knowledge base

```
USAGE
  $ sanity context imports create KNOWLEDGEBASEID [--content-type <mime>] [--file <path> | --text <value> | --url <url> |
    --query <value>] [--sanity-dataset <name> ] [--sanity-project <id> ] [--title <value> ]

ARGUMENTS
  KNOWLEDGEBASEID  Knowledge base ID

FLAGS
  --content-type=<mime>    Content type of the import (--text: text/markdown or text/plain; --file: any MIME type,
                           inferred from the file extension when omitted)
  --file=<path>            Path to a local file to import
  --query=<value>          GROQ query binding a Sanity dataset as a source
  --sanity-dataset=<name>  Sanity dataset for a dataset import
  --sanity-project=<id>    Sanity project ID for a dataset import
  --text=<value>           Inline text content to import (requires --title)
  --title=<value>          Title for an inline text import
  --url=<url>              Website URL to crawl

DESCRIPTION
  Import content into a knowledge base

EXAMPLES
  Import inline text

    $ sanity context imports create kb-abc123 --text "Refunds are processed within 5 days" --title "Refund policy"

  Upload and import a local file

    $ sanity context imports create kb-abc123 --file ./handbook.pdf

  Crawl a website

    $ sanity context imports create kb-abc123 --url https://example.com/docs

  Bind a Sanity dataset as a source

    $ sanity context imports create kb-abc123 --query '*[_type == "article"]' --sanity-project abc123 \
      --sanity-dataset production
```

## `sanity context imports delete KNOWLEDGEBASEID IMPORTID`

Delete an import from a knowledge base

```
USAGE
  $ sanity context imports delete KNOWLEDGEBASEID IMPORTID [-y]

ARGUMENTS
  KNOWLEDGEBASEID  Knowledge base ID
  IMPORTID         Import ID

FLAGS
  -y, --yes  Skip confirmation prompt (unattended mode)

DESCRIPTION
  Delete an import from a knowledge base

EXAMPLES
  Delete an import after confirmation

    $ sanity context imports delete kb-abc123 import-def456

  Delete an import without confirmation prompt

    $ sanity context imports delete kb-abc123 import-def456 --yes
```

## `sanity context imports download KNOWLEDGEBASEID IMPORTID`

Get a short-lived signed URL for the original uploaded bytes of a file import

```
USAGE
  $ sanity context imports download KNOWLEDGEBASEID IMPORTID [--json]

ARGUMENTS
  KNOWLEDGEBASEID  Knowledge base ID
  IMPORTID         Import ID

FLAGS
  --json  Output the download URL in JSON format

DESCRIPTION
  Get a short-lived signed URL for the original uploaded bytes of a file import

EXAMPLES
  Get a download URL for an uploaded file

    $ sanity context imports download kb-abc123 import-def456
```

## `sanity context imports get KNOWLEDGEBASEID IMPORTID`

Get details of an import

```
USAGE
  $ sanity context imports get KNOWLEDGEBASEID IMPORTID [--json]

ARGUMENTS
  KNOWLEDGEBASEID  Knowledge base ID
  IMPORTID         Import ID

FLAGS
  --json  Output the import in JSON format

DESCRIPTION
  Get details of an import

EXAMPLES
  Get details of a specific import

    $ sanity context imports get kb-abc123 import-def456

  Output the import as JSON

    $ sanity context imports get kb-abc123 import-def456 --json
```

## `sanity context imports list KNOWLEDGEBASEID`

List imports for a knowledge base

```
USAGE
  $ sanity context imports list KNOWLEDGEBASEID [--json]

ARGUMENTS
  KNOWLEDGEBASEID  Knowledge base ID

FLAGS
  --json  Output imports in JSON format

DESCRIPTION
  List imports for a knowledge base

EXAMPLES
  List all imports for a knowledge base

    $ sanity context imports list kb-abc123

  Output imports as JSON

    $ sanity context imports list kb-abc123 --json
```

## `sanity context jobs get KNOWLEDGEBASEID JOBID`

Get the status of a knowledge base job

```
USAGE
  $ sanity context jobs get KNOWLEDGEBASEID JOBID [--json] [--watch]

ARGUMENTS
  KNOWLEDGEBASEID  Knowledge base ID
  JOBID            Job ID

FLAGS
  --json   Output the job in JSON format
  --watch  Poll until the job reaches a terminal state

DESCRIPTION
  Get the status of a knowledge base job

EXAMPLES
  Get the current status of a job

    $ sanity context jobs get kb-abc123 job-def456

  Wait for the job to finish (non-zero exit if it does not succeed)

    $ sanity context jobs get kb-abc123 job-def456 --watch
```

## `sanity context list`

List knowledge bases in an organization

```
USAGE
  $ sanity context list [--organization <id>] [--json]

FLAGS
  --json  Output knowledge bases in JSON format

OVERRIDE FLAGS
  --organization=<id>  Organization to list knowledge bases for (overrides CLI configuration)

DESCRIPTION
  List knowledge bases in an organization

EXAMPLES
  List knowledge bases, selecting the organization interactively

    $ sanity context list

  List knowledge bases in a specific organization

    $ sanity context list --organization org-abc123

  Output knowledge bases as JSON

    $ sanity context list --organization org-abc123 --json
```

## `sanity context refresh KNOWLEDGEBASEID`

Refresh a knowledge base: re-check sources and apply what changed

```
USAGE
  $ sanity context refresh KNOWLEDGEBASEID

ARGUMENTS
  KNOWLEDGEBASEID  Knowledge base ID

DESCRIPTION
  Refresh a knowledge base: re-check sources and apply what changed

EXAMPLES
  Start an incremental refresh

    $ sanity context refresh kb-abc123
```

## `sanity context update KNOWLEDGEBASEID`

Update a knowledge base

```
USAGE
  $ sanity context update KNOWLEDGEBASEID [--description <value>] [--refresh-enabled] [--refresh-frequency
    weekly|monthly] [--title <value>]

ARGUMENTS
  KNOWLEDGEBASEID  Knowledge base ID

FLAGS
  --description=<value>         New knowledge base description
  --[no-]refresh-enabled        Enable scheduled refresh (--no-refresh-enabled to disable)
  --refresh-frequency=<option>  How often scheduled refresh runs
                                <options: weekly|monthly>
  --title=<value>               New knowledge base title

DESCRIPTION
  Update a knowledge base

EXAMPLES
  Rename a knowledge base

    $ sanity context update kb-abc123 --title "New title"

  Enable weekly scheduled refresh

    $ sanity context update kb-abc123 --refresh-enabled --refresh-frequency weekly

  Disable scheduled refresh

    $ sanity context update kb-abc123 --no-refresh-enabled
```

## `sanity cors add ORIGIN`

Add a CORS origin to the project

```
USAGE
  $ sanity cors add ORIGIN [-p <id>] [--credentials] [-y]

ARGUMENTS
  ORIGIN  Origin to allow (e.g., https://example.com)

FLAGS
  -y, --yes               Confirm risky wildcard origins without prompting
      --[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 abc123
```

## `sanity 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 abc123
```

## `sanity 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 abc123
```

## `sanity 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-2025
```

## `sanity 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 --force
```

## `sanity 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 --force
```

## `sanity 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 --force
```

## `sanity 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 10
```

## `sanity 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 private
```

## `sanity 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 --force
```

## `sanity 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 production
```

## `sanity 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 --wait
```

## `sanity 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 production
```

## `sanity 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-verification
```

## `sanity 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.ndjson
```

## `sanity 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 abc123
```

## `sanity 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-dataset
```

## `sanity 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 public
```

## `sanity 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 --secrets
```

## `sanity deploy [SOURCEDIR]`

Builds and deploys Sanity Studio or application to Sanity hosting

```
USAGE
  $ sanity deploy [SOURCEDIR] [--auto-updates] [--build] [--create | --external | --url <value>] [--dry-run]
    [-j] [--minify] [--schema-required] [--source-maps] [--title <value>] [--verbose] [-y]

ARGUMENTS
  [SOURCEDIR]  Source directory

FLAGS
  -j, --json               Output the result as JSON
  -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)
      --create             Create a new App SDK app, even if the organization has other apps
      --dry-run            Report what would be deployed without uploading or creating anything
      --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)
      --title=<value>      Title for a newly created application or studio. For apps, use --create to select creation
                           when the organization already has apps
      --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 --external

  Create and deploy an App SDK app without prompts. Save application.id as deployment.appId, then omit --create on
  later deploys

    $ sanity deploy --create --title "My App" --yes --json

  Preview a new App SDK deployment without creating or uploading anything

    $ sanity deploy --create --title "My App" --dry-run --json

  Deploy a studio without prompts using its hostname

    $ sanity deploy --url my-studio --yes
```

## `sanity 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-dashboard
```

## `sanity docs browse`

Open Sanity docs in your browser

```
USAGE
  $ sanity docs browse

DESCRIPTION
  Open Sanity docs in your browser
```

## `sanity 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 -w
```

## `sanity 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=5
```

## `sanity 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 cli
```

## `sanity 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 abc123
```

## `sanity 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 abc123
```

## `sanity 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 abc123
```

## `sanity 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>  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 production
```

## `sanity documents validate`

Validate documents in a dataset against the studio schema

```
USAGE
  $ sanity documents validate [-p <id>] [-d <name>] [--file <value>] [--format json|ndjson|pretty] [--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>                               Path to an NDJSON file or tar archive containing an NDJSON file
                                                   (optionally gzip-compressed)
      --format=<option>                            The output format used to print the found validation markers and
                                                   report progress
                                                   <options: json|ndjson|pretty>
      --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 production
```

## `sanity 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-argument
```

## `sanity functions add`

Add a Function to your Blueprint

```
USAGE
  $ sanity functions add [--json] [--example <value> | -n <value> | --type
    document-publish|document-create|document-delete|document-update|media-library-asset-create|media-library-asset-dele
    te|media-library-asset-update|pub-sub|scheduled-function|sync-tag-invalidate... | --language ts|js | --javascript |
    --helpers | --installer skip|npm|pnpm|yarn | -i]

FLAGS
  -i, --install             Shortcut for --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|pub-sub|scheduled-function|s
                            ync-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 js
```

## `sanity 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. The live-reload WebSocket server shares this host
  and port. 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 3333

  $ sanity functions dev --timeout 60
```

## `sanity 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] [--stack <value>]

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
  --stack=<value>  Stack name or ID to use instead of the locally configured Stack

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 add --stack <name-or-id> 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] [--stack <value>]

ARGUMENTS
  NAME  The name of the Sanity Function

FLAGS
  --json           Format output as json
  --stack=<value>  Stack name or ID to use instead of the locally configured Stack

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 MyFunction

  $ sanity functions env list --stack <name-or-id> MyFunction
```

## `sanity functions env remove NAME KEY`

Remove an environment variable from a deployed function

```
USAGE
  $ sanity functions env remove NAME KEY [--json] [--stack <value>]

ARGUMENTS
  NAME  The name of the Sanity Function
  KEY   The name of the environment variable

FLAGS
  --json           Format output as json
  --stack=<value>  Stack name or ID to use instead of the locally configured Stack

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_URL

  $ sanity functions env remove --stack <name-or-id> MyFunction API_URL
```

## `sanity 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> --delete
```

## `sanity functions test [NAME]`

Invoke a local Sanity Function

```
USAGE
  $ sanity functions test [NAME] [--json] [--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> | --organization-id <value>] | --dataset <value>] [--no-wait]

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
      --json                        Format output as json
      --media-library-id=<value>    Sanity Media Library ID to use
      --no-wait                     Skip durable wait delays instead of sleeping
      --organization-id=<value>     Sanity organization ID used to scope Blueprint and Stack
      --project-id=<value>          Sanity project ID used to scope Blueprint and Stack
      --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
  $ sanity functions test <name> --data '{ "id": 1 }'

  $ sanity functions test <name> --file 'payload.json'

  $ sanity functions test <name> --data '{ "id": 1 }' --timeout 60

  $ sanity functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
```

## `sanity graphql deploy`

Deploy a GraphQL API from the current Sanity schema

```
USAGE
  $ sanity graphql deploy [--api <value>...] [-d <name>] [--dry-run] [--force] [--generation gen1|gen2|gen3]
    [--non-null-document-fields] [--playground] [--tag <value>] [--with-union-cache]

FLAGS
  -d, --dataset=<name>            Deploy API for the given dataset
      --api=<value>...            Only deploy API with this ID (can be specified multiple times)
      --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          Cache union types (faster for schemas with many self-references)

DESCRIPTION
  Deploy a GraphQL API from the current Sanity schema

EXAMPLES
  Deploy all defined GraphQL APIs

    $ sanity graphql deploy

  Validate defined GraphQL APIs, check for breaking changes, skip deploy

    $ sanity graphql deploy --dry-run

  Deploy only the GraphQL APIs with the IDs "staging" and "ios"

    $ sanity graphql deploy --api staging --api ios

  Deploy all defined GraphQL APIs, overriding any playground setting

    $ sanity graphql deploy --playground
```

## `sanity graphql list`

List deployed GraphQL endpoints for the project

```
USAGE
  $ sanity graphql list [-p <id>]

OVERRIDE FLAGS
  -p, --project-id=<id>  Project ID to list GraphQL endpoints for (overrides CLI configuration)

DESCRIPTION
  List deployed GraphQL endpoints for the project

EXAMPLES
  List GraphQL endpoints for the project

    $ sanity graphql list

  List GraphQL endpoints for a specific project

    $ sanity graphql list --project-id abc123
```

## `sanity graphql undeploy`

Remove a deployed GraphQL API

```
USAGE
  $ sanity graphql undeploy [--api <value> | -p <id> | ] [-d <name>] [--force] [--tag <value>]

FLAGS
  --api=<value>  Undeploy API with this ID
  --force        Skip confirmation prompt
  --tag=<value>  [default: default] Tag to undeploy GraphQL API from

OVERRIDE FLAGS
  -d, --dataset=<name>   Dataset to undeploy GraphQL API from (overrides CLI configuration)
  -p, --project-id=<id>  Project ID to undeploy GraphQL API from (overrides CLI configuration)

DESCRIPTION
  Remove a deployed GraphQL API

EXAMPLES
  Undeploy GraphQL API for current project and dataset

    $ sanity graphql undeploy

  Undeploy API with ID "ios"

    $ sanity graphql undeploy --api ios

  Undeploy GraphQL API for staging dataset

    $ sanity graphql undeploy --dataset staging

  Undeploy GraphQL API for staging dataset with "next" tag

    $ sanity graphql undeploy --dataset staging --tag next

  Undeploy GraphQL API without confirmation prompt

    $ sanity graphql undeploy --force

  Undeploy GraphQL API for a specific project and dataset

    $ sanity graphql undeploy --project-id abc123 --dataset production
```

## `sanity help [COMMAND]`

Display help for sanity.

```
USAGE
  $ 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.
```

## `sanity hooks attempt ATTEMPTID`

Print details of a given webhook delivery attempt

```
USAGE
  $ sanity hooks attempt ATTEMPTID [-p <id>]

ARGUMENTS
  ATTEMPTID  The delivery attempt ID to get details for

OVERRIDE FLAGS
  -p, --project-id=<id>  Project ID to view webhook attempt for (overrides CLI configuration)

DESCRIPTION
  Print details of a given webhook delivery attempt

EXAMPLES
  Print details of webhook delivery attempt with ID abc123

    $ sanity hooks attempt abc123

  Get attempt details for a specific project

    $ sanity hooks attempt abc123 --project-id projectId
```

## `sanity hooks create`

Create a new webhook for the project

```
USAGE
  $ sanity hooks create [-p <id>]

OVERRIDE FLAGS
  -p, --project-id=<id>  Project ID to create webhook for (overrides CLI configuration)

DESCRIPTION
  Create a new webhook for the project

EXAMPLES
  Create a new webhook for the project

    $ sanity hooks create

  Create a webhook for a specific project

    $ sanity hooks create --project-id abc123
```

## `sanity hooks delete [NAME]`

Delete a webhook from the project

```
USAGE
  $ sanity hooks delete [NAME] [-p <id>]

ARGUMENTS
  [NAME]  Name of webhook to delete (will prompt if not provided)

OVERRIDE FLAGS
  -p, --project-id=<id>  Project ID to delete webhook from (overrides CLI configuration)

DESCRIPTION
  Delete a webhook from the project

EXAMPLES
  Interactively select and delete a webhook

    $ sanity hooks delete

  Delete a specific webhook by name

    $ sanity hooks delete my-hook

  Delete a webhook from a specific project

    $ sanity hooks delete --project-id abc123
```

## `sanity hooks list`

List webhooks for the project

```
USAGE
  $ sanity hooks list [-p <id>]

OVERRIDE FLAGS
  -p, --project-id=<id>  Project ID to list webhooks for (overrides CLI configuration)

DESCRIPTION
  List webhooks for the project

EXAMPLES
  List webhooks for the project

    $ sanity hooks list

  List webhooks for a specific project

    $ sanity hooks list --project-id abc123
```

## `sanity hooks logs [NAME]`

Show log entries for project webhooks

```
USAGE
  $ sanity hooks logs [NAME] [-p <id>] [--detailed]

ARGUMENTS
  [NAME]  Name of the webhook to show logs for

FLAGS
  --detailed  Include detailed payload and attempts

OVERRIDE FLAGS
  -p, --project-id=<id>  Project ID to view webhook logs for (overrides CLI configuration)

DESCRIPTION
  Show log entries for project webhooks

EXAMPLES
  Show log entries for project webhooks

    $ sanity hooks logs

  Show log entries for a specific webhook by name

    $ sanity hooks logs [NAME]

  Show log entries for a specific project

    $ sanity hooks logs --project-id abc123
```

## `sanity init`

Initialize a new Sanity Studio, project and/or app

```
USAGE
  $ sanity init [--json] [--auto-updates | --bare] [--coupon <code> | --project-plan <name>] [--dashboard
    |  | --env <filename>] [--dataset <name> | --dataset-default] [--git <message> | ] [--import-dataset] [--install | ]
    [--mcp] [--nextjs-add-config-files] [--nextjs-append-env] [--nextjs-embed-studio] [--organization <id>]
    [--output-path <path> | ] [--overwrite-files] [--package-manager <manager> | ] [--project <id> |  | --project-name
    <name>] [--provider <provider>] [--skills] [--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)
      --dashboard                  Set up the project to run in the Sanity Dashboard (beta)
      --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-]import-dataset        Import template sample dataset
      --[no-]install               Install dependencies after scaffolding
      --[no-]mcp                   Enable AI editor integration (MCP) setup
      --organization=<id>          Organization ID to use for the project (required for unattended project creation)
      --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-name=<name>        Create a new project with the given name
      --project-plan=<name>        Optionally select a plan for a new project
      --provider=<provider>        Login provider to use
      --[no-]skills                Install Sanity agent skills globally for detected AI editors
      --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
  $ sanity init

  Initialize a new project with a public dataset named "production"

    $ sanity init --dataset-default

  Initialize a project with the given project ID and dataset to the given path

    $ 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

    $ sanity init -y --project abc123 --dataset staging --template moviedb --output-path .

  Create a brand new project with name "Movies Unlimited"

    $ sanity init -y --project-name "Movies Unlimited" --dataset moviedb --visibility private --template moviedb \
      --output-path /Users/espenh/movies-unlimited
```

## `sanity install [PACKAGES]`

Install dependencies for the Sanity Studio project

```
USAGE
  $ sanity install [PACKAGES...]

ARGUMENTS
  [PACKAGES...]  Packages to install

DESCRIPTION
  Install dependencies for the Sanity Studio project

EXAMPLES
  $ sanity install

  $ sanity install @sanity/vision

  $ sanity install some-package another-package
```

## `sanity learn`

Open Sanity Learn in your browser

```
USAGE
  $ sanity learn

DESCRIPTION
  Open Sanity Learn in your browser
```

## `sanity login`

Log in to your Sanity account

```
USAGE
  $ sanity login [--with-token | --provider <providerId> | --sso <slug>] [--open] [--sso-provider <name> ]

FLAGS
  --with-token             Read token from standard input
  --[no-]open              Open a browser window to log in (`--no-open` only prints URL)
  --provider=<providerId>  Log in using a provider ID (google, github, sanity, vercel)
  --sso=<slug>             Log in using Single Sign-On, using the given organization slug
  --sso-provider=<name>    Select a specific SSO provider by name (use with --sso)

DESCRIPTION
  Log in to your Sanity account

EXAMPLES
  Log in using default settings

    $ sanity login

  Log in using a token from standard input

    $ sanity login --with-token < token.txt

  Login with GitHub provider, but do not open a browser window automatically

    $ sanity login --provider github --no-open

  Log in using Single Sign-On with the "my-organization" slug

    $ sanity login --sso my-organization

  Log in using a specific SSO provider within an organization

    $ sanity login --sso my-organization --sso-provider "Okta SSO"
```

## `sanity logout`

Log out of the current session

```
USAGE
  $ sanity logout

DESCRIPTION
  Log out of the current session
```

## `sanity manage`

Open project settings in your browser

```
USAGE
  $ sanity manage

DESCRIPTION
  Open project settings in your browser
```

## `sanity manifest extract`

Extract studio configuration as JSON manifest files.

```
USAGE
  $ sanity manifest extract [--path <value>]

FLAGS
  --path=<value>  [default: dist/static] Optional path to specify destination directory of the manifest files

DESCRIPTION
  Extract studio configuration as JSON manifest files.

  Note: This command is experimental and subject to change. It is currently intended for use with Create only.

EXAMPLES
  Extracts manifests

    $ sanity manifest extract

  Extracts manifests into /public/static

    $ sanity manifest extract --path /public/static
```

## `sanity mcp configure`

Configure Sanity MCP server for AI editors (Antigravity, Claude Code, Cline, Cline CLI, Codex CLI, Cursor, Gemini CLI, GitHub Copilot CLI, MCPorter, OpenCode, VS Code, VS Code Insiders, Zed)

```
USAGE
  $ sanity mcp configure

DESCRIPTION
  Configure Sanity MCP server for AI editors (Antigravity, Claude Code, Cline, Cline CLI, Codex CLI, Cursor, Gemini CLI,
  GitHub Copilot CLI, MCPorter, OpenCode, VS Code, VS Code Insiders, Zed)

EXAMPLES
  Configure Sanity MCP server for detected AI editors

    $ sanity mcp configure
```

## `sanity media create-aspect`

Create a new aspect definition file

```
USAGE
  $ sanity media create-aspect [--name <value>] [--title <value>]

FLAGS
  --name=<value>   Aspect name. Defaults to the title in camel case
  --title=<value>  Aspect title

DESCRIPTION
  Create a new aspect definition file

EXAMPLES
  Create a new aspect definition file

    $ sanity media create-aspect
```

## `sanity media delete-aspect ASPECTNAME`

Delete an aspect definition

```
USAGE
  $ sanity media delete-aspect ASPECTNAME [-p <id>] [--media-library-id <value>] [-y]

ARGUMENTS
  ASPECTNAME  Name of the aspect to delete

FLAGS
  -y, --yes                       Run without prompts and confirm deletion
      --media-library-id=<value>  The id of the target media library

OVERRIDE FLAGS
  -p, --project-id=<id>  Project ID to delete media aspect from (overrides CLI configuration)

DESCRIPTION
  Delete an aspect definition

EXAMPLES
  Delete the aspect named "someAspect"

    $ sanity media delete-aspect someAspect
```

## `sanity media deploy-aspect [ASPECTNAME]`

Deploy an aspect

```
USAGE
  $ sanity media deploy-aspect [ASPECTNAME] [-p <id>] [--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

OVERRIDE FLAGS
  -p, --project-id=<id>  Project ID to deploy media aspect to (overrides CLI configuration)

DESCRIPTION
  Deploy an aspect

EXAMPLES
  Deploy the aspect named "someAspect"

    $ sanity media deploy-aspect someAspect

  Deploy all aspects

    $ sanity media deploy-aspect --all
```

## `sanity media export [DESTINATION]`

Export file and image assets from a media library (excludes video)

```
USAGE
  $ sanity media export [DESTINATION] [-p <id>] [--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

OVERRIDE FLAGS
  -p, --project-id=<id>  Project ID to export media from (overrides CLI configuration)

DESCRIPTION
  Export file and image assets from a media library (excludes video)

EXAMPLES
  Export media library interactively

    $ sanity media export

  Export media library to output.tar.gz

    $ sanity media export output.tar.gz

  Export specific media library

    $ sanity media export --media-library-id my-library-id
```

## `sanity media import SOURCE`

Import a set of assets to the target media library.

```
USAGE
  $ sanity media import SOURCE [-p <id>] [--aspect <key=value>...] [--filename <filename>] [--media-library-id
    <value>] [--replace-aspects]

ARGUMENTS
  SOURCE  Directory, archive, or asset URL to import from. An https URL imports one asset that Sanity fetches itself

FLAGS
  --aspect=<key=value>...     Aspect value to set on the imported asset, as key=value. Repeatable. Only applies when the
                              source is a URL - directory and archive imports read aspects from their data.ndjson
  --filename=<filename>       Original filename to store on the asset. Only applies when the source is a URL. Defaults
                              to a name derived from the URL
  --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). Only applies to directory and archive imports

OVERRIDE FLAGS
  -p, --project-id=<id>  Project ID to import media to (overrides CLI configuration)

DESCRIPTION
  Import a set of assets to the target media library.

EXAMPLES
  Import all assets from the "products" directory

    $ sanity media import products

  Import all assets from "gallery" archive

    $ sanity media import gallery.tar.gz

  Import all assets from the "products" directory and replace aspects

    $ sanity media import products --replace-aspects

  Have Sanity fetch a single asset from a public URL

    $ sanity media import https://example.com/hero.png

  Fetch an asset from a URL and set aspect data on it

    $ sanity media import https://example.com/hero.png --aspect department=Brand
```

## `sanity migrations create [TITLE]`

Create a new migration within your project

```
USAGE
  $ sanity migrations 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

    $ sanity migrations create

  Create a new migration with the provided title, prompting for options

    $ sanity migrations create "Rename field from location to address"
```

## `sanity migrations list`

List available migrations

```
USAGE
  $ sanity migrations list

DESCRIPTION
  List available migrations

EXAMPLES
  List all available migrations in the project

    $ sanity migrations list
```

## `sanity migrations run [ID]`

Run a migration against a dataset

```
USAGE
  $ sanity migrations 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

    $ sanity migrations run <id>

  execute the migration against a dataset

    $ sanity migrations run <id> --no-dry-run --project xyz --dataset staging

  execute the migration using a dataset export as the source

    $ sanity migrations run <id> --from-export=production.tar.gz --no-dry-run --project xyz --dataset staging
```

## `sanity new [PROJECTNAME]`

Create a Sanity project without an account, and claim it within 72 hours to keep it.

```
USAGE
  $ sanity new [PROJECTNAME] [--json] [--instructions] [--scaffold] [-y]

ARGUMENTS
  [PROJECTNAME]  Display name for the new project

FLAGS
  -y, --yes            Skip prompts and use defaults (project: "My Sanity project")
      --instructions   Print the full setup guide from https://sanity.new and exit, creating nothing
      --[no-]scaffold  Set up a Studio in ./sanity and a Next.js website in ./web (on by default)

GLOBAL FLAGS
  --json  Format output as json.

DESCRIPTION
  Create a Sanity project without an account, and claim it within 72 hours to keep it.

  Sets up two folders here: ./sanity, a Studio where you write and edit your
  content, and ./web, a Next.js website that reads it. Both are already
  connected to your new project, so you can start them straight away. Use
  --no-scaffold if you just want the project and nothing else.

  The project is real and works immediately, but it is only yours for 72 hours.
  Claim it with a Sanity account before the deadline and everything you have
  built stays exactly as it is. Claiming is free and takes about a minute. Miss
  the deadline and the project and its content are deleted.

  Two things to keep private: the claim link, because anyone who opens it
  becomes the owner, and the access token saved in ./sanity/.env.local, because
  it can read and change everything in the project. ./web/.env.local has only
  the project ID and dataset. Keep both env files out of git, and never put the
  token in code that runs in the browser.

  Run this command with --instructions for the full agent setup guide.

EXAMPLES
  Create a project with a Studio and a website

    $ sanity new

  Create a project called "My New Project"

    $ sanity new "My New Project"

  Create a project without being asked anything

    $ sanity new --yes

  Create the project only, with no Studio or website

    $ sanity new --no-scaffold

  Create a project and print its details as JSON

    $ sanity new --json

  Print the full setup guide for an AI agent, without creating anything

    $ sanity new --instructions
```

## `sanity openapi get SLUG`

Get an OpenAPI specification by slug

```
USAGE
  $ 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)

    $ sanity openapi get query

  Get specification in JSON format

    $ sanity openapi get query --format=json

  Open specification in browser

    $ sanity openapi get query --web

  Pipe to file

    $ sanity openapi get query > query-api.yaml
```

## `sanity openapi list`

List all available OpenAPI specifications

```
USAGE
  $ 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

    $ sanity openapi list

  List with JSON output

    $ sanity openapi list --json

  Open HTTP Reference in browser

    $ sanity openapi list --web
```

## `sanity organizations create`

Create a new organization

```
USAGE
  $ sanity organizations create [--default-role <value>] [--name <value>]

FLAGS
  --default-role=<value>  Default role assigned to new members
  --name=<value>          Organization name

DESCRIPTION
  Create a new organization

EXAMPLES
  Interactively create an organization

    $ sanity organizations create

  Create an organization named "Acme Corp"

    $ sanity organizations create --name "Acme Corp"

  Create an organization with a default member role

    $ sanity organizations create --name "Acme Corp" --default-role member
```

## `sanity organizations delete ORGANIZATIONID`

Delete an organization

```
USAGE
  $ sanity organizations delete ORGANIZATIONID [--force]

ARGUMENTS
  ORGANIZATIONID  Organization ID to delete

FLAGS
  --force  Do not prompt for delete confirmation - forcefully delete

DESCRIPTION
  Delete an organization

EXAMPLES
  Delete an organization (prompts for confirmation)

    $ sanity organizations delete org-abc123

  Delete an organization without confirmation

    $ sanity organizations delete org-abc123 --force
```

## `sanity organizations get ORGANIZATIONID`

Get details of an organization

```
USAGE
  $ sanity organizations get ORGANIZATIONID

ARGUMENTS
  ORGANIZATIONID  Organization ID

DESCRIPTION
  Get details of an organization

EXAMPLES
  Get details of a specific organization

    $ sanity organizations get org-abc123
```

## `sanity organizations list`

List organizations you are a member of

```
USAGE
  $ sanity organizations list

DESCRIPTION
  List organizations you are a member of

EXAMPLES
  List all your organizations

    $ sanity organizations list
```

## `sanity organizations update ORGANIZATIONID`

Update an organization

```
USAGE
  $ sanity organizations update ORGANIZATIONID [--default-role <value>] [--name <value>] [--slug <value>]

ARGUMENTS
  ORGANIZATIONID  Organization ID

FLAGS
  --default-role=<value>  New default role for new members
  --name=<value>          New organization name
  --slug=<value>          New URL slug (requires authSAML feature on the organization)

DESCRIPTION
  Update an organization

EXAMPLES
  Rename an organization

    $ sanity organizations update org-abc123 --name "New Name"

  Set the organization slug (requires authSAML feature)

    $ sanity organizations update org-abc123 --slug new-slug

  Change the default member role

    $ sanity organizations update org-abc123 --default-role viewer
```

## `sanity preview [OUTPUTDIR]`

Start a local server to preview a production build

```
USAGE
  $ sanity preview [OUTPUTDIR] [--host <value>] [--port <value>]

ARGUMENTS
  [OUTPUTDIR]  Output directory

FLAGS
  --host=<value>  Local network interface to listen on (default: localhost)
  --port=<value>  TCP port to start server on (default: 3333)

DESCRIPTION
  Start a local server to preview a production build

EXAMPLES
  $ sanity preview --host=0.0.0.0

  $ sanity preview --port=1942

  $ sanity preview some/build-output-dir
```

## `sanity projects create [PROJECTNAME]`

Create a new Sanity project

```
USAGE
  $ 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

    $ sanity projects create

  Create a project named "My New Project"

    $ sanity projects create "My New Project"

  Create a project in a specific organization

    $ sanity projects create "My Project" --organization=my-org

  Create a project with a private dataset named "staging"

    $ sanity projects create "My Project" --dataset=staging --dataset-visibility=private

  Create a project non-interactively with JSON output

    $ sanity projects create "CI Project" --yes --json
```

## `sanity projects list`

List your projects

```
USAGE
  $ sanity projects list [--order asc|desc] [--sort id|members|name|url|created]

FLAGS
  --order=<option>  [default: desc] Sort direction
                    <options: asc|desc>
  --sort=<option>   [default: created] Sort field
                    <options: id|members|name|url|created>

DESCRIPTION
  List your projects

EXAMPLES
  List projects

    $ sanity projects list

  List projects sorted by member count, ascending

    $ sanity projects list --sort=members --order=asc
```

## `sanity projects unclaimed`

Recover details for unclaimed projects created on this machine

```
USAGE
  $ sanity projects unclaimed [--project-id <value>]

FLAGS
  --project-id=<value>  Project ID to recover

DESCRIPTION
  Recover details for unclaimed projects created on this machine

EXAMPLES
  List locally recorded unclaimed projects

    $ sanity projects unclaimed

  Show recovery details for one project

    $ sanity projects unclaimed --project-id abc123
```

## `sanity schemas delete`

Delete schema documents by id

```
USAGE
  $ sanity schemas delete --ids <value> [-p <id>] [-d <name>] [--verbose] [-y]

FLAGS
  -d, --dataset=<name>  Delete schemas from a specific dataset
  -y, --yes             Delete schemas without prompting for confirmation
      --ids=<value>     (required) Comma-separated list of schema ids to delete
      --verbose         Enable verbose logging

OVERRIDE FLAGS
  -p, --project-id=<id>  Project ID to delete schema from (overrides CLI configuration)

DESCRIPTION
  Delete schema documents by id

EXAMPLES
  Delete a single schema

    $ sanity schemas delete --ids sanity.workspace.schema.workspaceName

  Delete multiple schemas

    $ sanity schemas delete --ids \
      sanity.workspace.schema.workspaceName,prefix.sanity.workspace.schema.otherWorkspace
```

## `sanity schemas deploy`

Deploy schema documents into workspace datasets.

```
USAGE
  $ sanity schemas deploy [--extract-manifest] [--manifest-dir <directory>] [--tag <tag>] [--verbose] [--workspace
    <name>]

FLAGS
  --[no-]extract-manifest     Regenerate manifest before deploying (use --no-extract-manifest to skip)
  --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.

  Regenerates a manifest file by default. To re-use an existing manifest, use --no-extract-manifest.

EXAMPLES
  Deploy all workspace schemas

    $ sanity schemas deploy

  Deploy the schema for only the workspace "default"

    $ sanity schemas deploy --workspace default
```

## `sanity schemas extract`

Extract a JSON representation of a Sanity schema within a Studio context.

```
USAGE
  $ sanity schemas extract [--enforce-required-fields] [--force] [--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
  --force                     Overwrite an existing schema file
  --format=<format>           [default: groq-type-nodes] Output format (currently only groq-type-nodes)
  --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
  Extract 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

    $ sanity schemas extract --workspace default

  Watch mode - re-extract on changes

    $ sanity schemas extract --watch

  Watch with custom glob patterns

    $ sanity schemas extract --watch --watch-patterns "lib/**/*.ts"
```

## `sanity schemas list`

List all schemas in the current dataset.

```
USAGE
  $ sanity schemas list [--id <schema_id>] [--json]

FLAGS
  --id=<schema_id>  Fetch a single schema by id
  --json            Get schema as json

DESCRIPTION
  List all schemas in the current dataset.

  Note: This command is experimental and subject to change.

  Regenerates a manifest file by default. To reuse an existing manifest, use --no-extract-manifest.

EXAMPLES
  List all schemas found in any workspace dataset in a table

    $ sanity schemas list

  Get a schema for a given id

    $ sanity schemas list --id _.schemas.workspaceName

  Get stored schemas as pretty-printed json-array

    $ sanity schemas list --json

  Get singular stored schema as pretty-printed json-object

    $ sanity schemas list --json --id _.schemas.workspaceName
```

## `sanity schemas validate`

Validates all schema types specified in a workspace

```
USAGE
  $ sanity schemas 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

    $ sanity schemas validate --workspace default

  Save the results of the report into a file

    $ sanity schemas validate > report.txt

  Report out only errors

    $ sanity schemas validate --level error

  Generate a report which can be analyzed with https://esbuild.github.io/analyze/

    $ sanity schemas validate --debug-metafile-path metafile.json
```

## `sanity skills install`

Install Sanity agent skills for detected AI editors (Antigravity, Claude Code, Cline, Cline CLI, Codex CLI, Cursor, Gemini CLI, GitHub Copilot CLI, OpenCode, VS Code, VS Code Insiders)

```
USAGE
  $ sanity skills install

DESCRIPTION
  Install Sanity agent skills for detected AI editors (Antigravity, Claude Code, Cline, Cline CLI, Codex CLI, Cursor,
  Gemini CLI, GitHub Copilot CLI, OpenCode, VS Code, VS Code Insiders)

EXAMPLES
  Install Sanity agent skills for detected AI editors

    $ sanity skills install
```

## `sanity telemetry disable`

Disable telemetry for your account

```
USAGE
  $ sanity telemetry disable

DESCRIPTION
  Disable telemetry for your account

EXAMPLES
  Disable telemetry for your account

    $ sanity telemetry telemetry disable
```

## `sanity telemetry enable`

Enable telemetry for your account

```
USAGE
  $ sanity telemetry enable

DESCRIPTION
  Enable telemetry for your account

EXAMPLES
  Enable telemetry for your account

    $ sanity telemetry telemetry enable
```

## `sanity telemetry status`

Check telemetry status for your account

```
USAGE
  $ sanity telemetry status

DESCRIPTION
  Check telemetry status for your account

EXAMPLES
  Check telemetry status for your account

    $ sanity telemetry telemetry status
```

## `sanity tokens create [LABEL]`

Create a new API token for the project

```
USAGE
  $ sanity tokens create [LABEL] [-p <id>] [--expires-at 2027-01-01] [--json] [--role viewer] [-y]

ARGUMENTS
  [LABEL]  Label for the new token

FLAGS
  -y, --yes                    Skip prompts and use defaults (unattended mode)
      --expires-at=2027-01-01  Date or timestamp the token expires (ISO 8601; tokens never expire by default)
      --json                   Output as JSON
      --role=viewer            Role to assign to the token (defaults to viewer in unattended mode)

OVERRIDE FLAGS
  -p, --project-id=<id>  Project ID to create token in (overrides CLI configuration)

DESCRIPTION
  Create a new API token for the project

EXAMPLES
  Create a token with a label

    $ sanity tokens create "My API Token"

  Create a token with editor role

    $ sanity tokens create "My API Token" --role=editor

  Create a token in unattended mode

    $ sanity tokens create "CI Token" --role=editor --yes

  Create a token that expires on a given date

    $ sanity tokens create "Build Token" --expires-at 2027-01-01

  Output token information as JSON

    $ sanity tokens create "API Token" --json

  Create a token for a specific project

    $ sanity tokens create "My Token" --project-id abc123 --role=editor
```

## `sanity tokens delete [TOKENID]`

Delete an API token from the project

```
USAGE
  $ sanity tokens delete [TOKENID] [-p <id>] [-y]

ARGUMENTS
  [TOKENID]  Token ID to delete (will prompt if not provided)

FLAGS
  -y, --yes  Skip confirmation prompt (unattended mode)

OVERRIDE FLAGS
  -p, --project-id=<id>  Project ID to delete token from (overrides CLI configuration)

DESCRIPTION
  Delete an API token from the project

EXAMPLES
  Interactively select and delete a token

    $ sanity tokens delete

  Delete a specific token by ID

    $ sanity tokens delete silJ2lFmK6dONB

  Delete a specific token without confirmation prompt

    $ sanity tokens delete silJ2lFmK6dONB --yes

  Delete a token from a specific project

    $ sanity tokens delete --project-id abc123
```

## `sanity tokens list`

List API tokens for the project

```
USAGE
  $ sanity tokens list [-p <id>] [--json]

FLAGS
  --json  Output tokens in JSON format

OVERRIDE FLAGS
  -p, --project-id=<id>  Project ID to list tokens for (overrides CLI configuration)

DESCRIPTION
  List API tokens for the project

EXAMPLES
  List tokens for the project

    $ sanity tokens list

  List tokens in JSON format

    $ sanity tokens list --json

  List tokens for a specific project

    $ sanity tokens list --project-id abc123
```

## `sanity tokens rotate`

Rotate an API token, replacing its secret with a new one

```
USAGE
  $ sanity tokens rotate [--json] [-t <token>]

FLAGS
  -t, --token=<token>  Token to rotate (prefer standard input to keep it out of shell history)
      --json           Output as JSON

DESCRIPTION
  Rotate an API token, replacing its secret with a new one

EXAMPLES
  Rotate the token piped on standard input

    echo "$SANITY_TOKEN" | sanity tokens rotate

  Rotate a token read from a file

    $ sanity tokens rotate < token.txt

  Output the rotated token as JSON

    echo "$SANITY_TOKEN" | sanity tokens rotate --json
```

## `sanity typegen generate`

Sanity TypeGen

```
USAGE
  $ 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.

    $ sanity typegen generate
```

## `sanity undeploy [APPID]`

Removes the deployed Sanity Studio/App from Sanity hosting

```
USAGE
  $ sanity undeploy [APPID] [--dry-run] [-j] [-y]

ARGUMENTS
  [APPID]  ID of the application to undeploy. Overrides `deployment.appId` in sanity.cli.ts

FLAGS
  -j, --json     Output the result as JSON
  -y, --yes      Unattended mode, answers "yes" to any "yes/no" prompt and otherwise uses defaults
      --dry-run  Report what would be undeployed without deleting anything

DESCRIPTION
  Removes the deployed Sanity Studio/App from Sanity hosting

EXAMPLES
  Undeploy the studio or application after confirming

    $ sanity undeploy

  Undeploy the studio or application with the given ID

    $ sanity undeploy abc123

  Report what would be undeployed without deleting anything

    $ sanity undeploy --dry-run

  Undeploy without prompting and report the result as JSON

    $ sanity undeploy --json --yes
```

## `sanity users invite [EMAIL]`

Invite a new user to the project

```
USAGE
  $ sanity users invite [EMAIL] [-p <id>] [--role <value>]

ARGUMENTS
  [EMAIL]  Email address to invite

FLAGS
  --role=<value>  Role to invite the user as

OVERRIDE FLAGS
  -p, --project-id=<id>  Project ID to invite user to (overrides CLI configuration)

DESCRIPTION
  Invite a new user to the project

EXAMPLES
  Invite a new user to the project (prompt for details)

    $ sanity users invite

  Send a new user invite to the email "pippi@sanity.io", prompt for role

    $ sanity users invite pippi@sanity.io

  Send a new user invite to the email "pippi@sanity.io", as administrator

    $ sanity users invite pippi@sanity.io --role administrator

  Invite a user to a specific project

    $ sanity users invite pippi@sanity.io --project-id abc123
```

## `sanity users list`

List project members

```
USAGE
  $ sanity users list [-p <id>] [--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>

OVERRIDE FLAGS
  -p, --project-id=<id>  Project ID to list users for (overrides CLI configuration)

DESCRIPTION
  List project members

EXAMPLES
  List all users of the project

    $ sanity users list

  List all users of the project, but exclude pending invitations and robots

    $ sanity users list --no-invitations --no-robots

  List all users, sorted by role

    $ sanity users list --sort role

  List users for a specific project

    $ sanity users list --project-id abc123
```

## `sanity versions`

Show installed package versions

```
USAGE
  $ sanity versions

DESCRIPTION
  Show installed package versions

EXAMPLES
  $ sanity versions
```

## `sanity workflows abort INSTANCEID`

Abort an in-flight workflow instance — a hard stop: pending effects are cancelled, stage guards removed, and the instance is marked terminal where it stands.

```
USAGE
  $ sanity workflows abort INSTANCEID [--deployment <value> | --tag <value>] [--reason <value>]

ARGUMENTS
  INSTANCEID  Workflow instance id.

FLAGS
  --deployment=<value>  Deployment name — narrow the instance search to the resource that deployment targets; the tag
                        partition still comes from the loaded instance.
  --reason=<value>      Reason for aborting (recorded in history).
  --tag=<value>         Workflow environment tag (e.g. prod, test) — an optional query filter that also narrows which
                        resources are searched; omit to span them all.

DESCRIPTION
  Abort an in-flight workflow instance — a hard stop: pending effects are cancelled, stage guards removed, and the
  instance is marked terminal where it stands.

EXAMPLES
  $ sanity workflows abort wf-instance.abc123

  $ sanity workflows abort wf-instance.abc123 --reason 'superseded by relaunch'
```

## `sanity workflows definition delete NAME`

Delete a deployed workflow definition (every version, or one via --version). Refuses while non-terminal instances exist unless --cascade aborts them first — instances are aborted in place, never deleted.

```
USAGE
  $ sanity workflows definition delete NAME [--deployment <value> | --tag <value>] [--version <value>] [--cascade] [--reason
    <value>]

ARGUMENTS
  NAME  Workflow definition name.

FLAGS
  --cascade             Abort every non-terminal instance pinned to the targeted versions, then delete.
  --deployment=<value>  Deployment name — the unique identity of one deployment in the config.
  --reason=<value>      Free-text reason — recorded on each cascade-abort history entry.
  --tag=<value>         Workflow environment tag (e.g. prod, test) — selects the deployment to act on while the tag
                        names exactly one; pass --deployment when it spans several.
  --version=<value>     Delete only this deployed version (default: every version).

DESCRIPTION
  Delete a deployed workflow definition (every version, or one via --version). Refuses while non-terminal instances
  exist unless --cascade aborts them first — instances are aborted in place, never deleted.

EXAMPLES
  $ sanity workflows definition delete my-workflow

  $ sanity workflows definition delete my-workflow --version 2

  $ sanity workflows definition delete my-workflow --cascade --reason 'workflow retired'
```

## `sanity workflows definition diff NAME`

Diff an in-code definition against the deployed version (latest by default).

```
USAGE
  $ sanity workflows definition diff NAME [--deployment <value> | --tag <value>] [--version <value>]

ARGUMENTS
  NAME  Workflow definition name.

FLAGS
  --deployment=<value>  Deployment name — the unique identity of one deployment in the config.
  --tag=<value>         Workflow environment tag (e.g. prod, test) — selects the deployment to act on while the tag
                        names exactly one; pass --deployment when it spans several.
  --version=<value>     Deployed version to diff against (default: latest).

DESCRIPTION
  Diff an in-code definition against the deployed version (latest by default).

EXAMPLES
  $ sanity workflows definition diff productLaunch

  $ sanity workflows definition diff productLaunch --version 2
```

## `sanity workflows definition list`

List deployed workflow definitions.

```
USAGE
  $ sanity workflows definition list [--tag <value>] [--limit <value>] [--name <value>] [--json]

FLAGS
  --json           Emit structured JSON instead of rendered output.
  --limit=<value>  [default: 100] The maximum number of definitions to return.
  --name=<value>   Filter to a single workflow definition name (e.g. product-launch).
  --tag=<value>    Workflow environment tag (e.g. prod, test) — an optional query filter that also narrows which
                   resources are searched; omit to span them all.

DESCRIPTION
  List deployed workflow definitions.

EXAMPLES
  $ sanity workflows definition list

  $ sanity workflows definition list --tag prod

  $ sanity workflows definition list --json
```

## `sanity workflows definition show NAME`

Show a deployed workflow definition.

```
USAGE
  $ sanity workflows definition show NAME [--tag <value>] [--version <value>] [--json]

ARGUMENTS
  NAME  Workflow definition name.

FLAGS
  --json             Emit structured JSON instead of rendered output.
  --tag=<value>      Workflow environment tag (e.g. prod, test) — an optional query filter that also narrows which
                     resources are searched; omit to span them all.
  --version=<value>  Specific version (default: latest).

DESCRIPTION
  Show a deployed workflow definition.
```

## `sanity workflows deploy`

Validate, diff, and deploy workflow definitions to the resource bound by the selected deployment.

```
USAGE
  $ sanity workflows deploy [--all-tags |  | [--deployment <value> | --tag <value>]] [--dry-run] [--check] [--only
    <value>] [--share-defs]

FLAGS
  --all-tags            Deploy every deployment in the config, not just a selection.
  --check               Validate definitions only; do not contact the dataset.
  --deployment=<value>  Deployment name — the unique identity of one deployment in the config.
  --dry-run             Validate + diff against the deployed version; do not write.
  --only=<value>        Limit deploy/check/diff to a single workflow definition by name (deployments are selected with
                        --deployment). Every targeted deployment must contain it.
  --[no-]share-defs     Share the definition documents newly created by this deploy with Sanity — the full document,
                        verbatim (structure, names, filters, effect configuration, seeded values), plus its deployment
                        coordinates (project and dataset, or resource id); never content documents, instances, or your
                        Sanity auth token. Sharing is the default in every environment, including CI / non-TTY /
                        DO_NOT_TRACK. Use --no-share-defs to opt out.
  --tag=<value>         Workflow environment tag (e.g. prod, test) — deploys every deployment carrying the tag (a tag is
                        an environment group).

DESCRIPTION
  Validate, diff, and deploy workflow definitions to the resource bound by the selected deployment.

EXAMPLES
  $ sanity workflows deploy --deployment review-prod

  $ sanity workflows deploy --tag prod

  $ sanity workflows deploy --all-tags

  $ sanity workflows deploy --check

  $ sanity workflows deploy --dry-run

  $ sanity workflows deploy --only productLaunch
```

## `sanity workflows diagnose INSTANCEID`

Explain why a workflow instance is or isn't progressing, and what would unstick it.

```
USAGE
  $ sanity workflows diagnose INSTANCEID [--deployment <value> | --tag <value>] [--json]

ARGUMENTS
  INSTANCEID  Workflow instance id.

FLAGS
  --deployment=<value>  Deployment name — narrow the instance search to the resource that deployment targets; the tag
                        partition still comes from the loaded instance.
  --json                Emit structured JSON instead of rendered output.
  --tag=<value>         Workflow environment tag (e.g. prod, test) — an optional query filter that also narrows which
                        resources are searched; omit to span them all.

DESCRIPTION
  Explain why a workflow instance is or isn't progressing, and what would unstick it.

EXAMPLES
  $ sanity workflows diagnose wf-instance.abc123

  $ sanity workflows diagnose wf-instance.abc123 --tag prod

  $ sanity workflows diagnose wf-instance.abc123 --json
```

## `sanity workflows fire-action INSTANCEID`

Fire an action on an instance to unstick a waiting activity — the write acts as the configured token. Omit --action to list what can be fired.

```
USAGE
  $ sanity workflows fire-action INSTANCEID [--deployment <value> | --tag <value>] [--activity <value>] [--action <value>]
    [--param <value>...] [--json]

ARGUMENTS
  INSTANCEID  Workflow instance id.

FLAGS
  --action=<value>      Action to fire. Omit to list the actions available on the instance.
  --activity=<value>    Activity the action belongs to. Required to fire; omit --action to list.
  --deployment=<value>  Deployment name — narrow the instance search to the resource that deployment targets; the tag
                        partition still comes from the loaded instance.
  --json                Emit structured JSON instead of rendered output.
  --param=<value>...    [default: ] Action param as key=value (repeatable). Values are JSON-parsed, falling back to a
                        string.
  --tag=<value>         Workflow environment tag (e.g. prod, test) — an optional query filter that also narrows which
                        resources are searched; omit to span them all.

DESCRIPTION
  Fire an action on an instance to unstick a waiting activity — the write acts as the configured token. Omit --action to
  list what can be fired.

EXAMPLES
  $ sanity workflows fire-action wf-instance.abc123

  $ sanity workflows fire-action wf-instance.abc123 --activity approve --action approve

  $ sanity workflows fire-action wf-instance.abc123 --activity publish --action publish --param note=shipping
```

## `sanity workflows list`

List workflow instances in the configured dataset (in-flight by default).

```
USAGE
  $ sanity workflows list [--tag <value>] [--include-completed] [--failed] [--definition <value>] [--document
    <value>] [--assignment-user <value>] [--assignment-role <value>...] [--assignment-state unrouted|routed|held...]
    [--limit <value>] [--json]

FLAGS
  --assignment-role=<value>...    A literal project role held by --assignment-user. Repeat for multiple roles.
  --assignment-state=<option>...  Assignment state to include: unrouted, routed (offered through a supplied role), or
                                  held. Repeat for multiple states.
                                  <options: unrouted|routed|held>
  --assignment-user=<value>       Account-global user id used for viewer-scoped assignment filtering and counts.
  --definition=<value>            Only instances of this workflow definition (its `name`; the instance's `definition`
                                  field).
  --document=<value>              Only instances that reference this document (resource-qualified GDR URI, e.g.
                                  "dataset:proj:ds:article-1").
  --failed                        Only instances with at least one failed activity.
  --include-completed             Include completed/aborted instances (default: in-flight only).
  --json                          Emit structured JSON instead of rendered output.
  --limit=<value>                 [default: 50] Maximum rows to return.
  --tag=<value>                   Workflow environment tag (e.g. prod, test) — an optional query filter that also
                                  narrows which resources are searched; omit to span them all.

DESCRIPTION
  List workflow instances in the configured dataset (in-flight by default).

EXAMPLES
  $ sanity workflows list

  $ sanity workflows list --include-completed

  $ sanity workflows list --definition productLaunch

  $ sanity workflows list --document dataset:proj:ds:article-1

  $ sanity workflows list --assignment-user gAda --assignment-role legal --assignment-state routed

  $ sanity workflows list --tag prod

  $ sanity workflows list --json
```

## `sanity workflows nuke`

Delete engine-owned documents — a whole deployment tag, or a single instance.

```
USAGE
  $ sanity workflows nuke [--deployment <value>] [--tag <value>] [--instance <value>] [--force]

FLAGS
  --deployment=<value>  The deployment name to reset. With --instance, narrows which deployment the instance is looked
                        up in when its tag spans several.
  --force               Skip the confirmation prompt (for scripts/CI). The plan still prints.
  --instance=<value>    Delete a single terminal instance by id, plus its guard docs, instead of a tag.
  --tag=<value>         The deployment tag to reset (while it names exactly one deployment). Not valid with --instance,
                        which reads its tag from the instance id.

DESCRIPTION
  Delete engine-owned documents — a whole deployment tag, or a single instance.

  The reset for a dataset holding engine documents the versioned upgrade framework cannot yet migrate: deletes the tag's
  instances, definitions, and guards (across every alias-bound resource). --instance <id> instead deletes one terminal
  instance plus its guards. Content documents are never touched. Prints a dry-run plan, then confirms (--force skips the
  prompt; the plan still prints).

EXAMPLES
  $ sanity workflows nuke --deployment plugin-dev

  $ sanity workflows nuke --tag plugin-dev --force

  $ sanity workflows nuke --instance plugin-dev.wf-instance.abc123
```

## `sanity workflows reset-activity INSTANCEID ACTIVITY`

Reset a failed activity on an in-flight instance — back to active to re-run it, or --skip to bypass it (mark it skipped) so a gated exit transition can fire.

```
USAGE
  $ sanity workflows reset-activity INSTANCEID ACTIVITY [--deployment <value> | --tag <value>] [--skip]

ARGUMENTS
  INSTANCEID  Workflow instance id.
  ACTIVITY    Activity name within the current stage.

FLAGS
  --deployment=<value>  Deployment name — narrow the instance search to the resource that deployment targets; the tag
                        partition still comes from the loaded instance.
  --skip                Bypass the activity (mark it skipped) instead of re-running it (back to active).
  --tag=<value>         Workflow environment tag (e.g. prod, test) — an optional query filter that also narrows which
                        resources are searched; omit to span them all.

DESCRIPTION
  Reset a failed activity on an in-flight instance — back to active to re-run it, or --skip to bypass it (mark it
  skipped) so a gated exit transition can fire.

EXAMPLES
  $ sanity workflows reset-activity wf-instance.abc123 legal-review

  $ sanity workflows reset-activity wf-instance.abc123 legal-review --skip
```

## `sanity workflows set-stage INSTANCEID`

Force an instance into a stage, regardless of its declared transitions and filters — the engine's setStage admin override. The target stage's enter lifecycle still runs (auto-activities start, stage guards reconcile), and the post-move cascade can immediately auto-transition the instance onward.

```
USAGE
  $ sanity workflows set-stage INSTANCEID [--deployment <value> | --tag <value>] [--to <value>] [--reason <value>]

ARGUMENTS
  INSTANCEID  Workflow instance id to move.

FLAGS
  --deployment=<value>  Deployment name — narrow the instance search to the resource that deployment targets; the tag
                        partition still comes from the loaded instance.
  --reason=<value>      Free-text reason — recorded on the history entry for audit.
  --tag=<value>         Workflow environment tag (e.g. prod, test) — an optional query filter that also narrows which
                        resources are searched; omit to span them all.
  --to=<value>          Target stage name. Omit on an interactive terminal to pick from the workflow’s stages.

DESCRIPTION
  Force an instance into a stage, regardless of its declared transitions and filters — the engine's setStage admin
  override. The target stage's enter lifecycle still runs (auto-activities start, stage guards reconcile), and the
  post-move cascade can immediately auto-transition the instance onward.

EXAMPLES
  $ sanity workflows set-stage wf-instance.abc123 --to ready

  $ sanity workflows set-stage wf-instance.abc123

  $ sanity workflows set-stage wf-instance.abc123 --to ready --reason 'unblock for demo'
```

## `sanity workflows show INSTANCEID`

Show the state, activities, and effects of a workflow instance.

```
USAGE
  $ sanity workflows show INSTANCEID [--tag <value>] [--include history...] [--json]

ARGUMENTS
  INSTANCEID  Workflow instance document id.

FLAGS
  --include=<option>...  [default: ] Optional sections to include in rendered output (--json always carries the full
                         document).
                         <options: history>
  --json                 Emit structured JSON instead of rendered output.
  --tag=<value>          Workflow environment tag (e.g. prod, test) — an optional query filter that also narrows which
                         resources are searched; omit to span them all.

DESCRIPTION
  Show the state, activities, and effects of a workflow instance.

EXAMPLES
  $ sanity workflows show wf-instance.abc123

  $ sanity workflows show wf-instance.abc123 --include history

  $ sanity workflows show wf-instance.abc123 --json
```

## `sanity workflows start NAME`

Start a workflow instance from a deployed definition. Supply values for the workflow's input-sourced fields with --field (e.g. the subject document ref).

```
USAGE
  $ sanity workflows start NAME [--deployment <value> | --tag <value>] [--version <value>] [--field <value>...]
    [--instance-id <value>] [--json]

ARGUMENTS
  NAME  Workflow definition name.

FLAGS
  --deployment=<value>   Deployment name — the unique identity of one deployment in the config.
  --field=<value>...     [default: ] Initial value for a declared input-sourced field, as name=value (repeatable).
                         Values are JSON-parsed, falling back to a string; ref kinds take a JSON object with a GDR `id`
                         and doc `type`.
  --instance-id=<value>  Start under this instance id — for retries. The id is the start's idempotency key: pass the id
                         of a start that failed partway and the engine resumes it instead of creating a duplicate (an
                         already-settled start replays as a no-op). Omit to mint a fresh id.
  --json                 Emit structured JSON instead of rendered output.
  --tag=<value>          Workflow environment tag (e.g. prod, test) — selects the deployment to act on while the tag
                         names exactly one; pass --deployment when it spans several.
  --version=<value>      Definition version to start from (default: highest deployed).

DESCRIPTION
  Start a workflow instance from a deployed definition. Supply values for the workflow's input-sourced fields with
  --field (e.g. the subject document ref).

EXAMPLES
  $ sanity workflows start productLaunch

  $ sanity workflows start article-review --field subject='{"id":"dataset:proj:ds:article-1","type":"article"}'

  $ sanity workflows start productLaunch --version 2 --tag prod

  $ sanity workflows start productLaunch --instance-id prod.wf-instance.a1b2c3d4e5f6
```

## `sanity workflows tail INSTANCEID`

Stream new history entries on a workflow instance as they land in the dataset.

```
USAGE
  $ sanity workflows tail INSTANCEID [--tag <value>]

ARGUMENTS
  INSTANCEID  Workflow instance id to tail.

FLAGS
  --tag=<value>  Workflow environment tag (e.g. prod, test) — an optional query filter that also narrows which resources
                 are searched; omit to span them all.

DESCRIPTION
  Stream new history entries on a workflow instance as they land in the dataset.

EXAMPLES
  $ sanity workflows tail wf-instance.abc123
```

<!-- commandsstop -->
