Sanity logosanity.ioAll Systems Operational© Sanity 2026
Change Site Theme
Sanity logo

Documentation

    • Overview
    • Platform introduction
    • Next.js quickstart
    • Nuxt.js quickstart
    • Astro quickstart
    • React Router quickstart
    • Studio quickstart
    • Build with AI
    • Content Lake
    • Functions
    • APIs and SDKs
    • Agent Actions
    • Visual Editing
    • Blueprints
    • Platform management
    • Dashboard
    • Studio
    • Canvas
    • Media Library
    • App SDK
    • Content Agent
    • HTTP API
    • CLI
    • Libraries
    • Specifications
    • Changelog
    • User guides
    • Developer guides
    • Courses and certifications
    • Join the community
    • Templates
Media Library
Overview

  • Introduction
  • User guide

    Meet the library
    Asset Versions

  • Setup and development

    Studio configuration
    Media Library configuration

  • Aspects

    Create an aspect
    Add an aspect to an asset
    Query aspects
    Aspect patterns

  • Manage assets

    Importing assets (media + aspects)
    Upload an asset
    Link assets to documents
    Asset visibility
    Container URLs
    Working with video
    Migrate assets from Media Plugin

  • Reference

    HTTP API reference
    CLI reference
    Limits and usage

On this page

Previous

Studio configuration

Next

Create an aspect

Was this page helpful?

On this page

  • Obtain your mediaLibraryId
  • Configure the CLI
Media LibraryLast updated August 15, 2025

Configure your library

Set up and configure your media library

Once Media Library is enabled for your organization you can configure your CLI in order to create and deploy aspects.

This is a paid feature

This feature is available as an addon for certain Enterprise plans. Talk to sales to learn more.

Prerequisites:

  • npm, pnpm, or a similar package manager capable of installing and running the sanity CLI.
  • Read/write access to your organization's Media Library.

Obtain your mediaLibraryId

When you interact with the sanity media commands, you're prompted to select your library. If you only have a single organization, you should see a single library. If you're a member of multiple organizations, you can parse your organization and library ID using the URL.

Navigate to sanity.io/welcome, select your organization, then select the Media Library app. The URL for your library includes the mediaLibraryId.

https://www.sanity.io/@<organizationId>/media/<mediaLibraryId>/assets

Configure the CLI

Tell sanity CLI where to define your aspects by updating sanity.cli.ts.

import {defineCliConfig} from 'sanity/cli'

export default defineCliConfig({
  api: {
    projectId: '<projectId>',
    dataset: '<dataset-name>'
  },
  mediaLibrary: {
    // set the path relative to the location of sanity.cli.ts.
    aspectsPath: 'aspects',
  },
  /**
   * Enable auto-updates for studios.
   * Learn more at https://www.sanity.io/docs/cli#auto-updates
   */
  autoUpdates: true,
})

With the aspects path defined, you can now use the media commands to create and deploy aspects.

import {defineCliConfig} from 'sanity/cli'

export default defineCliConfig({
  api: {
    projectId: '<projectId>',
    dataset: '<dataset-name>'
  },
  mediaLibrary: {
    // set the path relative to the location of sanity.cli.ts.
    aspectsPath: 'aspects',
  },
  /**
   * Enable auto-updates for studios.
   * Learn more at https://www.sanity.io/docs/cli#auto-updates
   */
  autoUpdates: true,
})