CLI reference
Assets CLI command reference
Reference documentation for the Sanity CLI assets command.
npx sanity assets --help
pnpm dlx sanity assets --help
yarn dlx sanity assets --help
bunx sanity assets --help
Commands
upload
USAGE
$ sanity assets upload [-d <name>] [-p <id>] [--content-type <mime-type>] --file <path> [--filename <filename>] [--type <value>]
FLAGS
--content-type=<mime-type> MIME type of the asset, such as image/png or application/pdf
--file=<path> Path to the local file to upload
--filename=<filename> Original filename stored on the asset document. Defaults to the local filename
--type=<value> Asset type to create
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 local image or file to a Sanity dataset 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