Datasets CLI command reference

Interact with datasets in your project

npx 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 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

delete

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

link

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

unlink

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

copy

USAGE
  $ sanity datasets copy [SOURCE] [TARGET] [-p <id>] [--attach <value>] [--detach] [--limit <value>] [--list] [--offset <value>] [--skip-content-releases] [--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

create

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 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

delete

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

embeddings

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 production

enable

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

status

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

export

USAGE
  $ sanity datasets export [NAME] [DESTINATION] [-p <id>] [--asset-concurrency <value>] [--mode <value>] [--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>     Concurrent number of asset downloads
      --mode=<value>                  Export mode ('cursor' is faster for large datasets but may miss concurrent changes)
      --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

import

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.ndjson

list

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

visibility

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-dataset

set

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

Was this page helpful?

sanity.ioAll Systems Operational© Sanity 2026
Change site theme