Troubleshooting insufficient permissions error when creating a document in Sanity using a client and token.
This error means you don't have the necessary permissions to create documents in your Sanity project. Here's how to fix it:
Check your role and permissions:
The most common cause is that your user account or API token doesn't have the "create" permission. In Sanity, permissions are controlled through roles and access control.
If you're working in Sanity Studio:
- Go to your project's Manage page (access it from the Studio menu or run
npx sanity@latest manage) - Navigate to the Members section
- Check what role you're assigned - you need at least Editor or Administrator role to create documents
- If you're not an admin, ask a project administrator to grant you the appropriate permissions
If you're using an API token:
When making programmatic requests to Sanity's API, you need an API token with sufficient permissions:
- Go to Manage → API tab
- Check your existing tokens or create a new one
- Make sure the token is assigned a role with "create" permissions (typically Editor or a custom role with create permissions)
- If you created a new token, update it in your environment variables:
SANITY_API_TOKEN="your-new-token-here"
Custom roles:
If your project uses custom roles (available on Enterprise plans), the role assigned to you or your token might have restricted permissions. An administrator needs to update the role definition to include create permissions for the specific document types or content resources you need to work with.
Quick test:
If you're an administrator and need to quickly verify this is a permissions issue, try temporarily assigning yourself or your token the Administrator role, which has full permissions. If document creation works, then you know it's a role/permission configuration issue that needs to be adjusted.
Remember that roles in Sanity are additive - if you have multiple roles, you get the combined permissions of all of them.
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.