Compute and AI

Functions

New Function Type: Media Library Asset Functions

v2025-11-06

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:

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.

Scheduled Drafts

v4.14.0

✨ Highlights

Scheduled drafts

Sometimes you want to schedule a single draft to go live, but don't need the full power of content releases. Scheduled drafts allows content editors to schedule, and lock, a single document. It shows up as a special type of content release and is visible for other editors to see.

This feature is enabled by default for all paid plans. See the Scheduled drafts documentation for details.

Media Library Asset Function

The first Media Library Sanity Function type is now available. See the Functions changelog entry for details.

Other changes

  • It is now possible to disable the built-in Markdown shortcuts plugin for the Portable Text Input.
  • Improved visibility for the file drop message on large arrays inputs

Enhanced recursion protection and increased rate limits

v2025-10-16

Sanity Functions now includes improved safeguards and higher throughput limits. Recursion protection limits function chains to 16 invocations when mutating documents, reducing the risk of exceeding usage limits. Rate limits have increased significantly to support higher-volume workloads.

✨ Highlights

Improved recursion protection

Functions now limits recursive invocations to 16 when you mutate documents from within a function. This protection reduces the risk of exceeding your usage limits when a function triggers another function or itself through document mutations. You should still use caution when mutating documents from within functions.

This feature requires @sanity/client v7.12.0 or later.

Increased rate limits

Rate limits for Functions have increased to support higher-volume applications:

  • Individual function limit: 200 invocations per 30 seconds (previously 10 invocations per 30 seconds).
  • Project-wide limit: 4,000 invocations per 30 seconds (previously 200 invocations per 30 seconds).

When you exceed these limits, Functions stops additional invocations until the rate drops below the threshold.