
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeGood news - you're on the right track with SANITY_AUTH_TOKEN! This is exactly how you authenticate the Sanity CLI in non-interactive environments like GitHub Codespaces. Here's how to solve this:
You need to create a robot token (not a personal token) in your Sanity project:
sanity deploy: You need at least Deploy Studio permissionsOnce you have the token, set it as an environment variable in your Codespace:
export SANITY_AUTH_TOKEN="your-token-here"To make it persist across Codespace sessions, add it to your Codespace secrets at the repository or user level.
Once SANITY_AUTH_TOKEN is set, the CLI should automatically pick it up and skip the interactive login:
bun run sanity deployThe CLI will detect the environment variable and use it for authentication without trying to open the browser-based OAuth flow.
According to the Sanity authentication documentation, robot tokens are specifically designed for applications and non-interactive environments like yours, making them perfect for Codespaces where the localhost callback won't work. The docs explain that while personal tokens are for individual users, robot tokens are the right choice for "applications and third-party services" - which includes development environments like Codespaces.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store