App SDK

App SDK deployment

Learn how to deploy your App SDK app to your organization dashboard.

This guide shows how to deploy an App SDK app to your organization's Dashboard, enable auto-updates, undeploy the app, and set up deployment from a CI/CD pipeline.

Prerequisites

Before you deploy, make sure you have the following:

  • Node.js 22.12 or later. The Sanity CLI exits with an error on older versions.
  • An App SDK app with app.organizationId set in sanity.cli.ts to the ID of the Sanity organization that owns the app.
  • A recent Sanity CLI for some options on this page: @sanity/cli 8.12.0 or later for deploy --create, 8.13.0 or later to pass an app ID to undeploy, and 8.19.0 or later to create organization tokens with tokens create.

Deploy your app

To deploy your App SDK app, you use the same command as when deploying a studio: sanity deploy

npx sanity@latest deploy

To deploy App SDK apps, you need the Administrator or Developer role in your organization, or an equivalent role. Organization-level robot tokens with the "Manage SDK Apps" permission (which grants deploy, read, and delete access to App SDK apps) can also be used to deploy App SDK apps. For more information, see Roles and permissions.

Deployment size limit

Enable auto-updates

To keep your App SDK app up to date without redeploying, enable auto-updates the same way you do for a studio. Set deployment.autoUpdates to true in your sanity.cli.ts file, alongside the appId saved during your first deploy:

import {defineCliConfig} from 'sanity/cli'

export default defineCliConfig({
  app: {
    organizationId: 'YOUR_ORGANIZATION_ID',
  },
  deployment: {
    appId: 'YOUR_APP_ID',
    autoUpdates: true,
  },
})

Replace YOUR_ORGANIZATION_ID with the ID of the Sanity organization that owns the app, and YOUR_APP_ID with the app ID the CLI prints after your first deploy.

With auto-updates enabled, your deployed app loads @sanity/sdk, @sanity/sdk-react, and sanity (if installed) at runtime. It picks up patch and minor releases without a rebuild.

Undeploy your app

To undeploy your App SDK app, you can use sanity undeploy from within your app’s directory.

npx sanity@latest undeploy

To find the deployment to remove, the CLI reads your app's ID from deployment.appId in your sanity.cli.ts file, which the CLI tells you to add after your first deploy. With @sanity/cli 8.13.0 or later, you can pass the ID as an argument instead: npx sanity@latest undeploy YOUR_APP_ID.

Deploy from a CI/CD pipeline

App SDK deployment requires an organization-level robot token with the Manage SDK Apps permission. This is different from Studio deployment, which uses project-level tokens. To create this token, you need the Developer or Administrator role in your organization.

To create a robot token:

  • Go to Manage and select your organization.
  • Select API > Tokens.
  • Select Add API token, and then select the Manage SDK Apps permission. Select Save token.
  • Copy the token and store it as a secret in your CI/CD environment (for example, as a GitHub Actions secret).

Set the SANITY_AUTH_TOKEN environment variable to your robot token. The Sanity CLI reads this variable automatically when deploying.

In a CI/CD pipeline, the CLI can't prompt for input. The first deploy creates the app, so pass the --title flag to name it: npx sanity deploy --title "My App". If your organization already has other apps, also pass --create (requires @sanity/cli 8.12.0 or later). After the first deploy, add the app ID to your configuration as deployment.appId and commit it. Later deploys update that app without prompting. At that point, remove --create, because the CLI rejects it when an app ID is configured.

GitHub Actions example

name: Deploy App SDK
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - run: npm ci
      - run: npx sanity deploy --title 'My App'
        env:
          SANITY_AUTH_TOKEN: ${{ secrets.SANITY_DEPLOY_TOKEN }}

On its first run, this workflow creates the app. If your organization already has other apps, add --create to that first run. When the run finishes, the CLI output shows the new app ID. Add it to sanity.cli.ts as deployment.appId and commit the change before the next push. Without it, the next run fails, because the organization now has an app and the CLI can't ask which one to deploy to.

Environment variables

The following environment variables are relevant for App SDK deployment:

  • SANITY_AUTH_TOKEN: the organization-level robot token for authentication. Required for non-interactive deployment.
  • SANITY_APP_*: any environment variables prefixed with SANITY_APP_ are embedded in your app's browser code at build time.

Don't put secrets in SANITY_APP_ variables

Troubleshooting

The following errors are commonly reported by developers deploying App SDK apps:

  • "Unauthorized" or "Insufficient permissions": verify that your token is an organization-level robot token with the Manage SDK Apps permission enabled.
  • "Session does not match project host": this can occur in CI/CD environments. Ensure SANITY_AUTH_TOKEN is set correctly and that no cached credentials are interfering.

Next steps

Learn more about configuring and deploying App SDK apps:

Was this page helpful?

Sanity logosanity.ioAll Systems Operational© Sanity 2026
Change site theme