Can images be imported to Sanity without referencing them in documents?

8 replies
Last updated: Jan 28, 2026
Hello. Trying to understand importing assets to sanity. After reading https://www.sanity.io/docs/importing-data am I right that images can only be imported by referencing them as part of a document? I would like to just import the images to make them available to the authors when they build content but I don't know how they're going to use them.
AI Update

You're actually not quite right about that! While the documentation you're reading focuses on importing images within documents, you can absolutely upload images to Sanity directly without attaching them to a document first. The images will then be available in your asset library for authors to use later.

Uploading images without documents

You can upload standalone images using the Assets API. When you upload an image, Sanity automatically creates a sanity.imageAsset document that stores the metadata, but you don't need to create or reference it from any other document. These assets live independently in your dataset and are available for authors to browse and use.

Using the JavaScript client

import {createClient} from '@sanity/client'

const client = createClient({
  projectId: 'myProjectId',
  dataset: 'myDatasetName',
  apiVersion: '2021-08-29',
  token: 'myToken'
})

// Upload the image - it's now available in your asset library
client.assets
  .upload('image', createReadStream('/path/to/image.jpg'), {
    filename: 'bicycle.jpg'
  })
  .then(imageAsset => {
    console.log('Uploaded!', imageAsset._id)
    // The image is now in your library, ready for authors to use
  })

Using the HTTP API directly

You can also POST directly to the Assets API endpoint:

curl -X POST \
  -H 'Content-Type: image/jpeg' \
  --data-binary "@/path/to/image.jpg" \
  'https://myProjectId.api.sanity.io/v2021-06-07/assets/images/myDataset'

Both methods create the asset document automatically, making the image available in Studio's asset picker.

Browsing uploaded assets

Authors can access these pre-uploaded images through:

  • The built-in image picker in any image field
  • The Sanity Media plugin which provides a dedicated asset browser
  • The Media Library (Enterprise feature) for organization-wide asset management with tagging and metadata

Querying standalone assets

You can also query all uploaded images using GROQ:

*[_type == "sanity.imageAsset"]

So to directly answer your question: No, images don't need to be part of a document to be imported. You can upload them standalone, and they'll be immediately available for your authors to use wherever they need them in their content.

Show original thread
8 replies

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?