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
    • 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

Changelog

Track new features, improvements, and fixes across all Sanity products.

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

On this page

Back to Changelog
  1. Changelog
  2. Functions

New Function Type: Media Library Asset Functions

Published: November 6, 2025

v2025-11-06
Functions

We've added a new Sanity Function type that lets you respond to changes in your media library. This update brings the same event-driven capabilities from document functions to your media library assets.

✨ Highlights

React to Media Library asset events

You can now run functions whenever assets are uploaded, updated, or deleted in your media library. This new asset function type extends the event-driven architecture already available for documents, giving you more control over your content workflow automation.

Use this new function type to:

  • Know when new versions of an asset are created.
  • Clean up dependencies when assets are deleted.
  • Trigger notifications or webhooks for asset events.

Here's an example of defining a Media Library asset function:

import { defineBlueprint, defineMediaLibraryAssetFunction } from '@sanity/blueprints'

export default defineBlueprint({
  resources: [
    defineMediaLibraryAssetFunction({
      name: 'ml-asset',
      event: {
        on: ['update'],
        filter: "delta::changedAny(title)",
        projection: "{_id, title, assetType}",
        resource: {
          type: 'media-library',
          id: 'mlFqEeKZYecz',
        }
      },
    })
  ],
})

This function type specifically targets documents with a _type of sanity.asset. You can apply additional filters, as shown in the example above, but only sanity.asset documents will invoke the function.

More Media Library functions will come in the future to accommodate more document types.

To get started, update to the latest @sanity/blueprints and @sanity/functions libraries using npm or pnpm, and ensure you're using the latest sanity CLI (v4.14.0). ML support in functions requires @sanity/blueprints v0.4.0 or later and @sanity/functions v1.1.0 or later.

For more information about Functions, see the Sanity Functions documentation.

Note: This functionality requires that your plan includes access to Media Library.

Related documentation

  • Functions cheat sheet

  • Blueprint configuration reference

  • Functions

  • Configure @sanity/client in Functions

On this page

  • ✨ Highlights
  • React to Media Library asset events
Back to Blueprint configuration reference

Related documentation

  • Functions cheat sheet

  • Previous page

    Blueprint configuration reference

  • Functions

  • Configure @sanity/client in Functions

import { defineBlueprint, defineMediaLibraryAssetFunction } from '@sanity/blueprints'

export default defineBlueprint({
  resources: [
    defineMediaLibraryAssetFunction({
      name: 'ml-asset',
      event: {
        on: ['update'],
        filter: "delta::changedAny(title)",
        projection: "{_id, title, assetType}",
        resource: {
          type: 'media-library',
          id: 'mlFqEeKZYecz',
        }
      },
    })
  ],
})