
Templates
Have a Sanity powered app up and running in minutes with best-practice templates.
Deploy custom functions to automate content operations. Validate data, run agent actions, and integrate with any system.
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.
Instantly create new functions from the CLI, test locally with the included development environment and deploy to production.
Use Functions to automatically translate new fields and documents, validate with AI, or invalidate the cache of your front-end.
The content automation toolkit
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.
{ "blueprintVersion": "2024-10-01", "resources": [ { "displayName": "text-to-speech", "name": "text-to-speech", "type": "sanity.function.document", "src": "functions/text-to-speech", "event": { "on": "update", "filter": "_type == 'event'", "projection": "title, content" } } ] }
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.
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 async function handler({context, event}) { const audio = await textToSpeech(event.doc.content) await context.client.assets.upload('file', audio, { filename: `${event.doc.title}.mp3`, contentType: 'audio/mpeg', }) return {message: 'Audio generated and uploaded successfully'} }
Use Functions to invoke Agent Actions in response to content updates, schema changes, or external events. Automate enrichment, tagging, localization, or rewriting—directly inside your workflows.
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.
Sign up for Sanity for free and start crafting your first project.
{
"blueprintVersion": "2024-10-01",
"resources": [
{
"displayName": "text-to-speech",
"name": "text-to-speech",
"type": "sanity.function.document",
"src": "functions/text-to-speech",
"event": {
"on": "update",
"filter": "_type == 'event'",
"projection": "title, content"
}
}
]
}
import {textToSpeech} from './text-to-speech'
export async function handler({context, event}) {
const audio = await textToSpeech(event.doc.content)
await context.client.assets.upload('file', audio, {
filename: `${event.doc.title}.mp3`,
contentType: 'audio/mpeg',
})
return {message: 'Audio generated and uploaded successfully'}
}