Important
This package is currently in beta and may change. Refer to the CHANGELOG for details.
TypeScript helpers for defining and validating Sanity Blueprints — declarative infrastructure-as-code for your Sanity project.
npm install @sanity/blueprintsA blueprint is a module that declares the Sanity resources your project needs. Export it as the default from your blueprint file:
import {
defineBlueprint,
defineCorsOrigin,
defineDocumentFunction,
defineDocumentWebhook,
defineRobotToken,
defineRole,
} from '@sanity/blueprints'
export default defineBlueprint({
resources: [
defineCorsOrigin({
name: 'localhost-origin',
origin: 'http://localhost:3333',
allowCredentials: true,
}),
defineDocumentFunction({
name: 'on-publish',
event: {
on: ['create', 'update'],
filter: "_type == 'product'",
projection: '{_id, title, slug}',
},
}),
defineDocumentWebhook({
name: 'server-webhook',
url: 'https://api.example.com/webhooks/sanity',
on: ['create', 'update'],
dataset: 'production',
apiVersion: 'v2026-01-01',
}),
defineRobotToken({
name: 'ci-robot',
memberships: [{
resourceType: 'project',
resourceId: 'your-project-id',
roleNames: ['developer'],
}],
}),
],
})| Definer | Description |
|---|---|
defineBlueprint |
Top-level blueprint module containing resources |
defineDocumentFunction |
Function triggered by document events |
defineMediaLibraryAssetFunction |
Function triggered by media library events |
defineCorsOrigin β |
CORS origin allowing browser requests to your project |
defineDocumentWebhook β |
Webhook triggered by document changes |
defineRole β |
Custom role with permissions |
defineRobotToken β |
Robot token for automated access |
Each definer validates its input at call time and returns a typed resource object. See the reference docs for full configuration details and additional resource types.