How to invite users to a Sanity project via API?

2 replies
Last updated: Feb 28, 2024
I love the API that’s provided for projects — I have script that spins up a new install for each new project we make. One thing I’d love to have, though, would be an endpoint to be able to invite users to a project. It would save a time from having to go in and manually invite all the members of my team after. I spent a few minutes playing with the API today and it sorta seems like this already exists? but it isn’t documented here (https://www.sanity.io/docs/projects-api ) — if it does exist and someone can tell me how to do it, or tell me it doesn’t exist and I shouldn’t keep trying, would love to hear. Thanks!
AI Update

Good news! Yes, the Access API does have an endpoint to create invites, even though it might not have been clearly documented in the Projects API page you were looking at.

According to the Access API documentation, you can create invites using:

POST /v2025-07-11/access/{resourceType}/{resourceId}/invites

For inviting users to a project, you'd use:

POST https://api.sanity.io/v2025-07-11/access/project/{projectId}/invites

The request body should include:

  • email - The email address of the person you're inviting
  • roleNames - An array of role names to assign (like ["administrator", "editor", "developer", "contributor", "viewer"])

Here's what a typical request might look like:

const response = await fetch(
  `https://api.sanity.io/v2025-07-11/access/project/${projectId}/invites`,
  {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      email: 'teammate@example.com',
      roleNames: ['editor']
    })
  }
);

Required permission: You'll need sanity.project.members.update permission to create invites.

The Access API also has related endpoints for managing invites:

  • GET /invites - List all invites
  • DELETE /invites/{inviteId} - Revoke an invite
  • GET /invites/{token} - Get invite details by token
  • PUT /invites/{token} - Accept an invite

So you were right that this functionality exists! It's just under the Access API rather than the Projects API. This should save you a ton of time automating your team onboarding process. You can loop through your team members and fire off invite requests right after spinning up each new project.

Show original thread
2 replies
An API for invitations isn’t documented, but you can send a POST request containing
{ email: String, role: String }
in the body to
<https://api.sanity.io/v2021-06-07/invitations/project/<PROJECT_ID>>
. You will get back a 201 with an
invitationId
on success.
awesome, thanks!

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.

Was this answer helpful?