Was this page helpful?
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.
This article describes an experimental Sanity feature. The APIs described are subject to change and the documentation may not be completely accurate.
sanity@latest) is recommended to interact with Blueprints and Functions as shown in this guide. You can always run the latest CLI commands with npx sanity@latest.Like a configuration file, a blueprint lets you define and customize Sanity resources.
Core Sanity components are resources. For the time being, Functions are the only resource supported by Blueprints.
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 stacks command, and switch stacks by running sanity blueprints init or sanity blueprints config --edit in an existing blueprints project
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.
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.tsIf 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
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
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>
.
└── some-project/
├── sanity.blueprint.ts
└── another-project/
└── sanity.blueprint.ts.
└── some-project/
| └── sanity.blueprint.ts
└── another-project/
└── sanity.blueprint.tsnpx sanity@latest blueprints stackspnpm dlx sanity@latest blueprints stacksyarn dlx sanity@latest blueprints stacksbunx sanity@latest blueprints stacksnpx sanity@latest blueprints stackspnpm dlx sanity@latest blueprints stacksyarn dlx sanity@latest blueprints stacksbunx sanity@latest blueprints stacksnpx sanity@latest blueprints infopnpm dlx sanity@latest blueprints infoyarn dlx sanity@latest blueprints infobunx sanity@latest blueprints infonpx sanity@latest blueprints infopnpm dlx sanity@latest blueprints infoyarn dlx sanity@latest blueprints infobunx sanity@latest blueprints infonpx sanity@latest blueprints infopnpm dlx sanity@latest blueprints infoyarn dlx sanity@latest blueprints infobunx sanity@latest blueprints infonpx sanity@latest blueprints infopnpm dlx sanity@latest blueprints infoyarn dlx sanity@latest blueprints infobunx sanity@latest blueprints infoblueprints destroy --stack-id <ST-someid>