Manage stacks
List your Blueprints stacks, see which stack your local blueprint deploys to, and remove stacks you no longer need.
A stack is the deployed form of a blueprint: the live set of resources Sanity runs for it. Use the Blueprints CLI to see which stacks exist, check which stack your local blueprint deploys to, and remove stacks you no longer need. For how blueprint files, stacks, and scope fit together, see Stacks and scope.
This guide shows how to list stacks, view the current stack, and remove a stack.
Prerequisites
- Run the commands in this guide from a directory that contains a blueprint configured for the project or organization that owns the stacks. If you haven't set up a blueprint yet, see Your first Blueprint.
- Log in to the Sanity CLI with
npx sanity@latest login, using an account that can access the stacks in that project or organization. For details, see CLI authentication.
List stacks
To see every stack in your blueprint's scope, 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
The output shows each stack's name and ID, and marks the stack your local blueprint uses as current. Stack IDs start with ST-.
To list the stacks in a different project or organization, add --project-id or --organization-id. To list stacks across every project and organization you can access, add --all.
To list the stacks in one organization and in each of its projects, add --include-projects together with --organization-id. These broader listings check a limited number of projects: the first 200 with --all, and the first 50 with --include-projects. When you have more projects than that, the CLI prints a warning, for example Found 230 projects, only checked the first 200.
View the current stack
Your local blueprint deploys to one stack, recorded in .sanity/blueprint.config.json. To see that stack's status, configuration, and deployed resources, 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 inspect a different stack, pass its name or ID with --stack.
Remove a stack
By default, each project or organization can have up to 10 stacks. Removing a stack you no longer use frees a slot for a new one.
Removing a stack destroys its resources
blueprints destroy permanently removes the stack and destroys the resources it manages, following each resource's deletion policy. Resources with a retain policy are kept and detached from the stack, and a resource with a protect policy makes the destroy fail. Your blueprint file and resource files stay as they are. For each policy's behavior, see the lifecycle field in the Blueprint configuration reference.
First, find the name or ID of the stack you want to remove:
npx sanity@latest blueprints stacks
pnpm dlx sanity@latest blueprints stacks
yarn dlx sanity@latest blueprints stacks
bunx sanity@latest blueprints stacks
Then pass it to the blueprints destroy command with --stack:
npx sanity@latest blueprints destroy --stack STACK_NAME_OR_ID
pnpm dlx sanity@latest blueprints destroy --stack STACK_NAME_OR_ID
yarn dlx sanity@latest blueprints destroy --stack STACK_NAME_OR_ID
bunx sanity@latest blueprints destroy --stack STACK_NAME_OR_ID
Replace STACK_NAME_OR_ID with the stack's name or its ID. The CLI asks you to confirm before it destroys anything.
To remove the stack your local blueprint currently uses, run blueprints destroy without --stack. The CLI then removes that stack's ID from .sanity/blueprint.config.json.
In continuous integration (CI) and other non-interactive environments, add --force to skip the confirmation prompt. To remove a stack outside your local blueprint's scope, pass --project-id or --organization-id together with --stack and --force.
The CLI prints these messages for the most common stack errors:
No stack found with name "NAME": the--stackvalue doesn't exactly match the name of any stack in the scope. Runblueprints stacksto check the name, or pass the stack's ID instead.Stack destruction was accepted but completion could not be confirmed: the destroy started, but the CLI couldn't confirm that it finished, and it exits with code75. Runblueprints infoto check the stack's status before you retry.Quota exceeded: the project or organization already has its maximum number of stacks, so a new stack can't be created. Remove a stack you no longer use, then try again.