Blueprints introduction
Learn what Blueprints are, how they work, and how to get started.
Blueprints enable infrastructure-as-code level management of Sanity resources. At this time, Blueprints are limited to managing Functions.
Experimental feature
This article describes an experimental Sanity feature. The APIs described are subject to change and the documentation may not be completely accurate.
Requirements
- The latest version of Sanity CLI (
sanity@latest) is recommended to interact with Blueprints and Functions as shown in this guide. You can always run the latest CLI commands withnpx sanity@latest. - Write access to your organization and project settings.
Core concepts
Blueprint
Like a configuration file, a blueprint lets you define and customize Sanity resources.
Resource
Core Sanity components are resources. For the time being, Functions are the only resource supported by Blueprints.
Stack
A stack is a collection of resources that are managed as a single unit. These are linked to a project and can be multiple deployments of the same sanity.blueprint.ts configuration, or deployments for different blueprint configurations entirely.
For example, marketing might have a sanity.blueprint.ts that defines resources deployed to the marketing stack, while the commerce team may have their own sanity.blueprint.ts that deploys resources to the commerce stack.
You can view stacks with the sanity blueprints stack command, and switch stacks by running sanity blueprints init or sanity blueprints config --edit in an existing blueprints project
Limitations
Stack limit
Projects have a limit of 3 stacks. If you reach your limit and want to remove a stack, see the Remove a stack steps below.
No nested blueprints
When creating multiple blueprints in a single project, you cannot nest blueprints in subdirectories of a directory containing a sanity.blueprint.ts file.
❌ For example, don't do this:
.
└── some-project/
├── sanity.blueprint.ts
└── another-project/
└── sanity.blueprint.ts✅ Instead, do this:
.
└── some-project/
| └── sanity.blueprint.ts
└── another-project/
└── sanity.blueprint.tsTroubleshooting
View stacks for a project
If you're unsure which stacks are deployed, run the blueprints stacks command.
npx sanity@latest blueprints stacks
pnpm dlx sanity@latest blueprints stacks
yarn dlx sanity@latest blueprints stacks
bunx sanity@latest blueprints stacks
View current stack
To view the currently selected stack, run the blueprints info command.
npx sanity@latest blueprints info
pnpm dlx sanity@latest blueprints info
yarn dlx sanity@latest blueprints info
bunx sanity@latest blueprints info
Remove a stack
To remove a deployed stack, run the following commands from a directory containing a configured blueprint for the same project as the stack you want to delete.
First, retrieve the stack identifier (it starts with ST-):
npx sanity@latest blueprints info
pnpm dlx sanity@latest blueprints info
yarn dlx sanity@latest blueprints info
bunx sanity@latest blueprints info
Next, run the following command with the stack identifier from the previous step.
blueprints destroy --stack-id <ST-someid>
Was this page helpful?