canonical: https://jentic.com/apis/sanity.io/sanity-access-api

# Sanity Access API

The Sanity Access API controls who can reach a Sanity organization or project, and what they can do there. Every call is made against a resourceType and resourceId in the path, such as `/access/project/{resourceId}/roles`, and covers the users on that resource and their roles, custom roles and permissions, email invites, access requests, and robots with their own secret tokens. It can also report or check the calling user's own permissions, apply an organization's default role to every member, and let a robot rotate or revoke its own token.

## For AI agents

List who has access to a Sanity project or organization, change their roles, send or revoke invites, approve access requests, and create robot tokens scoped to one resource.

## Scope

Does not manage projects, datasets, content, or user sign-in and SSO. Use for Sanity users, roles, permissions, invites, access requests, and robot tokens only.

## Capabilities

- List the users of a Sanity project or organization with their roles, filtered by email or displayName and sorted with sortBy and orderBy
- Replace a user's complete role set in one call with roleNames, or add and remove a single role by roleName
- Create custom roles with a name, title, appliesToUsers and appliesToRobots flags, and a list of permissions with actions such as read or update
- Invite people by email with a role and optional callbackUrl, list pending invites, and revoke them by inviteId
- Review access requests, then accept them with roleNames or decline them
- Create robots with a label, optional expiresAt, and memberships naming roleNames, and receive the secret token once
- Check whether the calling user holds specific permissions on a resource with the permissions query parameter

## Use cases

### AI agent running access reviews

An agent asked who can change a Sanity project searches Jentic for 'list Sanity project users and roles', loads the getUsers operation, and calls it for the project's resourceId. It can then pull getUser for anyone with an administrator role and getRobots for robot access, and report the full picture without the bearer token ever entering its context.

Example prompt: Call GET `/v2025-07-11/access/project/{resourceId}/users` for project c7ja4siy, then GET `/v2025-07-11/access/project/{resourceId}/robots`, and summarize which users and robots hold the administrator role

### Onboarding through invites and access requests

New collaborators reach a Sanity project two ways. An admin sends an invite with createInvite, giving an email and a role, and Sanity emails a link to accept; each invitee gets one invite per resource and role. People can also ask for access themselves with createRequest, and an admin lists them with getRequests and either accepts with roleNames or declines.

Example prompt: POST `/v2025-07-11/access/project/{resourceId}/invites` with email jane@example.com and role editor, then GET `/v2024-07-01/access/project/{resourceId}/requests` and accept each pending request with roleNames ["viewer"]

### Scoped robot tokens for automation

CI jobs and scripts should not reuse a person's token. The createRobot operation makes a robot with a label, an optional expiresAt, and memberships that name a resourceType, resourceId, and roleNames, and returns its secret token once. Only the specified resource and its children can be granted, and the robot itself can later call the rotate or revoke endpoints under `/access/robots/me.`

Example prompt: POST `/v2025-07-11/access/project/{resourceId}/robots` with label ci-deploy, expiresAt set to 90 days out, and memberships [{resourceType: project, resourceId: c7ja4siy, roleNames: ["editor"]}], then store the returned token

### Custom roles for least-privilege access

Built-in roles do not fit every team. The createRole operation defines a role with a lowercase name, a title, and a permissions list pairing a permission name with an action, and appliesToUsers or appliesToRobots controls who can hold it. Creating roles requires the advancedRolesManagement feature, and getUserPermissions shows what the caller ends up with.

Example prompt: POST `/v2025-07-11/access/project/{resourceId}/roles` with name translator, title Translator, and a permissions list, then PUT `/v2025-07-11/access/project/{resourceId}/users/{sanityUserId}/roles/translator` for the translator's user id

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| GET | `/v2025-07-11/access/{resourceType}/{resourceId}/users` | List users of a resource and their roles |
| PUT | `/v2025-07-11/access/{resourceType}/{resourceId}/users/{sanityUserId}/roles` | Replace a user's role set |
| POST | `/v2025-07-11/access/{resourceType}/{resourceId}/roles` | Create a custom role |
| POST | `/v2025-07-11/access/{resourceType}/{resourceId}/invites` | Invite a user by email |
| PUT | `/v2024-07-01/access/{resourceType}/{resourceId}/requests/{requestId}/accept` | Accept an access request |
| POST | `/v2025-07-11/access/{resourceType}/{resourceId}/robots` | Create a robot and its token |
| GET | `/v2025-07-11/access/{resourceType}/{resourceId}/user-permissions/me/check` | Check the caller's permissions |

## Key resources

- **Resources** — The organization or project an access call applies to, given as resourceType and resourceId in the path
- **Users** — People with access to a resource and the roles they hold
- **Roles and permissions** — Built-in and custom roles made of permissions with actions such as read, update, or manage
- **Invites** — Email invitations to a resource with a role, accepted through an invite token
- **Access requests** — Requests for access or a role, accepted with roleNames or declined
- **Robots** — Non-human members with a label, memberships, optional expiry, and a secret token

## AI readiness

This API is usable in Jentic One now. Its AI-readiness score against Jentic's framework shows where it stands today and where improvements would make it even easier for agents to use.

- **Score:** 64 / 100
- **Maturity:** AI-Aware
- **Dimensions:**
  - Foundational Compliance: 56 / 100
  - Developer Experience & Jentic Compatibility: 68 / 100
  - AI-Readiness & Agent Experience: 50 / 100
  - Agent Usability: 94 / 100
  - Security: 68 / 100
  - AI Discoverability: 70 / 100
- **View full report:** https://jentic.com/apis/sanity.io/sanity-access-api/scorecard
- **How the score is calculated:** https://docs.jentic.com/reference/api-readiness-framework/overview/
- **More about the dimensions:** https://docs.jentic.com/reference/api-readiness-framework/specification/#dimensional-model-overview

### Score it yourself

Every API in the directory is allowlisted, so you can re-score it with no key required.

- **Score your own API:** https://jentic.com/scorecard.md
- **Scoring CLI agent skill:** https://github.com/jentic/jentic-api-scorecard/blob/main/skills/jentic-api-scorecard/SKILL.md

```sh
npx @jentic/api-scorecard-cli score <openapi-url>
```

## Why Jentic

- **Setup:** Wiring the Sanity Access API by hand means juggling two dated path prefixes (v2025-07-11 and v2024-07-01), a resourceType and resourceId on every call, a user bearer token for most operations and a robot's own token for rotation. Through Jentic you install once, import it from the API Directory, store the token once, and your agent calls it.
- **Permission scoping:** Sanity puts both the resource type and its id in the URL path (`/access/{resourceType}/{resourceId}/...`), so a rule can pin your agent to one project or organization and the operations you pick. You choose the operations it may call, so destructive ones like removeUser, deleteRole, or deleteRobot are not included unless you add them.
- **Credential handling:** Your Sanity token is stored once, encrypted, by your own Jentic One instance and injected at execution time. It never enters the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'invite a user to a Sanity project' or 'create a Sanity robot token', and Jentic returns the matching operation, such as createInvite or createRobot, with its input schema.

## Related APIs

- **Sanity Roles API** — Older Sanity roles, grants, and permission-resource endpoints
- **Sanity Projects API** — Create and configure the Sanity projects and datasets access applies to
- **Auth0 Management API** — Manage users, roles, and permissions for your own application
- **Okta API** — Identity provider for the people you grant Sanity access to

## FAQ

### What authentication does the Sanity Access API use?

Per its OpenAPI spec, the Sanity Access API uses a bearer token (bearerAuth, a JWT) in the Authorization header for most operations. The two self-service robot operations, revoking and rotating the current robot token under `/v2025-07-11/access/robots/me`, use robotTokenAuth instead: the robot's own bearer token. Each operation also lists the Sanity permission it needs, such as sanity.organization.members.update. Through Jentic the token is stored by your own instance and attached at call time.

### Can I create robot tokens with the Sanity Access API?

Yes. The createRobot operation takes a label, memberships naming a resourceType, resourceId, and roleNames, and an optional expiresAt, and returns the secret token once; it cannot be retrieved again. Only the specified resource and its children can be granted. Set sendNotification to false to skip the notification email.

### How do I change a user's roles in Sanity?

Call replaceRolesForUser with a roleNames list to make it the user's complete role set: missing roles are added and extra ones removed, and at least one role must remain. To change a single role, use addRoleToUser or removeRoleFromUser with the roleName in the path.

### What are the rate limits for the Sanity Access API?

The OpenAPI spec does not specify rate limits. Check the Sanity documentation at https://www.sanity.io/docs for current API limits for your plan.

### Is there a Sanity MCP server?

You don't need an MCP server to give your agent the Sanity Access API. Jentic connects it directly from the API Directory: import it, store your Sanity token once, and your agent calls the user, role, invite, and robot operations it needs without loading a separate server's tool definitions.

### How do I invite someone to a Sanity project through Jentic?

Search Jentic for 'invite a user to a Sanity project', load the createInvite operation, and execute POST `/v2025-07-11/access/project/{resourceId}/invites` with the email and role. The invitee receives an email with a link to accept. To run it on your own infrastructure, install Jentic One from its GitHub repo.

### Can I limit what my agent is allowed to do with the Sanity Access API?

Yes. Allow only the GET operations under `/v2025-07-11/access/project/c7ja4siy`, and the agent can review that project's users, roles, invites, and robots while role changes, user removal, and robot creation stay off its list. Every call it makes is logged.
