CLI reference
Blueprints CLI command reference
Reference documentation for the Sanity CLI Blueprints command.
The blueprints CLI command enables initializing, managing, and deploying Blueprints and resources like Functions.
npx sanity blueprints --help
pnpm dlx sanity blueprints --help
yarn dlx sanity blueprints --help
bunx sanity blueprints --help
Commands
add
USAGE
$ sanity blueprints add TYPE [--install] [-n <value>] [--example <value>] [--fn-helpers] [--fn-installer <value>] [--fn-type <value>] [--javascript] [--json] [--language <value>] [--validate-resources]
ARGUMENTS
TYPE Type of resource to add (only "function" is supported)
FLAGS
-i, --install Shortcut for --fn-installer npm
-n, --name=<value> Name of the resource to add
--example=<value> Example to use for the function resource. Discover examples at https://www.sanity.io/exchange/type=recipes/by=sanity
--fn-helpers Add helpers to the new function
--fn-installer=<value> Which package manager to use when installing the @sanity/functions helpers
--fn-type=<value> Document change event(s) that should trigger the function; you can specify multiple events by specifying this flag multiple times
--javascript Use JavaScript instead of TypeScript
--json Format output as json
--language=<value> Language of the new function
--validate-resources Validate resources
DESCRIPTION
Scaffolds a new Sanity Function in your Blueprint. Functions are serverless handlers triggered by document events (create, update, delete, publish) or media library events.
After adding a function, use 'functions dev' to test locally, then 'blueprints deploy' to publish it.
EXAMPLES
$ sanity blueprints add function
$ sanity blueprints add function --helpers
$ sanity blueprints add function --name my-function
$ sanity blueprints add function --name my-function --fn-type document-create
$ sanity blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang jsconfig
USAGE
$ sanity blueprints config [--edit] [--json] [--organization-id <value>] [--project-id <value>] [--stack <value>] [--validate-resources]
FLAGS
-e, --edit Modify the configuration interactively, or directly when combined with ID flags.
--json Format output as json
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
--stack=<value> Stack name or ID to set in the configuration. Requires --edit flag
--validate-resources Validate resources
DESCRIPTION
Manages the local Blueprint configuration, which links your Blueprint to a Sanity project and Stack.
Without flags, displays the current configuration. Use --edit to interactively modify settings, or combine --edit with ID flags to update values directly (useful for scripting and automation).
If you need to switch your Blueprint to a different Stack, use --edit --stack.
EXAMPLES
$ sanity blueprints config
$ sanity blueprints config --edit
$ sanity blueprints config --edit --project-id <projectId>
$ sanity blueprints config --edit --project-id <projectId> --stack <name-or-id>deploy
USAGE
$ sanity blueprints deploy [-m <value>] [--json] [--no-wait] [--stack <value>] [--validate-resources]
FLAGS
-m, --message=<value> Message describing the deployment (e.g. reason for change)
--json Format output as json
--no-wait Do not wait for Stack deployment to complete
--stack=<value> Stack name or ID to use instead of the locally configured Stack
--validate-resources Validate resources
DESCRIPTION
Applies your local Blueprint to the remote Stack, creating, updating, or removing resources as needed. This is the primary command for applying infrastructure changes.
Before deploying, run 'blueprints plan' to preview changes. After deployment, use 'blueprints info' to verify Stack status or 'blueprints logs' to monitor activity.
Use --no-wait to queue the deployment and return immediately without waiting for completion.
Use --fn-installer to force which package manager to use when deploying functions.
Set SANITY_ASSET_TIMEOUT (seconds) to override the 60-second timeout for processing resource assets.
EXAMPLES
$ sanity blueprints deploy
$ sanity blueprints deploy --message "Enable staging dataset"
$ sanity blueprints deploy --no-wait
$ sanity blueprints deploy --fn-installer npmdestroy
USAGE
$ sanity blueprints destroy [--force] [--json] [--no-wait] [--organization-id <value>] [--project-id <value>] [--stack <value>] [--validate-resources]
FLAGS
--force Force Stack destruction (skip confirmation)
--json Format output as json
--no-wait Do not wait for Stack destruction to complete
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
--stack=<value> Stack name or ID to destroy (defaults to the locally configured Stack)
--validate-resources Validate resources
DESCRIPTION
Permanently removes the remote Stack and all its provisioned resources. Your local Blueprint files remain untouched, allowing you to redeploy later with 'blueprints init' + 'blueprints deploy'.
This is a destructive operation. You will be prompted to confirm unless --force is specified.
Use this to clean up test environments or decommission a Stack you no longer need.
EXAMPLES
$ sanity blueprints destroy
$ sanity blueprints destroy --stack <name-or-id> --project-id <projectId> --force --no-waitdoctor
USAGE
$ sanity blueprints doctor [-p <value>] [--fix] [--json] [--validate-resources] [--verbose]
FLAGS
-p, --path=<value> Path to a Blueprint file or directory containing one
--fix Interactively fix configuration issues
--json Format output as json
--validate-resources Validate resources
--verbose Verbose output; defaults to true
DESCRIPTION
Analyzes your local Blueprint and remote Stack configuration for common issues, such as missing authentication, invalid project references, or misconfigured resources.
Run this command when encountering errors with other Blueprint commands. Use --fix to interactively resolve detected issues.
EXAMPLES
$ sanity blueprints doctor
$ sanity blueprints doctor --fixinfo
USAGE
$ sanity blueprints info [--json] [--project-id <value>] [--stack <value>] [--validate-resources]
FLAGS
--json Format output as json
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
--stack=<value> Stack name or ID
--validate-resources Validate resources
DESCRIPTION
Displays the current state and metadata of your remote Stack deployment, including deployed resources, status, and configuration.
Use this command to verify a deployment succeeded, check what resources are live, or confirm which Stack your local Blueprint is connected to.
Run 'blueprints stacks' to see all available Stacks in your project or organization.
EXAMPLES
$ sanity blueprints info
$ sanity blueprints info --stack <name-or-id>
$ sanity blueprints info --project-id <id> --stack <name-or-id>init
USAGE
$ sanity blueprints init [DIR] [--blueprint-type <value>] [--dir <value>] [--example <value>] [--json] [--organization-id <value>] [--project-id <value>] [--stack-id <value>] [--stack-name <value>] [--validate-resources] [--verbose]
ARGUMENTS
[DIR] Directory to create the local Blueprint in
FLAGS
--blueprint-type=<value> Blueprint manifest type to use for the local Blueprint
--dir=<value> Directory to create the local Blueprint in
--example=<value> Example to use for the local Blueprint
--json Format output as json
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
--stack-id=<value> Existing Stack ID used to scope local Blueprint
--stack-name=<value> Name to use for a new Stack provisioned during initialization
--validate-resources Validate resources
--verbose Verbose output
DESCRIPTION
A Blueprint is your local infrastructure-as-code configuration that defines Sanity resources (datasets, functions, etc.). A Stack is the remote deployment target where your Blueprint is applied.
[NOTE: Currently, accounts are limited to three (3) Stacks per project scope.]
This is typically the first command you run in a new project. It creates a local Blueprint manifest file (sanity.blueprint.ts, .js, or .json) and provisions a new remote Stack.
Additionally, a Blueprint configuration file is created in .sanity/ containing the scope and Stack IDs. This is .gitignored by default.
After initialization, use 'blueprints plan' to preview changes, then 'blueprints deploy' to apply them.
EXAMPLES
$ sanity blueprints init
$ sanity blueprints init [directory]
$ sanity blueprints init --blueprint-type <json|js|ts>
$ sanity blueprints init --blueprint-type <json|js|ts> --project-id <projectId> --stack-id <stackId>
$ sanity blueprints init --blueprint-type <json|js|ts> --stack-name <stackName>logs
USAGE
$ sanity blueprints logs [--watch] [--json] [--stack <value>] [--validate-resources]
FLAGS
-w, --watch Watch for new Stack logs (streaming mode)
--json Format output as json
--stack=<value> Stack name or ID to use instead of the locally configured Stack
--validate-resources Validate resources
DESCRIPTION
Retrieves Stack deployment logs, useful for debugging and monitoring deployment activity.
Use --watch (-w) to stream logs in real-time.
If you're not seeing expected logs, verify your Stack is deployed with 'blueprints info'.
EXAMPLES
$ sanity blueprints logs
$ sanity blueprints logs --watchplan
USAGE
$ sanity blueprints plan [--json] [--stack <value>] [--validate-resources]
FLAGS
--json Format output as json
--stack=<value> Stack name or ID to use instead of the locally configured Stack
--validate-resources Validate resources
DESCRIPTION
Use this command to preview what changes will be applied to your remote Stack before deploying. This is a safe, read-only operation—no resources are created, modified, or deleted.
Run 'blueprints plan' after making local changes to your Blueprint manifest to verify the expected diff. When ready, run 'blueprints deploy' to apply changes.
EXAMPLES
$ sanity blueprints planstacks
USAGE
$ sanity blueprints stacks [--json] [--organization-id <value>] [--project-id <value>] [--validate-resources]
FLAGS
--json Format output as json
--organization-id=<value> Sanity organization ID used to scope Blueprint and Stack
--project-id=<value> Sanity project ID used to scope Blueprint and Stack
--validate-resources Validate resources
DESCRIPTION
Shows all Stacks associated with a project or organization. By default, lists Stacks scoped to the local Blueprint.
Use this to discover existing Stacks you can scope a local Blueprint to (using 'blueprints config --edit'), or to audit what's deployed across your project.
EXAMPLES
$ sanity blueprints stacks
$ sanity blueprints stacks --project-id <projectId>
$ sanity blueprints stacks --organization-id <organizationId>