Sanity Deploy "You do not have access to the project" Error Despite Correct Login
This is a frustrating authentication issue that comes up occasionally! The "You do not have access to the project" error during sanity deploy is almost always caused by stale or corrupted authentication tokens in the Sanity CLI, even when you appear to be logged in.
Here's what to try:
1. Force a fresh login
Run these commands in order:
sanity logout
sanity loginThis clears your existing auth token and creates a new one. After logging back in, try sanity deploy again.
2. Check your auth token location
The Sanity CLI stores authentication tokens in a config file. On macOS/Linux, this is typically at ~/.config/sanity/config.json. Sometimes this file gets corrupted or contains tokens from old sessions.
You can manually delete this file and log in again:
rm ~/.config/sanity/config.json
sanity loginOn Windows, the config is usually stored in %USERPROFILE%\.config\sanity\config.json.
3. Verify your project ID
Double-check that the projectId in your sanity.config.ts (or sanity.json for older projects) exactly matches your actual project ID in manage.sanity.io. Even a single character difference will cause this error.
4. Check project permissions
Go to manage.sanity.io, select your project, and verify under Settings → Members that your account actually has admin or deploy permissions. If you were recently added to a project by someone else, you might not have the right role.
5. Try with an explicit auth token
As mentioned in the sanity deploy documentation, you can bypass the stored credentials by using an environment variable:
SANITY_AUTH_TOKEN=your-token-here sanity deployYou can generate a token at manage.sanity.io under your project's Settings → API → Tokens.
Why this happens:
The CLI authentication can get out of sync if you've logged in from multiple machines, changed your Sanity password, or if there were network issues during a previous login. The logout/login cycle forces the CLI to request a fresh token from Sanity's servers.
In 99% of cases, the sanity logout → sanity login sequence fixes this immediately. If it still doesn't work after that, there's likely a permissions issue with your Sanity account on that specific project.
Show original thread46 replies
Sanity – Build the way you think, not the way your CMS thinks
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.