CLI reference
Datasets CLI command reference
Interact with datasets in your project
npx sanity datasets --help
pnpm dlx sanity datasets --help
yarn dlx sanity datasets --help
bunx sanity datasets --help
Commands
alias
create
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 within your 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
Create alias with explicit ~ prefix
$ sanity datasets alias create ~conference conf-2025delete
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 within your project
EXAMPLES
Delete alias named "conference" with confirmation prompt
$ sanity datasets alias delete conference
Delete alias with explicit ~ prefix
$ sanity datasets alias delete ~conference
Delete alias named "conference" without confirmation prompt
$ sanity datasets alias delete conference --forcelink
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 within your 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
Link alias with explicit ~ prefix
$ sanity datasets alias link ~conference conf-2025
Force link without confirmation (skip relink prompt)
$ sanity datasets alias link conference conf-2025 --forceunlink
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 within your 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 with explicit ~ prefix
$ sanity datasets alias unlink ~conference
Unlink alias "conference" without confirmation prompt
$ sanity datasets alias unlink conference --forcecopy
USAGE
$ sanity datasets copy [SOURCE] [TARGET] [-p <id>] [--attach <value>] [--detach] [--limit <value>] [--list] [--offset <value>] [--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-history Don't preserve document history on copy
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to copy dataset in (overrides CLI configuration)
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 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
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 10create
USAGE
$ sanity datasets create [NAME] [-p <id>] [--embeddings] [--embeddings-projection <value>] [--visibility <value>]
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=<value> Set visibility for this dataset (custom/private/public)
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to create dataset in (overrides CLI configuration)
DESCRIPTION
Create a new dataset within your 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 privatedelete
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 within your project
EXAMPLES
Delete a specific dataset
$ sanity datasets delete my-dataset
Delete a specific dataset without confirmation
$ sanity datasets delete my-dataset --forceembeddings
disable
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 productionenable
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 --waitstatus
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 productionexport
USAGE
$ sanity datasets export [NAME] [DESTINATION] [-p <id>] [--asset-concurrency <value>] [--mode <value>] [--no-assets] [--no-compress] [--no-drafts] [--overwrite] [--raw] [--types <value>]
ARGUMENTS
[NAME] Name of the dataset to export
[DESTINATION] Output destination file path
FLAGS
--asset-concurrency=<value> Concurrent number of asset downloads
--mode=<value> 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=<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 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 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,shopsimport
USAGE
$ sanity datasets import SOURCE [TARGETDATASET] [-d <name>] [-p <id>] [-t <value>] [--allow-assets-in-different-dataset] [--allow-failing-assets] [--allow-replacement-characters] [--allow-system-documents] [--asset-concurrency <value>] [--missing] [--replace] [--replace-assets] [--skip-cross-dataset-references]
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> 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.ndjsonlist
USAGE
$ sanity datasets list [-p <id>]
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to list datasets for (overrides CLI configuration)
DESCRIPTION
List datasets of your project
EXAMPLES
List datasets of your project
$ sanity datasets list
List datasets for a specific project
$ sanity datasets list --project-id abc123visibility
get
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-datasetset
USAGE
$ sanity datasets visibility set DATASET MODE [-p <id>]
ARGUMENTS
DATASET The name of the dataset to set visibility for
MODE 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