> For AI agents: the complete Sanity documentation index is available at [https://www.sanity.io/docs/llms.txt](https://www.sanity.io/docs/llms.txt).

# Deploy Blueprints with GitHub Actions

Use the official Blueprints actions to plan and deploy your Blueprints with GitHub Actions.

The official [Blueprints GitHub Actions](https://github.com/sanity-io/blueprints-actions) let you add Blueprint planning and deployment to your existing GitHub workflows.

## Prerequisites

### Create a Blueprint

Before you get started, have a local Blueprint configured and committed to the git repository you want to use. If you’re new to Blueprints, you can [get started by creating a function](https://www.sanity.io/docs/functions/function-quickstart).

Before using these actions, you need **configuration values** from your project. Run the following command to retrieve your project and stack IDs:

**CLI input**

```sh
npx sanity@latest blueprints config
```

**CLI output**

```sh
Current configuration:
  Deployment: Stack <stack_id>
   Scoped to: Project <project_id>
     Updated: <timestamp>
        File: ./.sanity/blueprint.config.json
```

## Create a Sanity API token

Next, you’ll need a Sanity API token with permission to deploy the Blueprint. The recommended way to create one is with the CLI. In your project directory, run:

**npm**

```shell
npx sanity@latest blueprints mint-deploy-token --print
```

**pnpm**

```shell
pnpm dlx sanity@latest blueprints mint-deploy-token --print
```

**yarn**

```shell
yarn dlx sanity@latest blueprints mint-deploy-token --print
```

**bun**

```shell
bunx sanity@latest blueprints mint-deploy-token --print
```

The command creates a robot token with the role required to plan, deploy, and destroy Blueprints in your Blueprint’s scope: `blueprints-deployer` for a project-scoped Blueprint, or `blueprints-deployer-robot` for an organization-scoped one. The `--print` flag prints only the raw token, so copy it from your terminal. Minting a token requires project admin access for a project-scoped Blueprint, or organization admin access for an organization-scoped one.

To create the token in the Sanity Manage UI instead, follow these steps:

1. Go to [sanity.io/manage](https://www.sanity.io/manage).
2. Select your project or organization. Organization-scoped Blueprints require an organization-level token.
3. Go to **API** > **Tokens**.
4. Select **Add API token**.** **
5. Create a token with the **Blueprints Deployer** permission.
6. Copy the token (you won't be able to see it again).

If you’re creating tokens programmatically, you’ll need the following permissions:

- Project-scoped: `sanity.project.blueprints.deploy`
- Organization-scoped: `sanity.blueprints.deploy`

## Add token to GitHub secrets

Next, add the API token to your GitHub secrets.

1. Go to your GitHub repository.
2. Navigate to **Settings** > **Secrets and variables** > **Actions**.
3. Select **New repository secret**.
4. Name: `SANITY_TOKEN`.
5. Value: Paste your Sanity API token.
6. Select **Add secret**.

## Create your workflows

There are two actions available: deploy and plan.

The **Deploy action** executes `sanity blueprints deploy` in your GitHub workflow, automatically applying your Blueprint configuration to your Sanity project. It deploys your resources, like functions, and provides a deployment status output for use in your workflow.

Some ways you can use it are:

- On pushes to your main/production branch for continuous deployment.
- As part of a release workflow.
- For scheduled deployments.
- After manual workflow dispatch.

The **Plan action** runs `sanity blueprints plan` and automatically posts the results as a PR comment, giving your team visibility into what changes will be applied. It shows specific changes in the resources, as well as a summary of all changes.

![A Sanity Blueprints deployment plan from a GitHub Actions bot, detailing a new function, removed test resources, and the deploy command.](https://cdn.sanity.io/images/3do82whm/next/1aac0c23b5fb6293d6e9ddf060ca7903bed84a3f-1860x1040.png)

Some ways you can use it are:

- Confirm what a Blueprint will do before deploying.
- Automatically post results as a collapsible PR comment.
- Keep your PR discussions clean and organized.

### Create a Deploy workflow

Create `.github/workflows/deploy-blueprints.yml`. Replace the stack and project ID placeholders with your values.

**.github/workflows/deploy-blueprints.yml**

```yaml
name: Deploy Sanity Blueprints

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v5

      - name: Install dependencies
        run: npm ci  # or pnpm/yarn

      - name: Deploy blueprints
        uses: sanity-io/blueprints-actions/deploy@deploy-v3
        with:
          sanity-token: ${{ secrets.SANITY_TOKEN }}
          stack-id: 'ST_1234xyz'
          project-id: '1234xyz'
          # organization-id: '1234xyz' # if you're deploying an org-scoped blueprint
```

### Create a Plan workflow

Create `.github/workflows/plan-blueprints.yml`. Replace the stack and project ID placeholders with your values.

**.github/workflows/plan-blueprints.yml**

```yaml
name: Sanity Blueprints Plan

on:
  pull_request:

permissions:
  contents: read
  pull-requests: write  # Required for posting comments

jobs:
  plan:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v5

      - name: Install dependencies
        run: npm ci  # or pnpm/yarn

      - name: Plan blueprints changes
        uses: sanity-io/blueprints-actions/plan@plan-v2
        with:
          sanity-token: ${{ secrets.SANITY_TOKEN }}
          stack-id: 'ST_1234xyz'
          project-id: '1234xyz'
          # organization-id: '1234xyz' # if you're planning an org-scoped blueprint
```

### Custom working directory

If your Blueprint isn’t at the root of your repository, add `working-directory`.

**.github/workflows/plan-blueprints.yml**

```yaml
name: Sanity Blueprints Plan

on:
  pull_request:

permissions:
  contents: read
  pull-requests: write  # Required for posting comments

jobs:
  plan:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v5

      - name: Install dependencies
        run: npm ci  # or pnpm/yarn

      - name: Plan blueprints changes
        uses: sanity-io/blueprints-actions/plan@plan-v2
        with:
          sanity-token: ${{ secrets.SANITY_TOKEN }}
          stack-id: 'ST_1234xyz'
          project-id: '1234xyz'
          working-directory: 'path/to/blueprints'
```

### Use deployment status in workflow

The deploy action logs the deployment progress and provides a `deployment-status` output you can use in subsequent workflow steps. For example:

**action output**

```yaml
- name: Deploy blueprints
  id: deploy
  uses: sanity-io/blueprints-actions/deploy@deploy-v3
  with:
    sanity-token: ${{ secrets.SANITY_TOKEN }}
    stack-id: 'ST_1234xyz'
    project-id: '1234xyz'

- name: Notify on success
  if: steps.deploy.outputs.deployment-status == 'success'
  run: echo "Deployment successful!"
```

## Troubleshooting

### Missing project or organization ID

If the action fails with `Missing either a `project-id` or an `organization-id`.`, it received neither input. Set `project-id` for a project-scoped Blueprint, or `organization-id` for an organization-scoped one. If the value comes from a secret or variable, check that it isn’t empty.

### Plan results don’t appear on the pull request

The Plan action needs the `pull-requests: write` permission to create or update its pull request comment. Add it under the top-level `permissions` key of your workflow file.

### Deploys to an organization-scoped stack fail

When a project ID is set, the CLI uses the project scope, even if an organization ID is also set. For an organization-scoped Blueprint, set `organization-id` and remove `project-id`. The token must match the scope too. A project-scoped token can’t deploy an organization-scoped stack, including a stack you [promoted to organization scope](https://www.sanity.io/docs/blueprints/promote-stack-to-organization-scope). Mint an organization-scoped token and update the `SANITY_TOKEN` secret:

**npm**

```shell
npx sanity@latest blueprints mint-deploy-token --organization-id YOUR_ORGANIZATION_ID --print
```

**pnpm**

```shell
pnpm dlx sanity@latest blueprints mint-deploy-token --organization-id YOUR_ORGANIZATION_ID --print
```

**yarn**

```shell
yarn dlx sanity@latest blueprints mint-deploy-token --organization-id YOUR_ORGANIZATION_ID --print
```

**bun**

```shell
bunx sanity@latest blueprints mint-deploy-token --organization-id YOUR_ORGANIZATION_ID --print
```

## Configuration reference

#### Properties

**sanity-token** (string, required)

A Sanity API token with deploy permissions.

**stack-id** (string, required)

The Blueprint stack ID. Find this by running sanity blueprints config to view the active stack, or sanity blueprints stacks to view all current stacks.

**project-id** (string)

Sanity project ID. Find this by running sanity blueprints config or in your project settings at sanity.io/manage. Required if you don’t set organization-id. Don’t set both: when both are set, the CLI uses the project scope.

**organization-id** (string)

Set the Sanity organization ID for organization-scoped stacks. Required if you don’t set project-id. Don’t set both: when both are set, the CLI uses the project scope.

**working-directory** (string)

Path to the directory containing your Blueprint config (sanity.blueprint.ts). Defaults to the repository root.

Visit the [GitHub Actions repository](https://github.com/sanity-io/blueprints-actions) for additional details.

## Next steps

- To deploy from a CI system other than GitHub Actions, see [Deploy Blueprints from CI](https://www.sanity.io/docs/blueprints/deploy-blueprints-from-ci).
- To deploy one Blueprint to separate staging and production stacks, see [Manage environments with Blueprints](https://www.sanity.io/docs/blueprints/manage-environments).
- To learn what happens when a deploy fails, see [Errors and rollbacks](https://www.sanity.io/docs/blueprints/errors-and-rollbacks).



## Related changelog entries

Entries are listed newest first; each link points to the full entry as markdown. Follow one when you need to know what changed, when, or why — for example, to summarize recent updates, explain behavior that differs from older documentation, or check whether a fix has shipped.

- [Blueprints v2026-01-30: Official GitHub Actions for Blueprints](https://www.sanity.io/docs/changelog/7e6ae008-56e3-43a2-9fb3-1cdcb2524068.md) — February 2, 2026