ARGUMENTS TYPE (function) Type of resource to add (only "function" is supported)
FLAGS -i, --install Shortcut for --fn-installer npm -n, --name= Name of the resource to add --example= Example to use for the function resource. Discover examples at https://www.sanity.io/exchange/type=recipes/by=sanity --[no-]fn-helpers Add helpers to the new function --fn-installer=
DESCRIPTION Add a function resource to a Blueprint
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-run blueprints add function
$ sanity-run blueprints add function --helpers
$ sanity-run blueprints add function --name my-function
$ sanity-run blueprints add function --name my-function --fn-type document-create
FLAGS -e, --edit Modify the configuration interactively, or directly when combined with ID flags. --project-id= Directly set the project ID in the configuration. Requires --edit flag --stack-id= Directly set the Stack ID in the configuration. Requires --edit flag
DESCRIPTION View or edit the local Blueprint configuration
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-id.
FLAGS --no-wait Do not wait for Stack deployment to complete
DESCRIPTION Deploy the local Blueprint to the remote Stack
Pushes your local Blueprint configuration to the remote Stack; provisioning, updating, or destroying 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.
FLAGS --force Force Stack destruction (skip confirmation) --no-wait Do not wait for Stack destruction to complete --project-id= Project associated with the Stack --stack-id= Stack ID to destroy (defaults to current Stack)
DESCRIPTION Destroy the remote Stack deployment and its resources (will not delete local files)
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.
FLAGS --fix Interactively fix configuration issues --json Format output as json. --path= Path to the directory containing the Blueprint --verbose Verbose output
DESCRIPTION Diagnose potential issues with local Blueprint and remote Stack configuration
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.
ARGUMENTS [DIR] Directory to create the local Blueprint in
FLAGS --blueprint-type=
Blueprint manifest type to use for the local Blueprint --dir= Directory to create the local Blueprint in --example= Example to use for the local Blueprint --project-id= Sanity project ID used to scope local Blueprint and remote Stack --stack-id= Existing Stack ID used to scope local Blueprint --stack-name= Name to use for a new Stack provisioned during initialization --verbose Verbose output
DESCRIPTION Initialize a local Blueprint and optionally provision a remote Stack deployment
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.
Enumerate resources to be deployed to the remote Stack - will not modify any resources
` USAGE $ sanity-run blueprints plan
DESCRIPTION Enumerate resources to be deployed to the remote Stack - will not modify any resources
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.
FLAGS --project-id= Project ID to show Stack deployments for
DESCRIPTION List all remote Stack deployments (defaults to the current Blueprint's project scope)
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.
FLAGS -i, --install Shortcut for --fn-installer npm -n, --name= Name of the Function to add --example= Example to use for the Function --[no-]helpers Add helpers to the new Function --installer=
How to install the @sanity/functions helpers --javascript Use JavaScript instead of TypeScript --language=
[default: ts] Language of the new Function --type=
... Document change event(s) that should trigger the function; you can specify multiple events by specifying this flag multiple times et-create|media-library-asset-update|media-library-asset-delete>
DESCRIPTION Add a Function to your Blueprint
Scaffolds a new Function in the functions/ folder and templates a resource for your Blueprint manifest.
Functions are serverless handlers triggered by document events (create, update, delete, publish) or media library events.
After adding, use 'functions dev' to test locally, then 'blueprints deploy' to publish.
FLAGS -h, --host= The local network interface at which to listen. [default: "localhost"] -p, --port= TCP port to start emulator on. [default: 8080] -t, --timeout= Maximum execution time for all functions, in seconds. Takes precedence over function-specific
timeout
DESCRIPTION Start the Sanity Function emulator
Runs a local, web-based development server to test your functions before deploying.
Open the emulator in your browser to interactively test your functions with the payload editor.
Optionally, set the host and port with the --host and --port flags. Function timeout can be configured with the --timeout flag.
To invoke a function with the CLI, use 'functions test'.
EXAMPLES $ sanity-run functions dev --host 127.0.0.1 --port 8974
Add or set an environment variable for a deployed function
` USAGE $ sanity-run functions env add NAME KEY VALUE
ARGUMENTS NAME The name of the Sanity Function KEY The name of the environment variable VALUE The value of the environment variable
DESCRIPTION Add or set an environment variable for a deployed function
Sets an environment variable in a deployed Sanity Function. If the variable already exists, its value is updated.
Environment variables are useful for API keys, configuration values, and other secrets that shouldn't be hardcoded. Changes take effect on the next function invocation.
FLAGS -d, --delete Delete all logs for the function -f, --force Skip confirmation for deleting logs -j, --json Return logs in JSON format -l, --limit= [default: 50] Total number of log entries to retrieve -u, --utc Show dates in UTC time zone -w, --watch Watch for new logs (streaming mode)
DESCRIPTION Retrieve or delete logs for a Sanity Function
Fetches execution logs from a deployed function, useful for debugging production issues or monitoring activity.
Use --watch (-w) to stream logs in real-time. Use --delete to clear all logs for a function (requires confirmation unless --force is specified).
FLAGS -a, --api= Sanity API Version to use -d, --data= Data to send to the function -e, --event=
Type of event (create, update, delete) -f, --file= Read data from file and send to the function -t, --timeout= Execution timeout value in seconds --data-after= Current document --data-before= Original document --dataset= The Sanity dataset to use --document-id= Document to fetch and send to function --document-id-after= Current document --document-id-before= Original document --file-after= Current document --file-before= Original document --media-library-id= Sanity Media Library ID to use --project-id= Sanity Project ID to use --with-user-token Prime access token from CLI config
DESCRIPTION Invoke a local Sanity Function
Executes a function locally with the provided payload, simulating how it would run when deployed. Use this to test your function logic before deploying.
Provide test data via --data (inline JSON), --file (JSON file), or --document-id (fetch from Sanity). For update events, use the before/after flag pairs to simulate document changes.
EXAMPLES $ sanity-run functions test --data '{ "id": 1 }'