Skip to content

Using tokens to deploy APIs

9repliesLast updated: Nov 13, 2026

So many questions today 😆 .
I am collaborating with another dev on a project and I’d like them to be able to deploy the api but:
1. I don’t necessarily want to add them as an administrator - is there a non-admin role, or some kind of auth token they can use to deploy the api?
2. Can I specify which datasets they can deploy for (e.g. only development and not production)?
Thanks!
AI Update

You don't need to make the collaborator an Administrator. They can deploy with a non-admin role (Developer) or with a least-privilege API token passed in SANITY_AUTH_TOKEN. Limiting deploys to one dataset (say development but not production) only works with Enterprise custom roles, and even then you should test that the scoping covers GraphQL deploys.

1. Let someone deploy without Administrator

Option A: invite them with the Developer role (Growth plan and above). The built-in roles are described in Roles and Permissions Concepts:

RoleProject infrastructureMembers and roles
AdministratorFull: datasets, tokens, CORS, webhooks, GraphQL, deployFull, including adding administrators
DeveloperFull: datasets, tokens, CORS, webhooks, GraphQL, deployInvite, read, update; cannot delete members

So a Developer can run sanity graphql deploy and sanity deploy but can't change the plan or remove members. Plan availability: Free has Administrator and Viewer only. Growth adds Editor, Developer and Contributor. Enterprise adds custom roles (pricing).

Option B: give them a robot token. If the deploy command gets a missing-rights "Unauthorized" error, the CLI errors page says the deploy needs Administrator or a deploy token, and that Write/Read+Write isn't enough. To make a token:

SANITY_AUTH_TOKEN=<token> npx sanity@latest graphql deploy --dataset development

You can also log the CLI in with the token: echo "$SANITY_AUTH_TOKEN" | npx sanity login --with-token (CLI authentication). To revoke it later, run npx sanity tokens list, then npx sanity tokens delete <token-id>.

Enterprise: a robot-only deploy role. With the Access API you can build a role like the documented ci-deploy recipe: appliesToUsers: false, appliesToRobots: true, with sanity-project deployStudio and sanity-project-datasets read/create. Then create a robot token with roleNames: ["ci-deploy"] (recipes). That recipe targets Studio deploys. The Administrator role's GraphQL permission is listed separately as sanity-project-graphql (manage) (roles concepts), so for GraphQL deploys you'll likely need to add that permission too. Test with --dry-run before relying on it.

2. Restrict to specific datasets

Other options without Enterprise:

sanity graphql deploy also supports --dry-run, --api, --tag and --force (GraphQL CLI reference).

Show original thread
9 replies

Was this answer helpful?

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.

Related contributions