CLI reference
Dataset CLI command reference
Interact with datasets in your project
npx sanity dataset --help
pnpm dlx sanity dataset --help
yarn dlx sanity dataset --help
bunx sanity dataset --help
Commands
alias
create
USAGE
$ sanity dataset alias create [ALIASNAME] [TARGETDATASET]
ARGUMENTS
[ALIASNAME] Dataset alias name to create
[TARGETDATASET] Target dataset name to link the alias to
FLAGS
-p, --project-id=<PROJECT-ID> Project ID to create dataset alias in (overrides CLI configuration)
DESCRIPTION
Create a dataset alias within your project
EXAMPLES
Create alias in a specific project
sanity dataset alias create --project-id abc123 conference conf-2025
Create an alias with interactive prompts
sanity dataset alias create
Create alias named "conference" with interactive dataset selection
sanity dataset alias create conference
Create alias "conference" linked to "conf-2025" dataset
sanity dataset alias create conference conf-2025
Create alias with explicit ~ prefix
sanity dataset alias create ~conference conf-2025delete
USAGE
$ sanity dataset alias delete ALIASNAME
ARGUMENTS
ALIASNAME Dataset alias name to delete
FLAGS
-p, --project-id=<PROJECT-ID> Project ID to delete dataset alias from (overrides CLI configuration)
--force Skip confirmation prompt and delete immediately
DESCRIPTION
Delete a dataset alias within your project
EXAMPLES
Delete alias named "conference" with confirmation prompt
sanity dataset alias delete conference
Delete alias with explicit ~ prefix
sanity dataset alias delete ~conference
Delete alias named "conference" without confirmation prompt
sanity dataset alias delete conference --forcelink
USAGE
$ sanity dataset alias link [ALIASNAME] [TARGETDATASET]
ARGUMENTS
[ALIASNAME] Dataset alias name to link
[TARGETDATASET] Target dataset name to link the alias to
FLAGS
-p, --project-id=<PROJECT-ID> Project ID to link dataset alias in (overrides CLI configuration)
--force Skip confirmation prompt when relinking existing alias
DESCRIPTION
Link a dataset alias to a dataset within your project
EXAMPLES
Link an alias with interactive prompts
sanity dataset alias link
Link alias named "conference" with interactive dataset selection
sanity dataset alias link conference
Link alias "conference" to "conf-2025" dataset
sanity dataset alias link conference conf-2025
Link alias with explicit ~ prefix
sanity dataset alias link ~conference conf-2025
Force link without confirmation (skip relink prompt)
sanity dataset alias link conference conf-2025 --forceunlink
USAGE
$ sanity dataset alias unlink [ALIASNAME]
ARGUMENTS
[ALIASNAME] Dataset alias name to unlink
FLAGS
-p, --project-id=<PROJECT-ID> Project ID to unlink dataset alias in (overrides CLI configuration)
--force Skip confirmation prompt and unlink immediately
DESCRIPTION
Unlink a dataset alias from its dataset within your project
EXAMPLES
Unlink an alias with interactive selection
sanity dataset alias unlink
Unlink alias "conference" with confirmation prompt
sanity dataset alias unlink conference
Unlink alias with explicit ~ prefix
sanity dataset alias unlink ~conference
Unlink alias "conference" without confirmation prompt
sanity dataset alias unlink conference --forcecopy
USAGE
$ sanity dataset copy [SOURCE] [TARGET]
ARGUMENTS
[SOURCE] Name of the dataset to copy from
[TARGET] Name of the dataset to copy to
FLAGS
-p, --project-id=<PROJECT-ID> Project ID to copy dataset in (overrides CLI configuration)
--attach=<ATTACH> Attach to the running copy process to show progress
--detach Start the copy without waiting for it to finish
--limit=<LIMIT> Maximum number of jobs returned (default 10, max 1000)
--list Lists all dataset copy jobs
--offset=<OFFSET> Start position in the list of jobs (default 0)
--skip-history Don't preserve document history on copy
DESCRIPTION
Manages dataset copying, including starting a new copy job, listing copy jobs and following the progress of a running copy job
EXAMPLES
Interactively copy a dataset
sanity dataset copy
Copy from source-dataset (prompts for target)
sanity dataset copy source-dataset
Copy from source-dataset to target-dataset
sanity dataset copy source-dataset target-dataset
Copy without preserving document history (faster for large datasets)
sanity dataset copy --skip-history source target
Start copy job without waiting for completion
sanity dataset copy --detach source target
Attach to a running copy job to follow progress
sanity dataset copy --attach <job-id>
List all dataset copy jobs
sanity dataset copy --list
List copy jobs with pagination
sanity dataset copy --list --offset 2 --limit 10create
USAGE
$ sanity dataset create [NAME]
ARGUMENTS
[NAME] Name of the dataset to create
FLAGS
-p, --project-id=<PROJECT-ID> Project ID to create dataset in (overrides CLI configuration)
--embeddings Enable embeddings for this dataset
--embeddings-projection=<EMBEDDINGS-PROJECTION>GROQ projection for embeddings indexing (e.g. "{ title, body }")
--visibility=<VISIBILITY> Set visibility for this dataset (custom/private/public)
DESCRIPTION
Create a new dataset within your project
EXAMPLES
Interactively create a dataset
sanity dataset create
Create a dataset named "my-dataset"
sanity dataset create my-dataset
Create a private dataset named "my-dataset"
sanity dataset create my-dataset --visibility privatedelete
USAGE
$ sanity dataset delete DATASETNAME
ARGUMENTS
DATASETNAME Dataset name to delete
FLAGS
-p, --project-id=<PROJECT-ID> Project ID to delete dataset from (overrides CLI configuration)
--force Do not prompt for delete confirmation - forcefully delete
DESCRIPTION
Delete a dataset within your project
EXAMPLES
Delete a specific dataset
sanity dataset delete my-dataset
Delete a specific dataset without confirmation
sanity dataset delete my-dataset --forceembeddings
disable
USAGE
$ sanity dataset embeddings disable [DATASET]
ARGUMENTS
[DATASET] Dataset name to disable embeddings for
FLAGS
-p, --project-id=<PROJECT-ID> Project ID to disable embeddings for (overrides CLI configuration)
DESCRIPTION
Disable embeddings for a dataset
EXAMPLES
Disable embeddings for the production dataset
sanity dataset embeddings disable productionenable
USAGE
$ sanity dataset embeddings enable [DATASET]
ARGUMENTS
[DATASET] Dataset name to enable embeddings for
FLAGS
-p, --project-id=<PROJECT-ID> Project ID to enable embeddings for (overrides CLI configuration)
--projection=<PROJECTION> GROQ projection defining which fields to embed (e.g. "{ title, body }")
--wait Wait for embeddings processing to complete before returning
DESCRIPTION
Enable embeddings for a dataset
EXAMPLES
Enable embeddings for the production dataset
sanity dataset embeddings enable production
Enable embeddings with a specific projection
sanity dataset embeddings enable production --projection "{ title, body }"
Enable embeddings and wait for processing to complete
sanity dataset embeddings enable production --waitstatus
USAGE
$ sanity dataset embeddings status [DATASET]
ARGUMENTS
[DATASET] The name of the dataset to check embeddings status for
FLAGS
-p, --project-id=<PROJECT-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 dataset embeddings status productionexport
USAGE
$ sanity dataset export [NAME] [DESTINATION]
ARGUMENTS
[NAME] Name of the dataset to export
[DESTINATION] Output destination file path
FLAGS
-p, --project-id=<PROJECT-ID> Project ID to export dataset from (overrides CLI configuration)
--asset-concurrency=<ASSET-CONCURRENCY>Concurrent number of asset downloads
--mode=<MODE> Mode to export documents with `cursor` might be more performant for larger datasets, but might not be as accurate if the dataset is being modified during export
--no-assets Export only non-asset documents and remove references to image assets
--no-compress Skips compressing tarball entries (still generates a gzip file)
--no-drafts Export only published versions of documents
--overwrite Overwrite any file with the same name
--raw Extract only documents, without rewriting asset references
--types=<TYPES> Defines which document types to export (comma-separated)
DESCRIPTION
Export dataset to local filesystem as a gzipped tarball. Assets failing with HTTP status codes 401, 403 and 404 upon download are ignored and excluded from export.
EXAMPLES
Export dataset "moviedb" to localPath.tar.gz
sanity dataset export moviedb localPath.tar.gz
Export dataset without assets
sanity dataset export moviedb assetless.tar.gz --no-assets
Export raw documents without asset reference rewriting
sanity dataset export staging staging.tar.gz --raw
Export specific document types
sanity dataset export staging staging.tar.gz --types products,shopsimport
USAGE
$ sanity dataset import SOURCE [TARGETDATASET]
ARGUMENTS
SOURCE Source file (use "-" for stdin)
[TARGETDATASET] Target dataset (prefer --dataset flag instead)
FLAGS
--allow-assets-in-different-datasetAllow asset documents to reference different project/dataset
--allow-failing-assets Skip assets that cannot be fetched/uploaded
--allow-replacement-charactersAllow unicode replacement characters in imported documents
--allow-system-documents Imports system documents
--asset-concurrency=<ASSET-CONCURRENCY>Number of parallel asset imports
-d, --dataset=<DATASET> Dataset to import to
--missing Skip documents that already exist
-p, --project-id=<PROJECT-ID> Project ID to import to (overrides CLI configuration)
--replace Replace documents with the same IDs
--replace-assets Skip reuse of existing assets
--skip-cross-dataset-referencesSkips references to other datasets
-t, --token=<TOKEN> Token to authenticate with
DESCRIPTION
Import documents to a Sanity dataset
EXAMPLES
Import "./my-dataset.ndjson" into dataset "staging"
sanity dataset import -d staging -t someSecretToken my-dataset.ndjson
Import into dataset "test" from stdin
cat my-dataset.ndjson | sanity dataset import -d test -t someToken -
Import with explicit project ID (overrides CLI configuration)
sanity dataset import -p projectId -d staging -t someSecretToken my-dataset.ndjsonlist
USAGE
$ sanity dataset list
FLAGS
-p, --project-id=<PROJECT-ID> Project ID to list datasets for (overrides CLI configuration)
DESCRIPTION
List datasets of your project
EXAMPLES
List datasets of your project
sanity dataset list
List datasets for a specific project
sanity dataset list --project-id abc123visibility
get
USAGE
$ sanity dataset visibility get DATASET
ARGUMENTS
DATASET The name of the dataset to get visibility for
FLAGS
-p, --project-id=<PROJECT-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 dataset visibility get my-datasetset
USAGE
$ sanity dataset visibility set DATASET MODE
ARGUMENTS
DATASET The name of the dataset to set visibility for
MODE The visibility mode to set
FLAGS
-p, --project-id=<PROJECT-ID> Project ID to set dataset visibility for (overrides CLI configuration)
DESCRIPTION
Set the visibility of a dataset
EXAMPLES
Make a dataset private
sanity dataset visibility set my-dataset private
Make a dataset public
sanity dataset visibility set my-dataset public