younifyd
Menu

Create Role

Create a role

POST/projects/{projectId}/roles

Use it in a workflow

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

Request

Path parameters

projectIdstringrequired

The ID of the project

Request body

Enter the body as JSON in the step's Body field.

namestringrequired

The role name. Use lowercase letters, numbers, hyphens, and underscores. You can't use the name of a built-in role, or `read`, `write`, `public`, or `custom`.

titlestringrequired

The role title

descriptionstring

A description of the role's permissions

Default ""

appliesToUsersboolean

Whether the role applies to users

Default true

appliesToRobotsboolean

Whether the role applies to robots

Default true

json
{
  "name": "translator",
  "title": "Translator",
  "description": "Edit translated documents",
  "appliesToUsers": true,
  "appliesToRobots": false
}

Response

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

namestring

The role name

titlestring

The role title

descriptionstring

A description of the role's permissions. An empty string if the role has no description.

isCustomboolean

Whether this is a custom role

projectIdstring

The ID of the project this role belongs to

appliesToUsersboolean

Whether the role can be given to users

appliesToRobotsboolean

Whether the role can be given to robots

grantsobject

Grants grouped by permission resource schema name, such as `sanity.project` or `sanity.document.filter.mode`.

json
{
  "name": "administrator",
  "title": "Administrator",
  "description": "Read and write access to all datasets, with full access to all project settings.",
  "isCustom": false,
  "projectId": "3do82whm",
  "appliesToUsers": true,
  "appliesToRobots": false,
  "grants": {}
}

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

Create Role — Sanity — Documentation