CLI reference

Assets CLI command reference

Reference documentation for the Sanity CLI assets command.

npx sanity assets --help

Commands

upload

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

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=<value>              Asset type to create

OVERRIDE FLAGS
  -d, --dataset=<name>  Dataset to upload the asset to (overrides CLI configuration)
  -p, --project=<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 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

Was this page helpful?

Sanity logosanity.ioAll Systems Operational© Sanity 2026
Change site theme