
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYou'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.
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.
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
})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.
Authors can access these pre-uploaded images through:
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.
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store