Everything *[NYC] 2026: see what we announced. →
Skip to content

Compute + AI

Colocated logic for your content

Deploy functions that respond to content changes or run on a schedule. Validate, enrich, sync, and integrate without external infrastructure.

  • Write once, use everywhere

    Package functions as reusable modules to maintain consistent results and reduce code duplication. This approach allows you to build a library of tested, reliable functions that can be applied wherever needed.

  • Create. Invoke. Deploy.

    Instantly create new functions from the CLI, test locally with the included development environment and deploy to production.

  • Press publish and watch the magic

    Use Functions to automatically translate new fields and documents, validate with AI, or invalidate the cache of your front-end.

The content automation toolkit

Respond in real time

Event-driven content workflows

Turn any content change into a trigger using GROQ. Your functions can execute custom logics to maintain data consistency, trigger workflows, or perform automated tasks. No missed events, no delays.

import {defineBlueprint, defineDocumentFunction} from '@sanity/blueprints';

export default defineBlueprint({
  resources: [
    defineDocumentFunction({
      name: "text-to-speech",
      event: {
        on: ["update"],
        filter: "_type == 'event'",
        projection: "{title, content}",
      },
    })
  ]
});

Run on a schedule

Time-based automation, defined in code

Schedule recurring jobs in a Blueprint. No external cron tools to manage. Sync data nightly, invalidate caches, send scheduled notifications. Every Function runs with full access to your content.

// sanity.blueprint.ts
import {defineBlueprint, defineScheduledFunction} from '@sanity/blueprints';

export default defineBlueprint({
  resources: [
    defineScheduledFunction({
      name: "nightly-sync",
      event: {
        expression: "0 0 * * *",
      },
    })
  ]
});

Complete context

Runs inside the Content Lake

Functions have you full access to your content model, documents and API capabilities, allowing them to perform complex operations while maintaining security. No more data transfers or permission juggling.

a grid of nodes with a line connecting some of them

Workflow automation

Connects content to content operations

Functions makes every “if this, then that” scenario you’ve ever wanted possible. Make any mutation the beginning of any content process orchestration.

import { textToSpeech } from "./text-to-speech";

export const handler = documentEventHandler(async ({ context, event }) => {
  const audio = await textToSpeech(event.doc.content);

  const client = createClient({
    ...context.clientOptions,
    apiVersion: "2025-05-08",
  });

  await client.assets.upload("file", audio, {
    filename: `${event.doc.title}.mp3`,
    contentType: "audio/mpeg",
  });

  console.log("Audio generated and uploaded successfully");
});

FUNTIONS + AGENT API

Trigger AI workflows on any event

Use Functions to invoke the Agent API in response to content updates or on a recurring cadence. Automate enrichment, tagging, localization, or rewriting, whether triggered by a publish event or a nightly cron job, directly inside your workflows.

functions

Premade automations, integrations, and workflows

Add a function from a recipe with a single command. The code is already written. The infrastructure is managed.


Developers love Sanity

  • G2 Momentum LeaderSpring 2025

  • G2 Users Most Likely To RecommendMid Market, Spring 2025

  • G2 Grid LeaderEnterprise, Spring 2025

  • G2 High PerformerMid Market, Spring 2025

Tecovas
It's incredibly easy to push data into Sanity Content Lake from outbound systems. With the Sanity API, I'm not making 10,000 calls to update 10,000 items. I'm making one API call and the whole dataset is updated.
Kevin Harwood

Kevin Harwood

CTO

Tecovas


Get started with Sanity


Ready to build? Let's make it real.

Sign up for Sanity for free and start crafting your first project.

Get Started