App SDK deployment
Learn how to deploy your custom application to your organization dashboard.
Deploy your app
To deploy your custom application, you use the same command as when deploying a studio: sanity deploy
npx sanity deploypnpm dlx sanity deployyarn dlx sanity deploybunx sanity deployNote that to deploy SDK apps you need a role of organization admin, Developer, or equivalent. Organization-level robot tokens with the "Manage SDK Apps" permission (which grants deploy, read, and delete access to SDK applications) can also be used to deploy SDK apps. Read more about roles and permissions here.
Deployment size limit
A single deployment is limited to 2 GB. The limit applies to the total size of the built files in the deployment, and deploys that exceed it are rejected with an error. The same limit applies to Studio deployments and App SDK app deployments.
Most deployments are a few megabytes, so typical projects stay well below this limit.
Undeploy your app
To undeploy your custom application, you can use sanity undeploy from within your custom app’s directory.
npx sanity undeploypnpm dlx sanity undeployyarn dlx sanity undeploybunx sanity undeployNote that you’ll need to have your app.id saved in your sanity.cli.ts file (as prompted during the deploy process) in order for your app’s deployment to be removed.
Deployment setup for CI/CD
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 a sufficient token, you’ll need org-level developer or administrator permissions.
To create a robot token:
- Go to Manage and select your organization.
- Navigate to Settings > API > Robot tokens.
- Create a new token and select the Manage SDK Apps permission.
- Copy the token and store it as a secret in your CI/CD environment (for example, as a GitHub Actions secret).
At this time, you cannot create organization-level robot tokens with the CLI.
Set the SANITY_AUTH_TOKEN environment variable to your robot token. The Sanity CLI reads this variable automatically when deploying.
For App SDK apps, the --title flag is required for fully unattended deployments. Without it, the CLI will interactively prompt for an app title on the first deploy. In CI/CD pipelines, pass --title to skip this prompt. For example: npx sanity deploy --title "My App".
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: 20
- run: npm ci
- run: npx sanity deploy --title 'My App'
env:
SANITY_AUTH_TOKEN: ${{ secrets.SANITY_DEPLOY_TOKEN }}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 withSANITY_APP_are embedded in your app's browser code at build time.
Don't put secrets in SANITY_APP_ variables
The build writes the value of every SANITY_APP_ variable into your app's JavaScript files, and anyone who can load those files can read it. Limiting who can open the app in the Dashboard doesn't hide these values. Keep API keys, service tokens, and other secrets on a server you control, and have your app call that server instead.
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_TOKENis set correctly and that no cached credentials are interfering.
Was this page helpful?
Feedback submitted, thanks for helping us improve the docs. Have you tried these alternatives?