Error: You must login first - run "sanity login" at Object.apiClient
The error message is clear - after resetting your MacBook, you need to re-authenticate the Sanity CLI with your account. This is a common issue when setting up a development environment on a fresh machine.
Here's how to fix it:
Run the login command:
sanity loginThis will open your browser and prompt you to authenticate with your Sanity account. Once you complete the login, the CLI will store an authentication token locally on your machine.
Where the token is stored:
On macOS, Sanity stores your authentication token in ~/.config/sanity/ (typically in a file like tokens.json). When you reset your MacBook, this directory and its contents were wiped, which is why you need to log in again.
After logging in: Once authentication completes, you should be able to run:
sanity startAnd your Studio will start up normally.
Important notes:
- Make sure you're using the same Sanity account that has access to the project in your GitHub repo
- The
yarn startcommand works because it's running your React frontend, which doesn't need CLI authentication - The
sanity startcommand needs authentication because it's starting the Sanity Studio, which requires API access to your project's dataset
If you run into any issues with the login command, make sure you have the Sanity CLI installed globally:
npm install -g @sanity/cliOr if you're using the CLI from your project's node_modules, you can use:
npx sanity loginSanity – 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.