younifyd
Menu

Add Role To User

Add a role to a user.

PUT/v2025-07-11/access/{resourceType}/{resourceId}/users/{sanityUserId}/roles/{roleName}

Use it in a workflow

  1. Add a step and choose the Sanity connector.
  2. Pick the Add Role To User action (under Access).
  3. Fill in the fields below, then reference the result from later steps as {{addRoleToUser.response.data}}.

Request

Path parameters

resourceTypestringrequired

The resource type to scope the access requests to.

One oforganizationprojectmedia-librarycanvasdashboardviewknowledge-base

resourceIdstringrequired

The resource ID to scope the access request to. Must be a valid ID for the resource type.

sanityUserIdstringrequired

The User ID

roleNamestringrequired

The role name.

Response

Returns 201 with an object. Read it in later steps with {{addRoleToUser.response.data.<field>}}.

sanityUserIdstring
profileobject
idstringrequired
displayNamestringrequired
emailstringrequired
familyNamestring
givenNamestring
middleNamestring | null
imageUrlstring (uri)
providerstringrequired
tosAcceptedAtstring (date-time)
createdAtstring (date-time)required
updatedAtstring (date-time)
isCurrentUserboolean
providerIdstring
membershipsarray<object>
addedAtstring (date-time)
resourceTypestringrequired
resourceIdstringrequired
roleNamesarray<string>required
lastSeenAtstring | null

For project memberships, the latest recorded authenticated request to that project, including clients other than Studio. Updated by an hourly import when it succeeds, so it may lag if imports are delayed. Null or omitted means no activity was recorded, not that the project was unused. Not set for organization memberships.

resourceUserIdstring | null

An alternative ID for the user in the resource. Only present for project memberships. That is, a user can be assigned to multiple projects, and each project will have a different resourceUserId to reference the same user.

json
{
  "sanityUserId": "gDdcnv42e",
  "profile": {
    "id": "string",
    "displayName": "string",
    "email": "string",
    "provider": "string",
    "createdAt": "2025-01-01T00:00:00Z",
    "familyName": "string",
    "givenName": "string",
    "middleName": "string",
    "imageUrl": "string",
    "tosAcceptedAt": "2025-01-01T00:00:00Z",
    "updatedAt": "2025-01-01T00:00:00Z",
    "isCurrentUser": false
  },
  "memberships": [
    {
      "resourceType": "project",
      "resourceId": "c7ja4siy",
      "roleNames": [
        "administrator",
        "editor"
      ],
      "addedAt": "2024-01-15T12:15:30Z",
      "lastSeenAt": "2024-01-15T12:15:30Z",
      "resourceUserId": "projectUserId123"
    }
  ]
}

Need more? See the Sanity guide for connection setup and behaviour shared by every action.